diff options
Diffstat (limited to 'editor')
237 files changed, 7708 insertions, 5876 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 1c3ba89cd3..9126e0512e 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -200,7 +200,7 @@ void InputEventConfigurationDialog::_tab_selected(int p_tab) { if (is_connected("window_input", signal_method)) { disconnect("window_input", signal_method); } - input_list_tree->call_deferred("ensure_cursor_is_visible"); + input_list_tree->call_deferred(SNAME("ensure_cursor_is_visible")); if (input_list_tree->get_selected() == nullptr) { // If nothing selected, scroll to top. input_list_tree->scroll_to_item(input_list_tree->get_root()); @@ -532,14 +532,14 @@ void InputEventConfigurationDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - input_list_search->set_right_icon(input_list_search->get_theme_icon("Search", "EditorIcons")); + input_list_search->set_right_icon(input_list_search->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - physical_key_checkbox->set_icon(get_theme_icon("KeyboardPhysical", "EditorIcons")); + physical_key_checkbox->set_icon(get_theme_icon(SNAME("KeyboardPhysical"), SNAME("EditorIcons"))); - icon_cache.keyboard = get_theme_icon("Keyboard", "EditorIcons"); - icon_cache.mouse = get_theme_icon("Mouse", "EditorIcons"); - icon_cache.joypad_button = get_theme_icon("JoyButton", "EditorIcons"); - icon_cache.joypad_axis = get_theme_icon("JoyAxis", "EditorIcons"); + icon_cache.keyboard = get_theme_icon(SNAME("Keyboard"), SNAME("EditorIcons")); + icon_cache.mouse = get_theme_icon(SNAME("Mouse"), SNAME("EditorIcons")); + icon_cache.joypad_button = get_theme_icon(SNAME("JoyButton"), SNAME("EditorIcons")); + icon_cache.joypad_axis = get_theme_icon(SNAME("JoyAxis"), SNAME("EditorIcons")); _update_input_list(); } break; @@ -581,7 +581,7 @@ void InputEventConfigurationDialog::set_allowed_input_types(int p_type_masks) { InputEventConfigurationDialog::InputEventConfigurationDialog() { allowed_input_types = INPUT_KEY | INPUT_MOUSE_BUTTON | INPUT_JOY_BUTTON | INPUT_JOY_MOTION; - set_title("Event Configuration"); + set_title(TTR("Event Configuration")); set_min_size(Size2i(550 * EDSCALE, 0)); // Min width VBoxContainer *main_vbox = memnew(VBoxContainer); @@ -595,7 +595,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { main_vbox->add_child(tab_container); CenterContainer *cc = memnew(CenterContainer); - cc->set_name("Listen for Input"); + cc->set_name(TTR("Listen for Input")); event_as_text = memnew(Label); event_as_text->set_align(Label::ALIGN_CENTER); cc->add_child(event_as_text); @@ -604,7 +604,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { // List of all input options to manually select from. VBoxContainer *manual_vbox = memnew(VBoxContainer); - manual_vbox->set_name("Manual Selection"); + manual_vbox->set_name(TTR("Manual Selection")); manual_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); tab_container->add_child(manual_vbox); @@ -632,7 +632,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *opts_label = memnew(Label); opts_label->set_theme_type_variation("HeaderSmall"); - opts_label->set_text("Additional Options"); + opts_label->set_text(TTR("Additional Options")); additional_options_container->add_child(opts_label); // Device Selection @@ -641,7 +641,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { Label *device_label = memnew(Label); device_label->set_theme_type_variation("HeaderSmall"); - device_label->set_text("Device:"); + device_label->set_text(TTR("Device:")); device_container->add_child(device_label); device_id_option = memnew(OptionButton); @@ -724,7 +724,7 @@ void ActionMapEditor::_event_config_confirmed() { } new_action["events"] = events; - emit_signal("action_edited", current_action_name, new_action); + emit_signal(SNAME("action_edited"), current_action_name, new_action); } void ActionMapEditor::_add_action_pressed() { @@ -738,7 +738,7 @@ void ActionMapEditor::_add_action(const String &p_name) { } add_edit->clear(); - emit_signal("action_added", p_name); + emit_signal(SNAME("action_added"), p_name); } void ActionMapEditor::_action_edited() { @@ -762,7 +762,7 @@ void ActionMapEditor::_action_edited() { return; } - emit_signal("action_renamed", old_name, new_name); + emit_signal(SNAME("action_renamed"), old_name, new_name); } else if (action_tree->get_selected_column() == 1) { // Deadzone Edited String name = ti->get_meta("__name"); @@ -771,7 +771,7 @@ void ActionMapEditor::_action_edited() { new_action["deadzone"] = ti->get_range(1); // Call deferred so that input can finish propagating through tree, allowing re-making of tree to occur. - call_deferred("emit_signal", "action_edited", name, new_action); + call_deferred(SNAME("emit_signal"), "action_edited", name, new_action); } } @@ -808,7 +808,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i case ActionMapEditor::BUTTON_REMOVE_ACTION: { // Send removed action name String name = item->get_meta("__name"); - emit_signal("action_removed", name); + emit_signal(SNAME("action_removed"), name); } break; case ActionMapEditor::BUTTON_REMOVE_EVENT: { // Remove event and send updated action @@ -821,7 +821,7 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i events.remove(event_index); action["events"] = events; - emit_signal("action_edited", action_name, action); + emit_signal(SNAME("action_edited"), action_name, action); } break; default: break; @@ -922,7 +922,7 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, // Change action order. String relative_to = target->get_meta("__name"); String action_name = selected->get_meta("__name"); - emit_signal("action_reordered", action_name, relative_to, drop_above); + emit_signal(SNAME("action_reordered"), action_name, relative_to, drop_above); } else if (d["input_type"] == "event") { // Change event order @@ -956,7 +956,7 @@ void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, } new_action["events"] = new_events; - emit_signal("action_edited", selected->get_parent()->get_meta("__name"), new_action); + emit_signal(SNAME("action_edited"), selected->get_parent()->get_meta("__name"), new_action); } } @@ -964,7 +964,7 @@ void ActionMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - action_list_search->set_right_icon(get_theme_icon("Search", "EditorIcons")); + action_list_search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; default: break; @@ -1038,11 +1038,11 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info action_item->set_range(1, deadzone); // Third column - buttons - action_item->add_button(2, action_tree->get_theme_icon("Add", "EditorIcons"), BUTTON_ADD_EVENT, false, TTR("Add Event")); - action_item->add_button(2, action_tree->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? "Remove Action" : "Cannot Remove Action"); + action_item->add_button(2, action_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), BUTTON_ADD_EVENT, false, TTR("Add Event")); + action_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_ACTION, !action_info.editable, action_info.editable ? TTR("Remove Action") : TTR("Cannot Remove Action")); - action_item->set_custom_bg_color(0, action_tree->get_theme_color("prop_subsection", "Editor")); - action_item->set_custom_bg_color(1, action_tree->get_theme_color("prop_subsection", "Editor")); + action_item->set_custom_bg_color(0, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + action_item->set_custom_bg_color(1, action_tree->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); for (int evnt_idx = 0; evnt_idx < events.size(); evnt_idx++) { Ref<InputEvent> event = events[evnt_idx]; @@ -1058,8 +1058,8 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info event_item->set_meta("__index", evnt_idx); // Third Column - Buttons - event_item->add_button(2, action_tree->get_theme_icon("Edit", "EditorIcons"), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); - event_item->add_button(2, action_tree->get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); + event_item->add_button(2, action_tree->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_EDIT_EVENT, false, TTR("Edit Event")); + event_item->add_button(2, action_tree->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE_EVENT, false, TTR("Remove Event")); event_item->set_button_color(2, 0, Color(1, 1, 1, 0.75)); event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75)); } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 63ffab6727..1e3140e202 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -217,19 +217,19 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V void AnimationBezierTrackEdit::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons"); - bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons"); - selected_icon = get_theme_icon("KeyBezierSelected", "EditorIcons"); + bezier_icon = get_theme_icon(SNAME("KeyBezierPoint"), SNAME("EditorIcons")); + bezier_handle_icon = get_theme_icon(SNAME("KeyBezierHandle"), SNAME("EditorIcons")); + selected_icon = get_theme_icon(SNAME("KeyBezierSelected"), SNAME("EditorIcons")); if (handle_mode_option->get_item_count() == 0) { - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE); - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED); - handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesFree"), SNAME("EditorIcons")), TTR("Free"), HANDLE_MODE_FREE); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesBalanced"), SNAME("EditorIcons")), TTR("Balanced"), HANDLE_MODE_BALANCED); + handle_mode_option->add_icon_item(get_theme_icon(SNAME("BezierHandlesMirror"), SNAME("EditorIcons")), TTR("Mirror"), HANDLE_MODE_MIRROR); } } if (p_what == NOTIFICATION_RESIZED) { int right_limit = get_size().width - timeline->get_buttons_width(); - int hsep = get_theme_constant("hseparation", "ItemList"); - int vsep = get_theme_constant("vseparation", "ItemList"); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); handle_mode_option->set_position(Vector2(right_limit + hsep, get_size().height - handle_mode_option->get_combined_minimum_size().height - vsep)); handle_mode_option->set_size(Vector2(timeline->get_buttons_width() - hsep * 2, handle_mode_option->get_combined_minimum_size().height)); @@ -242,16 +242,16 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); - int hsep = get_theme_constant("hseparation", "ItemList"); - int vsep = get_theme_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + int vsep = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; @@ -261,7 +261,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor); - Ref<Texture2D> close_icon = get_theme_icon("Close", "EditorIcons"); + Ref<Texture2D> close_icon = get_theme_icon(SNAME("Close"), SNAME("EditorIcons")); close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep); close_icon_rect.size = close_icon->get_size(); @@ -349,7 +349,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { subtracks[i] = rect; } else { - Color ac = get_theme_color("accent_color", "Editor"); + Color ac = get_theme_color(SNAME("accent_color"), SNAME("Editor")); ac.a = 0.5; draw_rect(rect, ac); } @@ -360,7 +360,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { vofs += text_buf.get_size().y + vsep; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); { //guides float min_left_scale = font->get_height(font_size) + vsep; @@ -401,7 +401,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture2D> point = get_theme_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> point = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) { _draw_track(E->key(), E->get()); @@ -418,7 +418,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } //draw edited curve - const Color highlight = get_theme_color("highlight_color", "Editor"); + const Color highlight = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); _draw_track(track, highlight); } @@ -547,7 +547,7 @@ void AnimationBezierTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -576,7 +576,7 @@ String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const { void AnimationBezierTrackEdit::_clear_selection() { selection.clear(); - emit_signal("clear_selection"); + emit_signal(SNAME("clear_selection")); update(); } @@ -597,7 +597,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int ERR_FAIL_COND(idx < 0); selection.insert(idx); - emit_signal("select_key", idx, true); + emit_signal(SNAME("select_key"), idx, true); update(); } @@ -663,9 +663,9 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); if (selection.size()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -676,7 +676,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { if (close_icon_rect.has_point(mb->get_position())) { - emit_signal("close_request"); + emit_signal(SNAME("close_request")); return; } for (Map<int, Rect2>::Element *E = subtracks.front(); E; E = E->next()) { @@ -898,8 +898,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } // 6-(undo) reinsert overlapped keys - for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - AnimMoveRestore &amr = E->get(); + for (const AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -1091,9 +1090,9 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (const Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 05945a8ae2..91835c1866 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -598,12 +598,12 @@ public: if (ap) { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { + for (const StringName &E : anims) { if (animations != String()) { animations += ","; } - animations += String(E->get()); + animations += String(E); } } } @@ -702,8 +702,8 @@ public: for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int key = 0; - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; if (from != key_ofs) { key++; continue; @@ -728,8 +728,8 @@ public: bool change_notify_deserved = false; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -986,8 +986,8 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); + for (float &F : E->value()) { + float key_ofs = F; int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1137,8 +1137,8 @@ public: same_key_type = false; } - for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); + for (float &F : E->value()) { + int key = animation->track_find_key(track, F, true); ERR_FAIL_COND(key == -1); if (first_key < 0) { first_key = key; @@ -1290,7 +1290,7 @@ public: void AnimationTimelineEdit::_zoom_changed(double) { update(); play_position->update(); - emit_signal("zoom_changed"); + emit_signal(SNAME("zoom_changed")); } float AnimationTimelineEdit::get_zoom_scale() const { @@ -1321,7 +1321,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { editing = false; update(); - emit_signal("length_changed", p_new_len); + emit_signal(SNAME("length_changed"), p_new_len); } void AnimationTimelineEdit::_anim_loop_pressed() { @@ -1332,11 +1332,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { } int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons"); - Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons"); - Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture2D> remove_icon = get_theme_icon("Remove", "EditorIcons"); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")); + Ref<Texture2D> interp_type = get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")); + Ref<Texture2D> loop_type = get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")); + Ref<Texture2D> remove_icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1345,7 +1345,7 @@ int AnimationTimelineEdit::get_buttons_width() const { } int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1356,17 +1356,17 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - add_track->set_icon(get_theme_icon("Add", "EditorIcons")); - loop->set_icon(get_theme_icon("Loop", "EditorIcons")); - time_icon->set_texture(get_theme_icon("Time", "EditorIcons")); + add_track->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + loop->set_icon(get_theme_icon(SNAME("Loop"), SNAME("EditorIcons"))); + time_icon->set_texture(get_theme_icon(SNAME("Time"), SNAME("EditorIcons"))); add_track->get_popup()->clear(); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyValue", "EditorIcons"), TTR("Property Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyCall", "EditorIcons"), TTR("Call Method Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track")); - add_track->get_popup()->add_icon_item(get_theme_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), TTR("Property Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), TTR("3D Transform Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), TTR("Call Method Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), TTR("Bezier Curve Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), TTR("Audio Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")), TTR("Animation Playback Track")); } if (p_what == NOTIFICATION_RESIZED) { @@ -1381,9 +1381,9 @@ void AnimationTimelineEdit::_notification(int p_what) { return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); int zoomw = key_range; float scale = get_zoom_scale(); @@ -1394,7 +1394,7 @@ void AnimationTimelineEdit::_notification(int p_what) { l = 0.001; //avoid crashor } - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons")); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1443,7 +1443,7 @@ void AnimationTimelineEdit::_notification(int p_what) { int end_px = (l - get_value()) * scale; int begin_px = -get_value() * scale; - Color notimecol = get_theme_color("dark_color_2", "Editor"); + Color notimecol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); Color timecolor = color; timecolor.a = 0.2; Color linecolor = color; @@ -1568,10 +1568,10 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { Size2 AnimationTimelineEdit::get_minimum_size() const { Size2 ms = add_track->get_minimum_size(); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); ms.height = MAX(ms.height, font->get_height(font_size)); - ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2; + ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon(SNAME("Hsize"), SNAME("EditorIcons"))->get_width() + 2; return ms; } @@ -1633,11 +1633,11 @@ void AnimationTimelineEdit::_play_position_draw() { int px = (-get_value() + play_position_pos) * scale + get_name_limit(); if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); play_position->draw_texture( - get_theme_icon("TimelineIndicator", "EditorIcons"), - Point2(px - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), + Point2(px - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), color); } } @@ -1685,7 +1685,7 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int x = mb->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); dragging_timeline = true; } if (!dragging_timeline && mb->get_button_index() == MOUSE_BUTTON_MIDDLE) { @@ -1718,13 +1718,13 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; update(); - emit_signal("name_limit_changed"); + emit_signal(SNAME("name_limit_changed")); play_position->update(); } if (dragging_timeline) { int x = mm->get_position().x - get_name_limit(); float ofs = x / get_zoom_scale() + get_value(); - emit_signal("timeline_changed", ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); + emit_signal(SNAME("timeline_changed"), ofs, false, Input::get_singleton()->is_key_pressed(KEY_ALT)); } if (panning_timeline) { int x = mm->get_position().x - get_name_limit(); @@ -1750,7 +1750,7 @@ void AnimationTimelineEdit::set_hscroll(HScrollBar *p_hscroll) { } void AnimationTimelineEdit::_track_added(int p_track) { - emit_signal("track_added", p_track); + emit_signal(SNAME("track_added"), p_track); } void AnimationTimelineEdit::_bind_methods() { @@ -1832,31 +1832,31 @@ void AnimationTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; - int hsep = get_theme_constant("hseparation", "ItemList"); + int hsep = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); Color linecolor = color; linecolor.a = 0.2; // NAMES AND ICONS // { - Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon(SNAME("checked"), SNAME("CheckBox")) : get_theme_icon(SNAME("unchecked"), SNAME("CheckBox")); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1877,7 +1877,7 @@ void AnimationTrackEdit::_notification(int p_what) { String text; Color text_color = color; if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) { - text_color = get_theme_color("accent_color", "Editor"); + text_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } if (in_group) { @@ -1952,25 +1952,25 @@ void AnimationTrackEdit::_notification(int p_what) { { Ref<Texture2D> wrap_icon[2] = { - get_theme_icon("InterpWrapClamp", "EditorIcons"), - get_theme_icon("InterpWrapLoop", "EditorIcons"), + get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), }; Ref<Texture2D> interp_icon[3] = { - get_theme_icon("InterpRaw", "EditorIcons"), - get_theme_icon("InterpLinear", "EditorIcons"), - get_theme_icon("InterpCubic", "EditorIcons") + get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), + get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")) }; Ref<Texture2D> cont_icon[4] = { - get_theme_icon("TrackContinuous", "EditorIcons"), - get_theme_icon("TrackDiscrete", "EditorIcons"), - get_theme_icon("TrackTrigger", "EditorIcons"), - get_theme_icon("TrackCapture", "EditorIcons") + get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")) }; int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_theme_icon(SNAME("select_arrow"), SNAME("Tree")); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -2007,7 +2007,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_theme_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_theme_icon(SNAME("EditBezier"), SNAME("EditorIcons")); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2092,7 +2092,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture2D> icon = get_theme_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2109,7 +2109,7 @@ void AnimationTrackEdit::_notification(int p_what) { } if (dropping_at != 0) { - Color drop_color = get_theme_color("accent_color", "Editor"); + Color drop_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); if (dropping_at < 0) { draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE)); } else { @@ -2161,7 +2161,7 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, return; } - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; int from_x = MAX(p_x, p_clip_left); @@ -2186,16 +2186,16 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool const Variant &v = animation->track_get_key_value(track, p_index); Variant::Type valid_type = Variant::NIL; if (!_is_value_key_valid(v, valid_type)) { - icon_to_draw = get_theme_icon("KeyInvalid", "EditorIcons"); + icon_to_draw = get_theme_icon(SNAME("KeyInvalid"), SNAME("EditorIcons")); } } Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a = 0.5; Dictionary d = animation->track_get_key_value(track, p_index); @@ -2298,19 +2298,19 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati update(); Ref<Texture2D> type_icons[6] = { - get_theme_icon("KeyValue", "EditorIcons"), - get_theme_icon("KeyXform", "EditorIcons"), - get_theme_icon("KeyCall", "EditorIcons"), - get_theme_icon("KeyBezier", "EditorIcons"), - get_theme_icon("KeyAudio", "EditorIcons"), - get_theme_icon("KeyAnimation", "EditorIcons") + get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyXform"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyCall"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyBezier"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAudio"), SNAME("EditorIcons")), + get_theme_icon(SNAME("KeyAnimation"), SNAME("EditorIcons")) }; ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); type_icon = type_icons[animation->track_get_type(track)]; - selected_icon = get_theme_icon("KeySelected", "EditorIcons"); + selected_icon = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); } NodePath AnimationTrackEdit::get_path() const { @@ -2318,10 +2318,10 @@ NodePath AnimationTrackEdit::get_path() const { } Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons"); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); int max_h = MAX(texture->get_height(), font->get_height(font_size)); max_h = MAX(max_h, get_key_height()); @@ -2355,7 +2355,7 @@ void AnimationTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -2556,17 +2556,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (p_event->is_pressed()) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { - emit_signal("duplicate_request"); + emit_signal(SNAME("duplicate_request")); accept_event(); } if (ED_GET_SHORTCUT("animation_editor/duplicate_selection_transposed")->is_shortcut(p_event)) { - emit_signal("duplicate_transpose_request"); + emit_signal(SNAME("duplicate_transpose_request")); accept_event(); } if (ED_GET_SHORTCUT("animation_editor/delete_selection")->is_shortcut(p_event)) { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); accept_event(); } } @@ -2597,10 +2597,10 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_theme_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); - menu->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); + menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); @@ -2616,9 +2616,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_theme_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_theme_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); @@ -2634,8 +2634,8 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_theme_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_theme_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); menu->set_as_minsize(); Vector2 popup_pos = get_screen_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height); @@ -2645,13 +2645,13 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (remove_rect.has_point(pos)) { - emit_signal("remove_request", track); + emit_signal(SNAME("remove_request"), track); accept_event(); return; } if (bezier_edit_rect.has_point(pos)) { - emit_signal("bezier_edit"); + emit_signal(SNAME("bezier_edit")); accept_event(); } @@ -2692,16 +2692,16 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (key_idx != -1) { if (mb->is_command_pressed() || mb->is_shift_pressed()) { if (editor->is_key_selected(track, key_idx)) { - emit_signal("deselect_key", key_idx); + emit_signal(SNAME("deselect_key"), key_idx); } else { - emit_signal("select_key", key_idx, false); + emit_signal(SNAME("select_key"), key_idx, false); moving_selection_attempt = true; select_single_attempt = -1; moving_selection_from_ofs = (mb->get_position().x - limit) / timeline->get_zoom_scale(); } } else { if (!editor->is_key_selected(track, key_idx)) { - emit_signal("select_key", key_idx, true); + emit_signal(SNAME("select_key"), key_idx, true); select_single_attempt = -1; } else { select_single_attempt = key_idx; @@ -2727,12 +2727,12 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); - menu->add_icon_item(get_theme_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT); + menu->add_icon_item(get_theme_icon(SNAME("Key"), SNAME("EditorIcons")), TTR("Insert Key"), MENU_KEY_INSERT); if (editor->is_selection_active()) { menu->add_separator(); - menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -2757,7 +2757,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } path->set_text(animation->track_get_path(track)); - Vector2 theme_ofs = path->get_theme_stylebox("normal", "LineEdit")->get_offset(); + Vector2 theme_ofs = path->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->get_offset(); path_popup->set_position(get_screen_position() + path_rect.position - theme_ofs); path_popup->set_size(path_rect.size); path_popup->popup(); @@ -2770,9 +2770,9 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (!mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { moving_selection_attempt = false; if (moving_selection) { - emit_signal("move_selection_commit"); + emit_signal(SNAME("move_selection_commit")); } else if (select_single_attempt != -1) { - emit_signal("select_key", select_single_attempt, true); + emit_signal(SNAME("select_key"), select_single_attempt, true); } moving_selection = false; select_single_attempt = -1; @@ -2781,7 +2781,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (moving_selection && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) { moving_selection_attempt = false; moving_selection = false; - emit_signal("move_selection_cancel"); + emit_signal(SNAME("move_selection_cancel")); } } @@ -2789,11 +2789,11 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT && moving_selection_attempt) { if (!moving_selection) { moving_selection = true; - emit_signal("move_selection_begin"); + emit_signal(SNAME("move_selection_begin")); } float new_ofs = (mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale(); - emit_signal("move_selection", new_ofs - moving_selection_from_ofs); + emit_signal(SNAME("move_selection"), new_ofs - moving_selection_from_ofs); } } @@ -2847,7 +2847,7 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d } const_cast<AnimationTrackEdit *>(this)->update(); - const_cast<AnimationTrackEdit *>(this)->emit_signal("drop_attempted", track); + const_cast<AnimationTrackEdit *>(this)->emit_signal(SNAME("drop_attempted"), track); return true; } @@ -2875,9 +2875,9 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) int from_track = d["index"]; if (dropping_at < 0) { - emit_signal("dropped", from_track, track); + emit_signal(SNAME("dropped"), from_track, track); } else { - emit_signal("dropped", from_track, track + 1); + emit_signal(SNAME("dropped"), from_track, track + 1); } } @@ -2916,14 +2916,14 @@ void AnimationTrackEdit::_menu_selected(int p_index) { } break; case MENU_KEY_INSERT: { - emit_signal("insert_key", insert_at_pos); + emit_signal(SNAME("insert_key"), insert_at_pos); } break; case MENU_KEY_DUPLICATE: { - emit_signal("duplicate_request"); + emit_signal(SNAME("duplicate_request")); } break; case MENU_KEY_DELETE: { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); } break; } @@ -2956,9 +2956,9 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect if (select_rect.intersects(rect)) { if (p_deselection) { - emit_signal("deselect_key", i); + emit_signal(SNAME("deselect_key"), i); } else { - emit_signal("select_key", i, false); + emit_signal(SNAME("select_key"), i, false); } } } @@ -3057,19 +3057,19 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object void AnimationTrackEditGroup::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("hseparation", "ItemList"); - Color color = get_theme_color("font_color", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("hseparation"), SNAME("ItemList")); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); if (root && root->has_node(node)) { Node *n = root->get_node(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } } - Color bgcol = get_theme_color("dark_color_2", "Editor"); + Color bgcol = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); bgcol.a *= 0.6; draw_rect(Rect2(Point2(), get_size()), bgcol); Color linecolor = color; @@ -3087,7 +3087,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } @@ -3102,9 +3102,9 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co } Size2 AnimationTrackEditGroup::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - int separation = get_theme_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + int separation = get_theme_constant(SNAME("vseparation"), SNAME("ItemList")); return Vector2(0, MAX(font->get_height(font_size), icon->get_height()) + separation); } @@ -3226,7 +3226,7 @@ void AnimationTrackEditor::update_keying() { keying = keying_enabled; - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } bool AnimationTrackEditor::has_keying() const { @@ -3283,7 +3283,7 @@ void AnimationTrackEditor::_name_limit_changed() { } void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag, bool p_timeline_only) { - emit_signal("timeline_changed", p_new_pos, p_drag, p_timeline_only); + emit_signal(SNAME("timeline_changed"), p_new_pos, p_drag, p_timeline_only); } void AnimationTrackEditor::_track_remove_request(int p_track) { @@ -3356,9 +3356,9 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_frame = Engine::get_singleton()->get_frames_drawn(); - for (List<InsertData>::Element *E = insert_data.front(); E; E = E->next()) { + for (const InsertData &E : insert_data) { //prevent insertion of multiple tracks - if (E->get().path == p_id.path) { + if (E.path == p_id.path) { return; //already inserted a track for this on this frame } } @@ -3430,14 +3430,14 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { insert_confirm->popup_centered(); insert_query = true; } else { - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); insert_queue = true; } } else { if (!insert_query && !insert_queue) { // Create Beziers wouldn't make sense in this case, where no tracks are being created - call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); + call_deferred(SNAME("_insert_delay"), reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); insert_queue = true; } } @@ -3482,7 +3482,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi pos = animation->get_length(); } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } insert_queue = false; } @@ -3843,9 +3843,9 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b List<PropertyInfo> pinfo; property_info_base.get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { - return E->get(); + for (const PropertyInfo &E : pinfo) { + if (E.name == leftover_path[leftover_path.size() - 1]) { + return E; } } @@ -4166,7 +4166,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -4245,7 +4245,7 @@ void AnimationTrackEditor::_animation_changed() { } animation_changing_awaiting_update = true; - call_deferred("_animation_update"); + call_deferred(SNAME("_animation_update")); } void AnimationTrackEditor::_snap_mode_changed(int p_mode) { @@ -4313,8 +4313,8 @@ void AnimationTrackEditor::_animation_update() { bezier_edit->update(); _update_step_spinbox(); - emit_signal("animation_step_changed", animation->get_step()); - emit_signal("animation_len_changed", animation->get_length()); + emit_signal(SNAME("animation_step_changed"), animation->get_step()); + emit_signal(SNAME("animation_len_changed"), animation->get_length()); animation_changing_awaiting_update = false; } @@ -4325,13 +4325,13 @@ MenuButton *AnimationTrackEditor::get_edit_menu() { void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - zoom_icon->set_texture(get_theme_icon("Zoom", "EditorIcons")); - snap->set_icon(get_theme_icon("Snap", "EditorIcons")); + zoom_icon->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); - selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); - imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon("Reload", "EditorIcons")); + selected_filter->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); + imported_anim_warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + main_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_READY) { @@ -4341,7 +4341,7 @@ void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { update_keying(); EditorNode::get_singleton()->update_keying(); - emit_signal("keying_changed"); + emit_signal(SNAME("keying_changed")); } } @@ -4367,11 +4367,11 @@ void AnimationTrackEditor::_update_step(double p_new_step) { step->set_block_signals(true); undo_redo->commit_action(); step->set_block_signals(false); - emit_signal("animation_step_changed", step_value); + emit_signal(SNAME("animation_step_changed"), step_value); } void AnimationTrackEditor::_update_length(double p_new_len) { - emit_signal("animation_len_changed", p_new_len); + emit_signal(SNAME("animation_len_changed"), p_new_len); } void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { @@ -4675,21 +4675,21 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { List<MethodInfo> minfo; base->get_method_list(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - if (E->get().name == p_method) { + for (const MethodInfo &E : minfo) { + if (E.name == p_method) { Dictionary d; d["method"] = p_method; Array params; - int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); + int first_defarg = E.arguments.size() - E.default_arguments.size(); - for (int i = 0; i < E->get().arguments.size(); i++) { + for (int i = 0; i < E.arguments.size(); i++) { if (i >= first_defarg) { - Variant arg = E->get().default_arguments[i - first_defarg]; + Variant arg = E.default_arguments[i - first_defarg]; params.push_back(arg); } else { Callable::CallError ce; Variant arg; - Variant::construct(E->get().arguments[i].type, arg, nullptr, 0, ce); + Variant::construct(E.arguments[i].type, arg, nullptr, 0, ce); params.push_back(arg); } } @@ -4936,8 +4936,7 @@ void AnimationTrackEditor::_move_selection_commit() { } // 6 - (undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -4980,8 +4979,8 @@ float AnimationTrackEditor::get_moving_selection_offset() const { void AnimationTrackEditor::_box_selection_draw() { const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor")); - box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); + box_selection->draw_rect(selection_rect, get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { @@ -5151,9 +5150,9 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map<SelectedKey, KeyInfo> new_selection; - for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; - float time = E->get().second; + for (const Pair<int, float> &E : new_selection_values) { + int track = E.first; + float time = E.second; int existing_idx = animation->track_find_key(track, time, true); @@ -5201,7 +5200,7 @@ void AnimationTrackEditor::goto_prev_step(bool p_from_mouse_event) { pos = 0; } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) { @@ -5228,7 +5227,7 @@ void AnimationTrackEditor::goto_next_step(bool p_from_mouse_event) { } set_anim_pos(pos); - emit_signal("timeline_changed", pos, true); + emit_signal(SNAME("timeline_changed"), pos, true); } void AnimationTrackEditor::_edit_menu_pressed(int p_option) { @@ -5247,7 +5246,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } String text; - Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Node"), SNAME("EditorIcons")); if (node) { if (has_theme_icon(node->get_class(), "EditorIcons")) { icon = get_theme_icon(node->get_class(), "EditorIcons"); @@ -5462,8 +5461,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } // 6-(undo) reinsert overlapped keys - for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); + for (_AnimMoveRestore &amr : to_restore) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5543,8 +5541,8 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { if (cleanup_all->is_pressed()) { List<StringName> names; AnimationPlayerEditor::singleton->get_player()->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E->get())); + for (const StringName &E : names) { + _cleanup_animation(AnimationPlayerEditor::singleton->get_player()->get_animation(E)); } } else { _cleanup_animation(animation); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 54c1e89d1e..0caed1e8e3 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -42,12 +42,12 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); return checked->get_height(); } Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon(SNAME("checked"), SNAME("CheckBox")); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } @@ -72,7 +72,7 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, draw_texture(icon, ofs); if (p_selected) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect_clipped(Rect2(ofs, icon->get_size()), color, false); } } @@ -80,14 +80,14 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, /// COLOR /// int AnimationTrackEditColor::get_key_height() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return font->get_height(font_size) * 0.8; } Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(-fh / 2, 0, fh, get_size().height); } @@ -97,8 +97,8 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const { } void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = (font->get_height(font_size) * 0.8); fh /= 3; @@ -167,8 +167,8 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { Color color = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh)); @@ -180,7 +180,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect_clipped(rect, accent, false); } } @@ -206,8 +206,8 @@ int AnimationTrackEditAudio::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -239,8 +239,8 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -303,8 +303,8 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float fh = int(font->get_height(font_size) * 1.5); Rect2 rect = Rect2(from_x, (get_size().height - fh) / 2, to_x - from_x, fh); draw_rect(rect, Color(0.25, 0.25, 0.25)); @@ -330,20 +330,20 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -367,8 +367,8 @@ int AnimationTrackEditSpriteFrame::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 2); } @@ -435,8 +435,8 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se size = size.floor(); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int height = int(font->get_height(font_size) * 2); int width = height * size.width / size.height; @@ -526,8 +526,8 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.size = texture->get_size(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int height = int(font->get_height(font_size) * 2); int width = height * region.size.width / region.size.height; @@ -542,7 +542,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in return; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Color bg = accent; bg.a = 0.15; @@ -570,8 +570,8 @@ int AnimationTrackEditSubAnim::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -599,8 +599,8 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -654,13 +654,13 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -703,20 +703,20 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -729,12 +729,12 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { //// VOLUME DB //// int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -745,7 +745,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { } void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -780,12 +780,12 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon(SNAME("ColorTrackVu"), SNAME("EditorIcons")); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); color.a *= 0.7; draw_line(Point2(from_x, y_from + h * tex_h), Point2(to_x, y_from + h_n * tex_h), color, 2); @@ -806,8 +806,8 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { } int AnimationTrackEditTypeAudio::get_key_height() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -871,8 +871,8 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float fh = int(font->get_height(font_size) * 1.5); float len = stream->get_length(); @@ -947,7 +947,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); - Color cut_color = get_theme_color("accent_color", "Editor"); + Color cut_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); cut_color.a = 0.7; if (start_ofs > 0 && pixel_begin > p_clip_left) { draw_rect(Rect2(pixel_begin, rect.position.y, 1, rect.size.y), cut_color); @@ -957,7 +957,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } @@ -1143,8 +1143,8 @@ int AnimationTrackEditTypeAnimation::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return int(font->get_height(font_size) * 1.5); } @@ -1172,8 +1172,8 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_ return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -1227,13 +1227,13 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -1276,20 +1276,20 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); int fh = font->get_height(font_size) * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_theme_color("font_color", "Label"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); draw_rect(rect, color); if (p_selected) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_rect(rect, accent, false); } } diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index ad6e3ac1dc..f7f4988873 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -97,7 +97,7 @@ AudioStreamPreview::AudioStreamPreview() { //// void AudioStreamPreviewGenerator::_update_emit(ObjectID p_id) { - emit_signal("preview_updated", p_id); + emit_signal(SNAME("preview_updated"), p_id); } void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { @@ -150,7 +150,7 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { } frames_todo -= to_read; - singleton->call_deferred("_update_emit", preview->id); + singleton->call_deferred(SNAME("_update_emit"), preview->id); } preview->playback->stop(); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 03914bec3b..03695419cb 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -88,23 +88,23 @@ GotoLineDialog::GotoLineDialog() { void FindReplaceBar::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process_unhandled_input(is_visible_in_tree()); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else if (p_what == NOTIFICATION_PREDELETE) { if (base_text_editor) { base_text_editor->remove_find_replace_bar(); @@ -304,10 +304,10 @@ void FindReplaceBar::_replace_all() { } text_editor->set_v_scroll(vsval); - matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(TTR("%d replaced."), rc)); - text_editor->call_deferred("connect", "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); + text_editor->call_deferred(SNAME("connect"), "text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); results_count = -1; } @@ -368,7 +368,7 @@ void FindReplaceBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } @@ -480,10 +480,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { if (p_focus_replace) { search_text->deselect(); - replace_text->call_deferred("grab_focus"); + replace_text->call_deferred(SNAME("grab_focus")); } else { replace_text->deselect(); - search_text->call_deferred("grab_focus"); + search_text->call_deferred(SNAME("grab_focus")); } if (text_editor->is_selection_active() && !selection_only->is_pressed()) { @@ -585,7 +585,7 @@ bool FindReplaceBar::is_selection_only() const { } void FindReplaceBar::set_error(const String &p_label) { - emit_signal("error", p_label); + emit_signal(SNAME("error"), p_label); } void FindReplaceBar::set_text_edit(CodeTextEditor *p_text_editor) { @@ -760,10 +760,10 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMagnifyGesture> magnify_gesture = p_event; if (magnify_gesture.is_valid()) { - font_size = text_editor->get_theme_font_size("font_size"); + font_size = text_editor->get_theme_font_size(SNAME("font_size")); font_size *= powf(magnify_gesture->get_factor(), 0.25); - _add_font_size((int)font_size - text_editor->get_theme_font_size("font_size")); + _add_font_size((int)font_size - text_editor->get_theme_font_size(SNAME("font_size"))); return; } @@ -854,9 +854,7 @@ void CodeTextEditor::_complete_request() { return; } - for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) { - ScriptCodeCompletionOption &e = E->get(); - + for (const ScriptCodeCompletionOption &e : entries) { Color font_color = completion_font_color; if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { font_color = completion_string_color; @@ -875,38 +873,38 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp if (has_theme_icon(p_option.display, "EditorIcons")) { tex = get_theme_icon(p_option.display, "EditorIcons"); } else { - tex = get_theme_icon("Object", "EditorIcons"); + tex = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } } break; case ScriptCodeCompletionOption::KIND_ENUM: - tex = get_theme_icon("Enum", "EditorIcons"); + tex = get_theme_icon(SNAME("Enum"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_FILE_PATH: - tex = get_theme_icon("File", "EditorIcons"); + tex = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_NODE_PATH: - tex = get_theme_icon("NodePath", "EditorIcons"); + tex = get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_VARIABLE: - tex = get_theme_icon("Variant", "EditorIcons"); + tex = get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_CONSTANT: - tex = get_theme_icon("MemberConstant", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_MEMBER: - tex = get_theme_icon("MemberProperty", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_SIGNAL: - tex = get_theme_icon("MemberSignal", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_FUNCTION: - tex = get_theme_icon("MemberMethod", "EditorIcons"); + tex = get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")); break; case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: - tex = get_theme_icon("BoxMesh", "EditorIcons"); + tex = get_theme_icon(SNAME("BoxMesh"), SNAME("EditorIcons")); break; default: - tex = get_theme_icon("String", "EditorIcons"); + tex = get_theme_icon(SNAME("String"), SNAME("EditorIcons")); break; } return tex; @@ -919,7 +917,7 @@ void CodeTextEditor::_font_resize_timeout() { } bool CodeTextEditor::_add_font_size(int p_delta) { - int old_size = text_editor->get_theme_font_size("font_size"); + int old_size = text_editor->get_theme_font_size(SNAME("font_size")); int new_size = CLAMP(old_size + p_delta, 8 * EDSCALE, 96 * EDSCALE); if (new_size != old_size) { @@ -1411,19 +1409,19 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) { void CodeTextEditor::goto_line(int p_line) { text_editor->deselect(); text_editor->unfold_line(p_line); - text_editor->call_deferred("cursor_set_line", p_line); + text_editor->call_deferred(SNAME("cursor_set_line"), p_line); } void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { text_editor->unfold_line(p_line); - text_editor->call_deferred("cursor_set_line", p_line); - text_editor->call_deferred("cursor_set_column", p_begin); + text_editor->call_deferred(SNAME("cursor_set_line"), p_line); + text_editor->call_deferred(SNAME("cursor_set_column"), p_begin); text_editor->select(p_line, p_begin, p_line, p_end); } void CodeTextEditor::goto_line_centered(int p_line) { goto_line(p_line); - text_editor->call_deferred("center_viewport_to_cursor"); + text_editor->call_deferred(SNAME("center_viewport_to_cursor")); } void CodeTextEditor::set_executing_line(int p_line) { @@ -1542,20 +1540,20 @@ void CodeTextEditor::_update_text_editor_theme() { text_editor->add_theme_color_override("search_result_color", EDITOR_GET("text_editor/highlighting/search_result_color")); text_editor->add_theme_color_override("search_result_border_color", EDITOR_GET("text_editor/highlighting/search_result_border_color")); text_editor->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); - emit_signal("load_theme_settings"); + emit_signal(SNAME("load_theme_settings")); _load_theme_settings(); } void CodeTextEditor::_update_font() { - text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - text_editor->add_theme_font_size_override("font_size", get_theme_font_size("source_size", "EditorFonts")); + text_editor->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + text_editor->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); - error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); - error->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts")); - error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); - Ref<Font> status_bar_font = get_theme_font("status_source", "EditorFonts"); - int status_bar_font_size = get_theme_font_size("status_source_size", "EditorFonts"); + Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); + int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts")); error->add_theme_font_override("font", status_bar_font); error->add_theme_font_size_override("font_size", status_bar_font_size); int count = status_bar->get_child_count(); @@ -1614,7 +1612,7 @@ void CodeTextEditor::_on_settings_change() { void CodeTextEditor::_text_changed_idle_timeout() { _validate_script(); - emit_signal("validate_script"); + emit_signal(SNAME("validate_script")); } void CodeTextEditor::validate_script() { @@ -1633,19 +1631,19 @@ void CodeTextEditor::_warning_button_pressed() { void CodeTextEditor::_set_show_errors_panel(bool p_show) { is_errors_panel_opened = p_show; - emit_signal("show_errors_panel", p_show); + emit_signal(SNAME("show_errors_panel"), p_show); } void CodeTextEditor::_set_show_warnings_panel(bool p_show) { is_warnings_panel_opened = p_show; - emit_signal("show_warnings_panel", p_show); + emit_signal(SNAME("show_warnings_panel"), p_show); } void CodeTextEditor::_toggle_scripts_pressed() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon(SNAME("Back"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } } @@ -1666,8 +1664,8 @@ void CodeTextEditor::_notification(int p_what) { _update_font(); } break; case NOTIFICATION_ENTER_TREE: { - error_button->set_icon(get_theme_icon("StatusError", "EditorIcons")); - warning_button->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + error_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + warning_button->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); add_theme_constant_override("separation", 4 * EDSCALE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1779,9 +1777,9 @@ void CodeTextEditor::show_toggle_scripts_button() { void CodeTextEditor::update_toggle_scripts_button() { if (is_layout_rtl()) { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Forward", "EditorIcons") : get_theme_icon("Back", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon(SNAME("Forward"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon(SNAME("Back"), SNAME("EditorIcons")) : get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")"); } @@ -1871,9 +1869,9 @@ CodeTextEditor::CodeTextEditor() { error_button->connect("pressed", callable_mp(this, &CodeTextEditor::_error_button_pressed)); error_button->set_tooltip(TTR("Errors")); - error_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); - error_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - error_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + error_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); is_errors_panel_opened = false; set_error_count(0); @@ -1887,9 +1885,9 @@ CodeTextEditor::CodeTextEditor() { warning_button->connect("pressed", callable_mp(this, &CodeTextEditor::_warning_button_pressed)); warning_button->set_tooltip(TTR("Warnings")); - warning_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor")); - warning_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - warning_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + warning_button->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_button->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + warning_button->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); is_warnings_panel_opened = false; set_warning_count(0); @@ -1898,8 +1896,8 @@ CodeTextEditor::CodeTextEditor() { line_and_col_txt = memnew(Label); status_bar->add_child(line_and_col_txt); line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); - line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - line_and_col_txt->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + line_and_col_txt->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); line_and_col_txt->set_tooltip(TTR("Line and column numbers.")); line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c79a8d9a0e..c773f51342 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -134,7 +134,7 @@ void ConnectDialog::ok_pressed() { return; } } - emit_signal("connected"); + emit_signal(SNAME("connected")); hide(); } @@ -360,7 +360,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { void ConnectDialog::popup_dialog(const String &p_for_signal) { from_signal->set_text(p_for_signal); - error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", error_label->get_theme_color(SNAME("error_color"), SNAME("Editor"))); if (!advanced->is_pressed()) { error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root())); } @@ -509,13 +509,13 @@ ConnectDialog::~ConnectDialog() { // Originally copied and adapted from EditorProperty, try to keep style in sync. Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { 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 = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]"; text += p_text.get_slice("::", 1).strip_edges() + "\n"; text += p_text.get_slice("::", 2).strip_edges(); - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + help_bit->call_deferred(SNAME("set_text"), text); //hack so it uses proper theme once inside scene return help_bit; } @@ -591,7 +591,7 @@ void ConnectionsDock::_make_or_edit_connection() { it = nullptr; if (add_script_function) { - editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args); + editor->emit_signal(SNAME("script_add_function_request"), target, cToMake.method, script_function_args); hide(); } @@ -921,14 +921,14 @@ void ConnectionsDock::update_tree() { } } else { ClassDB::get_signal_list(base, &node_signals2, true); - if (has_theme_icon(base, "EditorIcons")) { - icon = get_theme_icon(base, "EditorIcons"); + if (has_theme_icon(base, SNAME("EditorIcons"))) { + icon = get_theme_icon(base, SNAME("EditorIcons")); } name = base; } if (!icon.is_valid()) { - icon = get_theme_icon("Object", "EditorIcons"); + icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } TreeItem *section_item = nullptr; @@ -940,13 +940,11 @@ void ConnectionsDock::update_tree() { section_item->set_icon(0, icon); section_item->set_selectable(0, false); section_item->set_editable(0, false); - section_item->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); + section_item->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); node_signals2.sort(); } - for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); - + for (MethodInfo &mi : node_signals2) { StringName signal_name = mi.name; String signaldesc = "("; PackedStringArray argnames; @@ -982,7 +980,7 @@ void ConnectionsDock::update_tree() { sinfo["name"] = signal_name; sinfo["args"] = argnames; signal_item->set_metadata(0, sinfo); - signal_item->set_icon(0, get_theme_icon("Signal", "EditorIcons")); + signal_item->set_icon(0, get_theme_icon(SNAME("Signal"), SNAME("EditorIcons"))); // Set tooltip with the signal's documentation. { @@ -1025,8 +1023,8 @@ void ConnectionsDock::update_tree() { List<Object::Connection> connections; selectedNode->get_signal_connection_list(signal_name, &connections); - for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) { - Connection cn = F->get(); + for (const Object::Connection &F : connections) { + Connection cn = F; if (!(cn.flags & CONNECT_PERSIST)) { continue; } @@ -1059,7 +1057,7 @@ void ConnectionsDock::update_tree() { connection_item->set_text(0, path); Connection cd = c; connection_item->set_metadata(0, cd); - connection_item->set_icon(0, get_theme_icon("Slot", "EditorIcons")); + connection_item->set_icon(0, get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); } } @@ -1083,7 +1081,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { search_box = memnew(LineEdit); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_placeholder(TTR("Filter signals")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); search_box->connect("text_changed", callable_mp(this, &ConnectionsDock::_filter_changed)); vbc->add_child(search_box); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 027cee3f1c..3389b53317 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -40,7 +40,7 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_select_type) { _fill_type_list(); - icon_fallback = search_options->has_theme_icon(base_type, "EditorIcons") ? base_type : "Object"; + icon_fallback = search_options->has_theme_icon(base_type, SNAME("EditorIcons")) ? base_type : "Object"; if (p_dont_clear) { search_box->select_all(); @@ -168,7 +168,7 @@ void CreateDialog::_update_search() { TreeItem *root = search_options->create_item(); root->set_text(0, base_type); - root->set_icon(0, search_options->get_theme_icon(icon_fallback, "EditorIcons")); + root->set_icon(0, search_options->get_theme_icon(icon_fallback, SNAME("EditorIcons"))); search_options_types[base_type] = root; _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); @@ -195,7 +195,8 @@ void CreateDialog::_update_search() { select_type(_top_result(candidates, search_text)); } else { favorite->set_disabled(true); - help_bit->set_text(""); + help_bit->set_text(vformat(TTR("No results for \"%s\"."), search_text)); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); get_ok_button()->set_disabled(true); search_options->deselect_all(); } @@ -236,7 +237,7 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String bool can_instantiate = (p_cpp_type && ClassDB::can_instantiate(p_type)) || !p_cpp_type; if (!can_instantiate) { - r_item->set_custom_color(0, search_options->get_theme_color("disabled_font_color", "Editor")); + r_item->set_custom_color(0, search_options->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, "NodeDisabled")); r_item->set_selectable(0, false); } else { @@ -338,7 +339,7 @@ void CreateDialog::_confirmed() { memdelete(f); } - emit_signal("create"); + emit_signal(SNAME("create")); hide(); _cleanup(); } @@ -366,16 +367,16 @@ void CreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - favorite->set_icon(search_options->get_theme_icon("Favorites", "EditorIcons")); + favorite->set_icon(search_options->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { - search_box->call_deferred("grab_focus"); // still not visible + search_box->call_deferred(SNAME("grab_focus")); // still not visible search_box->select_all(); } else { EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size())); @@ -393,8 +394,15 @@ void CreateDialog::select_type(const String &p_type) { to_select->select(0); search_options->scroll_to_item(to_select); - if (EditorHelp::get_doc_data()->class_list.has(p_type)) { - help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description)); + if (EditorHelp::get_doc_data()->class_list.has(p_type) && !DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description).is_empty()) { + // Display both class name and description, since the help bit may be displayed + // far away from the location (especially if the dialog was resized to be taller). + help_bit->set_text(vformat("[b]%s[/b]: %s", p_type, DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 1)); + } else { + // Use nested `vformat()` as translators shouldn't interfere with BBCode tags. + help_bit->set_text(vformat(TTR("No description available for %s."), vformat("[b]%s[/b]", p_type))); + help_bit->get_rich_text()->set_self_modulate(Color(1, 1, 1, 0.5)); } favorite->set_disabled(false); @@ -439,8 +447,7 @@ Variant CreateDialog::instance_selected() { List<PropertyInfo> pinfo; ((Object *)obj)->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (const PropertyInfo &pi : pinfo) { if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) { Object *prop = ClassDB::instantiate(pi.class_name); ((Object *)obj)->set(pi.name, prop); @@ -607,7 +614,7 @@ void CreateDialog::_save_and_update_favorite_list() { memdelete(f); } - emit_signal("favorites_updated"); + emit_signal(SNAME("favorites_updated")); } void CreateDialog::_load_favorites_and_history() { diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 6035cc072e..a1eb71235c 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -41,7 +41,7 @@ bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p } prop_values[p_name] = p_value; - emit_signal("value_edited", remote_object_id, p_name, p_value); + emit_signal(SNAME("value_edited"), remote_object_id, p_name, p_value); return true; } @@ -56,8 +56,8 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const { p_list->clear(); //sorry, no want category - for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : prop_list) { + p_list->push_back(E); } } @@ -114,11 +114,11 @@ void EditorDebuggerInspector::_notification(int p_what) { } void EditorDebuggerInspector::_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { - emit_signal("object_edited", p_id, p_prop, p_value); + emit_signal(SNAME("object_edited"), p_id, p_prop, p_value); } void EditorDebuggerInspector::_object_selected(ObjectID p_object) { - emit_signal("object_selected", p_object); + emit_signal(SNAME("object_selected"), p_object); } ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { @@ -190,7 +190,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { //only some may have changed, if so, then update those, if exist for (Set<String>::Element *E = changed.front(); E; E = E->next()) { - emit_signal("object_property_updated", debugObj->remote_object_id, E->get()); + emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E->get()); } } else { //full update, because props were added or removed diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 5f90680115..690ce98cb9 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -55,8 +55,8 @@ EditorDebuggerNode::EditorDebuggerNode() { singleton = this; } - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); @@ -112,7 +112,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { if (tabs->get_tab_count() > 1) { node->clear_style(); tabs->set_tabs_visible(true); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } if (!debugger_plugins.is_empty()) { @@ -135,7 +135,7 @@ void EditorDebuggerNode::_stack_frame_selected(int p_debugger) { void EditorDebuggerNode::_error_selected(const String &p_file, int p_line, int p_debugger) { Ref<Script> s = ResourceLoader::load(p_file); - emit_signal("goto_script_line", s, p_line - 1); + emit_signal(SNAME("goto_script_line"), s, p_line - 1); } void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_debugger) { @@ -145,8 +145,8 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d } stack_script = ResourceLoader::load(file); const int line = p_debugger->get_stack_script_line() - 1; - emit_signal("goto_script_line", stack_script, line); - emit_signal("set_execution", stack_script, line); + emit_signal(SNAME("goto_script_line"), stack_script, line); + emit_signal(SNAME("set_execution"), stack_script, line); stack_script.unref(); // Why?!? } @@ -226,10 +226,10 @@ void EditorDebuggerNode::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { - add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_LEFT)); - add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(SIDE_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))->get_margin(SIDE_RIGHT)); - tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } } break; case NOTIFICATION_READY: { @@ -268,11 +268,11 @@ void EditorDebuggerNode::_notification(int p_what) { } else { debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - debugger_button->set_icon(get_theme_icon("ErrorWarning", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); } else if (error_count >= 1) { - debugger_button->set_icon(get_theme_icon("Error", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); } else { - debugger_button->set_icon(get_theme_icon("Warning", "EditorIcons")); + debugger_button->set_icon(get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); } } last_error_count = error_count; @@ -359,7 +359,7 @@ void EditorDebuggerNode::_debugger_wants_stop(int p_id) { // Ask editor to kill PID. int pid = get_debugger(p_id)->get_remote_pid(); if (pid) { - EditorNode::get_singleton()->call_deferred("stop_child_process", pid); + EditorNode::get_singleton()->call_deferred(SNAME("stop_child_process"), pid); } } @@ -475,7 +475,7 @@ void EditorDebuggerNode::_breaked(bool p_breaked, bool p_can_debug, int p_debugg } _break_state_changed(); EditorNode::get_singleton()->get_pause_button()->set_pressed(p_breaked); - emit_signal("breaked", p_breaked, p_can_debug); + emit_signal(SNAME("breaked"), p_breaked, p_can_debug); } bool EditorDebuggerNode::is_skip_breakpoints() const { diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 3510ac0726..9a40383c17 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -123,7 +123,7 @@ protected: void _save_node_requested(ObjectID p_id, const String &p_file, int p_debugger); void _clear_execution(REF p_script) { - emit_signal("clear_execution", p_script); + emit_signal(SNAME("clear_execution"), p_script); } void _text_editor_stack_goto(const ScriptEditorDebugger *p_debugger); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index ec92edc795..1feab98948 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -75,7 +75,7 @@ void EditorDebuggerTree::_scene_tree_selected() { inspected_object_id = uint64_t(item->get_metadata(0)); - emit_signal("object_selected", inspected_object_id, debugger_id); + emit_signal(SNAME("object_selected"), inspected_object_id, debugger_id); } void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { @@ -105,8 +105,8 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { item->select(0); item_menu->clear(); - item_menu->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); - item_menu->add_icon_item(get_theme_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); + item_menu->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); + item_menu->add_icon_item(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); item_menu->set_position(get_screen_transform().xform(get_local_mouse_position())); item_menu->popup(); } @@ -211,7 +211,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int } debugger_id = p_debugger; // Needed by hook, could be avoided if every debugger had its own tree if (scroll_item) { - call_deferred("scroll_to_item", scroll_item); + call_deferred(SNAME("scroll_to_item"), scroll_item); } last_filter = filter; updating_scene_tree = false; @@ -279,5 +279,5 @@ void EditorDebuggerTree::_file_selected(const String &p_file) { if (inspected_object_id.is_null()) { return; } - emit_signal("save_node", inspected_object_id, p_file, debugger_id); + emit_signal(SNAME("save_node"), inspected_object_id, p_file, debugger_id); } diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index 1c781c4d98..9479fbd5d4 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -40,14 +40,14 @@ void EditorNetworkProfiler::_bind_methods() { void EditorNetworkProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); - incoming_bandwidth_text->set_right_icon(get_theme_icon("ArrowDown", "EditorIcons")); - outgoing_bandwidth_text->set_right_icon(get_theme_icon("ArrowUp", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + incoming_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowDown"), SNAME("EditorIcons"))); + outgoing_bandwidth_text->set_right_icon(get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); // This needs to be done here to set the faded color when the profiler is first opened - incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); - outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); + incoming_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5)); + outgoing_bandwidth_text->add_theme_color_override("font_uneditable_color", get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5)); } } @@ -73,13 +73,13 @@ void EditorNetworkProfiler::_update_frame() { void EditorNetworkProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorNetworkProfiler::_clear_pressed() { @@ -114,10 +114,10 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { // Make labels more prominent when the bandwidth is greater than 0 to attract user attention incoming_bandwidth_text->add_theme_color_override( "font_uneditable_color", - get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); + get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); outgoing_bandwidth_text->add_theme_color_override( "font_uneditable_color", - get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); + get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); } bool EditorNetworkProfiler::is_profiling() { diff --git a/editor/debugger/editor_performance_profiler.cpp b/editor/debugger/editor_performance_profiler.cpp index 08609080c5..08ed675d16 100644 --- a/editor/debugger/editor_performance_profiler.cpp +++ b/editor/debugger/editor_performance_profiler.cpp @@ -109,9 +109,9 @@ void EditorPerformanceProfiler::_monitor_draw() { info_message->hide(); - Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit"); - Ref<Font> graph_font = get_theme_font("font", "TextEdit"); - int font_size = get_theme_font_size("font_size", "TextEdit"); + Ref<StyleBox> graph_style_box = get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")); + Ref<Font> graph_font = get_theme_font(SNAME("font"), SNAME("TextEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("TextEdit")); int columns = int(Math::ceil(Math::sqrt(float(active.size())))); int rows = int(Math::ceil(float(active.size()) / float(columns))); @@ -130,7 +130,7 @@ void EditorPerformanceProfiler::_monitor_draw() { rect.position += graph_style_box->get_offset(); rect.size -= graph_style_box->get_minimum_size(); - Color draw_color = get_theme_color("accent_color", "Editor"); + Color draw_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); draw_color.set_hsv(Math::fmod(hue_shift * float(current.frame_index), 0.9f), draw_color.get_s() * 0.9f, draw_color.get_v() * value_multiplier, 0.6f); monitor_draw->draw_string(graph_font, rect.position + Point2(0, graph_font->get_ascent(font_size)), current.item->get_text(0), HALIGN_LEFT, rect.size.x, font_size, draw_color); @@ -271,7 +271,7 @@ void EditorPerformanceProfiler::_marker_input(const Ref<InputEvent> &p_event) { } else { marker_key = ""; } - Ref<StyleBox> graph_style_box = get_theme_stylebox("normal", "TextEdit"); + Ref<StyleBox> graph_style_box = get_theme_stylebox(SNAME("normal"), SNAME("TextEdit")); rect.position += graph_style_box->get_offset(); rect.size -= graph_style_box->get_minimum_size(); Vector2 point = mb->get_position() - rect.position; diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 5f4d1b6f36..fa9c9f61f5 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -135,11 +135,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca } Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); + Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); } void EditorProfiler::_item_edited() { @@ -180,7 +180,7 @@ void EditorProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); - const Color background_color = get_theme_color("dark_color_2", "Editor"); + const Color background_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { @@ -356,7 +356,7 @@ void EditorProfiler::_update_frame() { item->set_metadata(1, it.script); item->set_metadata(2, it.line); item->set_text_align(2, TreeItem::ALIGN_RIGHT); - item->set_tooltip(0, it.script + ":" + itos(it.line)); + item->set_tooltip(0, it.name + "\n" + it.script + ":" + itos(it.line)); float time = dtime == DISPLAY_SELF_TIME ? it.self : it.total; @@ -376,14 +376,14 @@ void EditorProfiler::_update_frame() { void EditorProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); _clear_pressed(); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorProfiler::_clear_pressed() { @@ -394,8 +394,8 @@ void EditorProfiler::_clear_pressed() { void EditorProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); } } @@ -462,7 +462,7 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { if (activate->is_pressed()) { if (!seeking) { - emit_signal("break_request"); + emit_signal(SNAME("break_request")); } } @@ -588,8 +588,8 @@ EditorProfiler::EditorProfiler() { hb->add_child(memnew(Label(TTR("Measure:")))); display_mode = memnew(OptionButton); - display_mode->add_item(TTR("Frame Time (sec)")); - display_mode->add_item(TTR("Average Time (sec)")); + display_mode->add_item(TTR("Frame Time (ms)")); + display_mode->add_item(TTR("Average Time (ms)")); display_mode->add_item(TTR("Frame %")); display_mode->add_item(TTR("Physics Frame %")); display_mode->connect("item_selected", callable_mp(this, &EditorProfiler::_combo_changed)); @@ -601,6 +601,7 @@ EditorProfiler::EditorProfiler() { display_time = memnew(OptionButton); display_time->add_item(TTR("Inclusive")); display_time->add_item(TTR("Self")); + display_time->set_tooltip(TTR("Inclusive: Includes time from other functions called by this function.\nUse this to spot bottlenecks.\n\nSelf: Only count the time spent in the function itself, not in other functions called by that function.\nUse this to find individual functions to optimize.")); display_time->connect("item_selected", callable_mp(this, &EditorProfiler::_combo_changed)); hb->add_child(display_time); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index a0e8a3bd35..f17ad0d36c 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -123,11 +123,11 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) { } Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); + Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor")); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.lerp(get_theme_color("base_color", "Editor"), 0.07); + return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07); } void EditorVisualProfiler::_item_selected() { @@ -318,7 +318,7 @@ void EditorVisualProfiler::_update_plot() { void EditorVisualProfiler::_update_frame(bool p_focus_selected) { int cursor_metric = _get_cursor_index(); - Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons"); + Ref<Texture> track_icon = get_theme_icon(SNAME("TrackColor"), SNAME("EditorIcons")); ERR_FAIL_INDEX(cursor_metric, frame_metrics.size()); @@ -365,13 +365,13 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } TreeItem *category = variables->create_item(parent); - for (List<TreeItem *>::Element *E = stack.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); + for (TreeItem *E : stack) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); total_cpu += cpu_time; total_gpu += gpu_time; - E->get()->set_metadata(1, cpu_time); - E->get()->set_metadata(2, gpu_time); + E->set_metadata(1, cpu_time); + E->set_metadata(2, gpu_time); } category->set_icon(0, track_icon); @@ -392,11 +392,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } } - for (List<TreeItem *>::Element *E = categories.front(); E; E = E->next()) { - float total_cpu = E->get()->get_metadata(1); - float total_gpu = E->get()->get_metadata(2); - E->get()->set_text(1, _get_time_as_text(total_cpu)); - E->get()->set_text(2, _get_time_as_text(total_gpu)); + for (TreeItem *E : categories) { + float total_cpu = E->get_metadata(1); + float total_gpu = E->get_metadata(2); + E->set_text(1, _get_time_as_text(total_cpu)); + E->set_text(2, _get_time_as_text(total_gpu)); } if (ensure_selected) { @@ -407,14 +407,14 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { void EditorVisualProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_theme_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); activate->set_text(TTR("Stop")); _clear_pressed(); //always clear on start } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); activate->set_text(TTR("Start")); } - emit_signal("enable_profiling", activate->is_pressed()); + emit_signal(SNAME("enable_profiling"), activate->is_pressed()); } void EditorVisualProfiler::_clear_pressed() { @@ -425,11 +425,11 @@ void EditorVisualProfiler::_clear_pressed() { void EditorVisualProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { if (is_layout_rtl()) { - activate->set_icon(get_theme_icon("PlayBackwards", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); } else { - activate->set_icon(get_theme_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); } - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); } } @@ -437,8 +437,8 @@ void EditorVisualProfiler::_graph_tex_draw() { if (last_metric < 0) { return; } - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); if (seeking) { int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 09bbf846fe..9856fbec74 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -87,9 +87,9 @@ void ScriptEditorDebugger::debug_copy() { void ScriptEditorDebugger::debug_skip_breakpoints() { skip_breakpoints_value = !skip_breakpoints_value; if (skip_breakpoints_value) { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOn"), SNAME("EditorIcons"))); } else { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); } Array msg; @@ -136,11 +136,11 @@ void ScriptEditorDebugger::update_tabs() { } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); if (error_count >= 1 && warning_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("ErrorWarning", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("ErrorWarning"), SNAME("EditorIcons"))); } else if (error_count >= 1) { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Error", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); } else { - tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Warning", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); } } } @@ -264,7 +264,7 @@ Object *ScriptEditorDebugger::get_remote_object(ObjectID p_id) { } void ScriptEditorDebugger::_remote_object_selected(ObjectID p_id) { - emit_signal("remote_object_requested", p_id); + emit_signal(SNAME("remote_object_requested"), p_id); } void ScriptEditorDebugger::_remote_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { @@ -273,7 +273,7 @@ void ScriptEditorDebugger::_remote_object_edited(ObjectID p_id, const String &p_ } void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const String &p_property) { - emit_signal("remote_object_property_updated", p_id, p_property); + emit_signal(SNAME("remote_object_property_updated"), p_id, p_property); } void ScriptEditorDebugger::_video_mem_request() { @@ -305,7 +305,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da can_debug = can_continue; _update_buttons_state(); _set_reason_text(error, MESSAGE_ERROR); - emit_signal("breaked", true, can_continue); + emit_signal(SNAME("breaked"), true, can_continue); DisplayServer::get_singleton()->window_move_to_foreground(); if (error != "") { tabs->set_current_tab(0); @@ -319,7 +319,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da _clear_execution(); _update_buttons_state(); _set_reason_text(TTR("Execution resumed."), MESSAGE_SUCCESS); - emit_signal("breaked", false, false); + emit_signal(SNAME("breaked"), false, false); profiler->set_enabled(true); profiler->disable_seeking(); } else if (p_msg == "set_pid") { @@ -332,12 +332,12 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "scene:scene_tree") { scene_tree->nodes.clear(); scene_tree->deserialize(p_data); - emit_signal("remote_tree_updated"); + emit_signal(SNAME("remote_tree_updated")); _update_buttons_state(); } else if (p_msg == "scene:inspect_object") { ObjectID id = inspector->add_object(p_data); if (id.is_valid()) { - emit_signal("remote_object_updated", id); + emit_signal(SNAME("remote_object_updated"), id); } } else if (p_msg == "memory:usage") { vmem_tree->clear(); @@ -347,18 +347,18 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da uint64_t total = 0; - for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { + for (const DebuggerMarshalls::ResourceInfo &E : usage.infos) { TreeItem *it = vmem_tree->create_item(root); - String type = E->get().type; - int bytes = E->get().vram; - it->set_text(0, E->get().path); + String type = E.type; + int bytes = E.vram; + it->set_text(0, E.path); it->set_text(1, type); - it->set_text(2, E->get().format); + it->set_text(2, E.format); it->set_text(3, String::humanize_size(bytes)); total += bytes; - if (has_theme_icon(type, "EditorIcons")) { - it->set_icon(0, get_theme_icon(type, "EditorIcons")); + if (has_theme_icon(type, SNAME("EditorIcons"))) { + it->set_icon(0, get_theme_icon(type, SNAME("EditorIcons"))); } } @@ -698,7 +698,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da network_profiler->set_bandwidth(p_data[0], p_data[1]); } else if (p_msg == "request_quit") { - emit_signal("stop_requested"); + emit_signal(SNAME("stop_requested")); _stop_and_notify(); } else if (p_msg == "performance:profile_names") { @@ -739,13 +739,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { switch (p_type) { case MESSAGE_ERROR: - reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); break; case MESSAGE_WARNING: - reason->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); break; default: - reason->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } reason->set_text(p_reason); reason->set_tooltip(p_reason.word_wrap(80)); @@ -754,21 +754,21 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType void ScriptEditorDebugger::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); - next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear)); error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); - vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); - vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); + vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); - reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; case NOTIFICATION_PROCESS: { @@ -793,7 +793,7 @@ void ScriptEditorDebugger::_notification(int p_what) { } else if (camera_override >= CameraOverride::OVERRIDE_3D_1) { int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1; Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx); - Camera3D *const cam = viewport->get_camera(); + Camera3D *const cam = viewport->get_camera_3d(); Array msg; msg.push_back(cam->get_camera_transform()); @@ -831,16 +831,16 @@ void ScriptEditorDebugger::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->has_theme_stylebox_override("panel")) { - tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); } - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); - next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); - vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); - vmem_export->set_icon(get_theme_icon("Save", "EditorIcons")); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); + vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); } break; } } @@ -854,7 +854,7 @@ void ScriptEditorDebugger::_clear_execution() { Dictionary d = ti->get_metadata(0); stack_script = ResourceLoader::load(d["file"]); - emit_signal("clear_execution", stack_script); + emit_signal(SNAME("clear_execution"), stack_script); stack_script.unref(); stack_dump->clear(); inspector->clear_stack_variables(); @@ -878,7 +878,7 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { tabs->set_current_tab(0); _set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS); _update_buttons_state(); - emit_signal("started"); + emit_signal(SNAME("started")); } void ScriptEditorDebugger::_update_buttons_state() { @@ -896,7 +896,7 @@ void ScriptEditorDebugger::_update_buttons_state() { void ScriptEditorDebugger::_stop_and_notify() { stop(); - emit_signal("stopped"); + emit_signal(SNAME("stopped")); _set_reason_text(TTR("Debug session closed."), MESSAGE_WARNING); } @@ -959,7 +959,7 @@ void ScriptEditorDebugger::_profiler_seeked() { } void ScriptEditorDebugger::_stack_dump_frame_selected() { - emit_signal("stack_frame_selected"); + emit_signal(SNAME("stack_frame_selected")); int frame = get_stack_script_frame(); @@ -1332,7 +1332,7 @@ void ScriptEditorDebugger::_error_selected() { return; } - emit_signal("error_selected", String(meta[0]), int(meta[1])); + emit_signal(SNAME("error_selected"), String(meta[0]), int(meta[1])); } void ScriptEditorDebugger::_expand_errors_list() { @@ -1373,8 +1373,8 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (error_tree->is_anything_selected()) { - item_menu->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), ACTION_COPY_ERROR); - item_menu->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); + item_menu->add_icon_item(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Error"), ACTION_COPY_ERROR); + item_menu->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Open C++ Source on GitHub"), ACTION_OPEN_SOURCE); } if (item_menu->get_item_count() > 0) { @@ -1393,9 +1393,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { String type; - if (ti->get_icon(0) == get_theme_icon("Warning", "EditorIcons")) { + if (ti->get_icon(0) == get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))) { type = "W "; - } else if (ti->get_icon(0) == get_theme_icon("Error", "EditorIcons")) { + } else if (ti->get_icon(0) == get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))) { type = "E "; } @@ -1518,7 +1518,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); - tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("DebuggerPanel"), SNAME("EditorStyles"))); tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed)); add_child(tabs); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index e26344f3ec..069ae2c7f2 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -55,8 +55,8 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->clear_filters(); List<String> ext; ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - search->add_filter("*" + E->get()); + for (const String &E : ext) { + search->add_filter("*" + E); } search->popup_file_dialog(); } @@ -120,13 +120,13 @@ void DependencyEditor::_fix_all() { Map<String, Map<String, String>> candidates; - for (List<String>::Element *E = missing.front(); E; E = E->next()) { - String base = E->get().get_file(); + for (const String &E : missing) { + String base = E.get_file(); if (!candidates.has(base)) { candidates[base] = Map<String, String>(); } - candidates[base][E->get()] = ""; + candidates[base][E] = ""; } _fix_and_find(EditorFileSystem::get_singleton()->get_filesystem(), candidates); @@ -162,14 +162,12 @@ void DependencyEditor::_update_list() { TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = tree->get_theme_icon("folder", "FileDialog"); + Ref<Texture2D> folder = tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); bool broken = false; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { + for (const String &n : deps) { TreeItem *item = tree->create_item(root); - - String n = E->get(); String path; String type; @@ -180,6 +178,15 @@ void DependencyEditor::_update_list() { path = n; type = "Resource"; } + + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(path); + if (uid != ResourceUID::INVALID_ID) { + // dependency is in uid format, obtain proper path + ERR_CONTINUE(!ResourceUID::get_singleton()->has_id(uid)); + + path = ResourceUID::get_singleton()->get_id_path(uid); + } + String name = path.get_file(); Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(type); @@ -278,7 +285,7 @@ void DependencyEditorOwners::_select_file(int p_idx) { if (ResourceLoader::get_resource_type(fpath) == "PackedScene") { editor->open_request(fpath); hide(); - emit_signal("confirmed"); + emit_signal(SNAME("confirmed")); } } @@ -412,17 +419,17 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed if (!tree_items.has(rd.dependency_folder)) { TreeItem *folder_item = owners->create_item(owners->get_root()); folder_item->set_text(0, rd.dependency_folder); - folder_item->set_icon(0, owners->get_theme_icon("Folder", "EditorIcons")); + folder_item->set_icon(0, owners->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); tree_items[rd.dependency_folder] = folder_item; } TreeItem *dependency_item = owners->create_item(tree_items[rd.dependency_folder]); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); tree_items[rd.dependency] = dependency_item; } else { TreeItem *dependency_item = owners->create_item(owners->get_root()); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon(SNAME("Warning"), SNAME("EditorIcons"))); tree_items[rd.dependency] = dependency_item; } } @@ -508,7 +515,7 @@ void DependencyRemoveDialog::ok_pressed() { if (err != OK) { EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + files_to_delete[i] + "\n"); } else { - emit_signal("file_removed", files_to_delete[i]); + emit_signal(SNAME("file_removed"), files_to_delete[i]); } } @@ -525,7 +532,7 @@ void DependencyRemoveDialog::ok_pressed() { if (err != OK) { EditorNode::get_singleton()->add_io_error(TTR("Cannot remove:") + "\n" + dirs_to_delete[i] + "\n"); } else { - emit_signal("folder_removed", dirs_to_delete[i]); + emit_signal(SNAME("folder_removed"), dirs_to_delete[i]); } } @@ -665,7 +672,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa if (p_parent) { dir_item = files->create_item(p_parent); dir_item->set_text(0, efsd->get_subdir(i)->get_name()); - dir_item->set_icon(0, files->get_theme_icon("folder", "FileDialog")); + dir_item->set_icon(0, files->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); } bool children = _fill_owners(efsd->get_subdir(i), refs, dir_item); @@ -701,7 +708,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); if (ds) { - ti->add_button(1, files->get_theme_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies")); + ti->add_button(1, files->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), -1, false, TTR("Show Dependencies")); } ti->set_metadata(0, path); has_children = true; @@ -741,9 +748,9 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path void OrphanResourcesDialog::_delete_confirm() { DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); - EditorFileSystem::get_singleton()->update_file(E->get()); + for (const String &E : paths) { + da->remove(E); + EditorFileSystem::get_singleton()->update_file(E); } memdelete(da); refresh(); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index befafec6cb..cbd4a1b916 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -266,20 +266,20 @@ void DocTools::generate(bool p_basic_types) { } List<PropertyInfo>::Element *EO = own_properties.front(); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (const PropertyInfo &E : properties) { bool inherited = EO == nullptr; - if (EO && EO->get() == E->get()) { + if (EO && EO->get() == E) { inherited = false; EO = EO->next(); } - if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) { + if (E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP || E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_INTERNAL) { continue; } DocData::PropertyDoc prop; - prop.name = E->get().name; + prop.name = E.name; prop.overridden = inherited; @@ -288,20 +288,20 @@ void DocTools::generate(bool p_basic_types) { if (name == "ProjectSettings") { // Special case for project settings, so that settings are not taken from the current project's settings - if (E->get().name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E->get().name)) { + if (E.name == "script" || !ProjectSettings::get_singleton()->is_builtin_setting(E.name)) { continue; } - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E->get().name)) { - default_value = ProjectSettings::get_singleton()->property_get_revert(E->get().name); + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (!ProjectSettings::get_singleton()->get_ignore_value_in_docs(E.name)) { + default_value = ProjectSettings::get_singleton()->property_get_revert(E.name); default_value_valid = true; } } } else { - default_value = get_documentation_default_value(name, E->get().name, default_value_valid); + default_value = get_documentation_default_value(name, E.name, default_value_valid); if (inherited) { bool base_default_value_valid = false; - Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E.name, base_default_value_valid); if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) { continue; } @@ -309,13 +309,13 @@ void DocTools::generate(bool p_basic_types) { } //used to track uninitialized values using valgrind - //print_line("getting default value for " + String(name) + "." + String(E->get().name)); + //print_line("getting default value for " + String(name) + "." + String(E.name)); if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); + StringName setter = ClassDB::get_property_setter(name, E.name); + StringName getter = ClassDB::get_property_getter(name, E.name); prop.setter = setter; prop.getter = getter; @@ -353,10 +353,10 @@ void DocTools::generate(bool p_basic_types) { } if (!found_type) { - if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { - prop.type = E->get().hint_string; + if (E.type == Variant::OBJECT && E.hint == PROPERTY_HINT_RESOURCE_TYPE) { + prop.type = E.hint_string; } else { - prop.type = Variant::get_type_name(E->get().type); + prop.type = Variant::get_type_name(E.type); } } @@ -367,62 +367,62 @@ void DocTools::generate(bool p_basic_types) { ClassDB::get_method_list(name, &method_list, true); method_list.sort(); - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) { + for (const MethodInfo &E : method_list) { + if (E.name == "" || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) { continue; //hidden, don't count } - if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { + if (skip_setter_getter_methods && setters_getters.has(E.name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. // E.g. CPUParticles3D::set_param(Parameter param, float value). - if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { + if (E.arguments.size() == 0 /* getter */ || (E.arguments.size() == 1 && E.return_val.type == Variant::NIL /* setter */)) { continue; } } DocData::MethodDoc method; - method.name = E->get().name; + method.name = E.name; - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (E.flags & METHOD_FLAG_VIRTUAL) { method.qualifiers = "virtual"; } - if (E->get().flags & METHOD_FLAG_CONST) { + if (E.flags & METHOD_FLAG_CONST) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "const"; } - if (E->get().flags & METHOD_FLAG_VARARG) { + if (E.flags & METHOD_FLAG_VARARG) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "vararg"; } - if (E->get().flags & METHOD_FLAG_STATIC) { + if (E.flags & METHOD_FLAG_STATIC) { if (method.qualifiers != "") { method.qualifiers += " "; } method.qualifiers += "static"; } - for (int i = -1; i < E->get().arguments.size(); i++) { + for (int i = -1; i < E.arguments.size(); i++) { if (i == -1) { #ifdef DEBUG_METHODS_ENABLED - DocData::return_doc_from_retinfo(method, E->get().return_val); + DocData::return_doc_from_retinfo(method, E.return_val); #endif } else { - const PropertyInfo &arginfo = E->get().arguments[i]; + const PropertyInfo &arginfo = E.arguments[i]; DocData::ArgumentDoc argument; DocData::argument_doc_from_arginfo(argument, arginfo); - int darg_idx = i - (E->get().arguments.size() - E->get().default_arguments.size()); + int darg_idx = i - (E.arguments.size() - E.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = E.default_arguments[darg_idx]; argument.default_value = default_arg.get_construct_string(); } @@ -455,12 +455,12 @@ void DocTools::generate(bool p_basic_types) { List<String> constant_list; ClassDB::get_integer_constant_list(name, &constant_list, true); - for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { + for (const String &E : constant_list) { DocData::ConstantDoc constant; - constant.name = E->get(); - constant.value = itos(ClassDB::get_integer_constant(name, E->get())); + constant.name = E; + constant.value = itos(ClassDB::get_integer_constant(name, E)); constant.is_value_valid = true; - constant.enumeration = ClassDB::get_integer_constant_enum(name, E->get()); + constant.enumeration = ClassDB::get_integer_constant_enum(name, E); c.constants.push_back(constant); } @@ -469,53 +469,53 @@ void DocTools::generate(bool p_basic_types) { { List<StringName> l; Theme::get_default()->get_constant_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; - pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname)); + pd.default_value = itos(Theme::get_default()->get_constant(E, cname)); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_color_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Color"; - pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string(); + pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_icon_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Texture2D"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "Font"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_font_size_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "int"; c.theme_properties.push_back(pd); } l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); - for (List<StringName>::Element *E = l.front(); E; E = E->next()) { + for (const StringName &E : l) { DocData::PropertyDoc pd; - pd.name = E->get(); + pd.name = E; pd.type = "StyleBox"; c.theme_properties.push_back(pd); } @@ -621,8 +621,7 @@ void DocTools::generate(bool p_basic_types) { method_list.push_back(mi); } - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : method_list) { DocData::MethodDoc method; method.name = mi.name; @@ -675,8 +674,7 @@ void DocTools::generate(bool p_basic_types) { List<PropertyInfo> properties; v.get_property_list(&properties); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (const PropertyInfo &pi : properties) { DocData::PropertyDoc property; property.name = pi.name; property.type = Variant::get_type_name(pi.type); @@ -688,10 +686,10 @@ void DocTools::generate(bool p_basic_types) { List<StringName> constants; Variant::get_constants_for_type(Variant::Type(i), &constants); - for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { + for (const StringName &E : constants) { DocData::ConstantDoc constant; - constant.name = E->get(); - Variant value = Variant::get_constant_value(Variant::Type(i), E->get()); + constant.name = E; + Variant value = Variant::get_constant_value(Variant::Type(i), E); constant.value = value.get_type() == Variant::INT ? itos(value) : value.get_construct_string(); constant.is_value_valid = true; c.constants.push_back(constant); @@ -723,9 +721,8 @@ void DocTools::generate(bool p_basic_types) { Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (const Engine::Singleton &s : singletons) { DocData::PropertyDoc pd; - Engine::Singleton &s = E->get(); if (!s.ptr) { continue; } @@ -743,13 +740,13 @@ void DocTools::generate(bool p_basic_types) { List<StringName> utility_functions; Variant::get_utility_function_list(&utility_functions); utility_functions.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = utility_functions.front(); E; E = E->next()) { + for (const StringName &E : utility_functions) { DocData::MethodDoc md; - md.name = E->get(); + md.name = E; //return - if (Variant::has_utility_function_return_value(E->get())) { + if (Variant::has_utility_function_return_value(E)) { PropertyInfo pi; - pi.type = Variant::get_utility_function_return_type(E->get()); + pi.type = Variant::get_utility_function_return_type(E); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -758,13 +755,13 @@ void DocTools::generate(bool p_basic_types) { md.return_type = ad.type; } - if (Variant::is_utility_function_vararg(E->get())) { + if (Variant::is_utility_function_vararg(E)) { md.qualifiers = "vararg"; } else { - for (int i = 0; i < Variant::get_utility_function_argument_count(E->get()); i++) { + for (int i = 0; i < Variant::get_utility_function_argument_count(E); i++) { PropertyInfo pi; - pi.type = Variant::get_utility_function_argument_type(E->get(), i); - pi.name = Variant::get_utility_function_argument_name(E->get(), i); + pi.type = Variant::get_utility_function_argument_type(E, i); + pi.name = Variant::get_utility_function_argument_name(E, i); if (pi.type == Variant::NIL) { pi.usage = PROPERTY_USAGE_NIL_IS_VARIANT; } @@ -793,8 +790,7 @@ void DocTools::generate(bool p_basic_types) { List<MethodInfo> minfo; lang->get_public_functions(&minfo); - for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); + for (const MethodInfo &mi : minfo) { DocData::MethodDoc md; md.name = mi.name; @@ -813,7 +809,7 @@ void DocTools::generate(bool p_basic_types) { int darg_idx = j - (mi.arguments.size() - mi.default_arguments.size()); if (darg_idx >= 0) { - Variant default_arg = E->get().default_arguments[darg_idx]; + Variant default_arg = mi.default_arguments[darg_idx]; ad.default_value = default_arg.get_construct_string(); } @@ -827,10 +823,10 @@ void DocTools::generate(bool p_basic_types) { List<Pair<String, Variant>> cinfo; lang->get_public_constants(&cinfo); - for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) { + for (const Pair<String, Variant> &E : cinfo) { DocData::ConstantDoc cd; - cd.name = E->get().first; - cd.value = E->get().second; + cd.name = E.first; + cd.value = E.second; cd.is_value_valid = true; c.constants.push_back(cd); } diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index 1f1446a8a8..c895e2c158 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -41,15 +41,15 @@ static const String META_TEXT_TO_COPY = "text_to_copy"; void EditorAbout::_theme_changed() { - const Ref<Font> font = get_theme_font("source", "EditorFonts"); - const int font_size = get_theme_font_size("source_size", "EditorFonts"); + const Ref<Font> font = get_theme_font(SNAME("source"), SNAME("EditorFonts")); + const int font_size = get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts")); _tpl_text->add_theme_font_override("normal_font", font); _tpl_text->add_theme_font_size_override("normal_font_size", font_size); _tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE); _license_text->add_theme_font_override("normal_font", font); _license_text->add_theme_font_size_override("normal_font_size", font_size); _license_text->add_theme_constant_override("line_separation", 6 * EDSCALE); - _logo->set_texture(get_theme_icon("Logo", "EditorIcons")); + _logo->set_texture(get_theme_icon(SNAME("Logo"), SNAME("EditorIcons"))); } void EditorAbout::_notification(int p_what) { diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index dc90f26d48..8dd3045887 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -132,57 +132,57 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { Map<String, Ref<Texture2D>> extension_guess; { - extension_guess["bmp"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["dds"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["exr"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["hdr"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["jpg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["jpeg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["png"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["svg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["svgz"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["tga"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - extension_guess["webp"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); - - extension_guess["wav"] = tree->get_theme_icon("AudioStreamSample", "EditorIcons"); - extension_guess["ogg"] = tree->get_theme_icon("AudioStreamOGGVorbis", "EditorIcons"); - extension_guess["mp3"] = tree->get_theme_icon("AudioStreamMP3", "EditorIcons"); - - extension_guess["scn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["tscn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["escn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["dae"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["gltf"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - extension_guess["glb"] = tree->get_theme_icon("PackedScene", "EditorIcons"); - - extension_guess["gdshader"] = tree->get_theme_icon("Shader", "EditorIcons"); - extension_guess["gd"] = tree->get_theme_icon("GDScript", "EditorIcons"); + extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["exr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["hdr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["jpg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["jpeg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["png"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["svg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["svgz"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["tga"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); + + extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamSample"), SNAME("EditorIcons")); + extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOGGVorbis"), SNAME("EditorIcons")); + extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons")); + + extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["tscn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["escn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["dae"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["gltf"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + extension_guess["glb"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + + extension_guess["gdshader"] = tree->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")); + extension_guess["gd"] = tree->get_theme_icon(SNAME("GDScript"), SNAME("EditorIcons")); if (Engine::get_singleton()->has_singleton("GodotSharp")) { - extension_guess["cs"] = tree->get_theme_icon("CSharpScript", "EditorIcons"); + extension_guess["cs"] = tree->get_theme_icon(SNAME("CSharpScript"), SNAME("EditorIcons")); } else { // Mark C# support as unavailable. - extension_guess["cs"] = tree->get_theme_icon("ImportFail", "EditorIcons"); + extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } - extension_guess["vs"] = tree->get_theme_icon("VisualScript", "EditorIcons"); + extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")); - extension_guess["res"] = tree->get_theme_icon("Resource", "EditorIcons"); - extension_guess["tres"] = tree->get_theme_icon("Resource", "EditorIcons"); - extension_guess["atlastex"] = tree->get_theme_icon("AtlasTexture", "EditorIcons"); + extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); + extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons")); + extension_guess["atlastex"] = tree->get_theme_icon(SNAME("AtlasTexture"), SNAME("EditorIcons")); // By default, OBJ files are imported as Mesh resources rather than PackedScenes. - extension_guess["obj"] = tree->get_theme_icon("Mesh", "EditorIcons"); - - extension_guess["txt"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["md"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["rst"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["json"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["yml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["yaml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["toml"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["cfg"] = tree->get_theme_icon("TextFile", "EditorIcons"); - extension_guess["ini"] = tree->get_theme_icon("TextFile", "EditorIcons"); + extension_guess["obj"] = tree->get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); + + extension_guess["txt"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["md"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["rst"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["json"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["yml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["yaml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["toml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["cfg"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); + extension_guess["ini"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")); } - Ref<Texture2D> generic_extension = tree->get_theme_icon("Object", "EditorIcons"); + Ref<Texture2D> generic_extension = tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); unzClose(pkg); @@ -191,7 +191,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { TreeItem *root = tree->create_item(); root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); root->set_checked(0, true); - root->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); + root->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); root->set_text(0, "res://"); root->set_editable(0, true); Map<String, TreeItem *> dir_map; @@ -242,7 +242,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { if (isdir) { dir_map[path] = ti; ti->set_text(0, path.get_file() + "/"); - ti->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); + ti->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); ti->set_metadata(0, String()); } else { String file = path.get_file(); @@ -257,7 +257,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { String res_path = "res://" + path; if (FileAccess::exists(res_path)) { num_file_conflicts += 1; - ti->set_custom_color(0, tree->get_theme_color("error_color", "Editor")); + ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor"))); ti->set_tooltip(0, vformat(TTR("%s (already exists)"), res_path)); ti->set_checked(0, false); } else { diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 3e3428ad93..4a19f007d4 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -64,42 +64,42 @@ void EditorAudioBus::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); + channel[i].vu_l->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_l->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); + channel[i].vu_r->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_r->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); channel[i].prev_active = true; } - disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); + disabled_vu = get_theme_icon(SNAME("BusVuFrozen"), SNAME("EditorIcons")); Color solo_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.89, 0.22) : Color(1.0, 0.92, 0.44); Color mute_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.16, 0.16) : Color(1.0, 0.44, 0.44); Color bypass_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(0.13, 0.8, 1.0) : Color(0.44, 0.87, 1.0); - solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); + solo->set_icon(get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"))); solo->add_theme_color_override("icon_pressed_color", solo_color); - mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); + mute->set_icon(get_theme_icon(SNAME("AudioBusMute"), SNAME("EditorIcons"))); mute->add_theme_color_override("icon_pressed_color", mute_color); - bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); + bypass->set_icon(get_theme_icon(SNAME("AudioBusBypass"), SNAME("EditorIcons"))); bypass->add_theme_color_override("icon_pressed_color", bypass_color); - bus_options->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + bus_options->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); update_bus(); set_process(true); } break; case NOTIFICATION_DRAW: { if (is_master) { - draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("disabled"), SNAME("Button")), Rect2(Vector2(), get_size())); } else if (has_focus()) { - draw_style_box(get_theme_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("focus"), SNAME("Button")), Rect2(Vector2(), get_size())); } else { - draw_style_box(get_theme_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")), Rect2(Vector2(), get_size())); } if (get_index() != 0 && hovering_drop) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -159,23 +159,23 @@ void EditorAudioBus::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); + channel[i].vu_l->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_l->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); + channel[i].vu_r->set_under_texture(get_theme_icon(SNAME("BusVuEmpty"), SNAME("EditorIcons"))); + channel[i].vu_r->set_progress_texture(get_theme_icon(SNAME("BusVuFull"), SNAME("EditorIcons"))); channel[i].prev_active = true; } - disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); + disabled_vu = get_theme_icon(SNAME("BusVuFrozen"), SNAME("EditorIcons")); - solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); - mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); - bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); + solo->set_icon(get_theme_icon(SNAME("AudioBusSolo"), SNAME("EditorIcons"))); + mute->set_icon(get_theme_icon(SNAME("AudioBusMute"), SNAME("EditorIcons"))); + bypass->set_icon(get_theme_icon(SNAME("AudioBusBypass"), SNAME("EditorIcons"))); - bus_options->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + bus_options->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - audio_value_preview_box->add_theme_color_override("font_color", get_theme_color("font_color", "TooltipLabel")); - audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + audio_value_preview_box->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"))); + audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { @@ -567,12 +567,12 @@ void EditorAudioBus::_effects_gui_input(Ref<InputEvent> p_event) { void EditorAudioBus::_bus_popup_pressed(int p_option) { if (p_option == 2) { // Reset volume - emit_signal("vol_reset_request"); + emit_signal(SNAME("vol_reset_request")); } else if (p_option == 1) { - emit_signal("delete_request"); + emit_signal(SNAME("delete_request")); } else if (p_option == 0) { //duplicate - emit_signal("duplicate_request", get_index()); + emit_signal(SNAME("duplicate_request"), get_index()); } } @@ -585,7 +585,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { Panel *p = memnew(Panel); c->add_child(p); p->set_modulate(Color(1, 1, 1, 0.7)); - p->add_theme_style_override("panel", get_theme_stylebox("focus", "Button")); + p->add_theme_style_override("panel", get_theme_stylebox(SNAME("focus"), SNAME("Button"))); p->set_size(get_size()); p->set_position(-p_point); set_drag_preview(c); @@ -594,7 +594,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { d["index"] = get_index(); if (get_index() < AudioServer::get_singleton()->get_bus_count() - 1) { - emit_signal("drop_end_request"); + emit_signal(SNAME("drop_end_request")); } return d; @@ -616,7 +616,7 @@ bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; - emit_signal("dropped", d["index"], get_index()); + emit_signal(SNAME("dropped"), d["index"], get_index()); } Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) { @@ -842,13 +842,13 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { audio_value_preview_label->set_v_size_flags(SIZE_EXPAND_FILL); audio_value_preview_label->set_h_size_flags(SIZE_EXPAND_FILL); audio_value_preview_label->set_mouse_filter(MOUSE_FILTER_PASS); - audio_value_preview_box->add_theme_color_override("font_color", get_theme_color("font_color", "TooltipLabel")); + audio_value_preview_box->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"))); audioprev_hbc->add_child(audio_value_preview_label); slider->add_child(audio_value_preview_box); audio_value_preview_box->set_as_top_level(true); - audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); + audio_value_preview_box->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"))); audio_value_preview_box->set_mouse_filter(MOUSE_FILTER_PASS); audio_value_preview_box->hide(); @@ -920,15 +920,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { List<StringName> effects; ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = effects.front(); E; E = E->next()) { - if (!ClassDB::can_instantiate(E->get())) { + for (const StringName &E : effects) { + if (!ClassDB::can_instantiate(E)) { continue; } - Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E->get()); - String name = E->get().operator String().replace("AudioEffect", ""); + Ref<Texture2D> icon = EditorNode::get_singleton()->get_class_icon(E); + String name = E.operator String().replace("AudioEffect", ""); effect_options->add_item(name); - effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get()); + effect_options->set_item_metadata(effect_options->get_item_count() - 1, E); effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } @@ -955,10 +955,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { void EditorAudioBusDrop::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("normal"), SNAME("Button")), Rect2(Vector2(), get_size())); if (hovering_drop) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -986,7 +986,7 @@ bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_d void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) { Dictionary d = p_data; - emit_signal("dropped", d["index"], AudioServer::get_singleton()->get_bus_count()); + emit_signal(SNAME("dropped"), d["index"], AudioServer::get_singleton()->get_bus_count()); } void EditorAudioBusDrop::_bind_methods() { @@ -1026,7 +1026,7 @@ void EditorAudioBuses::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + bus_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { _update_buses(); @@ -1217,7 +1217,7 @@ void EditorAudioBuses::_load_default_layout() { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } void EditorAudioBuses::_file_dialog_callback(const String &p_string) { @@ -1233,7 +1233,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { if (new_layout) { @@ -1253,7 +1253,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { file->set_text(String(TTR("Layout")) + ": " + p_string.get_file()); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } } @@ -1331,8 +1331,8 @@ EditorAudioBuses::EditorAudioBuses() { file_dialog = memnew(EditorFileDialog); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get() + "; Audio Bus Layout"); + for (const String &E : ext) { + file_dialog->add_filter("*." + E + "; Audio Bus Layout"); } add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorAudioBuses::_file_dialog_callback)); @@ -1354,7 +1354,7 @@ void EditorAudioBuses::open_layout(const String &p_path) { AudioServer::get_singleton()->set_bus_layout(state); _update_buses(); EditorNode::get_singleton()->get_undo_redo()->clear_history(); - call_deferred("_select_layout"); + call_deferred(SNAME("_select_layout")); } void AudioBusesEditorPlugin::edit(Object *p_node) { @@ -1385,8 +1385,8 @@ void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_va } Size2 EditorAudioMeterNotches::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); float width = 0; @@ -1411,7 +1411,7 @@ void EditorAudioMeterNotches::_bind_methods() { void EditorAudioMeterNotches::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - notch_color = get_theme_color("font_color", "Editor"); + notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); } break; case NOTIFICATION_DRAW: { _draw_audio_notches(); @@ -1420,8 +1420,8 @@ void EditorAudioMeterNotches::_notification(int p_what) { } void EditorAudioMeterNotches::_draw_audio_notches() { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); for (int i = 0; i < notches.size(); i++) { @@ -1443,5 +1443,5 @@ void EditorAudioMeterNotches::_draw_audio_notches() { } EditorAudioMeterNotches::EditorAudioMeterNotches() { - notch_color = get_theme_color("font_color", "Editor"); + notch_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 12ae55fbc1..fad76682b5 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -46,19 +46,18 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - for (List<String>::Element *E = afn.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); + for (const String &E : afn) { + file_dialog->add_filter("*." + E); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && info.in_editor) { - get_tree()->get_root()->call_deferred("add_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } } - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } @@ -102,8 +101,8 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin for (int i = 0; i < ScriptServer::get_language_count(); i++) { List<String> keywords; ScriptServer::get_language(i)->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (E->get() == p_name) { + for (const String &E : keywords) { + if (E == p_name) { if (r_error) { *r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name."); } @@ -379,8 +378,7 @@ void EditorAutoloadSettings::update_autoload() { Map<String, AutoLoadInfo> to_remove; List<AutoLoadInfo *> to_add; - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { to_remove.insert(info.name, info); } @@ -392,9 +390,7 @@ void EditorAutoloadSettings::update_autoload() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -453,10 +449,10 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_theme_icon("Load", "EditorIcons"), BUTTON_OPEN); - item->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); - item->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); - item->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_DELETE); + item->add_button(3, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_OPEN); + item->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP); + item->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN); + item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_DELETE); item->set_selectable(3, false); } @@ -470,7 +466,7 @@ void EditorAutoloadSettings::update_autoload() { } if (info.in_editor) { ERR_CONTINUE(!info.node); - get_tree()->get_root()->call_deferred("remove_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("remove_child"), info.node); } if (info.node) { @@ -483,9 +479,7 @@ void EditorAutoloadSettings::update_autoload() { // Load new/changed autoloads List<Node *> nodes_to_add; - for (List<AutoLoadInfo *>::Element *E = to_add.front(); E; E = E->next()) { - AutoLoadInfo *info = E->get(); - + for (AutoLoadInfo *info : to_add) { info->node = _create_autoload(info->path); ERR_CONTINUE(!info->node); @@ -518,8 +512,8 @@ void EditorAutoloadSettings::update_autoload() { } } - for (List<Node *>::Element *E = nodes_to_add.front(); E; E = E->next()) { - get_tree()->get_root()->add_child(E->get()); + for (Node *E : nodes_to_add) { + get_tree()->get_root()->add_child(E); } updating_autoload = false; @@ -649,8 +643,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - orders.write[i++] = F->get().order; + for (const AutoLoadInfo &F : autoload_cache) { + orders.write[i++] = F.order; } orders.sort(); @@ -661,9 +655,9 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; - for (List<AutoLoadInfo>::Element *F = autoload_cache.front(); F; F = F->next()) { - undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, orders[i++]); - undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F->get().name, F->get().order); + for (const AutoLoadInfo &F : autoload_cache) { + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, orders[i++]); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", "autoload/" + F.name, F.order); } orders.clear(); @@ -764,9 +758,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { // Make first cache List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -799,9 +791,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_cache.push_back(info); } - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); - + for (AutoLoadInfo &info : autoload_cache) { info.node = _create_autoload(info.path); if (info.node) { @@ -904,8 +894,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } EditorAutoloadSettings::~EditorAutoloadSettings() { - for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - AutoLoadInfo &info = E->get(); + for (const AutoLoadInfo &info : autoload_cache) { if (info.node && !info.in_editor) { memdelete(info.node); } @@ -914,7 +903,7 @@ EditorAutoloadSettings::~EditorAutoloadSettings() { void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) { autoload_add_path->set_text(p_text); - autoload_add_path->emit_signal("text_submitted", p_text); + autoload_add_path->emit_signal(SNAME("text_submitted"), p_text); } void EditorAutoloadSettings::_browse_autoload_add_path() { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 3823d7e14f..c62e5b75b2 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -299,13 +299,13 @@ void EditorData::copy_object_params(Object *p_object) { List<PropertyInfo> pinfo; p_object->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) || E.name == "script" || E.name == "scripts") { continue; } PropertyData pd; - pd.name = E->get().name; + pd.name = E.name; pd.value = p_object->get(pd.name); clipboard.push_back(pd); } @@ -404,9 +404,9 @@ void EditorData::restore_editor_global_states() { void EditorData::paste_object_params(Object *p_object) { ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); - for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) { - String name = E->get().name; - undo_redo.add_do_property(p_object, name, E->get().value); + for (const PropertyData &E : clipboard) { + String name = E.name; + undo_redo.add_do_property(p_object, name, E.value); undo_redo.add_undo_property(p_object, name, p_object->get(name)); } undo_redo.commit_action(); @@ -616,8 +616,8 @@ bool EditorData::check_and_update_scene(int p_idx) { //transfer selection List<Node *> new_selection; - for (List<Node *>::Element *E = edited_scene.write[p_idx].selection.front(); E; E = E->next()) { - NodePath p = edited_scene[p_idx].root->get_path_to(E->get()); + for (const Node *E : edited_scene.write[p_idx].selection) { + NodePath p = edited_scene[p_idx].root->get_path_to(E); Node *new_node = new_scene->get_node(p); if (new_node) { new_selection.push_back(new_node); @@ -841,8 +841,8 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, p_history->history = es.history_stored; p_selection->clear(); - for (List<Node *>::Element *E = es.selection.front(); E; E = E->next()) { - p_selection->add_node(E->get()); + for (Node *E : es.selection) { + p_selection->add_node(E); } set_editor_states(es.editor_states); @@ -964,9 +964,9 @@ void EditorData::script_class_save_icon_paths() { _script_class_icon_paths.get_key_list(&keys); Dictionary d; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - if (ScriptServer::is_global_class(E->get())) { - d[E->get()] = _script_class_icon_paths[E->get()]; + for (const StringName &E : keys) { + if (ScriptServer::is_global_class(E)) { + d[E] = _script_class_icon_paths[E]; } } @@ -996,8 +996,8 @@ void EditorData::script_class_load_icon_paths() { List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - String name = E->get().operator String(); + for (const Variant &E : keys) { + String name = E.operator String(); _script_class_icon_paths[name] = d[name]; String path = ScriptServer::get_global_class_path(name); @@ -1038,8 +1038,8 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; Object *meta = nullptr; - for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); + for (Object *E : editor_plugins) { + meta = E->call("_get_editor_data", p_node); if (meta) { break; } @@ -1048,7 +1048,7 @@ void EditorSelection::add_node(Node *p_node) { p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed), varray(p_node), CONNECT_ONESHOT); - //emit_signal("selection_changed"); + //emit_signal(SNAME("selection_changed")); } void EditorSelection::remove_node(Node *p_node) { @@ -1066,7 +1066,7 @@ void EditorSelection::remove_node(Node *p_node) { } selection.erase(p_node); p_node->disconnect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed)); - //emit_signal("selection_changed"); + //emit_signal(SNAME("selection_changed")); } bool EditorSelection::is_selected(Node *p_node) const { @@ -1076,8 +1076,8 @@ bool EditorSelection::is_selected(Node *p_node) const { Array EditorSelection::_get_transformable_selected_nodes() { Array ret; - for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const Node *E : selected_node_list) { + ret.push_back(E); } return ret; @@ -1144,12 +1144,12 @@ void EditorSelection::update() { changed = false; if (!emitted) { emitted = true; - call_deferred("_emit_change"); + call_deferred(SNAME("_emit_change")); } } void EditorSelection::_emit_change() { - emit_signal("selection_changed"); + emit_signal(SNAME("selection_changed")); emitted = false; } diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 4366d83fe2..5df392b91e 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -43,7 +43,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p String path = p_dir->get_path(); p_item->set_metadata(0, p_dir->get_path()); - p_item->set_icon(0, tree->get_theme_icon("Folder", "EditorIcons")); + p_item->set_icon(0, tree->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); if (!p_item->get_parent()) { p_item->set_text(0, "res://"); @@ -129,7 +129,7 @@ void EditorDirDialog::ok_pressed() { } String dir = ti->get_metadata(0); - emit_signal("dir_selected", dir); + emit_signal(SNAME("dir_selected"), dir); hide(); } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index fc483b46b7..b374f56f6d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -80,9 +80,9 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { } void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (platform->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (platform->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -436,9 +436,9 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { List<ExportOption> options; get_export_options(&options); - for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); - preset->values[E->get().option.name] = E->get().default_value; + for (const ExportOption &E : options) { + preset->properties.push_back(E.option); + preset->values[E.option.name] = E.default_value; } return preset; @@ -679,9 +679,9 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai platform->get_preset_features(p_preset, &feature_list); FeatureContainers result; - for (List<String>::Element *E = feature_list.front(); E; E = E->next()) { - result.features.insert(E->get()); - result.features_pv.push_back(E->get()); + for (const String &E : feature_list) { + result.features.insert(E); + result.features_pv.push_back(E); } if (p_preset->get_custom_features() != String()) { @@ -752,9 +752,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - + for (const PropertyInfo &pi : props) { if (!pi.name.begins_with("autoload/")) { continue; } @@ -899,8 +897,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Set<String> remap_features; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (const String &F : remaps) { + String remap = F; String feature = remap.get_slice(".", 1); if (features.has(feature)) { remap_features.insert(feature); @@ -913,8 +911,8 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & err = OK; - for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); + for (const String &F : remaps) { + String remap = F; if (remap == "path") { String remapped_path = config->get_value("remap", remap); Vector<uint8_t> array = FileAccess::get_file_as_array(remapped_path); @@ -1050,6 +1048,13 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & return err; } } + if (FileAccess::exists(ResourceUID::CACHE_FILE)) { + Vector<uint8_t> array = FileAccess::get_file_as_array(ResourceUID::CACHE_FILE); + err = p_func(p_udata, ResourceUID::CACHE_FILE, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } + } // Store text server data if it is supported. if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) { @@ -1362,7 +1367,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags if (breakpoints.size()) { r_flags.push_back("--breakpoints"); String bpoints; - for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { + for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) { bpoints += E->get().replace(" ", "%20"); if (E->next()) { bpoints += ","; @@ -1436,8 +1441,8 @@ void EditorExport::_save() { String option_section = "preset." + itos(i) + ".options"; - for (const List<PropertyInfo>::Element *E = preset->get_properties().front(); E; E = E->next()) { - config->set_value(option_section, E->get().name, preset->get(E->get().name)); + for (const PropertyInfo &E : preset->get_properties()) { + config->set_value(option_section, E.name, preset->get(E.name)); } } @@ -1642,10 +1647,10 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); - for (List<String>::Element *E = options.front(); E; E = E->next()) { - Variant value = config->get_value(option_section, E->get()); + for (const String &E : options) { + Variant value = config->get_value(option_section, E); - preset->set(E->get(), value); + preset->set(E, value); } add_export_preset(preset); @@ -1684,11 +1689,11 @@ void EditorExport::update_export_presets() { preset->properties.clear(); preset->values.clear(); - for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); + for (const EditorExportPlatform::ExportOption &E : options) { + preset->properties.push_back(E.option); - StringName option_name = E->get().option.name; - preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().default_value; + StringName option_name = E.option.name; + preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; } } } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 58d2b6e86e..22f44a54bb 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -497,7 +497,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S bool disabled_editor = edited->is_class_editor_disabled(p_class); bool disabled_properties = edited->has_class_properties_disabled(p_class); if (disabled) { - class_item->set_custom_color(0, class_list->get_theme_color("disabled_font_color", "Editor")); + class_item->set_custom_color(0, class_list->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } else if (disabled_editor && disabled_properties) { text += " " + TTR("(Editor Disabled, Properties Disabled)"); } else if (disabled_properties) { @@ -527,9 +527,8 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S ClassDB::get_direct_inheriters_from_class(p_class, &child_classes); child_classes.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = child_classes.front(); E; E = E->next()) { - String name = E->get(); - if (name.begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { + for (const StringName &name : child_classes) { + if (String(name).begins_with("Editor") || ClassDB::get_api_type(name) != ClassDB::API_CORE) { continue; } _fill_classes_from(class_item, name, p_selected); @@ -597,9 +596,9 @@ void EditorFeatureProfileManager::_class_list_item_selected() { TreeItem *properties = property_list->create_item(root); properties->set_text(0, TTR("Class Properties:")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : props) { + String name = E.name; + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } TreeItem *property = property_list->create_item(properties); @@ -609,7 +608,7 @@ void EditorFeatureProfileManager::_class_list_item_selected() { property->set_checked(0, !edited->is_class_property_disabled(class_name, name)); property->set_text(0, name.capitalize()); property->set_metadata(0, name); - String icon_type = Variant::get_type_name(E->get().type); + String icon_type = Variant::get_type_name(E.type); property->set_icon(0, EditorNode::get_singleton()->get_class_icon(icon_type)); } } @@ -834,7 +833,7 @@ void EditorFeatureProfileManager::_save_and_update() { } void EditorFeatureProfileManager::_emit_current_profile_changed() { - emit_signal("current_feature_profile_changed"); + emit_signal(SNAME("current_feature_profile_changed")); } void EditorFeatureProfileManager::notify_changed() { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index a07b3a7c19..5ccbed1b49 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -61,22 +61,22 @@ VBoxContainer *EditorFileDialog::get_vbox() { void EditorFileDialog::_notification(int p_what) { if (p_what == NOTIFICATION_READY || p_what == NOTIFICATION_THEME_CHANGED || p_what == Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { // Update icons. - mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + mode_list->set_icon(item_list->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); - favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); - show_hidden->set_icon(item_list->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); + refresh->set_icon(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + favorite->set_icon(item_list->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); + show_hidden->set_icon(item_list->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); - fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); + fav_up->set_icon(item_list->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + fav_down->set_icon(item_list->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); } else if (p_what == NOTIFICATION_PROCESS) { if (preview_waiting) { @@ -100,21 +100,21 @@ void EditorFileDialog::_notification(int p_what) { set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); // Update icons. - mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); + mode_list->set_icon(item_list->get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - dir_prev->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); - dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + dir_next->set_icon(item_list->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); - favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon(SNAME("ArrowUp"), SNAME("EditorIcons"))); + refresh->set_icon(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + favorite->set_icon(item_list->get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); - fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); + fav_up->set_icon(item_list->get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + fav_down->set_icon(item_list->get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD invalidate(); } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -245,7 +245,7 @@ void EditorFileDialog::_save_confirm_pressed() { String f = dir_access->get_current_dir().plus_file(file->get_text()); _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } void EditorFileDialog::_post_popup() { @@ -279,8 +279,8 @@ void EditorFileDialog::_post_popup() { } if (is_visible()) { - Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); recent->clear(); bool res = access == ACCESS_RESOURCES; @@ -379,7 +379,7 @@ void EditorFileDialog::_action_pressed() { if (files.size()) { _save_to_recent(); hide(); - emit_signal("files_selected", files); + emit_signal(SNAME("files_selected"), files); } return; @@ -390,7 +390,7 @@ void EditorFileDialog::_action_pressed() { if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) { String path = dir_access->get_current_dir(); @@ -409,7 +409,7 @@ void EditorFileDialog::_action_pressed() { _save_to_recent(); hide(); - emit_signal("dir_selected", path); + emit_signal(SNAME("dir_selected"), path); } if (mode == FILE_MODE_SAVE_FILE) { @@ -474,7 +474,7 @@ void EditorFileDialog::_action_pressed() { } else { _save_to_recent(); hide(); - emit_signal("file_selected", f); + emit_signal(SNAME("file_selected"), f); } } } @@ -563,8 +563,8 @@ void EditorFileDialog::_item_dc_selected(int p_item) { if (d["dir"]) { dir_access->change_dir(d["name"]); - call_deferred("_update_file_list"); - call_deferred("_update_dir"); + call_deferred(SNAME("_update_file_list")); + call_deferred(SNAME("_update_dir")); _push_history(); @@ -595,16 +595,16 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p } if (single_item_selected) { - item_menu->add_icon_item(item_list->get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), TTR("Copy Path"), ITEM_MENU_COPY_PATH); } if (allow_delete) { - item_menu->add_icon_item(item_list->get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); } if (single_item_selected) { item_menu->add_separator(); Dictionary item_meta = item_list->get_item_metadata(p_item); String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager"); - item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, ITEM_MENU_SHOW_IN_EXPLORER); } if (item_menu->get_item_count() > 0) { @@ -623,11 +623,11 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (can_create_dir) { - item_menu->add_icon_item(item_list->get_theme_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); } - item_menu->add_icon_item(item_list->get_theme_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); item_menu->add_separator(); - item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); item_menu->set_position(item_list->get_global_position() + p_pos); item_menu->popup(); @@ -731,11 +731,11 @@ void EditorFileDialog::update_file_list() { item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = item_list->get_theme_icon("FolderMediumThumb", "EditorIcons"); - file_thumbnail = item_list->get_theme_icon("FileMediumThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); + file_thumbnail = item_list->get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); } else { - folder_thumbnail = item_list->get_theme_icon("FolderBigThumb", "EditorIcons"); - file_thumbnail = item_list->get_theme_icon("FileBigThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); + file_thumbnail = item_list->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); } preview_vb->hide(); @@ -755,8 +755,8 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = item_list->get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); List<String> files; List<String> dirs; @@ -830,8 +830,8 @@ void EditorFileDialog::update_file_list() { while (!files.is_empty()) { bool match = patterns.is_empty(); - for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { + for (const String &E : patterns) { + if (files.front()->get().matchn(E)) { match = true; break; } @@ -1206,8 +1206,8 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture2D> folder_icon = item_list->get_theme_icon("Folder", "EditorIcons"); - const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = item_list->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + const Color folder_color = item_list->get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); favorites->clear(); favorite->set_pressed(false); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a2507f3cf2..78861eff9d 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -43,7 +43,7 @@ EditorFileSystem *EditorFileSystem::singleton = nullptr; //the name is the version, to keep compatibility with different versions of Godot -#define CACHE_FILE_NAME "filesystem_cache6" +#define CACHE_FILE_NAME "filesystem_cache7" void EditorFileSystemDirectory::sort_files() { files.sort_custom<FileInfoSort>(); @@ -116,7 +116,26 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, files.size(), Vector<String>()); - return files[p_idx]->deps; + Vector<String> deps; + + for (int i = 0; i < files[p_idx]->deps.size(); i++) { + String dep = files[p_idx]->deps[i]; + int sep_idx = dep.find("::"); //may contain type information, unwanted + if (sep_idx != -1) { + dep = dep.substr(0, sep_idx); + } + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(dep); + if (uid != ResourceUID::INVALID_ID) { + //return proper dependency resource from uid + if (ResourceUID::get_singleton()->has_id(uid)) { + dep = ResourceUID::get_singleton()->get_id_path(uid); + } else { + continue; + } + } + deps.push_back(dep); + } + return deps; } bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const { @@ -234,7 +253,7 @@ void EditorFileSystem::_scan_filesystem() { } else { Vector<String> split = l.split("::"); - ERR_CONTINUE(split.size() != 8); + ERR_CONTINUE(split.size() != 9); String name = split[0]; String file; @@ -243,15 +262,16 @@ void EditorFileSystem::_scan_filesystem() { FileCache fc; fc.type = split[1]; - fc.modification_time = split[2].to_int(); - fc.import_modification_time = split[3].to_int(); - fc.import_valid = split[4].to_int() != 0; - fc.import_group_file = split[5].strip_edges(); - fc.script_class_name = split[6].get_slice("<>", 0); - fc.script_class_extends = split[6].get_slice("<>", 1); - fc.script_class_icon_path = split[6].get_slice("<>", 2); - - String deps = split[7].strip_edges(); + fc.uid = split[2].to_int(); + fc.modification_time = split[3].to_int(); + fc.import_modification_time = split[4].to_int(); + fc.import_valid = split[5].to_int() != 0; + fc.import_group_file = split[6].strip_edges(); + fc.script_class_name = split[7].get_slice("<>", 0); + fc.script_class_extends = split[7].get_slice("<>", 1); + fc.script_class_icon_path = split[7].get_slice("<>", 2); + + String deps = split[8].strip_edges(); if (deps.length()) { Vector<String> dp = deps.split("<>"); for (int i = 0; i < dp.size(); i++) { @@ -368,6 +388,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo Vector<String> dest_files; String dest_md5 = ""; int version = 0; + bool found_uid = false; while (true) { assign = Variant(); @@ -395,6 +416,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo version = value; } else if (assign == "importer") { importer_name = value; + } else if (assign == "uid") { + found_uid = true; } else if (!p_only_imported_files) { if (assign == "source_file") { source_file = value; @@ -414,6 +437,10 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //keep mode, do not reimport } + if (!found_uid) { + return true; //UUID not found, old format, reimport. + } + Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name); if (importer->get_format_version() > version) { @@ -457,8 +484,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo memdelete(md5s); //imported files are gone, reimport - for (List<String>::Element *E = to_check.front(); E; E = E->next()) { - if (!FileAccess::exists(E->get())) { + for (const String &E : to_check) { + if (!FileAccess::exists(E)) { return true; } } @@ -497,9 +524,7 @@ bool EditorFileSystem::_update_scan_actions() { Vector<String> reimports; Vector<String> reloads; - for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) { - ItemAction &ia = E->get(); - + for (const ItemAction &ia : scan_actions) { switch (ia.action) { case ItemAction::ACTION_NONE: { } break; @@ -582,6 +607,9 @@ bool EditorFileSystem::_update_scan_actions() { if (reimports.size()) { reimport_files(reimports); + } else { + //reimport files will update the uid cache file so if nothing was reimported, update it manually + ResourceUID::get_singleton()->update_cache(); } if (first_scan) { @@ -592,7 +620,7 @@ bool EditorFileSystem::_update_scan_actions() { } if (reloads.size()) { - emit_signal("resources_reload", reloads); + emit_signal(SNAME("resources_reload"), reloads); } scan_actions.clear(); @@ -623,8 +651,8 @@ void EditorFileSystem::scan() { new_filesystem = nullptr; _update_scan_actions(); scanning = false; - emit_signal("filesystem_changed"); - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("filesystem_changed")); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } else { @@ -756,6 +784,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && !_test_for_reimport(path, true)) { fi->type = fc->type; + fi->uid = fc->uid; fi->deps = fc->deps; fi->modified_time = fc->modification_time; fi->import_modified_time = fc->import_modification_time; @@ -781,8 +810,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess //note: I think this should not happen any longer.. } + if (fc->uid == ResourceUID::INVALID_ID) { + // imported files should always have a UUID, so attempt to fetch it. + fi->uid = ResourceLoader::get_resource_uid(path); + } + } else { fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path); + fi->uid = ResourceFormatImporter::get_singleton()->get_resource_uid(path); fi->import_group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(path); fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path); fi->modified_time = 0; @@ -799,6 +834,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (fc && fc->modification_time == mt) { //not imported, so just update type if changed fi->type = fc->type; + fi->uid = fc->uid; fi->modified_time = fc->modification_time; fi->deps = fc->deps; fi->import_modified_time = 0; @@ -809,6 +845,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } else { //new or modified time fi->type = ResourceLoader::get_resource_type(path); + fi->uid = ResourceLoader::get_resource_uid(path); fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path); fi->deps = _get_dependencies(path); fi->modified_time = mt; @@ -817,6 +854,14 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } } + if (fi->uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(fi->uid)) { + ResourceUID::get_singleton()->set_id(fi->uid, path); + } else { + ResourceUID::get_singleton()->add_id(fi->uid, path); + } + } + for (int i = 0; i < ScriptServer::get_language_count(); i++) { ScriptLanguage *lang = ScriptServer::get_language(i); if (lang->supports_documentation() && fi->type == lang->get_type()) { @@ -1027,8 +1072,8 @@ void EditorFileSystem::_delete_internal_files(String p_file) { List<String> paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); + for (const String &E : paths) { + da->remove(E); } da->remove(p_file + ".import"); memdelete(da); @@ -1073,12 +1118,12 @@ void EditorFileSystem::scan_changes() { scan_total = 0; _scan_fs_changes(filesystem, sp); if (_update_scan_actions()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } } scanning_changes = false; scanning_changes_done = true; - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); } else { ERR_FAIL_COND(thread_sources.is_started()); set_process(true); @@ -1092,7 +1137,7 @@ void EditorFileSystem::scan_changes() { void EditorFileSystem::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - call_deferred("scan"); //this should happen after every editor node entered the tree + call_deferred(SNAME("scan")); //this should happen after every editor node entered the tree } break; case NOTIFICATION_EXIT_TREE: { @@ -1128,9 +1173,9 @@ void EditorFileSystem::_notification(int p_what) { thread_sources.wait_to_finish(); if (_update_scan_actions()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } @@ -1144,8 +1189,8 @@ void EditorFileSystem::_notification(int p_what) { new_filesystem = nullptr; thread.wait_to_finish(); _update_scan_actions(); - emit_signal("filesystem_changed"); - emit_signal("sources_changed", sources_changed.size() > 0); + emit_signal(SNAME("filesystem_changed")); + emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); _queue_update_script_classes(); first_scan = false; } @@ -1181,7 +1226,7 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, if (p_dir->files[i]->import_group_file != String()) { group_file_cache.insert(p_dir->files[i]->import_group_file); } - String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; + String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->uid) + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; s += "::"; for (int j = 0; j < p_dir->files[i]->deps.size(); j++) { if (j > 0) { @@ -1368,8 +1413,8 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { ResourceLoader::get_dependencies(p_path, &deps); Vector<String> ret; - for (List<String>::Element *E = deps.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const String &E : deps) { + ret.push_back(E); } return ret; @@ -1445,7 +1490,7 @@ void EditorFileSystem::_queue_update_script_classes() { } update_script_classes_queued.set(); - call_deferred("update_script_classes"); + call_deferred(SNAME("update_script_classes")); } void EditorFileSystem::update_file(const String &p_file) { @@ -1462,16 +1507,22 @@ void EditorFileSystem::update_file(const String &p_file) { //was removed _delete_internal_files(p_file); if (cpos != -1) { // Might've never been part of the editor file system (*.* files deleted in Open dialog). + if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(fs->files[cpos]->uid)) { + ResourceUID::get_singleton()->remove_id(fs->files[cpos]->uid); + } + } memdelete(fs->files[cpos]); fs->files.remove(cpos); } - call_deferred("emit_signal", "filesystem_changed"); //update later + call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later _queue_update_script_classes(); return; } String type = ResourceLoader::get_resource_type(p_file); + ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_file); if (cpos == -1) { // The file did not exist, it was added. @@ -1504,16 +1555,26 @@ void EditorFileSystem::update_file(const String &p_file) { } fs->files[cpos]->type = type; + fs->files[cpos]->uid = uid; fs->files[cpos]->script_class_name = _get_global_script_class(type, p_file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path); fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(p_file); fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); + if (uid != ResourceUID::INVALID_ID) { + if (ResourceUID::get_singleton()->has_id(uid)) { + ResourceUID::get_singleton()->set_id(uid, p_file); + } else { + ResourceUID::get_singleton()->add_id(uid, p_file); + } + + ResourceUID::get_singleton()->update_cache(); + } // Update preview EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); - call_deferred("emit_signal", "filesystem_changed"); //update later + call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later _queue_update_script_classes(); } @@ -1532,7 +1593,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector ERR_CONTINUE(file_importer_name == String()); if (importer_name != String() && importer_name != file_importer_name) { - print_line("one importer '" + importer_name + "' the other '" + file_importer_name + "'."); EditorNode::get_singleton()->show_warning(vformat(TTR("There are multiple importers for different types pointing to file %s, import aborted"), p_group_file)); ERR_FAIL_V(ERR_FILE_CORRUPT); } @@ -1549,15 +1609,14 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - source_file_options[p_files[i]][E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + source_file_options[p_files[i]][E.option.name] = E.default_value; } if (config->has_section("params")) { List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - String param = E->get(); + for (const String ¶m : sk) { Variant value = config->get_value("params", param); //override with whathever is in file source_file_options[p_files[i]][param] = value; @@ -1631,9 +1690,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector List<ResourceImporter::ImportOption> options; importer->get_import_options(&options); //set default values - for (List<ResourceImporter::ImportOption>::Element *F = options.front(); F; F = F->next()) { - String base = F->get().option.name; - Variant v = F->get().default_value; + for (const ResourceImporter::ImportOption &F : options) { + String base = F.option.name; + Variant v = F.default_value; if (source_file_options[file].has(base)) { v = source_file_options[file][base]; } @@ -1702,6 +1761,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName params = *p_custom_options; } + ResourceUID::ID uid = ResourceUID::INVALID_ID; + if (FileAccess::exists(p_file + ".import")) { //use existing if (p_custom_options == nullptr) { @@ -1712,12 +1773,20 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (cf->has_section("params")) { List<String> sk; cf->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { - params[E->get()] = cf->get_value("params", E->get()); + for (const String &E : sk) { + params[E] = cf->get_value("params", E); } } - if (p_custom_importer == String() && cf->has_section("remap")) { - importer_name = cf->get_value("remap", "importer"); + + if (cf->has_section("remap")) { + if (p_custom_importer == String()) { + importer_name = cf->get_value("remap", "importer"); + } + + if (cf->has_section_key("remap", "uid")) { + String uidt = cf->get_value("remap", "uid"); + uid = ResourceUID::get_singleton()->text_to_id(uidt); + } } } } @@ -1754,9 +1823,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<ResourceImporter::ImportOption> opts; importer->get_import_options(&opts); - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - if (!params.has(E->get().option.name)) { //this one is not present - params[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : opts) { + if (!params.has(E.option.name)) { //this one is not present + params[E.option.name] = E.default_value; } } @@ -1766,8 +1835,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName List<Variant> v; d.get_key_list(&v); - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params[E->get()] = d[E->get()]; + for (const Variant &E : v) { + params[E] = d[E]; } } @@ -1800,6 +1869,12 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName f->store_line("type=\"" + importer->get_resource_type() + "\""); } + if (uid == ResourceUID::INVALID_ID) { + uid = ResourceUID::get_singleton()->create_id(); + } + + f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); //store in readable format + Vector<String> dest_paths; if (err == OK) { @@ -1807,10 +1882,10 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //no path } else if (import_variants.size()) { //import with variants - for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); + for (const String &E : import_variants) { + String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension(); - f->store_line("path." + E->get() + "=\"" + path + "\""); + f->store_line("path." + E + "=\"" + path + "\""); dest_paths.push_back(path); } } else { @@ -1833,9 +1908,9 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName if (gen_files.size()) { Array genf; - for (List<String>::Element *E = gen_files.front(); E; E = E->next()) { - genf.push_back(E->get()); - dest_paths.push_back(E->get()); + for (const String &E : gen_files) { + genf.push_back(E); + dest_paths.push_back(E); } String value; @@ -1859,8 +1934,8 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. - for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - String base = E->get().option.name; + for (const ResourceImporter::ImportOption &E : opts) { + String base = E.option.name; String value; VariantWriter::write_to_string(params[base], value); f->store_line(base + "=" + value); @@ -1885,8 +1960,15 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->type = importer->get_resource_type(); + fs->files[cpos]->uid = uid; fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); + if (ResourceUID::get_singleton()->has_id(uid)) { + ResourceUID::get_singleton()->set_id(uid, p_file); + } else { + ResourceUID::get_singleton()->add_id(uid, p_file); + } + //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly if (ResourceCache::has(p_file)) { @@ -1937,11 +2019,18 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { Set<String> groups_to_reimport; for (int i = 0; i < p_files.size(); i++) { - String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(p_files[i]); + String file = p_files[i]; + + ResourceUID::ID uid = ResourceUID::get_singleton()->text_to_id(file); + if (uid != ResourceUID::INVALID_ID && ResourceUID::get_singleton()->has_id(uid)) { + file = ResourceUID::get_singleton()->get_id_path(uid); + } + + String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(file); - if (group_file_cache.has(p_files[i])) { + if (group_file_cache.has(file)) { //maybe the file itself is a group! - groups_to_reimport.insert(p_files[i]); + groups_to_reimport.insert(file); //groups do not belong to grups group_file = String(); } else if (group_file != String()) { @@ -1950,15 +2039,15 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } else { //it's a regular file ImportFile ifile; - ifile.path = p_files[i]; - ResourceFormatImporter::get_singleton()->get_import_order_threads_and_importer(p_files[i], ifile.order, ifile.threaded, ifile.importer); + ifile.path = file; + ResourceFormatImporter::get_singleton()->get_import_order_threads_and_importer(file, ifile.order, ifile.threaded, ifile.importer); reimport_files.push_back(ifile); } //group may have changed, so also update group reference EditorFileSystemDirectory *fs = nullptr; int cpos = -1; - if (_find_file(p_files[i], &fs, cpos)) { + if (_find_file(file, &fs, cpos)) { fs->files.write[cpos]->import_group_file = group_file; } } @@ -2023,13 +2112,15 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } } + ResourceUID::get_singleton()->update_cache(); //after reimporting, update the cache + _save_filesystem_cache(); importing = false; if (!is_scanning()) { - emit_signal("filesystem_changed"); + emit_signal(SNAME("filesystem_changed")); } - emit_signal("resources_reimported", p_files); + emit_signal(SNAME("resources_reimported"), p_files); } Error EditorFileSystem::_resource_import(const String &p_path) { @@ -2080,9 +2171,8 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S List<String> sk; config->get_section_keys("params", &sk); - for (List<String>::Element *E = sk.front(); E; E = E->next()) { + for (const String ¶m : sk) { //not very clean, but should work - String param = E->get(); String value = config->get_value("params", param); if (value == p_group_file) { config->set_value("params", param, p_new_location); @@ -2108,6 +2198,30 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new } } +ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) { + if (!p_path.is_resource_file() || p_path.begins_with("res://.godot")) { + //saved externally (configuration file) or internal file, do not assign an ID. + return ResourceUID::INVALID_ID; + } + + EditorFileSystemDirectory *fs = nullptr; + int cpos = -1; + + if (!singleton->_find_file(p_path, &fs, cpos)) { + if (p_generate) { + return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + } else { + return ResourceUID::INVALID_ID; + } + } else if (fs->files[cpos]->uid != ResourceUID::INVALID_ID) { + return fs->files[cpos]->uid; + } else if (p_generate) { + return ResourceUID::get_singleton()->create_id(); //just create a new one, we will be notified of save anyway and fetch the right UUID at that time, to keep things simple. + } else { + return ResourceUID::INVALID_ID; + } +} + void EditorFileSystem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_filesystem"), &EditorFileSystem::get_filesystem); ClassDB::bind_method(D_METHOD("is_scanning"), &EditorFileSystem::is_scanning); @@ -2131,14 +2245,14 @@ void EditorFileSystem::_update_extensions() { List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensionsl) { + valid_extensions.insert(E); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); - for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - import_extensions.insert(E->get()); + for (const String &E : extensionsl) { + import_extensions.insert(E); } } @@ -2169,8 +2283,11 @@ EditorFileSystem::EditorFileSystem() { scan_changes_pending = false; revalidate_import_files = false; import_threads.init(); + ResourceUID::get_singleton()->clear(); //will be updated on scan + ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path); } EditorFileSystem::~EditorFileSystem() { import_threads.finish(); + ResourceSaver::set_get_resource_id_for_path(nullptr); } diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 37eee13c16..9dce29d09c 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -55,6 +55,7 @@ class EditorFileSystemDirectory : public Object { struct FileInfo { String file; StringName type; + ResourceUID::ID uid = ResourceUID::INVALID_ID; uint64_t modified_time = 0; uint64_t import_modified_time = 0; bool import_valid = false; @@ -159,6 +160,7 @@ class EditorFileSystem : public Node { /* Used for reading the filesystem cache file */ struct FileCache { String type; + ResourceUID::ID uid = ResourceUID::INVALID_ID; uint64_t modification_time = 0; uint64_t import_modification_time = 0; Vector<String> deps; @@ -251,6 +253,8 @@ class EditorFileSystem : public Node { void _reimport_thread(uint32_t p_index, ImportThreadData *p_import_data); + static ResourceUID::ID _resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 5d6c415d39..29e3236ac2 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -109,10 +109,10 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p List<PropertyInfo> plist; p_node->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (E->get().type == Variant::OBJECT) { - RES res = p_node->get(E->get().name); + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_EDITOR) { + if (E.type == Variant::OBJECT) { + RES res = p_node->get(E.name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { Vector<String> res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); @@ -228,41 +228,41 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { Set<String> unfold_group; - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_CATEGORY) { + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; } - if (E->get().usage & PROPERTY_USAGE_GROUP) { - group = E->get().name; - group_base = E->get().hint_string; + if (E.usage & PROPERTY_USAGE_GROUP) { + group = E.name; + group_base = E.hint_string; if (group_base.ends_with("_")) { group_base = group_base.substr(0, group_base.length() - 1); } } //can unfold - if (E->get().usage & PROPERTY_USAGE_EDITOR) { + if (E.usage & PROPERTY_USAGE_EDITOR) { if (group != "") { //group - if (group_base == String() || E->get().name.begins_with(group_base)) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + if (group_base == String() || E.name.begins_with(group_base)) { + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { unfold_group.insert(group); } } } else { //path - int last = E->get().name.rfind("/"); + int last = E.name.rfind("/"); if (last != -1) { - bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); + bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { - unfold_group.insert(E->get().name.substr(0, last)); + unfold_group.insert(E.name.substr(0, last)); } } } - if (E->get().type == Variant::OBJECT) { - RES res = p_object->get(E->get().name); - print_line("res: " + String(E->get().name) + " valid " + itos(res.is_valid())); + if (E.type == Variant::OBJECT) { + RES res = p_object->get(E.name); + print_line("res: " + String(E.name) + " valid " + itos(res.is_valid())); if (res.is_valid()) { print_line("path " + res->get_path()); } diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 8968e562c1..1e3db1a7b0 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -37,19 +37,34 @@ #include "scene/resources/default_theme/default_theme.h" #include "scene/resources/font.h" -#define MAKE_FALLBACKS(m_name) \ - m_name->add_data(FontArabic); \ - m_name->add_data(FontBengali); \ - m_name->add_data(FontGeorgian); \ - m_name->add_data(FontMalayalam); \ - m_name->add_data(FontOriya); \ - m_name->add_data(FontSinhala); \ - m_name->add_data(FontTamil); \ - m_name->add_data(FontTelugu); \ - m_name->add_data(FontHebrew); \ - m_name->add_data(FontThai); \ - m_name->add_data(FontHindi); \ - m_name->add_data(FontJapanese); \ +#define MAKE_FALLBACKS(m_name) \ + m_name->add_data(FontArabic); \ + m_name->add_data(FontBengali); \ + m_name->add_data(FontDevanagari); \ + m_name->add_data(FontGeorgian); \ + m_name->add_data(FontHebrew); \ + m_name->add_data(FontMalayalam); \ + m_name->add_data(FontOriya); \ + m_name->add_data(FontSinhala); \ + m_name->add_data(FontTamil); \ + m_name->add_data(FontTelugu); \ + m_name->add_data(FontThai); \ + m_name->add_data(FontJapanese); \ + m_name->add_data(FontFallback); + +#define MAKE_FALLBACKS_BOLD(m_name) \ + m_name->add_data(FontArabicBold); \ + m_name->add_data(FontBengaliBold); \ + m_name->add_data(FontDevanagariBold); \ + m_name->add_data(FontGeorgianBold); \ + m_name->add_data(FontHebrewBold); \ + m_name->add_data(FontMalayalamBold); \ + m_name->add_data(FontOriyaBold); \ + m_name->add_data(FontSinhalaBold); \ + m_name->add_data(FontTamilBold); \ + m_name->add_data(FontTeluguBold); \ + m_name->add_data(FontThaiBold); \ + m_name->add_data(FontJapanese); \ m_name->add_data(FontFallback); // the custom spacings might only work with Noto Sans @@ -77,7 +92,7 @@ } \ m_name->set_spacing(Font::SPACING_TOP, -EDSCALE); \ m_name->set_spacing(Font::SPACING_BOTTOM, -EDSCALE); \ - MAKE_FALLBACKS(m_name); + MAKE_FALLBACKS_BOLD(m_name); #define MAKE_SOURCE_FONT(m_name) \ Ref<Font> m_name; \ @@ -175,36 +190,22 @@ void editor_register_fonts(Ref<Theme> p_theme) { memdelete(dir); - /* Droid Sans */ + /* Noto Sans UI */ Ref<FontData> DefaultFont; DefaultFont.instantiate(); - DefaultFont->load_memory(_font_NotoSansUI_Regular, _font_NotoSansUI_Regular_size, "ttf", default_font_size); + DefaultFont->load_memory(_font_NotoSans_Regular, _font_NotoSans_Regular_size, "ttf", default_font_size); DefaultFont->set_antialiased(font_antialiased); DefaultFont->set_hinting(font_hinting); DefaultFont->set_force_autohinter(true); //just looks better..i think? Ref<FontData> DefaultFontBold; DefaultFontBold.instantiate(); - DefaultFontBold->load_memory(_font_NotoSansUI_Bold, _font_NotoSansUI_Bold_size, "ttf", default_font_size); + DefaultFontBold->load_memory(_font_NotoSans_Bold, _font_NotoSans_Bold_size, "ttf", default_font_size); DefaultFontBold->set_antialiased(font_antialiased); DefaultFontBold->set_hinting(font_hinting); DefaultFontBold->set_force_autohinter(true); // just looks better..i think? - Ref<FontData> FontFallback; - FontFallback.instantiate(); - FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); - FontFallback->set_antialiased(font_antialiased); - FontFallback->set_hinting(font_hinting); - FontFallback->set_force_autohinter(true); //just looks better..i think? - - Ref<FontData> FontJapanese; - FontJapanese.instantiate(); - FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); - FontJapanese->set_antialiased(font_antialiased); - FontJapanese->set_hinting(font_hinting); - FontJapanese->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontArabic; FontArabic.instantiate(); FontArabic->load_memory(_font_NotoNaskhArabicUI_Regular, _font_NotoNaskhArabicUI_Regular_size, "ttf", default_font_size); @@ -212,13 +213,41 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontArabic->set_hinting(font_hinting); FontArabic->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontArabicBold; + FontArabicBold.instantiate(); + FontArabicBold->load_memory(_font_NotoNaskhArabicUI_Bold, _font_NotoNaskhArabicUI_Bold_size, "ttf", default_font_size); + FontArabicBold->set_antialiased(font_antialiased); + FontArabicBold->set_hinting(font_hinting); + FontArabicBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengali; FontBengali.instantiate(); - FontBengali->load_memory(_font_NotoSansBengali_Regular, _font_NotoSansBengali_Regular_size, "ttf", default_font_size); + FontBengali->load_memory(_font_NotoSansBengaliUI_Regular, _font_NotoSansBengaliUI_Regular_size, "ttf", default_font_size); FontBengali->set_antialiased(font_antialiased); FontBengali->set_hinting(font_hinting); FontBengali->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontBengaliBold; + FontBengaliBold.instantiate(); + FontBengaliBold->load_memory(_font_NotoSansBengaliUI_Bold, _font_NotoSansBengaliUI_Bold_size, "ttf", default_font_size); + FontBengaliBold->set_antialiased(font_antialiased); + FontBengaliBold->set_hinting(font_hinting); + FontBengaliBold->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagari; + FontDevanagari.instantiate(); + FontDevanagari->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); + FontDevanagari->set_antialiased(font_antialiased); + FontDevanagari->set_hinting(font_hinting); + FontDevanagari->set_force_autohinter(true); //just looks better..i think? + + Ref<FontData> FontDevanagariBold; + FontDevanagariBold.instantiate(); + FontDevanagariBold->load_memory(_font_NotoSansDevanagariUI_Bold, _font_NotoSansDevanagariUI_Bold_size, "ttf", default_font_size); + FontDevanagariBold->set_antialiased(font_antialiased); + FontDevanagariBold->set_hinting(font_hinting); + FontDevanagariBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgian; FontGeorgian.instantiate(); FontGeorgian->load_memory(_font_NotoSansGeorgian_Regular, _font_NotoSansGeorgian_Regular_size, "ttf", default_font_size); @@ -226,6 +255,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontGeorgian->set_hinting(font_hinting); FontGeorgian->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontGeorgianBold; + FontGeorgianBold.instantiate(); + FontGeorgianBold->load_memory(_font_NotoSansGeorgian_Bold, _font_NotoSansGeorgian_Bold_size, "ttf", default_font_size); + FontGeorgianBold->set_antialiased(font_antialiased); + FontGeorgianBold->set_hinting(font_hinting); + FontGeorgianBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrew; FontHebrew.instantiate(); FontHebrew->load_memory(_font_NotoSansHebrew_Regular, _font_NotoSansHebrew_Regular_size, "ttf", default_font_size); @@ -233,6 +269,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontHebrew->set_hinting(font_hinting); FontHebrew->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontHebrewBold; + FontHebrewBold.instantiate(); + FontHebrewBold->load_memory(_font_NotoSansHebrew_Bold, _font_NotoSansHebrew_Bold_size, "ttf", default_font_size); + FontHebrewBold->set_antialiased(font_antialiased); + FontHebrewBold->set_hinting(font_hinting); + FontHebrewBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalam; FontMalayalam.instantiate(); FontMalayalam->load_memory(_font_NotoSansMalayalamUI_Regular, _font_NotoSansMalayalamUI_Regular_size, "ttf", default_font_size); @@ -240,6 +283,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontMalayalam->set_hinting(font_hinting); FontMalayalam->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontMalayalamBold; + FontMalayalamBold.instantiate(); + FontMalayalamBold->load_memory(_font_NotoSansMalayalamUI_Bold, _font_NotoSansMalayalamUI_Bold_size, "ttf", default_font_size); + FontMalayalamBold->set_antialiased(font_antialiased); + FontMalayalamBold->set_hinting(font_hinting); + FontMalayalamBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriya; FontOriya.instantiate(); FontOriya->load_memory(_font_NotoSansOriyaUI_Regular, _font_NotoSansOriyaUI_Regular_size, "ttf", default_font_size); @@ -247,6 +297,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontOriya->set_hinting(font_hinting); FontOriya->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontOriyaBold; + FontOriyaBold.instantiate(); + FontOriyaBold->load_memory(_font_NotoSansOriyaUI_Bold, _font_NotoSansOriyaUI_Bold_size, "ttf", default_font_size); + FontOriyaBold->set_antialiased(font_antialiased); + FontOriyaBold->set_hinting(font_hinting); + FontOriyaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhala; FontSinhala.instantiate(); FontSinhala->load_memory(_font_NotoSansSinhalaUI_Regular, _font_NotoSansSinhalaUI_Regular_size, "ttf", default_font_size); @@ -254,6 +311,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontSinhala->set_hinting(font_hinting); FontSinhala->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontSinhalaBold; + FontSinhalaBold.instantiate(); + FontSinhalaBold->load_memory(_font_NotoSansSinhalaUI_Bold, _font_NotoSansSinhalaUI_Bold_size, "ttf", default_font_size); + FontSinhalaBold->set_antialiased(font_antialiased); + FontSinhalaBold->set_hinting(font_hinting); + FontSinhalaBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamil; FontTamil.instantiate(); FontTamil->load_memory(_font_NotoSansTamilUI_Regular, _font_NotoSansTamilUI_Regular_size, "ttf", default_font_size); @@ -261,6 +325,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTamil->set_hinting(font_hinting); FontTamil->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTamilBold; + FontTamilBold.instantiate(); + FontTamilBold->load_memory(_font_NotoSansTamilUI_Bold, _font_NotoSansTamilUI_Bold_size, "ttf", default_font_size); + FontTamilBold->set_antialiased(font_antialiased); + FontTamilBold->set_hinting(font_hinting); + FontTamilBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTelugu; FontTelugu.instantiate(); FontTelugu->load_memory(_font_NotoSansTeluguUI_Regular, _font_NotoSansTeluguUI_Regular_size, "ttf", default_font_size); @@ -268,6 +339,13 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontTelugu->set_hinting(font_hinting); FontTelugu->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontTeluguBold; + FontTeluguBold.instantiate(); + FontTeluguBold->load_memory(_font_NotoSansTeluguUI_Bold, _font_NotoSansTeluguUI_Bold_size, "ttf", default_font_size); + FontTeluguBold->set_antialiased(font_antialiased); + FontTeluguBold->set_hinting(font_hinting); + FontTeluguBold->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThai; FontThai.instantiate(); FontThai->load_memory(_font_NotoSansThaiUI_Regular, _font_NotoSansThaiUI_Regular_size, "ttf", default_font_size); @@ -275,12 +353,30 @@ void editor_register_fonts(Ref<Theme> p_theme) { FontThai->set_hinting(font_hinting); FontThai->set_force_autohinter(true); //just looks better..i think? - Ref<FontData> FontHindi; - FontHindi.instantiate(); - FontHindi->load_memory(_font_NotoSansDevanagariUI_Regular, _font_NotoSansDevanagariUI_Regular_size, "ttf", default_font_size); - FontHindi->set_antialiased(font_antialiased); - FontHindi->set_hinting(font_hinting); - FontHindi->set_force_autohinter(true); //just looks better..i think? + Ref<FontData> FontThaiBold; + FontThaiBold.instantiate(); + FontThaiBold->load_memory(_font_NotoSansThaiUI_Bold, _font_NotoSansThaiUI_Bold_size, "ttf", default_font_size); + FontThaiBold->set_antialiased(font_antialiased); + FontThaiBold->set_hinting(font_hinting); + FontThaiBold->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Fallback */ + + Ref<FontData> FontFallback; + FontFallback.instantiate(); + FontFallback->load_memory(_font_DroidSansFallback, _font_DroidSansFallback_size, "ttf", default_font_size); + FontFallback->set_antialiased(font_antialiased); + FontFallback->set_hinting(font_hinting); + FontFallback->set_force_autohinter(true); //just looks better..i think? + + /* Droid Sans Japanese */ + + Ref<FontData> FontJapanese; + FontJapanese.instantiate(); + FontJapanese->load_memory(_font_DroidSansJapanese, _font_DroidSansJapanese_size, "ttf", default_font_size); + FontJapanese->set_antialiased(font_antialiased); + FontJapanese->set_hinting(font_hinting); + FontJapanese->set_force_autohinter(true); //just looks better..i think? /* Hack */ diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 16db465a4a..569a28215c 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -43,16 +43,16 @@ DocTools *EditorHelp::doc = nullptr; void EditorHelp::_init_colors() { - title_color = get_theme_color("accent_color", "Editor"); - text_color = get_theme_color("default_color", "RichTextLabel"); - headline_color = get_theme_color("headline_color", "EditorHelp"); + title_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); + headline_color = get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); base_type_color = title_color.lerp(text_color, 0.5); comment_color = text_color * Color(1, 1, 1, 0.6); symbol_color = comment_color; value_color = text_color * Color(1, 1, 1, 0.6); qualifier_color = text_color * Color(1, 1, 1, 0.8); - type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); - class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5); + class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } @@ -78,10 +78,10 @@ void EditorHelp::_class_desc_select(const String &p_select) { } else { class_name = "@GlobalScope"; } - emit_signal("go_to_help", "class_enum:" + class_name + ":" + select); + emit_signal(SNAME("go_to_help"), "class_enum:" + class_name + ":" + select); return; } else if (p_select.begins_with("#")) { - emit_signal("go_to_help", "class_name:" + p_select.substr(1, p_select.length())); + emit_signal(SNAME("go_to_help"), "class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { int tag_end = p_select.find(" "); @@ -112,7 +112,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { } if (link.find(".") != -1) { - emit_signal("go_to_help", topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); + emit_signal(SNAME("go_to_help"), topic + ":" + link.get_slice(".", 0) + ":" + link.get_slice(".", 1)); } else { if (table->has(link)) { // Found in the current page @@ -125,7 +125,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { for (int i = 0; i < cd.constants.size(); i++) { if (cd.constants[i].enumeration == link) { // Found in @GlobalScope - emit_signal("go_to_help", topic + ":@GlobalScope:" + link); + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); break; } } @@ -136,7 +136,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { for (int i = 0; i < cd.constants.size(); i++) { if (cd.constants[i].name == link) { // Found in @GlobalScope - emit_signal("go_to_help", topic + ":@GlobalScope:" + link); + emit_signal(SNAME("go_to_help"), topic + ":@GlobalScope:" + link); break; } } @@ -154,12 +154,12 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { void EditorHelp::_class_desc_resized() { // Add extra horizontal margins for better readability. // The margins increase as the width of the editor help container increases. - Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); - int font_size = get_theme_font_size("doc_source_size", "EditorFonts"); + Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("doc_source_size"), SNAME("EditorFonts")); real_t char_width = doc_code_font->get_char_size('x', 0, font_size).width; const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; - Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate(); + Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("RichTextLabel"))->duplicate(); class_desc_stylebox->set_default_margin(SIDE_LEFT, display_margin); class_desc_stylebox->set_default_margin(SIDE_RIGHT, display_margin); class_desc->add_theme_style_override("normal", class_desc_stylebox); @@ -179,8 +179,8 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { t = p_enum.get_slice(".", 0); } } - const Color text_color = get_theme_color("default_color", "RichTextLabel"); - const Color type_color = get_theme_color("accent_color", "Editor").lerp(text_color, 0.5); + const Color text_color = get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); + const Color type_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(text_color, 0.5); class_desc->push_color(type_color); bool add_array = false; if (can_ref) { @@ -344,10 +344,10 @@ void EditorHelp::_update_doc() { DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying - Ref<Font> doc_font = get_theme_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = get_theme_font("doc_bold", "EditorFonts"); - Ref<Font> doc_title_font = get_theme_font("doc_title", "EditorFonts"); - Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); + Ref<Font> doc_font = get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> doc_bold_font = get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_title_font = get_theme_font(SNAME("doc_title"), SNAME("EditorFonts")); + Ref<Font> doc_code_font = get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); String link_color_text = title_color.to_html(false); // Class name @@ -1177,7 +1177,7 @@ void EditorHelp::_update_doc() { if (!cd.properties[i].description.strip_edges().is_empty()) { _add_text(DTR(cd.properties[i].description)); } else { - class_desc->add_image(get_theme_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); class_desc->add_text(" "); class_desc->push_color(comment_color); if (cd.is_script_doc) { @@ -1232,7 +1232,7 @@ void EditorHelp::_update_doc() { if (!methods_filtered[i].description.strip_edges().is_empty()) { _add_text(DTR(methods_filtered[i].description)); } else { - class_desc->add_image(get_theme_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); class_desc->add_text(" "); class_desc->push_color(comment_color); if (cd.is_script_doc) { @@ -1319,21 +1319,21 @@ void EditorHelp::_help_callback(const String &p_topic) { } } - class_desc->call_deferred("scroll_to_line", line); + class_desc->call_deferred(SNAME("scroll_to_line"), line); } static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { DocTools *doc = EditorHelp::get_doc_data(); String base_path; - Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts"); - Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts"); - Ref<Font> doc_kbd_font = p_rt->get_theme_font("doc_keyboard", "EditorFonts"); + Ref<Font> doc_font = p_rt->get_theme_font(SNAME("doc"), SNAME("EditorFonts")); + Ref<Font> doc_bold_font = p_rt->get_theme_font(SNAME("doc_bold"), SNAME("EditorFonts")); + Ref<Font> doc_code_font = p_rt->get_theme_font(SNAME("doc_source"), SNAME("EditorFonts")); + Ref<Font> doc_kbd_font = p_rt->get_theme_font(SNAME("doc_keyboard"), SNAME("EditorFonts")); - Color headline_color = p_rt->get_theme_color("headline_color", "EditorHelp"); - Color accent_color = p_rt->get_theme_color("accent_color", "Editor"); - Color property_color = p_rt->get_theme_color("property_color", "Editor"); + Color headline_color = p_rt->get_theme_color(SNAME("headline_color"), SNAME("EditorHelp")); + Color accent_color = p_rt->get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color property_color = p_rt->get_theme_color(SNAME("property_color"), SNAME("Editor")); Color link_color = accent_color.lerp(headline_color, 0.8); Color code_color = accent_color.lerp(headline_color, 0.6); Color kbd_color = accent_color.lerp(property_color, 0.6); @@ -1667,7 +1667,7 @@ EditorHelp::EditorHelp() { class_desc = memnew(RichTextLabel); add_child(class_desc); class_desc->set_v_size_flags(SIZE_EXPAND_FILL); - class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + class_desc->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select)); class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input)); @@ -1693,7 +1693,7 @@ EditorHelp::~EditorHelp() { void EditorHelpBit::_go_to_help(String p_what) { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); ScriptEditor::get_singleton()->goto_help(p_what); - emit_signal("request_hide"); + emit_signal(SNAME("request_hide")); } void EditorHelpBit::_meta_clicked(String p_select) { @@ -1733,7 +1733,7 @@ void EditorHelpBit::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); } break; default: break; @@ -1750,7 +1750,7 @@ EditorHelpBit::EditorHelpBit() { rich_text = memnew(RichTextLabel); add_child(rich_text); rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked)); - rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); rich_text->set_override_selected_font_color(false); set_custom_minimum_size(Size2(0, 70 * EDSCALE)); } @@ -1812,13 +1812,13 @@ void FindBar::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons"))); + find_next->set_icon(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons"))); + hide_button->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_hover_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + hide_button->set_pressed_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { set_process_unhandled_input(is_visible_in_tree()); @@ -1891,7 +1891,7 @@ void FindBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color(SNAME("font_color"), SNAME("Label")) : get_theme_color(SNAME("error_color"), SNAME("Editor"))); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index a9bbb92079..fabbf97f49 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -36,11 +36,11 @@ #include "editor_scale.h" void EditorHelpSearch::_update_icons() { - search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons")); - case_sensitive_button->set_icon(results_tree->get_theme_icon("MatchCase", "EditorIcons")); - hierarchy_button->set_icon(results_tree->get_theme_icon("ClassList", "EditorIcons")); + search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); + hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); if (is_visible()) { _update_results(); @@ -95,7 +95,7 @@ void EditorHelpSearch::_confirmed() { // Activate the script editor and emit the signal with the documentation link to display. EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); - emit_signal("go_to_help", item->get_metadata(0)); + emit_signal(SNAME("go_to_help"), item->get_metadata(0)); hide(); } @@ -104,7 +104,7 @@ void EditorHelpSearch::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { - results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation. + results_tree->call_deferred(SNAME("clear")); // Wait for the Tree's mouse event propagation. get_ok_button()->set_disabled(true); EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size())); } @@ -506,7 +506,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const if (ui_service->has_theme_icon(p_doc->name, "EditorIcons")) { icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons"); } else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) { - icon = ui_service->get_theme_icon("Object", "EditorIcons"); + icon = ui_service->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); } String tooltip = p_doc->brief_description.strip_edges(); @@ -580,10 +580,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { - icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); text = p_text; } else { - icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); /*// In flat mode, show the class icon. if (ui_service->has_icon(p_class_name, "EditorIcons")) icon = ui_service->get_icon(p_class_name, "EditorIcons"); @@ -621,6 +621,6 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, results_tree(p_results_tree), term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), search_flags(p_search_flags), - empty_icon(ui_service->get_theme_icon("ArrowRight", "EditorIcons")), - disabled_color(ui_service->get_theme_color("disabled_font_color", "Editor")) { + empty_icon(ui_service->get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))), + disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) { } 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()) { diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 437841ccc1..0c8660c216 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -70,10 +70,10 @@ void EditorLayoutsDialog::ok_pressed() { if (layout_names->is_anything_selected()) { Vector<int> const selected_items = layout_names->get_selected_items(); for (int i = 0; i < selected_items.size(); ++i) { - emit_signal("name_confirmed", layout_names->get_item_text(selected_items[i])); + emit_signal(SNAME("name_confirmed"), layout_names->get_item_text(selected_items[i])); } } else if (name->is_visible() && name->get_text() != "") { - emit_signal("name_confirmed", name->get_text()); + emit_signal(SNAME("name_confirmed"), name->get_text()); } } @@ -92,8 +92,8 @@ void EditorLayoutsDialog::_post_popup() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - layout_names->add_item(**E); + for (const String &E : layouts) { + layout_names->add_item(E); } } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index b3e90236a6..2cb73664f5 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -57,35 +57,43 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f } } +void EditorLog::_update_theme() { + Ref<Font> normal_font = get_theme_font(SNAME("output_source"), SNAME("EditorFonts")); + if (normal_font.is_valid()) { + log->add_theme_font_override("normal_font", normal_font); + } + + log->add_theme_font_size_override("normal_font_size", get_theme_font_size(SNAME("output_source_size"), SNAME("EditorFonts"))); + log->add_theme_color_override("selection_color", get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.4)); + + Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + if (bold_font.is_valid()) { + log->add_theme_font_override("bold_font", bold_font); + } + + type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon(SNAME("Popup"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); + show_search_button->set_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); +} + void EditorLog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - //button->set_icon(get_icon("Console","EditorIcons")); - log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); - log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts")); - log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); - log->add_theme_font_override("bold_font", get_theme_font("bold", "EditorFonts")); - - type_filter_map[MSG_TYPE_STD]->toggle_button->set_icon(get_theme_icon("Popup", "EditorIcons")); - type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_icon(get_theme_icon("StatusError", "EditorIcons")); - type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon("StatusWarning", "EditorIcons")); - type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - - clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); - copy_button->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - collapse_button->set_icon(get_theme_icon("CombineLines", "EditorIcons")); - show_search_button->set_icon(get_theme_icon("Search", "EditorIcons")); - - _load_state(); - - } else if (p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Font> df_output_code = get_theme_font("output_source", "EditorFonts"); - if (df_output_code.is_valid()) { - if (log != nullptr) { - log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); - log->add_theme_font_size_override("normal_font_size", get_theme_font_size("output_source_size", "EditorFonts")); - log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); - } - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _update_theme(); + _load_state(); + } break; + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); + _rebuild_log(); + } break; + default: + break; } } @@ -242,22 +250,22 @@ void EditorLog::_add_log_line(LogMessage &p_message, bool p_replace_previous) { case MSG_TYPE_STD: { } break; case MSG_TYPE_ERROR: { - log->push_color(get_theme_color("error_color", "Editor")); - Ref<Texture2D> icon = get_theme_icon("Error", "EditorIcons"); + log->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); + Ref<Texture2D> icon = get_theme_icon(SNAME("Error"), SNAME("EditorIcons")); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_WARNING: { - log->push_color(get_theme_color("warning_color", "Editor")); - Ref<Texture2D> icon = get_theme_icon("Warning", "EditorIcons"); + log->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + Ref<Texture2D> icon = get_theme_icon(SNAME("Warning"), SNAME("EditorIcons")); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_EDITOR: { // Distinguish editor messages from messages printed by the project - log->push_color(get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.6)); + log->push_color(get_theme_color(SNAME("font_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6)); } break; } @@ -336,7 +344,7 @@ EditorLog::EditorLog() { search_box = memnew(LineEdit); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->set_placeholder(TTR("Filter messages")); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); search_box->set_visible(true); search_box->connect("text_changed", callable_mp(this, &EditorLog::_search_changed)); @@ -398,22 +406,22 @@ EditorLog::EditorLog() { vb_right->add_child(memnew(HSeparator)); LogFilter *std_filter = memnew(LogFilter(MSG_TYPE_STD)); - std_filter->initialize_button("Toggle visibility of standard output messages.", callable_mp(this, &EditorLog::_set_filter_active)); + std_filter->initialize_button(TTR("Toggle visibility of standard output messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(std_filter->toggle_button); type_filter_map.insert(MSG_TYPE_STD, std_filter); LogFilter *error_filter = memnew(LogFilter(MSG_TYPE_ERROR)); - error_filter->initialize_button("Toggle visibility of errors.", callable_mp(this, &EditorLog::_set_filter_active)); + error_filter->initialize_button(TTR("Toggle visibility of errors."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(error_filter->toggle_button); type_filter_map.insert(MSG_TYPE_ERROR, error_filter); LogFilter *warning_filter = memnew(LogFilter(MSG_TYPE_WARNING)); - warning_filter->initialize_button("Toggle visibility of warnings.", callable_mp(this, &EditorLog::_set_filter_active)); + warning_filter->initialize_button(TTR("Toggle visibility of warnings."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(warning_filter->toggle_button); type_filter_map.insert(MSG_TYPE_WARNING, warning_filter); LogFilter *editor_filter = memnew(LogFilter(MSG_TYPE_EDITOR)); - editor_filter->initialize_button("Toggle visibility of editor messages.", callable_mp(this, &EditorLog::_set_filter_active)); + editor_filter->initialize_button(TTR("Toggle visibility of editor messages."), callable_mp(this, &EditorLog::_set_filter_active)); vb_right->add_child(editor_filter->toggle_button); type_filter_map.insert(MSG_TYPE_EDITOR, editor_filter); diff --git a/editor/editor_log.h b/editor/editor_log.h index 3b6476634a..6cbf4bedee 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -163,6 +163,8 @@ private: void _save_state(); void _load_state(); + void _update_theme(); + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 128908c132..46d76a946f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -316,7 +316,7 @@ void EditorNode::_update_scene_tabs() { disambiguate_filenames(full_path_names, disambiguated_scene_names); scene_tabs->clear_tabs(); - Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons"); + Ref<Texture2D> script_icon = gui_base->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *type_node = editor_data.get_edited_scene_root(i); Ref<Texture2D> icon; @@ -427,7 +427,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { } else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) { _editor_select(EDITOR_SCRIPT); } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { - emit_signal("request_help_search", ""); + emit_signal(SNAME("request_help_search"), ""); } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && StreamPeerSSL::is_available()) { _editor_select(EDITOR_ASSETLIB); } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { @@ -508,6 +508,9 @@ void EditorNode::_update_from_settings() { float lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels"); scene_root->set_lod_threshold(lod_threshold); + + RS::get_singleton()->decals_set_filter(RS::DecalFilter(int(GLOBAL_GET("rendering/textures/decals/filter")))); + RS::get_singleton()->light_projectors_set_filter(RS::LightProjectorFilter(int(GLOBAL_GET("rendering/textures/light_projectors/filter")))); } void EditorNode::_notification(int p_what) { @@ -553,7 +556,7 @@ void EditorNode::_notification(int p_what) { if (settings_changed) { _update_from_settings(); settings_changed = false; - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } } break; @@ -642,17 +645,17 @@ void EditorNode::_notification(int p_what) { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); + scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); - file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); - help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); @@ -665,7 +668,7 @@ void EditorNode::_notification(int p_what) { // debugger area if (EditorDebuggerNode::get_singleton()->is_visible()) { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } // update_icons @@ -683,17 +686,17 @@ void EditorNode::_notification(int p_what) { _build_icon_type_cache(); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); - pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); - stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); + pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); - distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); - scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); + distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); + scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property if (gui_base->is_layout_rtl()) { @@ -705,19 +708,19 @@ void EditorNode::_notification(int p_what) { } PopupMenu *p = help_menu->get_popup(); - p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SUGGEST_A_FEATURE), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon("Heart", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SUGGEST_A_FEATURE), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons"))); + p->set_item_icon(p->get_item_index(HELP_SUPPORT_GODOT_DEVELOPMENT), gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons"))); for (int i = 0; i < main_editor_buttons.size(); i++) { - main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font("main_button_font", "EditorFonts")); - main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + main_editor_buttons.write[i]->add_theme_font_override("font", gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); + main_editor_buttons.write[i]->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); } _update_update_spinner(); @@ -794,8 +797,8 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } if (changed.size()) { - for (List<Ref<Resource>>::Element *E = changed.front(); E; E = E->next()) { - E->get()->reload_from_file(); + for (Ref<Resource> &res : changed) { + res->reload_from_file(); } } } @@ -911,8 +914,8 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) { } } - for (List<String>::Element *E = scenes.front(); E; E = E->next()) { - reload_scene(E->get()); + for (const String &E : scenes) { + reload_scene(E); } scene_tabs->set_current_tab(current_tab); @@ -923,7 +926,7 @@ void EditorNode::_sources_changed(bool p_exist) { waiting_for_first_scan = false; // Reload the global shader variables, but this time - // loading texures, as they are now properly imported. + // loading textures, as they are now properly imported. RenderingServer::get_singleton()->global_variables_load_settings(true); // Start preview thread now that it's safe. @@ -972,7 +975,7 @@ void EditorNode::_scan_external_changes() { } if (need_reload) { - disk_changed->call_deferred("popup_centered_ratio", 0.5); + disk_changed->call_deferred(SNAME("popup_centered_ratio"), 0.5); } } @@ -1105,7 +1108,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St } ((Resource *)p_resource.ptr())->set_path(path); - emit_signal("resource_saved", p_resource); + emit_signal(SNAME("resource_saved"), p_resource); editor_data.notify_resource_saved(p_resource); } @@ -1140,13 +1143,13 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->clear_filters(); List<String> preferred; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (p_resource->is_class("Script") && (E->get() == "tres" || E->get() == "res")) { + for (const String &E : extensions) { + if (p_resource->is_class("Script") && (E == "tres" || E == "res")) { //this serves no purpose and confused people continue; } - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - preferred.push_back(E->get()); + file->add_filter("*." + E + " ; " + E.to_upper()); + preferred.push_back(E); } // Lowest priority extension List<String>::Element *res_element = preferred.find("res"); @@ -1256,10 +1259,10 @@ void EditorNode::_get_scene_metadata(const String &p_file) { cf->get_section_keys("editor_states", &esl); Dictionary md; - for (List<String>::Element *E = esl.front(); E; E = E->next()) { - Variant st = cf->get_value("editor_states", E->get()); + for (const String &E : esl) { + Variant st = cf->get_value("editor_states", E); if (st.get_type() != Variant::NIL) { - md[E->get()] = st; + md[E] = st; } } @@ -1292,8 +1295,8 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { List<Variant> keys; md.get_key_list(&keys); - for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - cf->set_value("editor_states", E->get(), md[E->get()]); + for (const Variant &E : keys) { + cf->set_value("editor_states", E, md[E]); } Error err = cf->save(path); @@ -1331,14 +1334,14 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> bool ret_changed = false; List<PropertyInfo> pi; obj->get_property_list(&pi); - for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : pi) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - switch (E->get().type) { + switch (E.type) { case Variant::OBJECT: { - RES res = obj->get(E->get().name); + RES res = obj->get(E.name); if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1346,7 +1349,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::ARRAY: { - Array varray = obj->get(E->get().name); + Array varray = obj->get(E.name); int len = varray.size(); for (int i = 0; i < len; i++) { const Variant &v = varray.get(i); @@ -1358,11 +1361,11 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::DICTIONARY: { - Dictionary d = obj->get(E->get().name); + Dictionary d = obj->get(E.name); List<Variant> keys; d.get_key_list(&keys); - for (List<Variant>::Element *F = keys.front(); F; F = F->next()) { - Variant v = d[F->get()]; + for (const Variant &F : keys) { + Variant v = d[F]; RES res = v; if (_find_and_save_resource(res, processed, flags)) { ret_changed = true; @@ -1517,9 +1520,9 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso p_resource->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_STORAGE && !(E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { - RES res = p_resource->get(E->get().name); + for (const PropertyInfo &E : plist) { + if (E.type == Variant::OBJECT && E.usage & PROPERTY_USAGE_STORAGE && !(E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { + RES res = p_resource->get(E.name); if (res.is_null()) { continue; } @@ -1548,12 +1551,11 @@ int EditorNode::_save_external_resources() { int saved = 0; List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> res = E->get(); + for (const Ref<Resource> &res : cached) { if (!res->get_path().is_resource_file()) { continue; } - //not only check if this resourec is edited, check contained subresources too + //not only check if this resource is edited, check contained subresources too if (_find_edited_resources(res, edited_subresources)) { ResourceSaver::save(res->get_path(), res, flg); saved++; @@ -1639,8 +1641,8 @@ void EditorNode::_save_scene(String p_file, int idx) { editor_data.save_editor_external_data(); - for (List<Ref<AnimatedValuesBackup>>::Element *E = anim_backups.front(); E; E = E->next()) { - E->get()->restore(); + for (Ref<AnimatedValuesBackup> &E : anim_backups) { + E->restore(); } if (err == OK) { @@ -1881,8 +1883,8 @@ void EditorNode::_dialog_action(String p_file) { // erase List<String> keys; config->get_section_keys(p_file, &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - config->set_value(p_file, E->get(), Variant()); + for (const String &E : keys) { + config->set_value(p_file, E, Variant()); } config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); @@ -2217,11 +2219,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } play_button->set_pressed(false); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); String run_filename; String args; @@ -2294,17 +2296,17 @@ void EditorNode::_run(bool p_current, const String &p_custom) { return; } - emit_signal("play_pressed"); + emit_signal(SNAME("play_pressed")); if (p_current) { play_scene_button->set_pressed(true); - play_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } else if (p_custom != "") { run_custom_filename = p_custom; play_custom_scene_button->set_pressed(true); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } else { play_button->set_pressed(true); - play_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } stop_button->set_disabled(false); @@ -2324,7 +2326,7 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) { } EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol()); - emit_signal("play_pressed"); + emit_signal(SNAME("play_pressed")); editor_run.run_native_notify(); } } @@ -2530,8 +2532,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Ref<MeshLibrary> ml(memnew(MeshLibrary)); ResourceSaver::get_recognized_extensions(ml, &extensions); file_export_lib->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_export_lib->add_filter("*." + E->get()); + for (const String &E : extensions) { + file_export_lib->add_filter("*." + E); } file_export_lib->popup_file_dialog(); @@ -2639,11 +2641,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { editor_run.stop(); run_custom_filename.clear(); play_button->set_pressed(false); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); stop_button->set_disabled(true); if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) { @@ -2655,7 +2657,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } EditorDebuggerNode::get_singleton()->stop(); - emit_signal("stop_pressed"); + emit_signal(SNAME("stop_pressed")); } break; @@ -2793,7 +2795,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case HELP_SEARCH: { - emit_signal("request_help_search", ""); + emit_signal(SNAME("request_help_search"), ""); } break; case HELP_DOCS: { OS::get_singleton()->shell_open("https://docs.godotengine.org/"); @@ -3067,8 +3069,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons")); } - tb->add_theme_font_override("font", singleton->gui_base->get_theme_font("main_button_font", "EditorFonts")); - tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size("main_button_font_size", "EditorFonts")); + tb->add_theme_font_override("font", singleton->gui_base->get_theme_font(SNAME("main_button_font"), SNAME("EditorFonts"))); + tb->add_theme_font_size_override("font_size", singleton->gui_base->get_theme_font_size(SNAME("main_button_font_size"), SNAME("EditorFonts"))); tb->set_name(p_editor->get_name()); singleton->main_editor_buttons.push_back(tb); @@ -3366,7 +3368,7 @@ void EditorNode::set_current_scene(int p_idx) { editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); } - call_deferred("_clear_undo_history"); + call_deferred(SNAME("_clear_undo_history")); } changing_scene = true; @@ -3403,7 +3405,7 @@ void EditorNode::set_current_scene(int p_idx) { _update_title(); - call_deferred("_set_main_scene_state", state, get_edited_scene()); //do after everything else is done setting up + call_deferred(SNAME("_set_main_scene_state"), state, get_edited_scene()); //do after everything else is done setting up } bool EditorNode::is_scene_open(const String &p_path) { @@ -3650,7 +3652,7 @@ void EditorNode::_add_to_recent_scenes(const String &p_scene) { void EditorNode::_open_recent_scene(int p_idx) { if (p_idx == recent_scenes->get_item_count() - 1) { EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array()); - call_deferred("_update_recent_scenes"); + call_deferred(SNAME("_update_recent_scenes")); } else { Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); ERR_FAIL_INDEX(p_idx, rc.size()); @@ -3712,7 +3714,7 @@ void EditorNode::add_io_error(const String &p_error) { void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { EditorNode *en = (EditorNode *)p_ud; - en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons")); + en->load_errors->add_image(en->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); en->load_errors->add_text(p_text + "\n"); en->load_error_dialog->popup_centered_ratio(0.5); } @@ -3939,7 +3941,7 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String } if (p_fallback.length()) { - return gui_base->get_theme_icon(p_fallback, "EditorIcons"); + return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); } return nullptr; @@ -3980,12 +3982,12 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } } - if (gui_base->has_theme_icon(p_class, "EditorIcons")) { - return gui_base->get_theme_icon(p_class, "EditorIcons"); + if (gui_base->has_theme_icon(p_class, SNAME("EditorIcons"))) { + return gui_base->get_theme_icon(p_class, SNAME("EditorIcons")); } - if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons")) { - return gui_base->get_theme_icon(p_fallback, "EditorIcons"); + if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, SNAME("EditorIcons"))) { + return gui_base->get_theme_icon(p_fallback, SNAME("EditorIcons")); } return nullptr; @@ -4052,11 +4054,11 @@ void EditorNode::_build_icon_type_cache() { List<StringName> tl; StringName ei = "EditorIcons"; theme_base->get_theme()->get_icon_list(ei, &tl); - for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - if (!ClassDB::class_exists(E->get())) { + for (const StringName &E : tl) { + if (!ClassDB::class_exists(E)) { continue; } - icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei); + icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei); } } @@ -4289,7 +4291,7 @@ void EditorNode::_dock_select_draw() { Color used = Color(0.6, 0.6, 0.6, 0.8); Color used_selected = Color(0.8, 0.8, 0.8, 0.8); - Color tab_selected = theme_base->get_theme_color("mono_color", "Editor"); + Color tab_selected = theme_base->get_theme_color(SNAME("mono_color"), SNAME("Editor")); Color unused = used; unused.a = 0.4; Color unusable = unused; @@ -4781,9 +4783,7 @@ void EditorNode::_update_layouts_menu() { List<String> layouts; config.ptr()->get_sections(&layouts); - for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - String layout = E->get(); - + for (const String &layout : layouts) { if (layout == TTR("Default")) { editor_layouts->remove_item(editor_layouts->get_item_index(SETTINGS_LAYOUT_DEFAULT)); overridden_default_layout = editor_layouts->get_item_count(); @@ -5052,9 +5052,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_items[i].control->set_visible(i == p_idx); } if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -5064,7 +5064,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_raise->show(); } else { - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); bottom_panel_items[p_idx].button->set_pressed(false); bottom_panel_items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -5153,7 +5153,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { //todo make proper previews - Ref<ImageTexture> texture = gui_base->get_theme_icon("FileBigThumb", "EditorIcons"); + Ref<ImageTexture> texture = gui_base->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); Ref<Image> img = texture->get_image(); img = img->duplicate(); img->resize(48, 48); //meh @@ -5205,10 +5205,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * if (p_paths[i].ends_with("/")) { label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); - icon->set_texture(gui_base->get_theme_icon("Folder", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } else { label->set_text(p_paths[i].get_file()); - icon->set_texture(gui_base->get_theme_icon("File", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon(SNAME("File"), SNAME("EditorIcons"))); } icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); icon->set_size(Size2(16, 16)); @@ -5333,27 +5333,6 @@ void EditorNode::_file_access_close_error_notify(const String &p_str) { } void EditorNode::reload_scene(const String &p_path) { - /* - * No longer necessary since scenes now reset and reload their internal resource if needed. - //first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk - - List<Ref<Resource>> cached; - ResourceCache::get_cached_resources(&cached); - List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene - to_clear.push_back(E->get()); - } - } - - //so reload reloads everything, clear subresources of previous scene - while (to_clear.front()) { - to_clear.front()->get()->set_path(""); - to_clear.pop_front(); - } - - */ - int scene_idx = -1; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { if (editor_data.get_scene_path(i) == p_path) { @@ -5480,7 +5459,7 @@ void EditorNode::_update_video_driver_color() { if (video_driver->get_text() == "GLES2") { video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); } else if (video_driver->get_text() == "Vulkan") { - video_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor")); + video_driver->add_theme_color_override("font_color", theme_base->get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); } } @@ -5910,7 +5889,7 @@ EditorNode::EditorNode() { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); resource_preview = memnew(EditorResourcePreview); add_child(resource_preview); @@ -6091,8 +6070,8 @@ EditorNode::EditorNode() { tab_preview_panel->add_child(tab_preview); scene_tabs = memnew(Tabs); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); + scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); + scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_LEFT); @@ -6126,7 +6105,7 @@ EditorNode::EditorNode() { #endif distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); - distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); + distraction_free->set_icon(gui_base->get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons"))); distraction_free->set_toggle_mode(true); scene_tab_add = memnew(Button); @@ -6134,13 +6113,13 @@ EditorNode::EditorNode() { tabbar_container->add_child(scene_tab_add); tabbar_container->add_child(distraction_free); scene_tab_add->set_tooltip(TTR("Add a new scene.")); - scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); + scene_tab_add->set_icon(gui_base->get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); scene_tab_add->add_theme_color_override("icon_normal_color", Color(0.6f, 0.6f, 0.6f, 0.8f)); scene_tab_add->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_NEW_SCENE)); scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); scene_root_parent->set_draw_behind_parent(true); srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -6164,12 +6143,12 @@ EditorNode::EditorNode() { file_menu->set_flat(false); file_menu->set_switch_on_hover(true); file_menu->set_text(TTR("Scene")); - file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(file_menu); prev_scene = memnew(Button); prev_scene->set_flat(true); - prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon(SNAME("PrevScene"), SNAME("EditorIcons"))); prev_scene->set_tooltip(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); prev_scene->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_OPEN_PREV)); @@ -6268,7 +6247,7 @@ EditorNode::EditorNode() { project_menu->set_switch_on_hover(true); project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools.")); project_menu->set_text(TTR("Project")); - project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(project_menu); p = project_menu->get_popup(); @@ -6302,7 +6281,7 @@ EditorNode::EditorNode() { tool_menu->add_item(TTR("Orphan Resource Explorer..."), TOOLS_ORPHAN_RESOURCES); p->add_separator(); - p->add_item(TTR("Reload Current Project"), RUN_RELOAD_CURRENT_PROJECT); + p->add_shortcut(ED_SHORTCUT("editor/reload_current_project", TTR("Reload Current Project")), RUN_RELOAD_CURRENT_PROJECT); #ifdef OSX_ENABLED p->add_shortcut(ED_SHORTCUT("editor/quit_to_project_list", TTR("Quit to Project List"), KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q), RUN_PROJECT_MANAGER, true); #else @@ -6319,7 +6298,7 @@ EditorNode::EditorNode() { debug_menu->set_flat(false); debug_menu->set_switch_on_hover(true); debug_menu->set_text(TTR("Debug")); - debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(debug_menu); menu_hb->add_spacer(); @@ -6328,7 +6307,7 @@ EditorNode::EditorNode() { settings_menu->set_flat(false); settings_menu->set_switch_on_hover(true); settings_menu->set_text(TTR("Editor")); - settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(settings_menu); p = settings_menu->get_popup(); @@ -6381,26 +6360,26 @@ EditorNode::EditorNode() { help_menu->set_flat(false); help_menu->set_switch_on_hover(true); help_menu->set_text(TTR("Help")); - help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); left_menu_hb->add_child(help_menu); p = help_menu->get_popup(); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); #ifdef OSX_ENABLED - p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE), HELP_SEARCH); #else - p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons")), ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F1), HELP_SEARCH); #endif p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Questions & Answers")), HELP_QA); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); - p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/online_docs", TTR("Online Documentation")), HELP_DOCS); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/q&a", TTR("Questions & Answers")), HELP_QA); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/suggest_a_feature", TTR("Suggest a Feature")), HELP_SUGGEST_A_FEATURE); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); p->add_separator(); - p->add_icon_shortcut(gui_base->get_theme_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About Godot")), HELP_ABOUT); - p->add_icon_shortcut(gui_base->get_theme_icon("Heart", "EditorIcons"), ED_SHORTCUT("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Godot"), SNAME("EditorIcons")), ED_SHORTCUT("editor/about", TTR("About Godot")), HELP_ABOUT); + p->add_icon_shortcut(gui_base->get_theme_icon(SNAME("Heart"), SNAME("EditorIcons")), ED_SHORTCUT("editor/support_development", TTR("Support Godot Development")), HELP_SUPPORT_GODOT_DEVELOPMENT); HBoxContainer *play_hb = memnew(HBoxContainer); menu_hb->add_child(play_hb); @@ -6409,7 +6388,7 @@ EditorNode::EditorNode() { play_button->set_flat(true); play_hb->add_child(play_button); play_button->set_toggle_mode(true); - play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY)); play_button->set_tooltip(TTR("Play the project.")); @@ -6422,7 +6401,7 @@ EditorNode::EditorNode() { pause_button = memnew(Button); pause_button->set_flat(true); pause_button->set_toggle_mode(true); - pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); + pause_button->set_icon(gui_base->get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->set_tooltip(TTR("Pause the scene execution for debugging.")); pause_button->set_disabled(true); @@ -6437,7 +6416,7 @@ EditorNode::EditorNode() { stop_button->set_flat(true); play_hb->add_child(stop_button); stop_button->set_focus_mode(Control::FOCUS_NONE); - stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); + stop_button->set_icon(gui_base->get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); stop_button->set_disabled(true); @@ -6456,7 +6435,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_scene_button); play_scene_button->set_toggle_mode(true); play_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons"))); play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_SCENE)); play_scene_button->set_tooltip(TTR("Play the edited scene.")); #ifdef OSX_ENABLED @@ -6470,7 +6449,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_custom_scene_button); play_custom_scene_button->set_toggle_mode(true); play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon(SNAME("PlayCustom"), SNAME("EditorIcons"))); play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_CUSTOM_SCENE)); play_custom_scene_button->set_tooltip(TTR("Play custom scene")); #ifdef OSX_ENABLED @@ -6486,8 +6465,8 @@ EditorNode::EditorNode() { video_driver = memnew(OptionButton); video_driver->set_focus_mode(Control::FOCUS_NONE); video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected)); - video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts")); - video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size("bold_size", "EditorFonts")); + video_driver->add_theme_font_override("font", gui_base->get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); + video_driver->add_theme_font_size_override("font_size", gui_base->get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts"))); // TODO: Show again when OpenGL is ported. video_driver->set_visible(false); right_menu_hb->add_child(video_driver); @@ -6529,7 +6508,7 @@ EditorNode::EditorNode() { update_spinner = memnew(MenuButton); update_spinner->set_tooltip(TTR("Spins when the editor window redraws.")); right_menu_hb->add_child(update_spinner); - update_spinner->set_icon(gui_base->get_theme_icon("Progress1", "EditorIcons")); + update_spinner->set_icon(gui_base->get_theme_icon(SNAME("Progress1"), SNAME("EditorIcons"))); update_spinner->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); p = update_spinner->get_popup(); p->add_radio_check_item(TTR("Update Continuously"), SETTINGS_UPDATE_CONTINUOUSLY); @@ -6606,7 +6585,7 @@ EditorNode::EditorNode() { // Bottom panels bottom_panel = memnew(PanelContainer); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); center_split->add_child(bottom_panel); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -6649,7 +6628,7 @@ EditorNode::EditorNode() { bottom_panel_raise = memnew(Button); bottom_panel_raise->set_flat(true); - bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); bottom_panel_raise->set_shortcut(ED_SHORTCUT("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KEY_MASK_SHIFT | KEY_F12)); @@ -6738,8 +6717,8 @@ EditorNode::EditorNode() { file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); - for (List<String>::Element *E = sexts.front(); E; E = E->next()) { - file_script->add_filter("*." + E->get()); + for (const String &E : sexts) { + file_script->add_filter("*." + E); } gui_base->add_child(file_script); file_script->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 63281ae1aa..f3b3eedccc 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -40,15 +40,15 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -60,7 +60,7 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(obj); String proper_name = ""; - Vector<String> name_parts = E->get().name.split("/"); + Vector<String> name_parts = E.name.split("/"); for (int i = 0; i < name_parts.size(); i++) { if (i > 0) { @@ -180,8 +180,8 @@ void EditorPath::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { update_path(); - sub_objects_icon->set_texture(get_theme_icon("select_arrow", "Tree")); - current_object_label->add_theme_font_override("font", get_theme_font("main", "EditorFonts")); + sub_objects_icon->set_texture(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); + current_object_label->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); } break; case NOTIFICATION_READY: { diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 63de06d5e2..07e9357e67 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -532,7 +532,7 @@ void EditorPlugin::set_force_draw_over_forwarding_enabled() { } void EditorPlugin::notify_scene_changed(const Node *scn_root) { - emit_signal("scene_changed", scn_root); + emit_signal(SNAME("scene_changed"), scn_root); } void EditorPlugin::notify_main_screen_changed(const String &screen_name) { @@ -540,16 +540,16 @@ void EditorPlugin::notify_main_screen_changed(const String &screen_name) { return; } - emit_signal("main_screen_changed", screen_name); + emit_signal(SNAME("main_screen_changed"), screen_name); last_main_screen_name = screen_name; } void EditorPlugin::notify_scene_closed(const String &scene_filepath) { - emit_signal("scene_closed", scene_filepath); + emit_signal(SNAME("scene_closed"), scene_filepath); } void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { - emit_signal("resource_saved", p_resource); + emit_signal(SNAME("resource_saved"), p_resource); } bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { @@ -729,13 +729,13 @@ void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationP void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) { ERR_FAIL_COND(!p_importer.is_valid()); ResourceFormatImporter::get_singleton()->add_importer(p_importer); - EditorFileSystem::get_singleton()->call_deferred("scan"); + EditorFileSystem::get_singleton()->call_deferred(SNAME("scan")); } void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) { ERR_FAIL_COND(!p_importer.is_valid()); ResourceFormatImporter::get_singleton()->remove_importer(p_importer); - EditorFileSystem::get_singleton()->call_deferred("scan"); + EditorFileSystem::get_singleton()->call_deferred(SNAME("scan")); } void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) { @@ -854,7 +854,7 @@ void EditorPlugin::remove_debugger_plugin(const Ref<Script> &p_script) { } void EditorPlugin::_editor_project_settings_changed() { - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } void EditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index a16a2f327e..a8b08dc9ed 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -108,7 +108,7 @@ void EditorPluginSettings::update_plugins() { bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(path); item->set_checked(3, is_active); item->set_editable(3, true); - item->add_button(4, get_theme_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); + item->add_button(4, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); } } } diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index ebd8d6427b..df763d5bf0 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -147,10 +147,10 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons"); + Ref<Texture2D> df = get_theme_icon(SNAME("DistractionFree"), SNAME("EditorIcons")); open_big_text->set_icon(df); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); text->set_custom_minimum_size(Vector2(0, font->get_height(font_size) * 6)); } break; @@ -276,9 +276,9 @@ void EditorPropertyTextEnum::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - edit_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - accept_button->set_icon(get_theme_icon("ImportCheck", "EditorIcons")); - cancel_button->set_icon(get_theme_icon("ImportFail", "EditorIcons")); + edit_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + accept_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); + cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); break; } } @@ -386,7 +386,7 @@ void EditorPropertyPath::set_save_mode() { void EditorPropertyPath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - path_edit->set_icon(get_theme_icon("Folder", "EditorIcons")); + path_edit->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } @@ -699,8 +699,8 @@ public: int hovered_index; virtual Size2 get_minimum_size() const override { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); return Vector2(0, font->get_height(font_size) * 2); } @@ -737,7 +737,7 @@ public: value |= (1 << hovered_index); } - emit_signal("flag_changed", value); + emit_signal(SNAME("flag_changed"), value); update(); } } @@ -753,7 +753,7 @@ public: const int h = bsize * 2 + 1; const int vofs = (rect.size.height - h) / 2; - Color color = get_theme_color("highlight_color", "Editor"); + Color color = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Point2 ofs(4, vofs); if (i == 1) { @@ -957,7 +957,7 @@ EditorPropertyInteger::EditorPropertyInteger() { ///////////////////// OBJECT ID ///////////////////////// void EditorPropertyObjectID::_edit_pressed() { - emit_signal("object_id_selected", get_edited_property(), get_edited_object()->get(get_edited_property())); + emit_signal(SNAME("object_id_selected"), get_edited_property(), get_edited_object()->get(get_edited_property())); } void EditorPropertyObjectID::update_property() { @@ -1112,14 +1112,14 @@ void EditorPropertyEasing::_draw_easing() { const float exp = get_edited_object()->get(get_edited_property()); - const Ref<Font> f = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - const Color font_color = get_theme_color("font_color", "Label"); + const Ref<Font> f = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + const Color font_color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color line_color; if (dragging) { - line_color = get_theme_color("accent_color", "Editor"); + line_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { - line_color = get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.9); + line_color = get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.9); } Vector<Point2> points; @@ -1205,15 +1205,15 @@ void EditorPropertyEasing::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { preset->clear(); - preset->add_icon_item(get_theme_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO); - preset->add_icon_item(get_theme_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR); - preset->add_icon_item(get_theme_icon("CurveIn", "EditorIcons"), "In", EASING_IN); - preset->add_icon_item(get_theme_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT); + preset->add_icon_item(get_theme_icon(SNAME("CurveConstant"), SNAME("EditorIcons")), "Zero", EASING_ZERO); + preset->add_icon_item(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons")), "Linear", EASING_LINEAR); + preset->add_icon_item(get_theme_icon(SNAME("CurveIn"), SNAME("EditorIcons")), "In", EASING_IN); + preset->add_icon_item(get_theme_icon(SNAME("CurveOut"), SNAME("EditorIcons")), "Out", EASING_OUT); if (full) { - preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT); - preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN); + preset->add_icon_item(get_theme_icon(SNAME("CurveInOut"), SNAME("EditorIcons")), "In-Out", EASING_IN_OUT); + preset->add_icon_item(get_theme_icon(SNAME("CurveOutIn"), SNAME("EditorIcons")), "Out-In", EASING_OUT_IN); } - easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height(get_theme_font_size("font_size", "Label")) * 2)); + easing_draw->set_custom_minimum_size(Size2(0, get_theme_font(SNAME("font"), SNAME("Label"))->get_height(get_theme_font_size(SNAME("font_size"), SNAME("Label"))) * 2)); } break; } } @@ -1273,7 +1273,7 @@ void EditorPropertyVector2::update_property() { void EditorPropertyVector2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1360,7 +1360,7 @@ void EditorPropertyRect2::update_property() { void EditorPropertyRect2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1482,7 +1482,7 @@ Vector3 EditorPropertyVector3::get_vector() { void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1565,7 +1565,7 @@ void EditorPropertyVector2i::update_property() { void EditorPropertyVector2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 2; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1652,7 +1652,7 @@ void EditorPropertyRect2i::update_property() { void EditorPropertyRect2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1747,7 +1747,7 @@ void EditorPropertyVector3i::update_property() { void EditorPropertyVector3i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1833,7 +1833,7 @@ void EditorPropertyPlane::update_property() { void EditorPropertyPlane::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -1920,7 +1920,7 @@ void EditorPropertyQuaternion::update_property() { void EditorPropertyQuaternion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 3; i++) { Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2010,7 +2010,7 @@ void EditorPropertyAABB::update_property() { void EditorPropertyAABB::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 6; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2087,7 +2087,7 @@ void EditorPropertyTransform2D::update_property() { void EditorPropertyTransform2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 6; i++) { Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2169,7 +2169,7 @@ void EditorPropertyBasis::update_property() { void EditorPropertyBasis::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 9; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2259,7 +2259,7 @@ void EditorPropertyTransform3D::update_using_transform(Transform3D p_transform) void EditorPropertyTransform3D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < 12; i++) { Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); @@ -2475,7 +2475,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); } } @@ -2527,7 +2527,7 @@ void EditorPropertyResource::_resource_selected(const RES &p_resource) { get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold); update_property(); } else { - emit_signal("resource_selected", get_edited_property(), p_resource); + emit_signal(SNAME("resource_selected"), get_edited_property(), p_resource); } } @@ -2580,22 +2580,22 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) { } void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) { - emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value, false); + emit_signal(SNAME("property_keyed_with_value"), String(get_edited_property()) + ":" + p_property, p_value, false); } void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) { - emit_signal("resource_selected", String(get_edited_property()) + ":" + p_property, p_resource); + emit_signal(SNAME("resource_selected"), String(get_edited_property()) + ":" + p_property, p_resource); } void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) { - emit_signal("object_id_selected", get_edited_property(), p_id); + emit_signal(SNAME("object_id_selected"), get_edited_property(), p_id); } void EditorPropertyResource::_open_editor_pressed() { RES res = get_edited_object()->get(get_edited_property()); if (res.is_valid()) { // May clear the editor so do it deferred. - EditorNode::get_singleton()->call_deferred("edit_item_resource", res); + EditorNode::get_singleton()->call_deferred(SNAME("edit_item_resource"), res); } } @@ -2651,18 +2651,18 @@ void EditorPropertyResource::_update_property_bg() { } count_subinspectors = MIN(15, count_subinspectors); - add_theme_color_override("property_color", get_theme_color("sub_inspector_property_color", "Editor")); + add_theme_color_override("property_color", get_theme_color(SNAME("sub_inspector_property_color"), SNAME("Editor"))); add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg_selected" + itos(count_subinspectors), "Editor")); add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), "Editor")); - add_theme_constant_override("font_offset", get_theme_constant("sub_inspector_font_offset", "Editor")); + add_theme_constant_override("font_offset", get_theme_constant(SNAME("sub_inspector_font_offset"), SNAME("Editor"))); add_theme_constant_override("vseparation", 0); } else { - add_theme_color_override("property_color", get_theme_color("property_color", "EditorProperty")); - add_theme_style_override("bg_selected", get_theme_stylebox("bg_selected", "EditorProperty")); - add_theme_style_override("bg", get_theme_stylebox("bg", "EditorProperty")); - add_theme_constant_override("vseparation", get_theme_constant("vseparation", "EditorProperty")); - add_theme_constant_override("font_offset", get_theme_constant("font_offset", "EditorProperty")); + add_theme_color_override("property_color", get_theme_color(SNAME("property_color"), SNAME("EditorProperty"))); + add_theme_style_override("bg_selected", get_theme_stylebox(SNAME("bg_selected"), SNAME("EditorProperty"))); + add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("EditorProperty"))); + add_theme_constant_override("vseparation", get_theme_constant(SNAME("vseparation"), SNAME("EditorProperty"))); + add_theme_constant_override("font_offset", get_theme_constant(SNAME("font_offset"), SNAME("EditorProperty"))); } updating_theme = false; @@ -2760,7 +2760,7 @@ void EditorPropertyResource::update_property() { // Open editor directly and hide other such editors which are currently open. _open_editor_pressed(); if (is_inside_tree()) { - get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this); + get_tree()->call_deferred(SNAME("call_group"), "_editor_resource_properties", "_fold_other_editors", this); } opened_editor = true; } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 8b67b67571..596f515067 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -203,7 +203,7 @@ void EditorPropertyArray::_change_type_menu(int p_index) { } void EditorPropertyArray::_object_id_selected(const StringName &p_property, ObjectID p_id) { - emit_signal("object_id_selected", p_property, p_id); + emit_signal(SNAME("object_id_selected"), p_property, p_id); } void EditorPropertyArray::update_property() { @@ -346,7 +346,7 @@ void EditorPropertyArray::update_property() { vbox->add_child(hbox); Button *reorder_button = memnew(Button); - reorder_button->set_icon(get_theme_icon("TripleBar", "EditorIcons")); + reorder_button->set_icon(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons"))); reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE); reorder_button->connect("gui_input", callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input)); reorder_button->connect("button_down", callable_mp(this, &EditorPropertyArray::_reorder_button_down), varray(i + offset)); @@ -383,12 +383,12 @@ void EditorPropertyArray::update_property() { if (is_untyped_array) { Button *edit = memnew(Button); - edit->set_icon(get_theme_icon("Edit", "EditorIcons")); + edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); hbox->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset)); } else { Button *remove = memnew(Button); - remove->set_icon(get_theme_icon("Remove", "EditorIcons")); + remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset)); hbox->add_child(remove); } @@ -421,7 +421,7 @@ void EditorPropertyArray::_remove_pressed(int p_index) { void EditorPropertyArray::_button_draw() { if (dropping) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); edit->draw_rect(Rect2(Point2(), edit->get_size()), color, false); } } @@ -1070,7 +1070,7 @@ void EditorPropertyDictionary::update_property() { for (int j = 0; j < 4; j++) { flat->set_default_margin(Side(j), 2 * EDSCALE); } - flat->set_bg_color(get_theme_color("prop_subsection", "Editor")); + flat->set_bg_color(get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); pc->add_theme_style_override("panel", flat); add_vbox = memnew(VBoxContainer); @@ -1105,7 +1105,7 @@ void EditorPropertyDictionary::update_property() { hbox->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *edit = memnew(Button); - edit->set_icon(get_theme_icon("Edit", "EditorIcons")); + edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); hbox->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type), varray(edit, change_index)); @@ -1131,7 +1131,7 @@ void EditorPropertyDictionary::update_property() { } void EditorPropertyDictionary::_object_id_selected(const StringName &p_property, ObjectID p_id) { - emit_signal("object_id_selected", p_property, p_id); + emit_signal(SNAME("object_id_selected"), p_property, p_id); } void EditorPropertyDictionary::_notification(int p_what) { diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 495db29789..7d809ea656 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -76,7 +76,7 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const } if (p_preview.is_valid()) { - preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox("normal")->get_default_margin(SIDE_LEFT) + get_theme_constant("hseparation", "Button")); + preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button"))); if (type == "GradientTexture") { preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE); @@ -100,7 +100,7 @@ void EditorResourcePicker::_resource_selected() { return; } - emit_signal("resource_selected", edited_resource); + emit_signal(SNAME("resource_selected"), edited_resource); } void EditorResourcePicker::_file_selected(const String &p_path) { @@ -125,7 +125,7 @@ void EditorResourcePicker::_file_selected(const String &p_path) { } edited_resource = loaded_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } @@ -148,14 +148,14 @@ void EditorResourcePicker::_update_menu_items() { set_create_options(edit_menu); // Add an option to load a resource from a file. - edit_menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); + edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Load"), OBJ_MENU_LOAD); // Add options for changing existing value of the resource. if (edited_resource.is_valid()) { - edit_menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); - edit_menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); - edit_menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); - edit_menu->add_icon_item(get_theme_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE); + edit_menu->add_icon_item(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), TTR("Edit"), OBJ_MENU_EDIT); + edit_menu->add_icon_item(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), TTR("Clear"), OBJ_MENU_CLEAR); + edit_menu->add_icon_item(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + edit_menu->add_icon_item(get_theme_icon(SNAME("Save"), SNAME("EditorIcons")), TTR("Save"), OBJ_MENU_SAVE); if (edited_resource->get_path().is_resource_file()) { edit_menu->add_separator(); @@ -200,10 +200,10 @@ void EditorResourcePicker::_update_menu_items() { for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); Ref<Texture2D> icon; - if (has_theme_icon(what, "EditorIcons")) { - icon = get_theme_icon(what, "EditorIcons"); + if (has_theme_icon(what, SNAME("EditorIcons"))) { + icon = get_theme_icon(what, SNAME("EditorIcons")); } else { - icon = get_theme_icon(what, "Resource"); + icon = get_theme_icon(what, SNAME("Resource")); } edit_menu->add_icon_item(icon, vformat(TTR("Convert to %s"), what), CONVERT_BASE_ID + i); @@ -221,8 +221,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensions) { + valid_extensions.insert(E); } if (!file_dialog) { @@ -242,13 +242,13 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { case OBJ_MENU_EDIT: { if (edited_resource.is_valid()) { - emit_signal("resource_selected", edited_resource); + emit_signal(SNAME("resource_selected"), edited_resource); } } break; case OBJ_MENU_CLEAR: { edited_resource = RES(); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -260,9 +260,8 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { List<PropertyInfo> property_list; edited_resource->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = edited_resource->get(pi.name); @@ -276,13 +275,12 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { Ref<Resource> unique_resource = Ref<Resource>(Object::cast_to<Resource>(inst)); ERR_FAIL_COND(unique_resource.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { unique_resource->set(p.first, p.second); } edited_resource = unique_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -299,7 +297,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { case OBJ_MENU_PASTE: { edited_resource = EditorSettings::get_singleton()->get_resource_clipboard(); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; @@ -324,7 +322,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ERR_FAIL_INDEX(to_type, conversions.size()); edited_resource = conversions[to_type]->convert(edited_resource); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); break; } @@ -354,7 +352,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { ERR_BREAK(!resp); edited_resource = RES(resp); - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } break; } @@ -404,7 +402,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) { inheritors_array.push_back(t); if (!icon.is_valid()) { - icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons"); + icon = get_theme_icon(has_theme_icon(t, SNAME("EditorIcons")) ? t : String("Object"), SNAME("EditorIcons")); } int id = TYPE_BASE_ID + idx; @@ -429,7 +427,7 @@ bool EditorResourcePicker::handle_menu_selected(int p_which) { void EditorResourcePicker::_button_draw() { if (dropping) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); assign_button->draw_rect(Rect2(Point2(), assign_button->get_size()), color, false); } } @@ -467,13 +465,13 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> * List<StringName> inheriters; ClassDB::get_inheriters_from_class(base, &inheriters); - for (List<StringName>::Element *E = inheriters.front(); E; E = E->next()) { - p_vector->insert(E->get()); + for (const StringName &E : inheriters) { + p_vector->insert(E); } - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - if (EditorNode::get_editor_data().script_class_is_parent(E->get(), base)) { - p_vector->insert(E->get()); + for (const StringName &E : global_classes) { + if (EditorNode::get_editor_data().script_class_is_parent(E, base)) { + p_vector->insert(E); } } @@ -620,7 +618,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ } edited_resource = dropped_resource; - emit_signal("resource_changed", edited_resource); + emit_signal(SNAME("resource_changed"), edited_resource); _update_resource(); } } @@ -661,11 +659,11 @@ void EditorResourcePicker::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - edit_button->set_icon(get_theme_icon("select_arrow", "Tree")); + edit_button->set_icon(get_theme_icon(SNAME("select_arrow"), SNAME("Tree"))); } break; case NOTIFICATION_DRAW: { - draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), get_size())); } break; case NOTIFICATION_DRAG_BEGIN: { @@ -827,8 +825,8 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) { return; } - menu_node->add_icon_item(get_theme_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); - menu_node->add_icon_item(get_theme_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); + menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); menu_node->add_separator(); } diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index f904ae80a7..7f4ee7848f 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -161,7 +161,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } r_texture = generated; - int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size + int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))->get_width(); // Kind of a workaround to retrieve the default icon size if (preview_generators[i]->can_generate_small_preview()) { Ref<Texture2D> generated_small; @@ -419,7 +419,7 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { } if (call_invalidated) { //do outside mutex - call_deferred("emit_signal", "preview_invalidated", p_path); + call_deferred(SNAME("emit_signal"), "preview_invalidated", p_path); } } diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 5e6d2ab69c..4fadbf5922 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -228,8 +228,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } printf("Running: %s", exec.utf8().get_data()); - for (List<String>::Element *E = args.front(); E; E = E->next()) { - printf(" %s", E->get().utf8().get_data()); + for (const String &E : args) { + printf(" %s", E.utf8().get_data()); }; printf("\n"); @@ -250,8 +250,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } bool EditorRun::has_child_process(OS::ProcessID p_pid) const { - for (const List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - if (E->get() == p_pid) { + for (const OS::ProcessID &E : pids) { + if (E == p_pid) { return true; } } @@ -267,8 +267,8 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) { void EditorRun::stop() { if (status != STATUS_STOP && pids.size() > 0) { - for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { - OS::get_singleton()->kill(E->get()); + for (const OS::ProcessID &E : pids) { + OS::get_singleton()->kill(E); } } diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index a604022391..e115cd77e1 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -127,7 +127,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) { return; } - emit_signal("native_run", preset); + emit_signal(SNAME("native_run"), preset); int flags = 0; diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 6bfb17f9c2..751cc7a574 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -76,8 +76,7 @@ class SectionedInspectorFilter : public Object { List<PropertyInfo> pinfo; edited->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); + for (PropertyInfo &pi : pinfo) { int sp = pi.name.find("/"); if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) { //skip resource stuff @@ -221,9 +220,7 @@ void SectionedInspector::update_category_list() { filter = search_box->get_text(); } - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); - + for (PropertyInfo &pi : pinfo) { if (pi.usage & PROPERTY_USAGE_CATEGORY) { continue; } else if (!(pi.usage & PROPERTY_USAGE_EDITOR) || (restrict_to_basic && !(pi.usage & PROPERTY_USAGE_EDITOR_BASIC_SETTING))) { @@ -250,8 +247,8 @@ void SectionedInspector::update_category_list() { for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; - //parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); - parent->set_custom_font(0, get_theme_font("bold", "EditorFonts")); + //parent->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + parent->set_custom_font(0, get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); if (i > 0) { metasection += "/" + sectionarr[i]; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index b6f889268f..df4469b6fe 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -63,7 +63,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { bool changed = _set_only(p_name, p_value); if (changed) { - emit_signal("settings_changed"); + emit_signal(SNAME("settings_changed")); } return true; } @@ -759,8 +759,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { List<String> keys; p_extra_config->get_section_keys("presets", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (const String &key : keys) { Variant val = p_extra_config->get_value("presets", key); set(key, val); } @@ -815,8 +814,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { props.get_key_list(&keys); keys.sort(); - for (const List<String>::Element *E = keys.front(); E; E = E->next()) { - const String &key = E->get(); + for (const String &key : keys) { if (key.begins_with("text_editor/highlighting/") && key.find("color") >= 0) { cf->set_value(theme_section, key.replace("text_editor/highlighting/", ""), ((Color)props[key].variant).to_html()); } @@ -1015,15 +1013,13 @@ void EditorSettings::setup_network() { String selected = "127.0.0.1"; // Check that current remote_host is a valid interface address and populate hints. - for (List<IPAddress>::Element *E = local_ip.front(); E; E = E->next()) { - String ip = E->get(); - + for (const IPAddress &ip : local_ip) { // link-local IPv6 addresses don't work, skipping them - if (ip.begins_with("fe80:0:0:0:")) { // fe80::/64 + if (String(ip).begins_with("fe80:0:0:0:")) { // fe80::/64 continue; } // Same goes for IPv4 link-local (APIPA) addresses. - if (ip.begins_with("169.254.")) { // 169.254.0.0/16 + if (String(ip).begins_with("169.254.")) { // 169.254.0.0/16 continue; } // Select current IP (found) @@ -1303,8 +1299,8 @@ void EditorSettings::list_text_editor_themes() { memdelete(d); custom_themes.sort(); - for (List<String>::Element *E = custom_themes.front(); E; E = E->next()) { - themes += "," + E->get(); + for (const String &E : custom_themes) { + themes += "," + E; } } add_property_hint(PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, themes)); @@ -1332,8 +1328,7 @@ void EditorSettings::load_text_editor_theme() { List<String> keys; cf->get_section_keys("color_theme", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); + for (const String &key : keys) { String val = cf->get_value("color_theme", key); // don't load if it's not already there! @@ -1344,7 +1339,7 @@ void EditorSettings::load_text_editor_theme() { } } } - emit_signal("settings_changed"); + emit_signal(SNAME("settings_changed")); // if it doesn't load just use what is currently loaded } @@ -1434,7 +1429,7 @@ float EditorSettings::get_auto_display_scale() const { return DisplayServer::get_singleton()->screen_get_max_scale(); #else const int screen = DisplayServer::get_singleton()->window_get_current_screen(); - // Use the smallest dimension to use a correct display scale on portait displays. + // Use the smallest dimension to use a correct display scale on portrait displays. const int smallest_dimension = MIN(DisplayServer::get_singleton()->screen_get_size(screen).x, DisplayServer::get_singleton()->screen_get_size(screen).y); if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && smallest_dimension >= 1400) { // hiDPI display. @@ -1585,8 +1580,8 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr int event_idx = 0; // Check equality of each event. - for (List<Ref<InputEvent>>::Element *E = builtin_events.front(); E; E = E->next()) { - if (!E->get()->is_match(p_events[event_idx])) { + for (const Ref<InputEvent> &E : builtin_events) { + if (!E->is_match(p_events[event_idx])) { same_as_builtin = false; break; } @@ -1615,8 +1610,8 @@ const Array EditorSettings::get_builtin_action_overrides(const String &p_name) c Array event_array; List<Ref<InputEvent>> events_list = AO->get(); - for (List<Ref<InputEvent>>::Element *E = events_list.front(); E; E = E->next()) { - event_array.push_back(E->get()); + for (const Ref<InputEvent> &E : events_list) { + event_array.push_back(E); } return event_array; } diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 436d67b882..58ab7d3cef 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -88,7 +88,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } } else if (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP || mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { if (grabber->is_visible()) { - call_deferred("update"); + call_deferred(SNAME("update")); } } } @@ -193,7 +193,7 @@ void EditorSpinSlider::_update_value_input_stylebox() { // when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's // default margins. Ref<StyleBoxFlat> stylebox = - EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "LineEdit")->duplicate(); + EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->duplicate(); // EditorSpinSliders with a label have more space on the left, so add an // higher margin to match the location where the text begins. // The margin values below were determined by empirical testing. @@ -229,19 +229,19 @@ void EditorSpinSlider::_notification(int p_what) { bool rtl = is_layout_rtl(); Vector2 size = get_size(); - Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); if (!flat) { draw_style_box(sb, Rect2(Vector2(), size)); } - Ref<Font> font = get_theme_font("font", "LineEdit"); - int font_size = get_theme_font_size("font_size", "LineEdit"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("LineEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("LineEdit")); int sep_base = 4 * EDSCALE; int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better int label_width = font->get_string_size(label, font_size).width; int number_width = size.width - sb->get_minimum_size().width - label_width - sep; - Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox"); + Ref<Texture2D> updown = get_theme_icon(SNAME("updown"), SNAME("SpinBox")); if (get_step() == 1) { number_width -= updown->get_width(); @@ -251,7 +251,7 @@ void EditorSpinSlider::_notification(int p_what) { int vofs = (size.height - font->get_height(font_size)) / 2 + font->get_ascent(font_size); - Color fc = get_theme_color("font_color", "LineEdit"); + Color fc = get_theme_color(SNAME("font_color"), SNAME("LineEdit")); Color lc; if (use_custom_label_color) { lc = custom_label_color; @@ -260,7 +260,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (flat && label != String()) { - Color label_bg_color = get_theme_color("dark_color_3", "Editor"); + Color label_bg_color = get_theme_color(SNAME("dark_color_3"), SNAME("Editor")); if (rtl) { draw_rect(Rect2(Vector2(size.width - (sb->get_offset().x * 2 + label_width), 0), Vector2(sb->get_offset().x * 2 + label_width, size.height)), label_bg_color); } else { @@ -269,7 +269,7 @@ void EditorSpinSlider::_notification(int p_what) { } if (has_focus()) { - Ref<StyleBox> focus = get_theme_stylebox("focus", "LineEdit"); + Ref<StyleBox> focus = get_theme_stylebox(SNAME("focus"), SNAME("LineEdit")); draw_style_box(focus, Rect2(Vector2(), size)); } @@ -307,7 +307,7 @@ void EditorSpinSlider::_notification(int p_what) { TS->free(num_rid); if (get_step() == 1) { - Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox"); + Ref<Texture2D> updown2 = get_theme_icon(SNAME("updown"), SNAME("SpinBox")); int updown_vofs = (size.height - updown2->get_height()) / 2; if (rtl) { updown_offset = sb->get_margin(SIDE_LEFT); @@ -350,9 +350,9 @@ void EditorSpinSlider::_notification(int p_what) { if (display_grabber) { Ref<Texture2D> grabber_tex; if (mouse_over_grabber) { - grabber_tex = get_theme_icon("grabber_highlight", "HSlider"); + grabber_tex = get_theme_icon(SNAME("grabber_highlight"), SNAME("HSlider")); } else { - grabber_tex = get_theme_icon("grabber", "HSlider"); + grabber_tex = get_theme_icon(SNAME("grabber"), SNAME("HSlider")); } if (grabber->get_texture() != grabber_tex) { @@ -395,9 +395,9 @@ LineEdit *EditorSpinSlider::get_line_edit() { } Size2 EditorSpinSlider::get_minimum_size() const { - Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); - Ref<Font> font = get_theme_font("font", "LineEdit"); - int font_size = get_theme_font_size("font_size", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("LineEdit")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("LineEdit")); Size2 ms = sb->get_minimum_size(); ms.height += font->get_height(font_size); @@ -529,9 +529,9 @@ void EditorSpinSlider::_focus_entered() { value_input->set_text(get_text_value()); value_input_popup->set_position(gr.position); value_input_popup->set_size(gr.size); - value_input_popup->call_deferred("popup"); - value_input->call_deferred("grab_focus"); - value_input->call_deferred("select_all"); + value_input_popup->call_deferred(SNAME("popup")); + value_input->call_deferred(SNAME("grab_focus")); + value_input->call_deferred(SNAME("select_all")); value_input->set_focus_next(find_next_valid_focus()->get_path()); value_input->set_focus_previous(find_prev_valid_focus()->get_path()); } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 427f079669..0c908be441 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -996,7 +996,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("DebuggerPanel", "EditorStyles", style_panel_debugger); Ref<StyleBoxFlat> style_panel_invisible_top = style_content_panel->duplicate(); - int stylebox_offset = theme->get_font("tab_selected", "TabContainer")->get_height(theme->get_font_size("tab_selected", "TabContainer")) + theme->get_stylebox("tab_selected", "TabContainer")->get_minimum_size().height + theme->get_stylebox("panel", "TabContainer")->get_default_margin(SIDE_TOP); + int stylebox_offset = theme->get_font("tab_selected", "TabContainer")->get_height(theme->get_font_size("tab_selected", "TabContainer")) + theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height + theme->get_stylebox(SNAME("panel"), SNAME("TabContainer"))->get_default_margin(SIDE_TOP); style_panel_invisible_top->set_expand_margin_size(SIDE_TOP, -stylebox_offset); style_panel_invisible_top->set_default_margin(SIDE_TOP, 0); theme->set_stylebox("BottomPanelDebuggerOverride", "EditorStyles", style_panel_invisible_top); @@ -1024,6 +1024,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled); theme->set_icon("clear", "LineEdit", theme->get_icon("GuiClose", "EditorIcons")); theme->set_color("read_only", "LineEdit", font_disabled_color); + theme->set_color("font_uneditable_color", "LineEdit", font_disabled_color); theme->set_color("font_color", "LineEdit", font_color); theme->set_color("font_selected_color", "LineEdit", mono_color); theme->set_color("caret_color", "LineEdit", font_color); @@ -1189,7 +1190,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tooltip->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE * 0.5); style_tooltip->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_bg_color(mono_color.inverted() * Color(1, 1, 1, 0.8)); + style_tooltip->set_bg_color(mono_color.inverted()); style_tooltip->set_border_width_all(0); theme->set_color("font_color", "TooltipLabel", font_hover_color); theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0)); diff --git a/editor/editor_zoom_widget.cpp b/editor/editor_zoom_widget.cpp index 44751a480a..420aeb03fe 100644 --- a/editor/editor_zoom_widget.cpp +++ b/editor/editor_zoom_widget.cpp @@ -52,17 +52,17 @@ void EditorZoomWidget::_update_zoom_label() { void EditorZoomWidget::_button_zoom_minus() { set_zoom_by_increments(-6, Input::get_singleton()->is_key_pressed(KEY_ALT)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } void EditorZoomWidget::_button_zoom_reset() { set_zoom(1.0 * MAX(1, EDSCALE)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } void EditorZoomWidget::_button_zoom_plus() { set_zoom_by_increments(6, Input::get_singleton()->is_key_pressed(KEY_ALT)); - emit_signal("zoom_changed", zoom); + emit_signal(SNAME("zoom_changed"), zoom); } float EditorZoomWidget::get_zoom() { @@ -145,8 +145,8 @@ void EditorZoomWidget::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + zoom_minus->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_plus->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); break; default: break; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index e24f6a11ed..699957897f 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -106,8 +106,8 @@ void ExportTemplateManager::_update_template_status() { TreeItem *ti = installed_table->create_item(installed_root); ti->set_text(0, version_string); - ti->add_button(0, get_theme_icon("Folder", "EditorIcons"), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); - ti->add_button(0, get_theme_icon("Remove", "EditorIcons"), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); + ti->add_button(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), OPEN_TEMPLATE_FOLDER, false, TTR("Open the folder containing these templates.")); + ti->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), UNINSTALL_TEMPLATE, false, TTR("Uninstall these templates.")); } } @@ -352,9 +352,9 @@ void ExportTemplateManager::_set_current_progress_status(const String &p_status, download_progress_label->set_text(p_status); if (p_error) { - download_progress_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else { - download_progress_label->add_theme_color_override("font_color", get_theme_color("font_color", "Label")); + download_progress_label->add_theme_color_override("font_color", get_theme_color(SNAME("font_color"), SNAME("Label"))); } } @@ -739,11 +739,11 @@ void ExportTemplateManager::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - current_value->add_theme_font_override("font", get_theme_font("main", "EditorFonts")); - current_missing_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - current_installed_label->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + current_value->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + current_missing_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + current_installed_label->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); - mirror_options_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + mirror_options_button->set_icon(get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 3dc854d6bd..daee61c2dd 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -50,9 +50,9 @@ Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { Ref<Texture2D> file_icon; if (!p_is_valid) { - file_icon = get_theme_icon("ImportFail", "EditorIcons"); + file_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - file_icon = (has_theme_icon(p_file_type, "EditorIcons")) ? get_theme_icon(p_file_type, "EditorIcons") : get_theme_icon("File", "EditorIcons"); + file_icon = (has_theme_icon(p_file_type, SNAME("EditorIcons"))) ? get_theme_icon(p_file_type, SNAME("EditorIcons")) : get_theme_icon(SNAME("File"), SNAME("EditorIcons")); } return file_icon; } @@ -69,8 +69,8 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory subdirectory_item->set_text(0, dname); subdirectory_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); - subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons")); - subdirectory_item->set_icon_modulate(0, get_theme_color("folder_icon_modulate", "FileDialog")); + subdirectory_item->set_icon(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + subdirectory_item->set_icon_modulate(0, get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog"))); subdirectory_item->set_selectable(0, true); String lpath = p_dir->get_path(); subdirectory_item->set_metadata(0, lpath); @@ -135,9 +135,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory _sort_file_info_list(file_list); // Build the tree. - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo fi = E->get(); - + for (const FileInfo &fi : file_list) { TreeItem *file_item = tree->create_item(subdirectory_item); file_item->set_text(0, fi.name); file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE); @@ -149,7 +147,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_as_cursor(0); } if (main_scene == file_metadata) { - file_item->set_custom_color(0, get_theme_color("accent_color", "Editor")); + file_item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } Array udata; udata.push_back(tree_update_id); @@ -215,7 +213,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo // Handles the favorites. TreeItem *favorites = tree->create_item(root); - favorites->set_icon(0, get_theme_icon("Favorites", "EditorIcons")); + favorites->set_icon(0, get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); favorites->set_text(0, TTR("Favorites:")); favorites->set_metadata(0, "Favorites"); favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); @@ -227,8 +225,8 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo continue; } - Ref<Texture2D> folder_icon = get_theme_icon("Folder", "EditorIcons"); - const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")); + const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); String text; Ref<Texture2D> icon; @@ -248,7 +246,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (dir) { icon = _get_tree_item_icon(dir->get_file_import_is_valid(index), dir->get_file_type(index)); } else { - icon = get_theme_icon("File", "EditorIcons"); + icon = get_theme_icon(SNAME("File"), SNAME("EditorIcons")); } color = Color(1, 1, 1); } @@ -339,28 +337,28 @@ void FileSystemDock::_notification(int p_what) { String ei = "EditorIcons"; - button_reload->set_icon(get_theme_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display)); files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file)); button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history)); button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history)); - tree_search_box->set_right_icon(get_theme_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon("Sort", ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); - file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon("Sort", ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon("Back", ei)); - button_hist_prev->set_icon(get_theme_icon("Forward", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); } else { - button_hist_next->set_icon(get_theme_icon("Forward", ei)); - button_hist_prev->set_icon(get_theme_icon("Back", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); } file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option)); tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); @@ -412,28 +410,28 @@ void FileSystemDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons. String ei = "EditorIcons"; - button_reload->set_icon(get_theme_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon("Back", ei)); - button_hist_prev->set_icon(get_theme_icon("Forward", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); } else { - button_hist_next->set_icon(get_theme_icon("Forward", ei)); - button_hist_prev->set_icon(get_theme_icon("Back", ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); } if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) { - button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); } else { - button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); } - tree_search_box->set_right_icon(get_theme_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon("Sort", ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); - file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon("Sort", ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); // Update always show folders. bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders")); @@ -451,7 +449,7 @@ void FileSystemDock::_notification(int p_what) { void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_selected) { // Update the import dock. import_dock_needs_update = true; - call_deferred("_update_import_dock"); + call_deferred(SNAME("_update_import_dock")); // Return if we don't select something new. if (!p_selected) { @@ -581,17 +579,17 @@ void FileSystemDock::_tree_thumbnail_done(const String &p_path, const Ref<Textur void FileSystemDock::_toggle_file_display() { _set_file_display(file_list_display_mode != FILE_LIST_DISPLAY_LIST); - emit_signal("display_mode_changed"); + emit_signal(SNAME("display_mode_changed")); } void FileSystemDock::_set_file_display(bool p_active) { if (p_active) { file_list_display_mode = FILE_LIST_DISPLAY_LIST; - button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); button_file_list_display_mode->set_tooltip(TTR("View items as a grid of thumbnails.")); } else { file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; - button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); button_file_list_display_mode->set_tooltip(TTR("View items as a list.")); } @@ -733,13 +731,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_theme_icon("FolderMediumThumb", ei); - file_thumbnail = get_theme_icon("FileMediumThumb", ei); - file_thumbnail_broken = get_theme_icon("FileDeadMediumThumb", ei); + folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), ei); + file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), ei); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), ei); } else { - folder_thumbnail = get_theme_icon("FolderBigThumb", ei); - file_thumbnail = get_theme_icon("FileBigThumb", ei); - file_thumbnail_broken = get_theme_icon("FileDeadBigThumb", ei); + folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), ei); + file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), ei); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), ei); } } else { // No thumbnails. @@ -750,8 +748,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2()); } - Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon("folder", "FileDialog"); - const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon(SNAME("folder"), SNAME("FileDialog")); + const Color folder_color = get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")); // Build the FileInfo list. List<FileInfo> file_list; @@ -869,8 +867,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Fills the ItemList control node from the FileInfos. String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene"); String oi = "Object"; - for (List<FileInfo>::Element *E = file_list.front(); E; E = E->next()) { - FileInfo *finfo = &(E->get()); + for (FileInfo &E : file_list) { + FileInfo *finfo = &(E); String fname = finfo->name; String fpath = finfo->path; String ftype = finfo->type; @@ -885,7 +883,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei); big_icon = file_thumbnail; } else { - type_icon = get_theme_icon("ImportFail", ei); + type_icon = get_theme_icon(SNAME("ImportFail"), ei); big_icon = file_thumbnail_broken; tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually."); } @@ -905,7 +903,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } if (fpath == main_scene) { - files->set_item_custom_fg_color(item_index, get_theme_color("accent_color", "Editor")); + files->set_item_custom_fg_color(item_index, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } // Generate the preview. @@ -966,8 +964,8 @@ void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorit List<String> importer_exts; ResourceImporterScene::get_singleton()->get_recognized_extensions(&importer_exts); String extension = fpath.get_extension(); - for (List<String>::Element *E = importer_exts.front(); E; E = E->next()) { - if (extension.nocasecmp_to(E->get()) == 0) { + for (const String &E : importer_exts) { + if (extension.nocasecmp_to(E) == 0) { is_imported = true; break; } @@ -1189,11 +1187,11 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_ for (int i = 0; i < file_changed_paths.size(); ++i) { p_file_renames[file_changed_paths[i]] = file_changed_paths[i].replace_first(old_path, new_path); print_verbose(" Remap: " + file_changed_paths[i] + " -> " + p_file_renames[file_changed_paths[i]]); - emit_signal("files_moved", file_changed_paths[i], p_file_renames[file_changed_paths[i]]); + emit_signal(SNAME("files_moved"), file_changed_paths[i], p_file_renames[file_changed_paths[i]]); } for (int i = 0; i < folder_changed_paths.size(); ++i) { p_folder_renames[folder_changed_paths[i]] = folder_changed_paths[i].replace_first(old_path, new_path); - emit_signal("folder_moved", folder_changed_paths[i], p_folder_renames[folder_changed_paths[i]].substr(0, p_folder_renames[folder_changed_paths[i]].length() - 1)); + emit_signal(SNAME("folder_moved"), folder_changed_paths[i], p_folder_renames[folder_changed_paths[i]].substr(0, p_folder_renames[folder_changed_paths[i]].length() - 1)); } } else { EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n"); @@ -1239,9 +1237,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> r = E->get(); - + for (Ref<Resource> &r : cached) { String base_path = r->get_path(); String extra_path; int sep_pos = r->get_path().find("::"); @@ -1317,16 +1313,16 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin // Also search for the file in autoload, as they are stored differently from normal files. List<PropertyInfo> property_list; ProjectSettings::get_singleton()->get_property_list(&property_list); - for (const List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - if (E->get().name.begins_with("autoload/")) { + for (const PropertyInfo &E : property_list) { + if (E.name.begins_with("autoload/")) { // If the autoload resource paths has a leading "*", it indicates that it is a Singleton, // so we have to handle both cases when updating. - String autoload = GLOBAL_GET(E->get().name); + String autoload = GLOBAL_GET(E.name); String autoload_singleton = autoload.substr(1, autoload.length()); if (p_renames.has(autoload)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]); + ProjectSettings::get_singleton()->set_setting(E.name, p_renames[autoload]); } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) { - ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]); + ProjectSettings::get_singleton()->set_setting(E.name, "*" + p_renames[autoload_singleton]); } } } @@ -1417,8 +1413,8 @@ void FileSystemDock::_make_scene_confirm() { ResourceSaver::get_recognized_extensions(sd, &extensions); bool extension_correct = false; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get() == extension) { + for (const String &E : extensions) { + if (E == extension) { extension_correct = true; break; } @@ -1442,7 +1438,7 @@ void FileSystemDock::_make_scene_confirm() { } void FileSystemDock::_file_removed(String p_file) { - emit_signal("file_removed", p_file); + emit_signal(SNAME("file_removed"), p_file); // Find the closest parent directory available, in case multiple items were deleted along the same path. path = p_file.get_base_dir(); @@ -1455,7 +1451,7 @@ void FileSystemDock::_file_removed(String p_file) { } void FileSystemDock::_folder_removed(String p_folder) { - emit_signal("folder_removed", p_folder); + emit_signal(SNAME("folder_removed"), p_folder); // Find the closest parent directory available, in case multiple items were deleted along the same path. path = p_folder.get_base_dir(); @@ -1762,7 +1758,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_INHERIT: { // Create a new scene inherited from the selected one. if (p_selected.size() == 1) { - emit_signal("inherit", p_selected[0]); + emit_signal(SNAME("inherit"), p_selected[0]); } } break; @@ -1786,7 +1782,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected } } if (!paths.is_empty()) { - emit_signal("instance", paths); + emit_signal(SNAME("instance"), paths); } } break; @@ -2019,7 +2015,7 @@ void FileSystemDock::_rescan() { void FileSystemDock::_toggle_split_mode(bool p_active) { set_display_mode(p_active ? DISPLAY_MODE_SPLIT : DISPLAY_MODE_TREE_ONLY); - emit_signal("display_mode_changed"); + emit_signal(SNAME("display_mode_changed")); } void FileSystemDock::fix_dependencies(const String &p_for_file) { @@ -2404,28 +2400,28 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (all_files) { if (all_files_scenes) { if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN); - p_popup->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scene"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), TTR("New Inherited Scene"), FILE_INHERIT); if (ProjectSettings::get_singleton()->get("application/run/main_scene") != filenames[0]) { - p_popup->add_icon_item(get_theme_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE); + p_popup->add_icon_item(get_theme_icon(SNAME("PlayScene"), SNAME("EditorIcons")), TTR("Set As Main Scene"), FILE_MAIN_SCENE); } } else { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open Scenes"), FILE_OPEN); } - p_popup->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE); + p_popup->add_icon_item(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instance"), FILE_INSTANCE); p_popup->add_separator(); } else if (filenames.size() == 1) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } } if (p_paths.size() >= 1) { if (!all_favorites) { - p_popup->add_icon_item(get_theme_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE); + p_popup->add_icon_item(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")), TTR("Add to Favorites"), FILE_ADD_FAVORITE); } if (!all_not_favorites) { - p_popup->add_icon_item(get_theme_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); + p_popup->add_icon_item(get_theme_icon(SNAME("NonFavorite"), SNAME("EditorIcons")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); } p_popup->add_separator(); } @@ -2438,36 +2434,36 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } } else if (all_folders && foldernames.size() > 0) { - p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } if (p_paths.size() == 1) { - p_popup->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); if (p_paths[0] != "res://") { - p_popup->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); - p_popup->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); } } if (p_paths.size() > 1 || p_paths[0] != "res://") { - p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE); - p_popup->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); + p_popup->add_icon_item(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), TTR("Move To..."), FILE_MOVE); + p_popup->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); } if (p_paths.size() == 1) { p_popup->add_separator(); if (p_display_path_dependent_options) { - p_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - p_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - p_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - p_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + p_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + p_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + p_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + p_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); p_popup->add_separator(); } String fpath = p_paths[0]; String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager"); - p_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER); + p_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), item_text, FILE_SHOW_IN_EXPLORER); } } @@ -2478,8 +2474,8 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { tree_popup->clear(); if (paths.size() == 1) { if (paths[0].ends_with("/")) { - tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL); - tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); + tree_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), TTR("Expand All"), FOLDER_EXPAND_ALL); + tree_popup->add_icon_item(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); tree_popup->add_separator(); } } @@ -2498,10 +2494,10 @@ void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) { path = "res://"; tree_popup->clear(); tree_popup->set_size(Size2(1, 1)); - tree_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - tree_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - tree_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - tree_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + tree_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + tree_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + tree_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); tree_popup->set_position(tree->get_global_position() + p_pos); tree_popup->popup(); } @@ -2543,12 +2539,12 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) { file_list_popup->clear(); file_list_popup->set_size(Size2(1, 1)); - file_list_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - file_list_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - file_list_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - file_list_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), TTR("New Folder..."), FILE_NEW_FOLDER); + file_list_popup->add_icon_item(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")), TTR("New Scene..."), FILE_NEW_SCENE); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); file_list_popup->add_separator(); - file_list_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); + file_list_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); file_list_popup->set_position(files->get_global_position() + p_pos); file_list_popup->popup(); } @@ -2572,7 +2568,7 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { // Update the import dock. import_dock_needs_update = true; - call_deferred("_update_import_dock"); + call_deferred(SNAME("_update_import_dock")); } void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index cb8de09a9a..87277e79f3 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -116,12 +116,12 @@ void FindInFiles::_notification(int p_notification) { void FindInFiles::start() { if (_pattern == "") { print_verbose("Nothing to search, pattern is empty"); - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); return; } if (_extension_filter.size() == 0) { print_verbose("Nothing to search, filter matches no files"); - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); return; } @@ -201,7 +201,7 @@ void FindInFiles::_iterate() { set_process(false); _current_dir = ""; _searching = false; - emit_signal(SIGNAL_FINISHED); + emit_signal(SNAME(SIGNAL_FINISHED)); } } @@ -267,7 +267,7 @@ void FindInFiles::_scan_file(String fpath) { String line = f->get_line(); while (find_next(line, _pattern, end, _match_case, _whole_words, begin, end)) { - emit_signal(SIGNAL_RESULT_FOUND, fpath, line_number, begin, end, line); + emit_signal(SNAME(SIGNAL_RESULT_FOUND), fpath, line_number, begin, end, line); } } @@ -457,7 +457,7 @@ void FindInFilesDialog::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible()) { // Doesn't work more than once if not deferred... - _search_text_line_edit->call_deferred("grab_focus"); + _search_text_line_edit->call_deferred(SNAME("grab_focus")); _search_text_line_edit->select_all(); // Extensions might have changed in the meantime, we clean them and instance them again. for (int i = 0; i < _filters_container->get_child_count(); i++) { @@ -487,10 +487,10 @@ void FindInFilesDialog::custom_action(const String &p_action) { _filters_preferences[cb->get_text()] = cb->is_pressed(); } if (p_action == "find") { - emit_signal(SIGNAL_FIND_REQUESTED); + emit_signal(SNAME(SIGNAL_FIND_REQUESTED)); hide(); } else if (p_action == "replace") { - emit_signal(SIGNAL_REPLACE_REQUESTED); + emit_signal(SNAME(SIGNAL_REPLACE_REQUESTED)); hide(); } } @@ -565,8 +565,8 @@ FindInFilesPanel::FindInFilesPanel() { hbc->add_child(find_label); _search_text_label = memnew(Label); - _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); - _search_text_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts")); + _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _search_text_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); hbc->add_child(_search_text_label); _progress_bar = memnew(ProgressBar); @@ -594,8 +594,8 @@ FindInFilesPanel::FindInFilesPanel() { } _results_display = memnew(Tree); - _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); - _results_display->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("source_size", "EditorFonts")); + _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _results_display->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("source_size"), SNAME("EditorFonts"))); _results_display->set_v_size_flags(SIZE_EXPAND_FILL); _results_display->connect("item_selected", callable_mp(this, &FindInFilesPanel::_on_result_selected)); _results_display->connect("item_edited", callable_mp(this, &FindInFilesPanel::_on_item_edited)); @@ -688,8 +688,8 @@ void FindInFilesPanel::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { _progress_bar->set_as_ratio(_finder->get_progress()); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - _search_text_label->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - _results_display->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); + _search_text_label->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); + _results_display->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts"))); } } @@ -754,8 +754,8 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { } Result r = E->value(); String item_text = item->get_text(_with_replace ? 1 : 0); - Ref<Font> font = _results_display->get_theme_font("font"); - int font_size = _results_display->get_theme_font_size("font_size"); + Ref<Font> font = _results_display->get_theme_font(SNAME("font")); + int font_size = _results_display->get_theme_font_size(SNAME("font_size")); Rect2 match_rect = rect; match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), font_size).x; @@ -764,7 +764,7 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { match_rect.size.y -= 2 * EDSCALE; // Use the inverted accent color to help match rectangles stand out even on the currently selected line. - _results_display->draw_rect(match_rect, get_theme_color("accent_color", "Editor").inverted() * Color(1, 1, 1, 0.5)); + _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5)); // Text is drawn by Tree already. } @@ -773,11 +773,11 @@ void FindInFilesPanel::_on_item_edited() { TreeItem *item = _results_display->get_selected(); if (item->is_checked(0)) { - item->set_custom_color(1, _results_display->get_theme_color("font_color")); + item->set_custom_color(1, _results_display->get_theme_color(SNAME("font_color"))); } else { // Grey out - Color color = _results_display->get_theme_color("font_color"); + Color color = _results_display->get_theme_color(SNAME("font_color")); color.a /= 2.0; item->set_custom_color(1, color); } @@ -823,7 +823,7 @@ void FindInFilesPanel::_on_result_selected() { TreeItem *file_item = item->get_parent(); String fpath = file_item->get_metadata(0); - emit_signal(SIGNAL_RESULT_SELECTED, fpath, r.line_number, r.begin, r.end); + emit_signal(SNAME(SIGNAL_RESULT_SELECTED), fpath, r.line_number, r.begin, r.end); } void FindInFilesPanel::_on_replace_text_changed(String text) { @@ -860,7 +860,7 @@ void FindInFilesPanel::_on_replace_all_clicked() { // Hide replace bar so we can't trigger the action twice without doing a new search _replace_container->hide(); - emit_signal(SIGNAL_FILES_MODIFIED, modified_files); + emit_signal(SNAME(SIGNAL_FILES_MODIFIED), modified_files); } // Same as get_line, but preserves line ending characters diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 76fbee7490..113306fc8a 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -94,7 +94,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (!_can_edit(p_current, selected_group)) { node->set_selectable(0, false); - node->set_custom_color(0, groups->get_theme_color("disabled_font_color", "Editor")); + node->set_custom_color(0, groups->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } } @@ -204,7 +204,7 @@ void GroupDialog::_add_group(String p_name) { TreeItem *new_group = groups->create_item(groups_root); new_group->set_text(0, name); - new_group->add_button(0, groups->get_theme_icon("Remove", "EditorIcons"), 0); + new_group->add_button(0, groups->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0); new_group->set_editable(0, true); new_group->select(0); groups->ensure_cursor_is_visible(); @@ -240,8 +240,7 @@ void GroupDialog::_group_renamed() { List<Node *> nodes; scene_tree->get_nodes_in_group(selected_group, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : nodes) { if (_can_edit(node, selected_group)) { undo_redo->add_do_method(node, "remove_from_group", selected_group); undo_redo->add_undo_method(node, "remove_from_group", name); @@ -286,11 +285,11 @@ void GroupDialog::_load_groups(Node *p_current) { List<Node::GroupInfo> gi; p_current->get_groups(&gi); - for (List<Node::GroupInfo>::Element *E = gi.front(); E; E = E->next()) { - if (!E->get().persistent) { + for (const Node::GroupInfo &E : gi) { + if (!E.persistent) { continue; } - _add_group(E->get().name); + _add_group(E.name); } for (int i = 0; i < p_current->get_child_count(); i++) { @@ -311,10 +310,10 @@ void GroupDialog::_delete_group_pressed(Object *p_item, int p_column, int p_id) List<Node *> nodes; scene_tree->get_nodes_in_group(name, &nodes); bool removed_all = true; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - if (_can_edit(E->get(), name)) { - undo_redo->add_do_method(E->get(), "remove_from_group", name); - undo_redo->add_undo_method(E->get(), "add_to_group", name, true); + for (Node *E : nodes) { + if (_can_edit(E, name)) { + undo_redo->add_do_method(E, "remove_from_group", name); + undo_redo->add_undo_method(E, "add_to_group", name, true); } else { removed_all = false; } @@ -365,16 +364,16 @@ void GroupDialog::_notification(int p_what) { case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_ENTER_TREE: { if (is_layout_rtl()) { - add_button->set_icon(groups->get_theme_icon("Back", "EditorIcons")); - remove_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons")); + add_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + remove_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons")); - remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons")); + add_button->set_icon(groups->get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + remove_button->set_icon(groups->get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } - add_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); + add_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); add_filter->set_clear_button_enabled(true); - remove_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); + remove_filter->set_right_icon(groups->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); remove_filter->set_clear_button_enabled(true); } break; } @@ -628,8 +627,7 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); - for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo gi = E->get(); + for (const GroupInfo &gi : groups) { if (!gi.persistent) { continue; } @@ -655,7 +653,7 @@ void GroupsEditor::update_tree() { TreeItem *item = tree->create_item(root); item->set_text(0, gi.name); if (can_be_deleted) { - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0); } else { item->set_selectable(0, false); } diff --git a/editor/icons/ImmediateGeometry3D.svg b/editor/icons/ImmediateGeometry3D.svg deleted file mode 100644 index ec5a392a68..0000000000 --- a/editor/icons/ImmediateGeometry3D.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2.9208 1046.4c-.26373.3-.4204.7296-.4204 1.2383 0 1.6277-3.1381-.1781-.33757 2.6703.88382.899 2.6544.6701 3.5382-.2288.88384-.899.88382-2.3565 0-3.2554-1.1002-1.1191-2.2001-1.0845-2.7803-.4244zm2.3802-1.6103 2.4005 2.4416 6.8014-6.9177c.66286-.6742.66286-1.7673 0-2.4415-.66288-.6741-1.7376-.6741-2.4005 0z" fill="#fc7f7f" transform="translate(0 -1036.4)"/></svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index ddf89f077b..b615c73422 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -894,8 +894,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor surftool->add_vertex(vertex_array[k].vertex); } - for (List<int>::Element *E = indices_list.front(); E; E = E->next()) { - surftool->add_index(E->get()); + for (int &E : indices_list) { + surftool->add_index(E); } if (!normal_src) { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 01603c0a6a..34bc0a7d8d 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -438,17 +438,16 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in Node3D *scene = memnew(Node3D); - for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { + for (const Ref<Mesh> &m : meshes) { Ref<EditorSceneImporterMesh> mesh; mesh.instantiate(); - Ref<Mesh> m = E->get(); for (int i = 0; i < m->get_surface_count(); i++) { mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i)); } EditorSceneImporterMeshNode3D *mi = memnew(EditorSceneImporterMeshNode3D); mi->set_mesh(mesh); - mi->set_name(E->get()->get_name()); + mi->set_name(m->get_name()); scene->add_child(mi); mi->set_owner(scene); } diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index c14b948dae..e9160f0414 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -312,8 +312,8 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + for (const StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); ERR_CONTINUE(anim.is_null()); for (int i = 0; i < anim->get_track_count(); i++) { NodePath path = anim->track_get_path(i); @@ -328,14 +328,14 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E } } - String animname = E->get(); + String animname = E; const int loop_string_count = 3; static const char *loop_strings[loop_string_count] = { "loops", "loop", "cycle" }; for (int i = 0; i < loop_string_count; i++) { if (_teststr(animname, loop_strings[i])) { anim->set_loop(true); animname = _fixstr(animname, loop_strings[i]); - ap->rename_animation(E->get(), animname); + ap->rename_animation(E, animname); } } } @@ -659,9 +659,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } int idx = 0; - for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { + for (const Ref<Shape3D> &E : shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); base->add_child(cshape); cshape->set_owner(base->get_owner()); @@ -712,9 +712,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill node settings for this node with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts); - for (List<ImportOption>::Element *E = iopts.front(); E; E = E->next()) { - if (!node_settings.has(E->get().option.name)) { - node_settings[E->get().option.name] = E->get().default_value; + for (const ImportOption &E : iopts) { + if (!node_settings.has(E.option.name)) { + node_settings[E.option.name] = E.default_value; } } } @@ -756,8 +756,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< } else { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &name : anims) { Ref<Animation> anim = ap->get_animation(name); if (p_animation_data.has(name)) { Dictionary anim_settings = p_animation_data[name]; @@ -765,9 +764,9 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< //fill with default values List<ImportOption> iopts; get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION, &iopts); - for (List<ImportOption>::Element *F = iopts.front(); F; F = F->next()) { - if (!anim_settings.has(F->get().option.name)) { - anim_settings[F->get().option.name] = F->get().default_value; + for (const ImportOption &F : iopts) { + if (!anim_settings.has(F.option.name)) { + anim_settings[F.option.name] = F.default_value; } } } @@ -936,8 +935,8 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_ void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle) { List<StringName> anim_names; anim->get_animation_list(&anim_names); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - Ref<Animation> a = anim->get_animation(E->get()); + for (const StringName &E : anim_names) { + Ref<Animation> a = anim->get_animation(E); a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle)); } } @@ -1046,11 +1045,11 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in String script_ext_hint; - for (List<String>::Element *E = script_extentions.front(); E; E = E->next()) { + for (const String &E : script_extentions) { if (script_ext_hint != "") { script_ext_hint += ","; } - script_ext_hint += "*." + E->get(); + script_ext_hint += "*." + E; } r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0)); @@ -1089,9 +1088,9 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (const String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1119,9 +1118,9 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); + for (const String &F : extensions) { + if (F.to_lower() == ext) { + importer = E; break; } } @@ -1291,9 +1290,9 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } void ResourceImporterScene::_add_shapes(Node *p_node, const List<Ref<Shape3D>> &p_shapes) { - for (const List<Ref<Shape3D>>::Element *E = p_shapes.front(); E; E = E->next()) { + for (const Ref<Shape3D> &E : p_shapes) { CollisionShape3D *cshape = memnew(CollisionShape3D); - cshape->set_shape(E->get()); + cshape->set_shape(E); p_node->add_child(cshape); cshape->set_owner(p_node->get_owner()); @@ -1311,8 +1310,8 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) { List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { + for (const String &F : extensions) { + if (F.to_lower() == ext) { importer = E->get(); break; } @@ -1351,8 +1350,8 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p List<String> extensions; E->get()->get_extensions(&extensions); - for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { + for (const String &F : extensions) { + if (F.to_lower() == ext) { importer = E->get(); break; } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index c6e5836a23..781beff689 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -155,7 +155,8 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override; - virtual int get_import_order() const override { return 100; } //after everything + // Import scenes *after* everything else (such as textures). + virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; } Node *_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<EditorSceneImporterMesh>, List<Ref<Shape3D>>> &collision_map); Node *_post_fix_node(Node *p_node, Node *p_root, Map<Ref<EditorSceneImporterMesh>, List<Ref<Shape3D>>> &collision_map, Set<Ref<EditorSceneImporterMesh>> &r_scanned_meshes, const Dictionary &p_node_data, const Dictionary &p_material_data, const Dictionary &p_animation_data, float p_animation_fps); diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index f9f47ec4f4..19a8f209bb 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -71,9 +71,9 @@ class SceneImportSettingsData : public Object { return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E->get().option.name, current)) { - p_list->push_back(E->get().option); + for (const ResourceImporter::ImportOption &E : options) { + if (ResourceImporterScene::get_singleton()->get_internal_option_visibility(category, E.option.name, current)) { + p_list->push_back(E.option); } } } @@ -105,7 +105,7 @@ void SceneImportSettings::_fill_material(Tree *p_tree, const Ref<Material> &p_ma MaterialData &material_data = material_map[import_id]; - Ref<Texture2D> icon = get_theme_icon("StandardMaterial3D", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_material->get_name()); @@ -161,7 +161,7 @@ void SceneImportSettings::_fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, Tree MeshData &mesh_data = mesh_map[import_id]; - Ref<Texture2D> icon = get_theme_icon("Mesh", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_mesh->get_name()); @@ -211,7 +211,7 @@ void SceneImportSettings::_fill_animation(Tree *p_tree, const Ref<Animation> &p_ AnimationData &animation_data = animation_map[p_name]; - Ref<Texture2D> icon = get_theme_icon("Animation", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")); TreeItem *item = p_tree->create_item(p_parent); item->set_text(0, p_name); @@ -255,17 +255,17 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { String type = p_node->get_class(); - if (!has_theme_icon(type, "EditorIcons")) { + if (!has_theme_icon(type, SNAME("EditorIcons"))) { type = "Node3D"; } - Ref<Texture2D> icon = get_theme_icon(type, "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(type, SNAME("EditorIcons")); TreeItem *item = scene_tree->create_item(p_parent_item); item->set_text(0, p_node->get_name()); if (p_node == scene) { - icon = get_theme_icon("PackedScene", "EditorIcons"); + icon = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); item->set_text(0, "Scene"); } @@ -305,8 +305,8 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { if (anim_node) { List<StringName> animations; anim_node->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - _fill_animation(scene_tree, anim_node->get_animation(E->get()), E->get(), item); + for (const StringName &E : animations) { + _fill_animation(scene_tree, anim_node->get_animation(E), E, item); } } @@ -394,8 +394,8 @@ void SceneImportSettings::_load_default_subresource_settings(Map<StringName, Var d = d[p_import_id]; List<ResourceImporterScene::ImportOption> options; ResourceImporterScene::get_singleton()->get_internal_import_options(p_category, &options); - for (List<ResourceImporterScene::ImportOption>::Element *E = options.front(); E; E = E->next()) { - String key = E->get().option.name; + for (const ResourceImporterScene::ImportOption &E : options) { + String key = E.option.name; if (d.has(key)) { settings[key] = d[key]; } @@ -440,12 +440,12 @@ void SceneImportSettings::open_settings(const String &p_path) { if (err == OK) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - Variant value = config->get_value("params", E->get()); - if (E->get() == "_subresources") { + for (const String &E : keys) { + Variant value = config->get_value("params", E); + if (E == "_subresources") { base_subresource_settings = value; } else { - defaults[E->get()] = value; + defaults[E] = value; } } } @@ -605,13 +605,13 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) { scene_import_settings_data->defaults.clear(); scene_import_settings_data->current.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - scene_import_settings_data->defaults[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + scene_import_settings_data->defaults[E.option.name] = E.default_value; //needed for visibility toggling (fails if something is missing) - if (scene_import_settings_data->settings->has(E->get().option.name)) { - scene_import_settings_data->current[E->get().option.name] = (*scene_import_settings_data->settings)[E->get().option.name]; + if (scene_import_settings_data->settings->has(E.option.name)) { + scene_import_settings_data->current[E.option.name] = (*scene_import_settings_data->settings)[E.option.name]; } else { - scene_import_settings_data->current[E->get().option.name] = E->get().default_value; + scene_import_settings_data->current[E.option.name] = E.default_value; } } scene_import_settings_data->options = options; @@ -795,11 +795,11 @@ void SceneImportSettings::_save_path_changed(const String &p_path) { if (FileAccess::exists(p_path)) { save_path_item->set_text(2, "Warning: File exists"); save_path_item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); - save_path_item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + save_path_item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { save_path_item->set_text(2, "Will create new File"); - save_path_item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + save_path_item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } } @@ -829,7 +829,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.material_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("StandardMaterial3D", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("StandardMaterial3D"), SNAME("EditorIcons"))); item->set_text(0, name); if (md.has_import_id) { @@ -851,20 +851,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will create new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } else { item->set_text(2, "No import ID"); item->set_tooltip(2, TTR("Material has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon("StatusError", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } save_path_items.push_back(item); @@ -882,7 +882,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = md.mesh_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("Mesh", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons"))); item->set_text(0, name); if (md.has_import_id) { @@ -904,20 +904,20 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will save to new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } else { item->set_text(2, "No import ID"); item->set_tooltip(2, TTR("Mesh has no name nor any other way to identify on re-import.\nPlease name it or ensure it is exported with an unique ID.")); - item->set_icon(2, get_theme_icon("StatusError", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))); } save_path_items.push_back(item); @@ -935,7 +935,7 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { String name = ad.scene_node->get_text(0); item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_icon(0, get_theme_icon("Animation", "EditorIcons")); + item->set_icon(0, get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); item->set_text(0, name); if (ad.settings.has("save_to_file/enabled") && bool(ad.settings["save_to_file/enabled"])) { @@ -956,14 +956,14 @@ void SceneImportSettings::_save_dir_callback(const String &p_path) { if (FileAccess::exists(path)) { item->set_text(2, "Warning: File exists"); item->set_tooltip(2, TTR("Existing file with the same name will be replaced on import.")); - item->set_icon(2, get_theme_icon("StatusWarning", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); } else { item->set_text(2, "Will save to new File"); - item->set_icon(2, get_theme_icon("StatusSuccess", "EditorIcons")); + item->set_icon(2, get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons"))); } - item->add_button(1, get_theme_icon("Folder", "EditorIcons")); + item->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } save_path_items.push_back(item); diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index f8e93df382..0d14347225 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -79,11 +79,11 @@ void EditorSceneImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const List<Variant> lods; p_lods.get_key_list(&lods); - for (List<Variant>::Element *E = lods.front(); E; E = E->next()) { - ERR_CONTINUE(!E->get().is_num()); + for (const Variant &E : lods) { + ERR_CONTINUE(!E.is_num()); Surface::LOD lod; - lod.distance = E->get(); - lod.indices = p_lods[E->get()]; + lod.distance = E; + lod.indices = p_lods[E]; ERR_CONTINUE(lod.indices.size() == 0); s.lods.push_back(lod); } diff --git a/editor/import_defaults_editor.cpp b/editor/import_defaults_editor.cpp index 43b97eb910..25bca1d4f4 100644 --- a/editor/import_defaults_editor.cpp +++ b/editor/import_defaults_editor.cpp @@ -61,9 +61,9 @@ protected: if (importer.is_null()) { return; } - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (importer->get_option_visibility(E->get().name, values)) { - p_list->push_back(E->get()); + for (const PropertyInfo &E : properties) { + if (importer->get_option_visibility(E.name, values)) { + p_list->push_back(E); } } } @@ -98,7 +98,7 @@ void ImportDefaultsEditor::_save() { ProjectSettings::get_singleton()->set("importer_defaults/" + settings->importer->get_importer_name(), Variant()); } - emit_signal("project_settings_changed"); + emit_signal(SNAME("project_settings_changed")); } } @@ -106,9 +106,9 @@ void ImportDefaultsEditor::_update_importer() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Ref<ResourceImporter> importer; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - if (E->get()->get_visible_name() == importers->get_item_text(importers->get_selected())) { - importer = E->get(); + for (const Ref<ResourceImporter> &E : importer_list) { + if (E->get_visible_name() == importers->get_item_text(importers->get_selected())) { + importer = E; break; } } @@ -125,14 +125,14 @@ void ImportDefaultsEditor::_update_importer() { d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name()); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - settings->properties.push_back(E->get().option); - if (d.has(E->get().option.name)) { - settings->values[E->get().option.name] = d[E->get().option.name]; + for (const ResourceImporter::ImportOption &E : options) { + settings->properties.push_back(E.option); + if (d.has(E.option.name)) { + settings->values[E.option.name] = d[E.option.name]; } else { - settings->values[E->get().option.name] = E->get().default_value; + settings->values[E.option.name] = E.default_value; } - settings->default_values[E->get().option.name] = E->get().default_value; + settings->default_values[E.option.name] = E.default_value; } save_defaults->set_disabled(false); @@ -166,8 +166,8 @@ void ImportDefaultsEditor::clear() { List<Ref<ResourceImporter>> importer_list; ResourceFormatImporter::get_singleton()->get_importers(&importer_list); Vector<String> names; - for (List<Ref<ResourceImporter>>::Element *E = importer_list.front(); E; E = E->next()) { - String vn = E->get()->get_visible_name(); + for (const Ref<ResourceImporter> &E : importer_list) { + String vn = E->get_visible_name(); names.push_back(vn); } names.sort(); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 6fa9864830..648e60a554 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -65,14 +65,14 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!importer->get_option_visibility(E->get().name, values)) { + for (const PropertyInfo &E : properties) { + if (!importer->get_option_visibility(E.name, values)) { continue; } - PropertyInfo pi = E->get(); + PropertyInfo pi = E; if (checking) { pi.usage |= PROPERTY_USAGE_CHECKABLE; - if (checked.has(E->get().name)) { + if (checked.has(E.name)) { pi.usage |= PROPERTY_USAGE_CHECKED; } } @@ -111,18 +111,18 @@ void ImportDock::set_edit_path(const String &p_path) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (const Ref<ResourceImporter> &E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == importer_name) { + for (const Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == importer_name) { import_as->select(import_as->get_item_count() - 1); } } @@ -153,12 +153,12 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { params->checking = params->paths.size() > 1; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); - if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) { - params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name); + for (const ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); + if (p_config.is_valid() && p_config->has_section_key("params", E.option.name)) { + params->values[E.option.name] = p_config->get_value("params", E.option.name); } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -201,17 +201,17 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { List<String> keys; config->get_section_keys("params", &keys); - for (List<String>::Element *E = keys.front(); E; E = E->next()) { - if (!value_frequency.has(E->get())) { - value_frequency[E->get()] = Dictionary(); + for (const String &E : keys) { + if (!value_frequency.has(E)) { + value_frequency[E] = Dictionary(); } - Variant value = config->get_value("params", E->get()); + Variant value = config->get_value("params", E); - if (value_frequency[E->get()].has(value)) { - value_frequency[E->get()][value] = int(value_frequency[E->get()][value]) + 1; + if (value_frequency[E].has(value)) { + value_frequency[E][value] = int(value_frequency[E][value]) + 1; } else { - value_frequency[E->get()][value] = 1; + value_frequency[E][value] = 1; } } } @@ -226,25 +226,25 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { params->checking = true; params->checked.clear(); - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); + for (const ResourceImporter::ImportOption &E : options) { + params->properties.push_back(E.option); - if (value_frequency.has(E->get().option.name)) { - Dictionary d = value_frequency[E->get().option.name]; + if (value_frequency.has(E.option.name)) { + Dictionary d = value_frequency[E.option.name]; int freq = 0; List<Variant> v; d.get_key_list(&v); Variant value; - for (List<Variant>::Element *F = v.front(); F; F = F->next()) { - int f = d[F->get()]; + for (const Variant &F : v) { + int f = d[F]; if (f > freq) { - value = F->get(); + value = F; } } - params->values[E->get().option.name] = value; + params->values[E.option.name] = value; } else { - params->values[E->get().option.name] = E->get().default_value; + params->values[E.option.name] = E.default_value; } } @@ -254,18 +254,18 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(), &importers); List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { - importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); + for (const Ref<ResourceImporter> &E : importers) { + importer_names.push_back(Pair<String, String>(E->get_visible_name(), E->get_importer_name())); } importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { - import_as->add_item(E->get().first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); - if (E->get().second == params->importer->get_importer_name()) { + for (const Pair<String, String> &E : importer_names) { + import_as->add_item(E.first); + import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + if (E.second == params->importer->get_importer_name()) { import_as->select(import_as->get_item_count() - 1); } } @@ -345,8 +345,8 @@ void ImportDock::_preset_selected(int p_idx) { case ITEM_SET_AS_DEFAULT: { Dictionary d; - for (const List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - d[E->get().name] = params->values[E->get().name]; + for (const PropertyInfo &E : params->properties) { + d[E.name] = params->values[E.name]; } ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), d); @@ -363,10 +363,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<Variant>::Element *E = v.front(); E; E = E->next()) { - params->values[E->get()] = d[E->get()]; + for (const Variant &E : v) { + params->values[E] = d[E]; if (params->checking) { - params->checked.insert(E->get()); + params->checked.insert(E); } } params->update(); @@ -384,10 +384,10 @@ void ImportDock::_preset_selected(int p_idx) { if (params->checking) { params->checked.clear(); } - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->values[E->get().option.name] = E->get().default_value; + for (const ResourceImporter::ImportOption &E : options) { + params->values[E.option.name] = E.default_value; if (params->checking) { - params->checked.insert(E->get().option.name); + params->checked.insert(E.option.name); } } params->update(); @@ -486,9 +486,9 @@ void ImportDock::_reimport() { if (params->checking && config->get_value("remap", "importer") == params->importer->get_importer_name()) { //update only what is edited (checkboxes) if the importer is the same - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - if (params->checked.has(E->get().name)) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (const PropertyInfo &E : params->properties) { + if (params->checked.has(E.name)) { + config->set_value("params", E.name, params->values[E.name]); } } } else { @@ -498,8 +498,8 @@ void ImportDock::_reimport() { config->erase_section("params"); } - for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { - config->set_value("params", E->get().name, params->values[E->get().name]); + for (const PropertyInfo &E : params->properties) { + config->set_value("params", E.name, params->values[E.name]); } } @@ -526,18 +526,18 @@ void ImportDock::_reimport() { } EditorFileSystem::get_singleton()->reimport_files(params->paths); - EditorFileSystem::get_singleton()->emit_signal("filesystem_changed"); //it changed, so force emitting the signal + EditorFileSystem::get_singleton()->emit_signal(SNAME("filesystem_changed")); //it changed, so force emitting the signal } void ImportDock::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); } break; case NOTIFICATION_ENTER_TREE: { import_opts->edit(params); - label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + label_warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; } } @@ -563,7 +563,7 @@ void ImportDock::initialize_import_options() const { ImportDock::ImportDock() { set_name("Import"); imported = memnew(Label); - imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); imported->set_clip_text(true); add_child(imported); HBoxContainer *hb = memnew(HBoxContainer); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index e8c01d0e0c..1973494a2a 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -63,7 +63,7 @@ void InspectorDock::_menu_option(int p_option) { case OBJECT_REQUEST_HELP: { if (current) { editor->set_visible_editor(EditorNode::EDITOR_SCRIPT); - emit_signal("request_help", current->get_class()); + emit_signal(SNAME("request_help"), current->get_class()); } } break; @@ -87,12 +87,12 @@ void InspectorDock::_menu_option(int p_option) { List<PropertyInfo> props; current->get_property_list(&props); Map<RES, RES> duplicates; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = current->get(E->get().name); + Variant v = current->get(E.name); if (v.is_ref()) { REF ref = v; if (ref.is_valid()) { @@ -103,8 +103,8 @@ void InspectorDock::_menu_option(int p_option) { } res = duplicates[res]; - current->set(E->get().name, res); - editor->get_inspector()->update_property(E->get().name); + current->set(E.name, res); + editor->get_inspector()->update_property(E.name); } } } @@ -216,7 +216,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture2D> base_icon = get_theme_icon("Object", "EditorIcons"); + Ref<Texture2D> base_icon = get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); Set<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { ObjectID id = editor_history->get_history_obj(i); @@ -337,27 +337,27 @@ void InspectorDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { set_theme(editor->get_gui_base()->get_theme()); - resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); - resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); - resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); - resource_extra_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); + resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon("ActionPaste", "EditorIcons")); - resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_theme_icon("ActionCopy", "EditorIcons")); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - backward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); - forward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + forward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); - forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + forward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } - history_menu->set_icon(get_theme_icon("History", "EditorIcons")); - object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); - warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + history_menu->set_icon(get_theme_icon(SNAME("History"), SNAME("EditorIcons"))); + object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; } } @@ -433,8 +433,8 @@ void InspectorDock::update(Object *p_object) { PopupMenu *p = object_menu->get_popup(); p->clear(); - p->add_icon_shortcut(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); - p->add_icon_shortcut(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); + p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/expand_all", TTR("Expand All")), EXPAND_ALL); + p->add_icon_shortcut(get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse All")), COLLAPSE_ALL); p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Properties")), OBJECT_COPY_PARAMS); @@ -499,7 +499,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_new_button = memnew(Button); resource_new_button->set_flat(true); resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it.")); - resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); + resource_new_button->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_new_button); resource_new_button->connect("pressed", callable_mp(this, &InspectorDock::_new_resource)); resource_new_button->set_focus_mode(Control::FOCUS_NONE); @@ -507,14 +507,14 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_load_button = memnew(Button); resource_load_button->set_flat(true); resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it.")); - resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); + resource_load_button->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_load_button); resource_load_button->connect("pressed", callable_mp(this, &InspectorDock::_open_resource_selector)); resource_load_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button = memnew(MenuButton); resource_save_button->set_tooltip(TTR("Save the currently edited resource.")); - resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); + resource_save_button->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); general_options_hb->add_child(resource_save_button); resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE); resource_save_button->get_popup()->add_item(TTR("Save As..."), RESOURCE_SAVE_AS); @@ -523,10 +523,11 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_save_button->set_disabled(true); resource_extra_button = memnew(MenuButton); - resource_extra_button->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + resource_extra_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + resource_extra_button->set_tooltip(TTR("Extra resource options.")); general_options_hb->add_child(resource_extra_button); - resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon("ActionPaste", "EditorIcons"), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD); - resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); + resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource from Clipboard")), RESOURCE_EDIT_CLIPBOARD); + resource_extra_button->get_popup()->add_icon_shortcut(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")), ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); resource_extra_button->get_popup()->set_item_disabled(1, true); resource_extra_button->get_popup()->add_separator(); resource_extra_button->get_popup()->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Resource Built-In")), RESOURCE_MAKE_BUILT_IN); @@ -539,9 +540,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { backward_button->set_flat(true); general_options_hb->add_child(backward_button); if (is_layout_rtl()) { - backward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + backward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } backward_button->set_tooltip(TTR("Go to the previous edited object in history.")); backward_button->set_disabled(true); @@ -551,9 +552,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { forward_button->set_flat(true); general_options_hb->add_child(forward_button); if (is_layout_rtl()) { - forward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + forward_button->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } else { - forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + forward_button->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } forward_button->set_tooltip(TTR("Go to the next edited object in history.")); forward_button->set_disabled(true); @@ -561,7 +562,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { history_menu = memnew(MenuButton); history_menu->set_tooltip(TTR("History of recently edited objects.")); - history_menu->set_icon(get_theme_icon("History", "EditorIcons")); + history_menu->set_icon(get_theme_icon(SNAME("History"), SNAME("EditorIcons"))); general_options_hb->add_child(history_menu); history_menu->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_history)); history_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_select_history)); @@ -576,7 +577,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { open_docs_button->set_flat(true); open_docs_button->set_visible(false); open_docs_button->set_tooltip(TTR("Open documentation for this object.")); - open_docs_button->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); + open_docs_button->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); open_docs_button->set_shortcut(ED_SHORTCUT("property_editor/open_help", TTR("Open Documentation"))); subresource_hb->add_child(open_docs_button); open_docs_button->connect("pressed", callable_mp(this, &InspectorDock::_menu_option), varray(OBJECT_REQUEST_HELP)); @@ -592,13 +593,13 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { search = memnew(LineEdit); search->set_h_size_flags(Control::SIZE_EXPAND_FILL); search->set_placeholder(TTR("Filter properties")); - search->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search->set_clear_button_enabled(true); property_tools_hb->add_child(search); object_menu = memnew(MenuButton); object_menu->set_shortcut_context(this); - object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); + object_menu->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); property_tools_hb->add_child(object_menu); object_menu->set_tooltip(TTR("Manage object properties.")); object_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option)); @@ -606,8 +607,8 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { warning = memnew(Button); add_child(warning); warning->set_text(TTR("Changes may be lost!")); - warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); - warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + warning->set_icon(get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"))); + warning->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warning->set_clip_text(true); warning->hide(); warning->connect("pressed", callable_mp(this, &InspectorDock::_warning_pressed)); diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 977ca83671..b32ea67d4d 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -43,15 +43,15 @@ void LocalizationEditor::_notification(int p_what) { List<String> tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); - for (List<String>::Element *E = tfn.front(); E; E = E->next()) { - translation_file_open->add_filter("*." + E->get()); + for (const String &E : tfn) { + translation_file_open->add_filter("*." + E); } List<String> rfn; ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); - for (List<String>::Element *E = rfn.front(); E; E = E->next()) { - translation_res_file_open_dialog->add_filter("*." + E->get()); - translation_res_option_file_open_dialog->add_filter("*." + E->get()); + for (const String &E : rfn) { + translation_res_file_open_dialog->add_filter("*." + E); + translation_res_option_file_open_dialog->add_filter("*." + E); } _update_pot_file_extensions(); @@ -176,7 +176,7 @@ void LocalizationEditor::_translation_res_select() { return; } - call_deferred("update_translations"); + call_deferred(SNAME("update_translations")); } void LocalizationEditor::_translation_res_option_changed() { @@ -430,8 +430,8 @@ void LocalizationEditor::_update_pot_file_extensions() { pot_file_open_dialog->clear_filters(); List<String> translation_parse_file_extensions; EditorTranslationParser::get_singleton()->get_recognized_extensions(&translation_parse_file_extensions); - for (List<String>::Element *E = translation_parse_file_extensions.front(); E; E = E->next()) { - pot_file_open_dialog->add_filter("*." + E->get()); + for (const String &E : translation_parse_file_extensions) { + pot_file_open_dialog->add_filter("*." + E); } } @@ -453,7 +453,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } } @@ -560,8 +560,8 @@ void LocalizationEditor::update_translations() { List<Variant> rk; remaps.get_key_list(&rk); Vector<String> keys; - for (List<Variant>::Element *E = rk.front(); E; E = E->next()) { - keys.push_back(E->get()); + for (const Variant &E : rk) { + keys.push_back(E); } keys.sort(); @@ -571,7 +571,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -588,7 +588,7 @@ void LocalizationEditor::update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -621,7 +621,7 @@ void LocalizationEditor::update_translations() { t->set_text(0, pot_translations[i].replace_first("res://", "")); t->set_tooltip(0, pot_translations[i]); t->set_metadata(0, i); - t->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), 0, false, TTR("Remove")); } } diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index b714109af7..fd4a4334fc 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -52,12 +52,12 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS); - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -98,12 +98,12 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { name = "script"; } - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - const Node *n = es->get_node(E->get()); + const Node *n = es->get_node(E); if (!n) { continue; } @@ -130,12 +130,12 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PLData *> data_list; - for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) { + for (const NodePath &E : nodes) { + if (!es->has_node(E)) { continue; } - Node *n = es->get_node(E->get()); + Node *n = es->get_node(E); if (!n) { continue; } @@ -143,30 +143,30 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PropertyInfo> plist; n->get_property_list(&plist, true); - for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) { - if (F->get().name == "script") { + for (const PropertyInfo &F : plist) { + if (F.name == "script") { continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) } - if (!usage.has(F->get().name)) { + if (!usage.has(F.name)) { PLData pld; pld.uses = 0; - pld.info = F->get(); - usage[F->get().name] = pld; - data_list.push_back(usage.getptr(F->get().name)); + pld.info = F; + usage[F.name] = pld; + data_list.push_back(usage.getptr(F.name)); } // Make sure only properties with the same exact PropertyInfo data will appear - if (usage[F->get().name].info == F->get()) { - usage[F->get().name].uses++; + if (usage[F.name].info == F) { + usage[F.name].uses++; } } nc++; } - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (nc == E->get()->uses) { - p_list->push_back(E->get()->info); + for (const PLData *E : data_list) { + if (nc == E->uses) { + p_list->push_back(E->info); } } diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 95a2d81e00..532413897b 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -52,8 +52,8 @@ void NodeDock::_bind_methods() { void NodeDock::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - connections_button->set_icon(get_theme_icon("Signals", "EditorIcons")); - groups_button->set_icon(get_theme_icon("Groups", "EditorIcons")); + connections_button->set_icon(get_theme_icon(SNAME("Signals"), SNAME("EditorIcons"))); + groups_button->set_icon(get_theme_icon(SNAME("Groups"), SNAME("EditorIcons"))); } } diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index e2938c8156..5fe466140b 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -113,7 +113,7 @@ void PluginConfigDialog::_on_confirmed() { } #endif - emit_signal("plugin_ready", script.operator->(), active_edit->is_pressed() ? _to_absolute_plugin_path(subfolder_edit->get_text()) : ""); + emit_signal(SNAME("plugin_ready"), script.operator->(), active_edit->is_pressed() ? _to_absolute_plugin_path(subfolder_edit->get_text()) : ""); } else { EditorNode::get_singleton()->get_project_settings()->update_plugins(); } @@ -128,8 +128,8 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { int lang_idx = script_option_edit->get_selected(); String ext = ScriptServer::get_language(lang_idx)->get_extension(); - Ref<Texture2D> valid_icon = get_theme_icon("StatusSuccess", "EditorIcons"); - Ref<Texture2D> invalid_icon = get_theme_icon("StatusWarning", "EditorIcons"); + Ref<Texture2D> valid_icon = get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); + Ref<Texture2D> invalid_icon = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); // Set variables to assume all is valid bool is_valid = true; @@ -150,7 +150,7 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { if (script_edit->get_text().get_extension() != ext) { is_valid = false; script_validation->set_texture(invalid_icon); - script_validation->set_tooltip(vformat(TTR("Script extension must match chosen langauge extension (.%s)."), ext)); + script_validation->set_tooltip(vformat(TTR("Script extension must match chosen language extension (.%s)."), ext)); } if (script_edit->get_text().get_basename().is_empty()) { is_valid = false; diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index e6f7ec1fbf..df01ecd1be 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -150,9 +150,9 @@ void AbstractPolygon2DEditor::_notification(int p_what) { case NOTIFICATION_READY: { disable_polygon_editing(false, String()); - button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); - button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); - button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); + button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); + button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &AbstractPolygon2DEditor::_node_removed)); @@ -477,7 +477,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); // All polygon points are sharp, so use the sharp handle icon - const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -550,8 +550,8 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl p_overlay->draw_texture(handle, point - handle->get_size() * 0.5, modulate); if (vertex == hover_point) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); String num = String::num(vertex.vertex); Size2 num_size = font->get_string_size(num, font_size); p_overlay->draw_string(font, point - num_size * 0.5, num, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5)); @@ -560,7 +560,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } if (edge_point.valid()) { - Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index b6dd9474d3..ad2d9866fa 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -72,22 +72,22 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -196,19 +196,19 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); + Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } @@ -279,7 +279,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { color = linecolor; color.a *= 0.5; @@ -373,8 +373,8 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -529,15 +529,15 @@ void AnimationNodeBlendSpace1DEditor::_open_editor() { void AnimationNodeBlendSpace1DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 359df95bce..49fcac512b 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -96,21 +96,21 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -295,8 +295,8 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -392,18 +392,18 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { } void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); - Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Ref<Texture2D> icon = get_theme_icon(SNAME("KeyValue"), SNAME("EditorIcons")); + Ref<Texture2D> icon_selected = get_theme_icon(SNAME("KeySelected"), SNAME("EditorIcons")); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_theme_color("accent_color", "Editor"); + Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } blend_space_draw->draw_line(Point2(1, 0), Point2(1, s.height - 1), linecolor); @@ -483,7 +483,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color color; if (i == selected_triangle) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); color.a *= 0.5; } else { color = linecolor; @@ -543,7 +543,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_theme_color("accent_color", "Editor"); + color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); } else { color = linecolor; color.a *= 0.5; @@ -733,21 +733,21 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - tool_blend->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("EditKey", "EditorIcons")); - tool_triangle->set_icon(get_theme_icon("ToolTriangle", "EditorIcons")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - snap->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); - auto_triangles->set_icon(get_theme_icon("AutoTriangle", "EditorIcons")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + tool_blend->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("EditKey"), SNAME("EditorIcons"))); + tool_triangle->set_icon(get_theme_icon(SNAME("ToolTriangle"), SNAME("EditorIcons"))); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + snap->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + open_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + auto_triangles->set_icon(get_theme_icon(SNAME("AutoTriangle"), SNAME("EditorIcons"))); interpolation->clear(); - interpolation->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), "", 0); - interpolation->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), "", 1); - interpolation->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), "", 2); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackContinuous"), SNAME("EditorIcons")), "", 0); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), "", 1); + interpolation->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), "", 2); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index dcde89f177..c94014944c 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -121,46 +121,46 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> nodes; blend_tree->get_node_list(&nodes); - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { + for (const StringName &E : nodes) { GraphNode *node = memnew(GraphNode); graph->add_child(node); - Ref<AnimationNode> agnode = blend_tree->get_node(E->get()); + Ref<AnimationNode> agnode = blend_tree->get_node(E); - node->set_position_offset(blend_tree->get_node_position(E->get()) * EDSCALE); + node->set_position_offset(blend_tree->get_node_position(E) * EDSCALE); node->set_title(agnode->get_caption()); - node->set_name(E->get()); + node->set_name(E); int base = 0; - if (String(E->get()) != "output") { + if (String(E) != "output") { LineEdit *name = memnew(LineEdit); - name->set_text(E->get()); + name->set_text(E); name->set_expand_to_text_length_enabled(true); node->add_child(name); - node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label")); + node->set_slot(0, false, 0, Color(), true, 0, get_theme_color(SNAME("font_color"), SNAME("Label"))); name->connect("text_submitted", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode), CONNECT_DEFERRED); name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out), varray(name, agnode), CONNECT_DEFERRED); base = 1; node->set_show_close_button(true); - node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E->get()), CONNECT_DEFERRED); + node->connect("close_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_request), varray(E), CONNECT_DEFERRED); } for (int i = 0; i < agnode->get_input_count(); i++) { Label *in_name = memnew(Label); node->add_child(in_name); in_name->set_text(agnode->get_input_name(i)); - node->set_slot(base + i, true, 0, get_theme_color("font_color", "Label"), false, 0, Color()); + node->set_slot(base + i, true, 0, get_theme_color(SNAME("font_color"), SNAME("Label")), false, 0, Color()); } List<PropertyInfo> pinfo; agnode->get_parameter_list(&pinfo); - for (List<PropertyInfo>::Element *F = pinfo.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &F : pinfo) { + if (!(F.usage & PROPERTY_USAGE_EDITOR)) { continue; } - String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->get()) + "/" + F->get().name; - EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F->get().type, base_path, F->get().hint, F->get().hint_string, F->get().usage); + String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name; + EditorProperty *prop = EditorInspector::instantiate_property_editor(AnimationTreeEditor::get_singleton()->get_tree(), F.type, base_path, F.hint, F.hint_string, F.usage); if (prop) { prop->set_object_and_property(AnimationTreeEditor::get_singleton()->get_tree(), base_path); prop->update_property(); @@ -171,15 +171,15 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } } - node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E->get())); + node->connect("dragged", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_dragged), varray(E)); if (AnimationTreeEditor::get_singleton()->can_edit(agnode)) { node->add_child(memnew(HSeparator)); Button *open_in_editor = memnew(Button); open_in_editor->set_text(TTR("Open Editor")); - open_in_editor->set_icon(get_theme_icon("Edit", "EditorIcons")); + open_in_editor->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); node->add_child(open_in_editor); - open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E->get()), CONNECT_DEFERRED); + open_in_editor->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_open_in_editor), varray(E), CONNECT_DEFERRED); open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -187,9 +187,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { node->add_child(memnew(HSeparator)); Button *edit_filters = memnew(Button); edit_filters->set_text(TTR("Edit Filters")); - edit_filters->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); + edit_filters->set_icon(get_theme_icon(SNAME("AnimationFilter"), SNAME("EditorIcons"))); node->add_child(edit_filters); - edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED); + edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E), CONNECT_DEFERRED); edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER); } @@ -197,7 +197,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { if (anim.is_valid()) { MenuButton *mb = memnew(MenuButton); mb->set_text(anim->get_animation()); - mb->set_icon(get_theme_icon("Animation", "EditorIcons")); + mb->set_icon(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons"))); Array options; node->add_child(memnew(HSeparator)); @@ -212,9 +212,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<StringName> anims; ap->get_animation_list(&anims); - for (List<StringName>::Element *F = anims.front(); F; F = F->next()) { - mb->get_popup()->add_item(F->get()); - options.push_back(F->get()); + for (const StringName &F : anims) { + mb->get_popup()->add_item(F); + options.push_back(F); } if (ap->has_animation(anim->get_animation())) { @@ -225,13 +225,13 @@ void AnimationNodeBlendTreeEditor::_update_graph() { pb->set_percent_visible(false); pb->set_custom_minimum_size(Vector2(0, 14) * EDSCALE); - animations[E->get()] = pb; + animations[E] = pb; node->add_child(pb); - mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E->get()), CONNECT_DEFERRED); + mb->get_popup()->connect("index_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_anim_selected), varray(options, E), CONNECT_DEFERRED); } - Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + Ref<StyleBoxFlat> sb = node->get_theme_stylebox(SNAME("frame"), SNAME("GraphNode")); Color c = sb->get_border_color(); Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0); mono_color.a = 0.85; @@ -246,10 +246,10 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } @@ -274,8 +274,8 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -394,9 +394,9 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().output_node == p_which || E->get().input_node == p_which) { - undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E->get().input_node, E->get().input_index, E->get().output_node); + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { + if (E.output_node == p_which || E.input_node == p_which) { + undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", E.input_node, E.input_index, E.output_node); } } @@ -423,8 +423,8 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { undo_redo->create_action(TTR("Delete Node(s)")); - for (List<StringName>::Element *F = to_erase.front(); F; F = F->next()) { - _delete_request(F->get()); + for (const StringName &F : to_erase) { + _delete_request(F); } undo_redo->commit_action(); @@ -517,8 +517,8 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (const StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); paths.insert(track_path); @@ -617,7 +617,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_text(0, F->get()); ti->set_selectable(0, false); ti->set_editable(0, false); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); } else { ti = parenthood[accum]; } @@ -628,7 +628,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); ti->set_text(0, concat); ti->set_checked(0, anode->is_path_filtered(path)); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, path); } else { @@ -690,8 +690,8 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() { void AnimationNodeBlendTreeEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -718,13 +718,13 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { List<AnimationNodeBlendTree::NodeConnection> conns; blend_tree->get_node_connections(&conns); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) { + for (const AnimationNodeBlendTree::NodeConnection &E : conns) { float activity = 0; - StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) { - activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E->get().input_index); + activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E.input_index); } - graph->set_connection_activity(E->get().output_node, 0, E->get().input_node, E->get().input_index, activity); + graph->set_connection_activity(E.output_node, 0, E.input_node, E.input_index, activity); } AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); @@ -741,7 +741,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { Ref<Animation> anim = player->get_animation(an->get_animation()); if (anim.is_valid()) { E->get()->set_max(anim->get_length()); - //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node; + //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E.input_node; StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->key()) + "/time"; E->get()->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path)); } @@ -828,10 +828,10 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima List<AnimationNodeBlendTree::NodeConnection> connections; blend_tree->get_node_connections(&connections); - for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; - StringName to = E->get().input_node; - int to_idx = E->get().input_index; + for (const AnimationNodeBlendTree::NodeConnection &E : connections) { + StringName from = E.output_node; + StringName to = E.input_node; + int to_idx = E.input_index; graph->connect_node(from, 0, to, to_idx); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 2b92943f7e..4ba9147955 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -99,23 +99,23 @@ void AnimationPlayerEditor::_notification(int p_what) { get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed)); - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); } break; case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); + autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); - play->set_icon(get_theme_icon("PlayStart", "EditorIcons")); - play_from->set_icon(get_theme_icon("Play", "EditorIcons")); - play_bw->set_icon(get_theme_icon("PlayStartBackwards", "EditorIcons")); - play_bw_from->set_icon(get_theme_icon("PlayBackwards", "EditorIcons")); + play->set_icon(get_theme_icon(SNAME("PlayStart"), SNAME("EditorIcons"))); + play_from->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); + play_bw->set_icon(get_theme_icon(SNAME("PlayStartBackwards"), SNAME("EditorIcons"))); + play_bw_from->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); - autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons"); - reset_icon = get_theme_icon("Reload", "EditorIcons"); + autoplay_icon = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); + reset_icon = get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")); { Ref<Image> autoplay_img = autoplay_icon->get_image(); Ref<Image> reset_img = reset_icon->get_image(); @@ -128,17 +128,17 @@ void AnimationPlayerEditor::_notification(int p_what) { autoplay_reset_icon.instantiate(); autoplay_reset_icon->create_from_image(autoplay_reset_img); } - stop->set_icon(get_theme_icon("Stop", "EditorIcons")); + stop->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); - onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons")); - onion_skinning->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + onion_toggle->set_icon(get_theme_icon(SNAME("Onion"), SNAME("EditorIcons"))); + onion_skinning->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - pin->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); - tool_anim->add_theme_style_override("normal", get_theme_stylebox("normal", "Button")); - track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox("normal", "Button")); + tool_anim->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); + track_editor->get_edit_menu()->add_theme_style_override("normal", get_theme_stylebox(SNAME("normal"), SNAME("Button"))); -#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(m_icon, "EditorIcons")) +#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(SNAME(m_icon), SNAME("EditorIcons"))) ITEM_ICON(TOOL_NEW_ANIM, "New"); ITEM_ICON(TOOL_LOAD_ANIM, "Load"); @@ -350,8 +350,8 @@ void AnimationPlayerEditor::_animation_load() { List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -373,7 +373,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou } ((Resource *)p_resource.ptr())->set_path(path); - editor->emit_signal("resource_saved", p_resource); + editor->emit_signal(SNAME("resource_saved"), p_resource); } void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) { @@ -584,8 +584,7 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->clear(); blend_editor.next->add_item("", i); - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String to = E->get(); + for (const StringName &to : anims) { TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); blend->set_editable(1, true); @@ -830,20 +829,20 @@ void AnimationPlayerEditor::_update_player() { } int active_idx = -1; - for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) { + for (const StringName &E : animlist) { Ref<Texture2D> icon; - if (E->get() == player->get_autoplay()) { - if (E->get() == "RESET") { + if (E == player->get_autoplay()) { + if (E == "RESET") { icon = autoplay_reset_icon; } else { icon = autoplay_icon; } - } else if (E->get() == "RESET") { + } else if (E == "RESET") { icon = reset_icon; } - animation->add_icon_item(icon, E->get()); + animation->add_icon_item(icon, E); - if (player->get_assigned_animation() == E->get()) { + if (player->get_assigned_animation() == E) { active_idx = animation->get_item_count() - 1; } } @@ -966,9 +965,9 @@ void AnimationPlayerEditor::_animation_duplicate() { Ref<Animation> new_anim = memnew(Animation); List<PropertyInfo> plist; anim->get_property_list(&plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - new_anim->set(E->get().name, anim->get(E->get().name)); + for (const PropertyInfo &E : plist) { + if (E.usage & PROPERTY_USAGE_STORAGE) { + new_anim->set(E.name, anim->get(E.name)); } } new_anim->set_path(""); @@ -1324,11 +1323,11 @@ void AnimationPlayerEditor::_prepare_onion_layers_1() { } // And go to next step afterwards. - call_deferred("_prepare_onion_layers_2"); + call_deferred(SNAME("_prepare_onion_layers_2")); } void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() { - call_deferred("_prepare_onion_layers_1"); + call_deferred(SNAME("_prepare_onion_layers_1")); } void AnimationPlayerEditor::_prepare_onion_layers_2() { @@ -1733,27 +1732,27 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); onion.capture.shader = Ref<Shader>(memnew(Shader)); - onion.capture.shader->set_code(" \ - shader_type canvas_item; \ - \ - uniform vec4 bkg_color; \ - uniform vec4 dir_color; \ - uniform bool differences_only; \ - uniform sampler2D present; \ - \ - float zero_if_equal(vec4 a, vec4 b) { \ - return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); \ - } \ - \ - void fragment() { \ - vec4 capture_samp = texture(TEXTURE, UV); \ - vec4 present_samp = texture(present, UV); \ - float bkg_mask = zero_if_equal(capture_samp, bkg_color); \ - float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); \ - diff_mask = min(1.0, diff_mask + float(!differences_only)); \ - COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \ - } \ - "); + onion.capture.shader->set_code(R"( +shader_type canvas_item; + +uniform vec4 bkg_color; +uniform vec4 dir_color; +uniform bool differences_only; +uniform sampler2D present; + +float zero_if_equal(vec4 a, vec4 b) { + return smoothstep(0.0, 0.005, length(a.rgb - b.rgb) / sqrt(3.0)); +} + +void fragment() { + vec4 capture_samp = texture(TEXTURE, UV); + vec4 present_samp = texture(present, UV); + float bkg_mask = zero_if_equal(capture_samp, bkg_color); + float diff_mask = 1.0 - zero_if_equal(present_samp, bkg_color); + diff_mask = min(1.0, diff_mask + float(!differences_only)); + COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); +} +)"); RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); } diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 94e526922d..a1f96f21bf 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -93,21 +93,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (ap) { List<StringName> names; ap->get_animation_list(&names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); - animations_to_add.push_back(E->get()); + for (const StringName &E : names) { + animations_menu->add_icon_item(get_theme_icon(SNAME("Animation"), SNAME("EditorIcons")), E); + animations_to_add.push_back(E); } } } - for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); + for (const StringName &E : classes) { + String name = String(E).replace_first("AnimationNode", ""); if (name == "Animation") { continue; // nope } int idx = menu->get_item_count(); menu->add_item(vformat("Add %s", name), idx); - menu->set_item_metadata(idx, E->get()); + menu->set_item_metadata(idx, E); } Ref<AnimationNode> clipb = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -145,7 +145,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv if (node_rects[i].name.has_point(mb->get_position())) { //edit name - Ref<StyleBox> line_sb = get_theme_stylebox("normal", "LineEdit"); + Ref<StyleBox> line_sb = get_theme_stylebox(SNAME("normal"), SNAME("LineEdit")); Rect2 edit_rect = node_rects[i].name; edit_rect.position -= line_sb->get_offset(); @@ -163,7 +163,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } if (node_rects[i].edit.has_point(mb->get_position())) { //edit name - call_deferred("_open_editor", node_rects[i].node_name); + call_deferred(SNAME("_open_editor"), node_rects[i].node_name); return; } @@ -318,24 +318,24 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv float best_d_x = 1e20; float best_d_y = 1e20; - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - if (E->get() == selected_node) { + for (const StringName &E : nodes) { + if (E == selected_node) { continue; } - Vector2 npos = state_machine->get_node_position(E->get()); + Vector2 npos = state_machine->get_node_position(E); float d_x = ABS(npos.x - cpos.x); if (d_x < MIN(5, best_d_x)) { drag_ofs.x -= cpos.x - npos.x; best_d_x = d_x; - snap_x = E->get(); + snap_x = E; } float d_y = ABS(npos.y - cpos.y); if (d_y < MIN(5, best_d_y)) { drag_ofs.y -= cpos.y - npos.y; best_d_y = d_y; - snap_y = E->get(); + snap_y = E; } } } @@ -409,8 +409,8 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); - for (List<String>::Element *E = filters.front(); E; E = E->next()) { - open_file->add_filter("*." + E->get()); + for (const String &E : filters) { + open_file->add_filter("*." + E); } open_file->popup_file_dialog(); return; @@ -487,9 +487,9 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { } void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) { - Color linecolor = get_theme_color("font_color", "Label"); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); Color icon_color(1, 1, 1); - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); if (!p_enabled) { linecolor.a *= 0.2; @@ -498,12 +498,12 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } Ref<Texture2D> icons[6] = { - get_theme_icon("TransitionImmediateBig", "EditorIcons"), - get_theme_icon("TransitionSyncBig", "EditorIcons"), - get_theme_icon("TransitionEndBig", "EditorIcons"), - get_theme_icon("TransitionImmediateAutoBig", "EditorIcons"), - get_theme_icon("TransitionSyncAutoBig", "EditorIcons"), - get_theme_icon("TransitionEndAutoBig", "EditorIcons") + get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionSyncBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionEndBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionImmediateAutoBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionSyncAutoBig"), SNAME("EditorIcons")), + get_theme_icon(SNAME("TransitionEndAutoBig"), SNAME("EditorIcons")) }; if (p_selected) { @@ -555,19 +555,19 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Ve void AnimationNodeStateMachineEditor::_state_machine_draw() { Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); - Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode"); - Ref<StyleBox> style_selected = get_theme_stylebox("state_machine_selectedframe", "GraphNode"); - - Ref<Font> font = get_theme_font("title_font", "GraphNode"); - int font_size = get_theme_font_size("title_font_size", "GraphNode"); - Color font_color = get_theme_color("title_color", "GraphNode"); - Ref<Texture2D> play = get_theme_icon("Play", "EditorIcons"); - Ref<Texture2D> auto_play = get_theme_icon("AutoPlay", "EditorIcons"); - Ref<Texture2D> edit = get_theme_icon("Edit", "EditorIcons"); - Color accent = get_theme_color("accent_color", "Editor"); - Color linecolor = get_theme_color("font_color", "Label"); + Ref<StyleBox> style = get_theme_stylebox(SNAME("state_machine_frame"), SNAME("GraphNode")); + Ref<StyleBox> style_selected = get_theme_stylebox(SNAME("state_machine_selectedframe"), SNAME("GraphNode")); + + Ref<Font> font = get_theme_font(SNAME("title_font"), SNAME("GraphNode")); + int font_size = get_theme_font_size(SNAME("title_font_size"), SNAME("GraphNode")); + Color font_color = get_theme_color(SNAME("title_color"), SNAME("GraphNode")); + Ref<Texture2D> play = get_theme_icon(SNAME("Play"), SNAME("EditorIcons")); + Ref<Texture2D> auto_play = get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons")); + Ref<Texture2D> edit = get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color linecolor = get_theme_color(SNAME("font_color"), SNAME("Label")); linecolor.a *= 0.3; - Ref<StyleBox> playing_overlay = get_theme_stylebox("position", "GraphNode"); + Ref<StyleBox> playing_overlay = get_theme_stylebox(SNAME("position"), SNAME("GraphNode")); bool playing = false; StringName current; @@ -606,11 +606,11 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } //pre pass nodes so we know the rectangles - for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - Ref<AnimationNode> anode = state_machine->get_node(E->get()); - String name = E->get(); + for (const StringName &E : nodes) { + Ref<AnimationNode> anode = state_machine->get_node(E); + String name = E; bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); - Ref<StyleBox> sb = E->get() == selected_node ? style_selected : style; + Ref<StyleBox> sb = E == selected_node ? style_selected : style; Size2 s = sb->get_minimum_size(); int strsize = font->get_string_size(name, font_size).width; @@ -622,8 +622,8 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } Vector2 offset; - offset += state_machine->get_node_position(E->get()) * EDSCALE; - if (selected_node == E->get() && dragging_selected) { + offset += state_machine->get_node_position(E) * EDSCALE; + if (selected_node == E && dragging_selected) { offset += drag_ofs; } offset -= s / 2; @@ -633,7 +633,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { NodeRect nr; nr.node = Rect2(offset, s); - nr.node_name = E->get(); + nr.node_name = E; scroll_range = scroll_range.merge(nr.node); //merge with range @@ -667,7 +667,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { _connection_draw(from, to, AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected()), true, false, false, false); } - Ref<Texture2D> tr_reference_icon = get_theme_icon("TransitionImmediateBig", "EditorIcons"); + Ref<Texture2D> tr_reference_icon = get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -857,7 +857,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { float pos = CLAMP(play_pos, 0, len); float c = pos / len; - Color fg = get_theme_color("font_color", "Label"); + Color fg = get_theme_color(SNAME("font_color"), SNAME("Label")); Color bg = fg; bg.a *= 0.3; @@ -882,26 +882,26 @@ void AnimationNodeStateMachineEditor::_update_graph() { void AnimationNodeStateMachineEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - tool_select->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_theme_icon("ToolAddNode", "EditorIcons")); - tool_connect->set_icon(get_theme_icon("ToolConnect", "EditorIcons")); + tool_select->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_create->set_icon(get_theme_icon(SNAME("ToolAddNode"), SNAME("EditorIcons"))); + tool_connect->set_icon(get_theme_icon(SNAME("ToolConnect"), SNAME("EditorIcons"))); transition_mode->clear(); - transition_mode->add_icon_item(get_theme_icon("TransitionImmediate", "EditorIcons"), TTR("Immediate")); - transition_mode->add_icon_item(get_theme_icon("TransitionSync", "EditorIcons"), TTR("Sync")); - transition_mode->add_icon_item(get_theme_icon("TransitionEnd", "EditorIcons"), TTR("At End")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionImmediate"), SNAME("EditorIcons")), TTR("Immediate")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionSync"), SNAME("EditorIcons")), TTR("Sync")); + transition_mode->add_icon_item(get_theme_icon(SNAME("TransitionEnd"), SNAME("EditorIcons")), TTR("At End")); - tool_erase->set_icon(get_theme_icon("Remove", "EditorIcons")); - tool_autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); - tool_end->set_icon(get_theme_icon("AutoEnd", "EditorIcons")); + tool_erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + tool_autoplay->set_icon(get_theme_icon(SNAME("AutoPlay"), SNAME("EditorIcons"))); + tool_end->set_icon(get_theme_icon(SNAME("AutoEnd"), SNAME("EditorIcons"))); play_mode->clear(); - play_mode->add_icon_item(get_theme_icon("PlayTravel", "EditorIcons"), TTR("Travel")); - play_mode->add_icon_item(get_theme_icon("Play", "EditorIcons"), TTR("Immediate")); + play_mode->add_icon_item(get_theme_icon(SNAME("PlayTravel"), SNAME("EditorIcons")), TTR("Travel")); + play_mode->add_icon_item(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")), TTR("Immediate")); } if (p_what == NOTIFICATION_PROCESS) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index e90665f84d..cd84be0c25 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -79,7 +79,7 @@ void AnimationTreeEditor::_update_path() { group.instantiate(); Button *b = memnew(Button); - b->set_text("Root"); + b->set_text(TTR("Root")); b->set_toggle_mode(true); b->set_button_group(group); b->set_pressed(true); @@ -215,8 +215,8 @@ Vector<String> AnimationTreeEditor::get_animation_list() { List<StringName> anims; ap->get_animation_list(&anims); Vector<String> ret; - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const StringName &E : anims) { + ret.push_back(E); } return ret; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 596b2a6527..785bab42cf 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -58,7 +58,7 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur void EditorAssetLibraryItem::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); + icon->set_normal_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); category->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); author->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); price->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); @@ -66,15 +66,15 @@ void EditorAssetLibraryItem::_notification(int p_what) { } void EditorAssetLibraryItem::_asset_clicked() { - emit_signal("asset_selected", asset_id); + emit_signal(SNAME("asset_selected"), asset_id); } void EditorAssetLibraryItem::_category_clicked() { - emit_signal("category_selected", category_id); + emit_signal(SNAME("category_selected"), category_id); } void EditorAssetLibraryItem::_author_clicked() { - emit_signal("author_selected", author_id); + emit_signal(SNAME("author_selected"), author_id); } void EditorAssetLibraryItem::_bind_methods() { @@ -144,7 +144,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { if (preview_images[i].is_video) { - Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_image(); + Ref<Image> overlay = previews->get_theme_icon(SNAME("PlayOverlay"), SNAME("EditorIcons"))->get_image(); Ref<Image> thumbnail = p_image->get_image(); thumbnail = thumbnail->duplicate(); Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); @@ -185,7 +185,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const void EditorAssetLibraryItemDescription::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox("normal", "TextEdit")); + previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox(SNAME("normal"), SNAME("TextEdit"))); } break; } } @@ -240,12 +240,12 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons preview.video_link = p_url; preview.is_video = p_video; preview.button = memnew(Button); - preview.button->set_icon(previews->get_theme_icon("ThumbnailWait", "EditorIcons")); + preview.button->set_icon(previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons"))); preview.button->set_toggle_mode(true); preview.button->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDescription::_preview_click), varray(p_id)); preview_hb->add_child(preview.button); if (!p_video) { - preview.image = previews->get_theme_icon("ThumbnailWait", "EditorIcons"); + preview.image = previews->get_theme_icon(SNAME("ThumbnailWait"), SNAME("EditorIcons")); } preview_images.push_back(preview); if (preview_images.size() == 1 && !p_video) { @@ -379,7 +379,7 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse icon->set_texture(p_preview); asset_id = p_asset_id; if (!p_preview.is_valid()) { - icon->set_texture(get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + icon->set_texture(get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } host = p_download_url; sha256 = p_sha256_hash; @@ -390,8 +390,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { switch (p_what) { // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used. case NOTIFICATION_ENTER_TREE: { - add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer")); - dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons")); + add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); } break; case NOTIFICATION_PROCESS: { // Make the progress bar visible again when retrying the download. @@ -455,7 +455,7 @@ void EditorAssetLibraryItemDownload::_install() { String file = download->get_download_file(); if (external_install) { - emit_signal("install_asset", file, title->get_text()); + emit_signal(SNAME("install_asset"), file, title->get_text()); return; } @@ -553,8 +553,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { void EditorAssetLibrary::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); error_label->raise(); @@ -588,10 +588,10 @@ void EditorAssetLibrary::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - downloads_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); - error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + downloads_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + error_tr->set_texture(get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; @@ -603,12 +603,11 @@ void EditorAssetLibrary::_notification(int p_what) { void EditorAssetLibrary::_update_repository_options() { Dictionary default_urls; - default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api"; - default_urls["localhost"] = "http://127.0.0.1/asset-library/api"; + default_urls["godotengine.org (Official)"] = "https://godotengine.org/asset-library/api"; Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true); repository->clear(); Array keys = available_urls.keys(); - for (int i = 0; i < available_urls.size(); i++) { + for (int i = 0; i < keys.size(); i++) { String key = keys[i]; repository->add_item(key); repository->set_item_metadata(i, available_urls[key]); @@ -773,7 +772,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB } if (!image_set && final) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } } } @@ -816,7 +815,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons WARN_PRINT("Error getting image file from URL: " + image_queue[p_queue_id].image_url); Object *obj = ObjectDB::get_instance(image_queue[p_queue_id].target); if (obj) { - obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon(SNAME("FileBrokenBigThumb"), SNAME("EditorIcons"))); } } @@ -1315,7 +1314,7 @@ void EditorAssetLibrary::_manage_plugins() { } void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) { - emit_signal("install_asset", p_zip_path, p_title); + emit_signal(SNAME("install_asset"), p_zip_path, p_title); } void EditorAssetLibrary::disable_community_support() { @@ -1490,7 +1489,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { error_hb = memnew(HBoxContainer); library_main->add_child(error_hb); error_label = memnew(Label); - error_label->add_theme_color_override("color", get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_hb->add_child(error_label); error_tr = memnew(TextureRect); error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER); diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 3b54b30b54..482c08f50a 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -43,10 +43,10 @@ void AudioStreamEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); - _stop_button->set_icon(get_theme_icon("Stop", "EditorIcons")); - _preview->set_color(get_theme_color("dark_color_2", "Editor")); - set_color(get_theme_color("dark_color_1", "Editor")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); + _stop_button->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons"))); + _preview->set_color(get_theme_color(SNAME("dark_color_2"), SNAME("Editor"))); + set_color(get_theme_color(SNAME("dark_color_1"), SNAME("Editor"))); _indicator->update(); _preview->update(); @@ -86,7 +86,7 @@ void AudioStreamEditor::_draw_preview() { } Vector<Color> color; - color.push_back(get_theme_color("contrast_color_2", "Editor")); + color.push_back(get_theme_color(SNAME("contrast_color_2"), SNAME("Editor"))); RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); } @@ -109,25 +109,25 @@ void AudioStreamEditor::_play() { // '_pausing' variable indicates that we want to pause the audio player, not stop it. See '_on_finished()'. _pausing = true; _player->stop(); - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); set_process(false); } else { _player->play(_current); - _play_button->set_icon(get_theme_icon("Pause", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); set_process(true); } } void AudioStreamEditor::_stop() { _player->stop(); - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); _current = 0; _indicator->update(); set_process(false); } void AudioStreamEditor::_on_finished() { - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); if (!_pausing) { _current = 0; _indicator->update(); @@ -145,11 +145,11 @@ void AudioStreamEditor::_draw_indicator() { Rect2 rect = _preview->get_rect(); float len = stream->get_length(); float ofs_x = _current / len * rect.size.width; - const Color color = get_theme_color("accent_color", "Editor"); + const Color color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), color, Math::round(2 * EDSCALE)); _indicator->draw_texture( - get_theme_icon("TimelineIndicator", "EditorIcons"), - Point2(ofs_x - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons")), + Point2(ofs_x - get_theme_icon(SNAME("TimelineIndicator"), SNAME("EditorIcons"))->get_width() * 0.5, 0), color); _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /"); @@ -243,14 +243,14 @@ AudioStreamEditor::AudioStreamEditor() { _current_label = memnew(Label); _current_label->set_align(Label::ALIGN_RIGHT); _current_label->set_h_size_flags(SIZE_EXPAND_FILL); - _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + _current_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); _current_label->set_modulate(Color(1, 1, 1, 0.5)); hbox->add_child(_current_label); _duration_label = memnew(Label); - _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); - _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("status_source_size", "EditorFonts")); + _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + _duration_label->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); hbox->add_child(_duration_label); } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4af499f10c..869a582d96 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -301,8 +301,8 @@ void CanvasItemEditor::_snap_other_nodes( // Check if the element is in the exception bool exception = false; - for (List<const CanvasItem *>::Element *E = p_exceptions.front(); E; E = E->next()) { - if (E->get() == p_current) { + for (const CanvasItem *&E : p_exceptions) { + if (E == p_current) { exception = true; break; } @@ -399,8 +399,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig if ((is_snap_active && snap_other_nodes && (p_modes & SNAP_OTHER_NODES)) || (p_forced_modes & SNAP_OTHER_NODES)) { Transform2D to_snap_transform = Transform2D(); List<const CanvasItem *> exceptions = List<const CanvasItem *>(); - for (List<CanvasItem *>::Element *E = p_other_nodes_exceptions.front(); E; E = E->next()) { - exceptions.push_back(E->get()); + for (const CanvasItem *E : p_other_nodes_exceptions) { + exceptions.push_back(E); } if (p_self_canvas_item) { exceptions.push_back(p_self_canvas_item); @@ -527,8 +527,7 @@ Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_li Rect2 rect = Rect2(canvas_item->get_global_transform_with_canvas().xform(canvas_item->_edit_get_rect().position + canvas_item->_edit_get_rect().size / 2), Size2()); // Expand with the other ones - for (List<CanvasItem *>::Element *E = p_list.front(); E; E = E->next()) { - CanvasItem *canvas_item2 = E->get(); + for (CanvasItem *canvas_item2 : p_list) { Transform2D xform = canvas_item2->get_global_transform_with_canvas(); Rect2 current_rect = canvas_item2->_edit_get_rect(); @@ -760,9 +759,9 @@ List<CanvasItem *> CanvasItemEditor::_get_edited_canvas_items(bool retreive_lock if (remove_canvas_item_if_parent_in_selection) { List<CanvasItem *> filtered_selection; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!selection.find(E->get()->get_parent())) { - filtered_selection.push_back(E->get()); + for (CanvasItem *E : selection) { + if (!selection.find(E->get_parent())) { + filtered_selection.push_back(E); } } return filtered_selection; @@ -800,8 +799,7 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2 } void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items, bool save_bones) { - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { se->undo_state = canvas_item->_edit_get_state(); @@ -816,8 +814,7 @@ void CanvasItemEditor::_save_canvas_item_state(List<CanvasItem *> p_canvas_items } void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones) { - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); canvas_item->_edit_set_state(se->undo_state); } @@ -825,8 +822,7 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { List<CanvasItem *> modified_canvas_items; - for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : p_canvas_items) { Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state; Dictionary new_state = canvas_item->_edit_get_state(); @@ -840,17 +836,16 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } undo_redo->create_action(action_name); - for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : modified_canvas_items) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); if (se) { undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); if (commit_bones) { - for (List<Dictionary>::Element *F = se->pre_drag_bones_undo_state.front(); F; F = F->next()) { + for (const Dictionary &F : se->pre_drag_bones_undo_state) { canvas_item = Object::cast_to<CanvasItem>(canvas_item->get_parent()); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); - undo_redo->add_undo_method(canvas_item, "_edit_set_state", F->get()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", F); } } } @@ -903,7 +898,7 @@ void CanvasItemEditor::_node_created(Node *p_node) { c->_edit_set_position(xform.xform(node_create_position)); } - call_deferred("_reset_create_position"); // Defer the call in case more than one node is added. + call_deferred(SNAME("_reset_create_position")); // Defer the call in case more than one node is added. } void CanvasItemEditor::_reset_create_position() { @@ -1197,7 +1192,17 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo Ref<InputEventKey> k = p_event; if (k.is_valid()) { if (k->is_pressed()) { - if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { + if (ED_GET_SHORTCUT("canvas_item_editor/zoom_3.125_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 32.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_6.25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 16.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_12.5_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 8.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_25_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 4.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_50_percent")->is_shortcut(p_event)) { + _update_zoom((1.0 / 2.0) * MAX(1, EDSCALE)); + } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_100_percent")->is_shortcut(p_event)) { _update_zoom(1.0 * MAX(1, EDSCALE)); } else if (ED_GET_SHORTCUT("canvas_item_editor/zoom_200_percent")->is_shortcut(p_event)) { _update_zoom(2.0 * MAX(1, EDSCALE)); @@ -1294,8 +1299,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { // Filters the selection with nodes that allow setting the pivot drag_selection = List<CanvasItem *>(); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { if (canvas_item->_edit_use_pivot()) { drag_selection.push_back(canvas_item); } @@ -1311,8 +1315,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, nullptr, drag_selection); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } @@ -1333,8 +1336,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { } else { new_pos = snap_point(drag_to, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL); } - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { canvas_item->_edit_set_pivot(canvas_item->get_global_transform_with_canvas().affine_inverse().xform(new_pos)); } return true; @@ -1377,8 +1379,8 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { List<CanvasItem *> selection = _get_edited_canvas_items(); // Remove not movable nodes - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - if (!_is_node_movable(E->get(), true)) { + for (CanvasItem *E : selection) { + if (!_is_node_movable(E, true)) { selection.erase(E); } } @@ -1404,8 +1406,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { // Rotate the node if (m.is_valid()) { _restore_canvas_item_state(drag_selection); - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { drag_to = transform.affine_inverse().xform(m->get_position()); //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); @@ -2036,8 +2037,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2152,8 +2152,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } int index = 0; - for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : drag_selection) { Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform(); canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos)); @@ -2365,8 +2364,8 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { if (selitems.size() == 1 && editor_selection->get_selected_node_list().is_empty()) { editor->push_item(selitems[0]); } - for (List<CanvasItem *>::Element *E = selitems.front(); E; E = E->next()) { - editor_selection->add_node(E->get()); + for (CanvasItem *E : selitems) { + editor_selection->add_node(E); } } @@ -2529,7 +2528,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { // Grab focus if (!viewport->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) { - viewport->call_deferred("grab_focus"); + viewport->call_deferred(SNAME("grab_focus")); } } @@ -2617,10 +2616,10 @@ void CanvasItemEditor::_update_cursor() { } void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) { - Color color = get_theme_color("font_color", "Editor"); + Color color = get_theme_color(SNAME("font_color"), SNAME("Editor")); color.a = 0.8; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Size2 text_size = font->get_string_size(p_string, font_size); switch (p_side) { case SIDE_LEFT: @@ -2656,7 +2655,7 @@ void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_posi void CanvasItemEditor::_draw_focus() { // Draw the focus around the base viewport if (viewport->has_focus()) { - get_theme_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); + get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); } } @@ -2688,21 +2687,21 @@ void CanvasItemEditor::_draw_guides() { } // Dragged guide - Color text_color = get_theme_color("font_color", "Editor"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); Color outline_color = text_color.inverted(); const float outline_size = 2; if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x))); - 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")); Size2 text_size = font->get_string_size(str, font_size); viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color, outline_size, outline_color); viewport->draw_line(Point2(dragged_guide_pos.x, 0), Point2(dragged_guide_pos.x, viewport->get_size().y), guide_color, Math::round(EDSCALE)); } if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_H_GUIDE) { String str = TS->format_number(vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y))); - 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")); Size2 text_size = font->get_string_size(str, font_size); viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, HALIGN_LEFT, -1, font_size, text_color, outline_size, outline_color); viewport->draw_line(Point2(0, dragged_guide_pos.y), Point2(viewport->get_size().x, dragged_guide_pos.y), guide_color, Math::round(EDSCALE)); @@ -2724,12 +2723,12 @@ void CanvasItemEditor::_draw_smart_snapping() { } void CanvasItemEditor::_draw_rulers() { - Color bg_color = get_theme_color("dark_color_2", "Editor"); - Color graduation_color = get_theme_color("font_color", "Editor").lerp(bg_color, 0.5); - Color font_color = get_theme_color("font_color", "Editor"); + Color bg_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); + Color graduation_color = get_theme_color(SNAME("font_color"), SNAME("Editor")).lerp(bg_color, 0.5); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); font_color.a = 0.8; - Ref<Font> font = get_theme_font("rulers", "EditorFonts"); - int font_size = get_theme_font_size("rulers_size", "EditorFonts"); + Ref<Font> font = get_theme_font(SNAME("rulers"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("rulers_size"), SNAME("EditorFonts")); // The rule transform Transform2D ruler_transform = Transform2D(); @@ -2890,7 +2889,7 @@ void CanvasItemEditor::_draw_ruler_tool() { } if (ruler_tool_active) { - Color ruler_primary_color = get_theme_color("accent_color", "Editor"); + Color ruler_primary_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Color ruler_secondary_color = ruler_primary_color; ruler_secondary_color.a = 0.5; @@ -2907,9 +2906,9 @@ void CanvasItemEditor::_draw_ruler_tool() { viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE)); } - Ref<Font> font = get_theme_font("bold", "EditorFonts"); - int font_size = get_theme_font_size("bold_size", "EditorFonts"); - Color font_color = get_theme_color("font_color", "Editor"); + Ref<Font> font = get_theme_font(SNAME("bold"), SNAME("EditorFonts")); + int font_size = get_theme_font_size(SNAME("bold_size"), SNAME("EditorFonts")); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); Color font_secondary_color = font_color; font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3); Color outline_color = font_color.inverted(); @@ -3010,8 +3009,8 @@ void CanvasItemEditor::_draw_ruler_tool() { } } else { if (grid_snap_active) { - Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons"); - viewport->draw_texture(get_theme_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + viewport->draw_texture(get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } } } @@ -3229,17 +3228,17 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture2D> pivot_icon = get_theme_icon("EditorPivot", "EditorIcons"); - Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons"); - Ref<Texture2D> previous_position_icon = get_theme_icon("EditorPositionPrevious", "EditorIcons"); + Ref<Texture2D> pivot_icon = get_theme_icon(SNAME("EditorPivot"), SNAME("EditorIcons")); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); + Ref<Texture2D> previous_position_icon = get_theme_icon(SNAME("EditorPositionPrevious"), SNAME("EditorIcons")); RID ci = viewport->get_canvas_item(); List<CanvasItem *> selection = _get_edited_canvas_items(true, false); bool single = selection.size() == 1; - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (CanvasItem *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); bool item_locked = canvas_item->has_meta("_edit_lock_"); @@ -3357,16 +3356,16 @@ void CanvasItemEditor::_draw_selection() { points.push_back(Vector2(move_factor.x * EDSCALE, -5 * EDSCALE)); points.push_back(Vector2((move_factor.x + 10) * EDSCALE, 0)); - viewport->draw_colored_polygon(points, get_theme_color("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE)); points.clear(); points.push_back(Vector2(5 * EDSCALE, move_factor.y * EDSCALE)); points.push_back(Vector2(-5 * EDSCALE, move_factor.y * EDSCALE)); points.push_back(Vector2(0, (move_factor.y + 10) * EDSCALE)); - viewport->draw_colored_polygon(points, get_theme_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_colored_polygon(points, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3396,12 +3395,12 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_set_transform_matrix(simple_xform); Rect2 x_handle_rect = Rect2(scale_factor.x * EDSCALE, -5 * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(x_handle_rect, get_theme_color("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color("axis_x_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_rect(x_handle_rect, get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")), Math::round(EDSCALE)); Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(y_handle_rect, get_theme_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color("axis_y_color", "Editor"), Math::round(EDSCALE)); + viewport->draw_rect(y_handle_rect, get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")), Math::round(EDSCALE)); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3416,11 +3415,11 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color("box_selection_fill_color", "Editor")); + get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_theme_color("box_selection_stroke_color", "Editor"), + get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } @@ -3430,7 +3429,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line( transform.xform(drag_rotation_center), transform.xform(drag_to), - get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), + get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.6), Math::round(2 * EDSCALE)); } } @@ -3478,8 +3477,8 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c void CanvasItemEditor::_draw_axis() { if (show_origin) { - _draw_straight_line(Point2(), Point2(1, 0), get_theme_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75)); - _draw_straight_line(Point2(), Point2(0, 1), get_theme_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(1, 0), get_theme_color(SNAME("axis_x_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); + _draw_straight_line(Point2(), Point2(0, 1), get_theme_color(SNAME("axis_y_color"), SNAME("Editor")) * Color(1, 1, 1, 0.75)); } if (show_viewport) { @@ -3533,7 +3532,7 @@ void CanvasItemEditor::_draw_invisible_nodes_positions(Node *p_node, const Trans Transform2D xform = transform * canvas_xform * parent_xform; // Draw the node's position - Ref<Texture2D> position_icon = get_theme_icon("EditorPositionUnselected", "EditorIcons"); + Ref<Texture2D> position_icon = get_theme_icon(SNAME("EditorPositionUnselected"), SNAME("EditorIcons")); Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; viewport->draw_set_transform_matrix(simple_xform); @@ -3549,16 +3548,16 @@ void CanvasItemEditor::_draw_hover() { Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Size2 node_name_size = font->get_string_size(node_name); Size2 item_size = Size2(node_icon->get_size().x + 4 + node_name_size.x, MAX(node_icon->get_size().y, node_name_size.y - 3)); Point2 pos = transform.xform(hovering_results[i].position) - Point2(0, item_size.y) + (Point2(node_icon->get_size().x, -node_icon->get_size().y) / 4); // Rectify the position to avoid overlapping items - for (List<Rect2>::Element *E = previous_rects.front(); E; E = E->next()) { - if (E->get().intersects(Rect2(pos, item_size))) { - pos.y = E->get().get_position().y - item_size.y; + for (const Rect2 &E : previous_rects) { + if (E.intersects(Rect2(pos, item_size))) { + pos.y = E.get_position().y - item_size.y; } } @@ -3603,13 +3602,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (canvas_item) { float offset = 0; - Ref<Texture2D> lock = get_theme_icon("LockViewport", "EditorIcons"); + Ref<Texture2D> lock = get_theme_icon(SNAME("LockViewport"), SNAME("EditorIcons")); if (p_node->has_meta("_edit_lock_") && show_edit_locks) { lock->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); offset += lock->get_size().x; } - Ref<Texture2D> group = get_theme_icon("GroupViewport", "EditorIcons"); + Ref<Texture2D> group = get_theme_icon(SNAME("GroupViewport"), SNAME("EditorIcons")); if (canvas_item->has_meta("_edit_group_") && show_edit_locks) { group->draw(viewport_canvas_item, (transform * canvas_xform * parent_xform).xform(Point2(0, 0)) + Point2(offset, 0)); //offset += group->get_size().x; @@ -3632,14 +3631,14 @@ void CanvasItemEditor::_draw_viewport() { all_locked = false; all_group = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<CanvasItem>(E->get()) && !Object::cast_to<CanvasItem>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<CanvasItem>(E) && !Object::cast_to<CanvasItem>(E)->has_meta("_edit_group_")) { all_group = false; break; } @@ -3706,8 +3705,7 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if the canvas_item changes List<CanvasItem *> selection = _get_edited_canvas_items(true); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = E->get(); + for (CanvasItem *canvas_item : selection) { CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); Rect2 rect; @@ -3809,7 +3807,7 @@ void CanvasItemEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); for (int i = 0; i < 4; i++) { select_sb->set_margin_size(Side(i), 4); select_sb->set_default_margin(Side(i), 4); @@ -3819,92 +3817,92 @@ void CanvasItemEditor::_notification(int p_what) { _keying_changed(); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - list_select_button->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - move_button->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - scale_button->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - rotate_button->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - smart_snap_button->set_icon(get_theme_icon("Snap", "EditorIcons")); - grid_snap_button->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - snap_config_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); - skeleton_menu->set_icon(get_theme_icon("Bone", "EditorIcons")); - override_camera_button->set_icon(get_theme_icon("Camera2D", "EditorIcons")); - pan_button->set_icon(get_theme_icon("ToolPan", "EditorIcons")); - ruler_button->set_icon(get_theme_icon("Ruler", "EditorIcons")); - pivot_button->set_icon(get_theme_icon("EditPivot", "EditorIcons")); - select_handle = get_theme_icon("EditorHandle", "EditorIcons"); - anchor_handle = get_theme_icon("EditorControlAnchor", "EditorIcons"); - lock_button->set_icon(get_theme_icon("Lock", "EditorIcons")); - unlock_button->set_icon(get_theme_icon("Unlock", "EditorIcons")); - group_button->set_icon(get_theme_icon("Group", "EditorIcons")); - ungroup_button->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - key_loc_button->set_icon(get_theme_icon("KeyPosition", "EditorIcons")); - key_rot_button->set_icon(get_theme_icon("KeyRotation", "EditorIcons")); - key_scale_button->set_icon(get_theme_icon("KeyScale", "EditorIcons")); - key_insert_button->set_icon(get_theme_icon("Key", "EditorIcons")); - key_auto_insert_button->set_icon(get_theme_icon("AutoKey", "EditorIcons")); + select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + list_select_button->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + move_button->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + scale_button->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + rotate_button->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + smart_snap_button->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + grid_snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + snap_config_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + skeleton_menu->set_icon(get_theme_icon(SNAME("Bone"), SNAME("EditorIcons"))); + override_camera_button->set_icon(get_theme_icon(SNAME("Camera2D"), SNAME("EditorIcons"))); + pan_button->set_icon(get_theme_icon(SNAME("ToolPan"), SNAME("EditorIcons"))); + ruler_button->set_icon(get_theme_icon(SNAME("Ruler"), SNAME("EditorIcons"))); + pivot_button->set_icon(get_theme_icon(SNAME("EditPivot"), SNAME("EditorIcons"))); + select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + anchor_handle = get_theme_icon(SNAME("EditorControlAnchor"), SNAME("EditorIcons")); + lock_button->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + unlock_button->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + group_button->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + ungroup_button->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + key_loc_button->set_icon(get_theme_icon(SNAME("KeyPosition"), SNAME("EditorIcons"))); + key_rot_button->set_icon(get_theme_icon(SNAME("KeyRotation"), SNAME("EditorIcons"))); + key_scale_button->set_icon(get_theme_icon(SNAME("KeyScale"), SNAME("EditorIcons"))); + key_insert_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); + key_auto_insert_button->set_icon(get_theme_icon(SNAME("AutoKey"), SNAME("EditorIcons"))); // Use a different color for the active autokey icon to make them easier // to distinguish from the other key icons at the top. On a light theme, // the icon will be dark, so we need to lighten it before blending it // with the red color. const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25); key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55)); - animation_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + animation_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons")); + presets_menu->set_icon(get_theme_icon(SNAME("ControlLayout"), SNAME("EditorIcons"))); PopupMenu *p = presets_menu->get_popup(); p->clear(); - p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons")), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopRight"), SNAME("EditorIcons")), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomRight"), SNAME("EditorIcons")), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomLeft"), SNAME("EditorIcons")), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT); - p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP); - p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT); - p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM); - p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftCenter"), SNAME("EditorIcons")), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopCenter"), SNAME("EditorIcons")), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignRightCenter"), SNAME("EditorIcons")), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomCenter"), SNAME("EditorIcons")), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons")), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE); - p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE); - p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE); - p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftWide"), SNAME("EditorIcons")), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignTopWide"), SNAME("EditorIcons")), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignRightWide"), SNAME("EditorIcons")), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomWide"), SNAME("EditorIcons")), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlVcenterWide"), SNAME("EditorIcons")), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE); + p->add_icon_item(get_theme_icon(SNAME("ControlHcenterWide"), SNAME("EditorIcons")), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE); p->add_separator(); - p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE); - p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO); + p->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE); + p->add_icon_item(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons")), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO); p->add_separator(); p->add_submenu_item(TTR("Anchors only"), "Anchors"); - p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons")); + p->set_item_icon(21, get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); anchors_popup->clear(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopLeft"), SNAME("EditorIcons")), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopRight"), SNAME("EditorIcons")), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomRight"), SNAME("EditorIcons")), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomLeft"), SNAME("EditorIcons")), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftCenter"), SNAME("EditorIcons")), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopCenter"), SNAME("EditorIcons")), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignRightCenter"), SNAME("EditorIcons")), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomCenter"), SNAME("EditorIcons")), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignCenter"), SNAME("EditorIcons")), TTR("Center"), ANCHORS_PRESET_CENTER); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE); - anchors_popup->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignLeftWide"), SNAME("EditorIcons")), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignTopWide"), SNAME("EditorIcons")), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignRightWide"), SNAME("EditorIcons")), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignBottomWide"), SNAME("EditorIcons")), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlVcenterWide"), SNAME("EditorIcons")), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlHcenterWide"), SNAME("EditorIcons")), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE); anchors_popup->add_separator(); - anchors_popup->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE); + anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_PRESET_WIDE); - anchor_mode_button->set_icon(get_theme_icon("Anchor", "EditorIcons")); + anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -3922,8 +3920,8 @@ void CanvasItemEditor::_selection_changed() { int nbValidControls = 0; int nbAnchorsMode = 0; List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control) { continue; } @@ -4091,8 +4089,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_preset(Control::LayoutPreset p_p undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); switch (p_preset) { @@ -4132,8 +4130,8 @@ void CanvasItemEditor::_set_anchors_and_offsets_to_keep_ratio() { undo_redo->create_action(TTR("Change Anchors and Offsets")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { Point2 top_left_anchor = _position_to_anchor(control, Point2()); Point2 bottom_right_anchor = _position_to_anchor(control, control->get_size()); @@ -4159,8 +4157,8 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Change Anchors")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (Node *E : selection) { + Control *control = Object::cast_to<Control>(E); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state()); @@ -4285,15 +4283,15 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } if (has_chain && ik_chain.size()) { - for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) { + for (Node2D *&F : ik_chain) { if (key_pos) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "position", F->get_position(), p_on_existing); } if (key_rot) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "rotation", F->get()->get_rotation(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "rotation", F->get_rotation(), p_on_existing); } if (key_scale) { - AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), p_on_existing); + AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F, "scale", F->get_scale(), p_on_existing); } } } @@ -4317,8 +4315,8 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, void CanvasItemEditor::_button_toggle_anchor_mode(bool p_status) { List<CanvasItem *> selection = _get_edited_canvas_items(false, false); - for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); + for (CanvasItem *E : selection) { + Control *control = Object::cast_to<Control>(E); if (!control || Object::cast_to<Container>(control->get_parent())) { continue; } @@ -4431,13 +4429,13 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_SHOW_BONES: { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + for (Node *E : selection) { // Add children nodes so they are processed - for (int child = 0; child < E->get()->get_child_count(); child++) { - selection.push_back(E->get()->get_child(child)); + for (int child = 0; child < E->get_child_count(); child++) { + selection.push_back(E->get_child(child)); } - Bone2D *bone_2d = Object::cast_to<Bone2D>(E->get()); + Bone2D *bone_2d = Object::cast_to<Bone2D>(E); if (!bone_2d || !bone_2d->is_inside_tree()) { continue; } @@ -4467,8 +4465,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Lock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4489,8 +4487,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Unlock Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4511,8 +4509,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Group Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4533,8 +4531,8 @@ void CanvasItemEditor::_popup_callback(int p_op) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); + for (Node *E : selection) { + CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E); if (!canvas_item || !canvas_item->is_inside_tree()) { continue; } @@ -4701,14 +4699,14 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->create_action(TTR("Paste Pose")); - for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id)); + for (const PoseClipboard &E : pose_clipboard) { + Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E.id)); if (!n2d) { continue; } - undo_redo->add_do_method(n2d, "set_position", E->get().pos); - undo_redo->add_do_method(n2d, "set_rotation", E->get().rot); - undo_redo->add_do_method(n2d, "set_scale", E->get().scale); + undo_redo->add_do_method(n2d, "set_position", E.pos); + undo_redo->add_do_method(n2d, "set_rotation", E.rot); + undo_redo->add_do_method(n2d, "set_scale", E.scale); undo_redo->add_undo_method(n2d, "set_position", n2d->get_position()); undo_redo->add_undo_method(n2d, "set_rotation", n2d->get_rotation()); undo_redo->add_undo_method(n2d, "set_scale", n2d->get_scale()); @@ -4889,7 +4887,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { zoom *= 0.90; viewport->update(); zoom_widget->set_zoom(zoom); - call_deferred("_popup_callback", VIEW_CENTER_TO_SELECTION); + call_deferred(SNAME("_popup_callback"), VIEW_CENTER_TO_SELECTION); } } } @@ -5215,8 +5213,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { editor->get_scene_tree_dock()->connect("node_created", callable_mp(this, &CanvasItemEditor::_node_created)); editor->get_scene_tree_dock()->connect("add_node_used", callable_mp(this, &CanvasItemEditor::_reset_create_position)); - editor->call_deferred("connect", "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true)); - editor->call_deferred("connect", "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false)); + editor->call_deferred(SNAME("connect"), "play_pressed", Callable(this, "_update_override_camera_button"), make_binds(true)); + editor->call_deferred(SNAME("connect"), "stop_pressed", Callable(this, "_update_override_camera_button"), make_binds(false)); hb = memnew(HBoxContainer); add_child(hb); @@ -5276,9 +5274,9 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { warning_child_of_container = memnew(Label); warning_child_of_container->hide(); warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent.")); - warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor")); - warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); - warning_child_of_container->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + warning_child_of_container->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + warning_child_of_container->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + warning_child_of_container->add_theme_font_size_override("font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); add_control_to_info_overlay(warning_child_of_container); h_scroll = memnew(HScrollBar); @@ -5315,7 +5313,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->set_pressed(true); select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q)); select_button->set_shortcut_context(this); - select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.")); + select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("RMB: Add node at position clicked.")); hb->add_child(memnew(VSeparator)); @@ -5615,8 +5613,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { add_node_menu = memnew(PopupMenu); add_child(add_node_menu); - add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Add", "EditorIcons"), TTR("Add Node Here")); - add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon("Instance", "EditorIcons"), TTR("Instance Scene Here")); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add Node Here")); + add_node_menu->add_icon_item(editor->get_scene_tree_dock()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Instance Scene Here")); add_node_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_add_node_pressed)); multiply_grid_step_shortcut = ED_SHORTCUT("canvas_item_editor/multiply_grid_step", TTR("Multiply grid step by 2"), KEY_KP_MULTIPLY); @@ -5630,6 +5628,11 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { // those shortcuts one by one. // Resetting zoom to 100% is a duplicate shortcut of `canvas_item_editor/reset_zoom`, // but it ensures both 1 and Ctrl + 0 can be used to reset zoom. + ED_SHORTCUT("canvas_item_editor/zoom_3.125_percent", TTR("Zoom to 3.125%"), KEY_MASK_SHIFT | KEY_5); + ED_SHORTCUT("canvas_item_editor/zoom_6.25_percent", TTR("Zoom to 6.25%"), KEY_MASK_SHIFT | KEY_4); + ED_SHORTCUT("canvas_item_editor/zoom_12.5_percent", TTR("Zoom to 12.5%"), KEY_MASK_SHIFT | KEY_3); + ED_SHORTCUT("canvas_item_editor/zoom_25_percent", TTR("Zoom to 25%"), KEY_MASK_SHIFT | KEY_2); + ED_SHORTCUT("canvas_item_editor/zoom_50_percent", TTR("Zoom to 50%"), KEY_MASK_SHIFT | KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_100_percent", TTR("Zoom to 100%"), KEY_1); ED_SHORTCUT("canvas_item_editor/zoom_200_percent", TTR("Zoom to 200%"), KEY_2); ED_SHORTCUT("canvas_item_editor/zoom_400_percent", TTR("Zoom to 400%"), KEY_3); @@ -5639,7 +5642,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { set_process_unhandled_key_input(true); // Update the menus' checkboxes - call_deferred("set_state", get_state()); + call_deferred(SNAME("set_state"), get_state()); } CanvasItemEditor *CanvasItemEditor::singleton = nullptr; @@ -5804,14 +5807,14 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & String property = "texture"; List<PropertyInfo> props; child->get_property_list(&props); - for (const List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name == "config/texture") { // Particles2D + for (const PropertyInfo &E : props) { + if (E.name == "config/texture") { // Particles2D property = "config/texture"; break; - } else if (E->get().name == "texture/texture") { // Polygon2D + } else if (E.name == "texture/texture") { // Polygon2D property = "texture/texture"; break; - } else if (E->get().name == "normal") { // TouchScreenButton + } else if (E.name == "normal") { // TouchScreenButton property = "normal"; break; } @@ -6075,7 +6078,7 @@ void CanvasItemEditorViewport::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); - label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 6f90d278bd..5d5f78e0dc 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -42,8 +42,8 @@ void CollisionPolygon3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon(get_theme_icon("Edit", "EditorIcons")); - button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons")); + button_create->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + button_edit->set_icon(get_theme_icon(SNAME("MovePoint"), SNAME("EditorIcons"))); button_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &CollisionPolygon3DEditor::_node_removed)); @@ -531,7 +531,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index c38458c37f..2c2adc2672 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -31,6 +31,7 @@ #include "collision_shape_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/os/keyboard.h" #include "scene/resources/capsule_shape_2d.h" #include "scene/resources/circle_shape_2d.h" #include "scene/resources/concave_polygon_shape_2d.h" @@ -97,7 +98,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const { case RECTANGLE_SHAPE: { Ref<RectangleShape2D> rect = node->get_shape(); - if (idx < 3) { + if (idx < 8) { return rect->get_size().abs(); } @@ -176,16 +177,26 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { } break; case RECTANGLE_SHAPE: { - if (idx < 3) { + if (idx < 8) { Ref<RectangleShape2D> rect = node->get_shape(); + Vector2 size = (Point2)original; - Vector2 size = rect->get_size(); - if (idx == 2) { - size = p_point * 2; + if (RECT_HANDLES[idx].x != 0) { + size.x = p_point.x * RECT_HANDLES[idx].x * 2; + } + if (RECT_HANDLES[idx].y != 0) { + size.y = p_point.y * RECT_HANDLES[idx].y * 2; + } + + if (Input::get_singleton()->is_key_pressed(KEY_ALT)) { + rect->set_size(size.abs()); + node->set_global_position(original_transform.get_origin()); } else { - size[idx] = p_point[idx] * 2; + rect->set_size(((Point2)original + (size - (Point2)original) * 0.5).abs()); + Point2 pos = original_transform.affine_inverse().xform(original_transform.get_origin()); + pos += (size - (Point2)original) * 0.5 * RECT_HANDLES[idx] * 0.5; + node->set_global_position(original_transform.xform(pos)); } - rect->set_size(size.abs()); canvas_item_editor->update_viewport(); } @@ -280,8 +291,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { Ref<RectangleShape2D> rect = node->get_shape(); undo_redo->add_do_method(rect.ptr(), "set_size", rect->get_size()); + undo_redo->add_do_method(node, "set_global_transform", node->get_global_transform()); undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(rect.ptr(), "set_size", p_org); + undo_redo->add_undo_method(node, "set_global_transform", original_transform); undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); } break; @@ -342,6 +355,8 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e } original = get_handle_value(edit_handle); + original_transform = node->get_global_transform(); + last_point = original; pressed = true; return true; @@ -369,13 +384,26 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e } Vector2 cpoint = canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position())); - cpoint = node->get_global_transform().affine_inverse().xform(cpoint); + cpoint = original_transform.affine_inverse().xform(cpoint); + last_point = cpoint; set_handle(edit_handle, cpoint); return true; } + Ref<InputEventKey> k = p_event; + + if (k.is_valid()) { + if (edit_handle == -1 || !pressed || k->is_echo()) { + return false; + } + + if (shape_type == RECTANGLE_SHAPE && k->get_keycode() == KEY_ALT) { + set_handle(edit_handle, last_point); // Update handle when Alt key is toggled. + } + } + return false; } @@ -430,7 +458,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla Transform2D gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Ref<Texture2D> h = get_theme_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> h = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); Vector2 size = h->get_size() * 0.5; handles.clear(); @@ -492,15 +520,12 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla case RECTANGLE_SHAPE: { Ref<RectangleShape2D> shape = node->get_shape(); - handles.resize(3); + handles.resize(8); Vector2 ext = shape->get_size() / 2; - handles.write[0] = Point2(ext.x, 0); - handles.write[1] = Point2(0, ext.y); - handles.write[2] = Point2(ext.x, ext.y); - - p_overlay->draw_texture(h, gt.xform(handles[0]) - size); - p_overlay->draw_texture(h, gt.xform(handles[1]) - size); - p_overlay->draw_texture(h, gt.xform(handles[2]) - size); + for (int i = 0; i < handles.size(); i++) { + handles.write[i] = RECT_HANDLES[i] * ext; + p_overlay->draw_texture(h, gt.xform(handles[i]) - size); + } } break; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 054db1a61b..7db6bd22aa 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -52,6 +52,17 @@ class CollisionShape2DEditor : public Control { SEGMENT_SHAPE }; + const Point2 RECT_HANDLES[8] = { + Point2(1, 0), + Point2(1, 1), + Point2(0, 1), + Point2(-1, 1), + Point2(-1, 0), + Point2(-1, -1), + Point2(0, -1), + Point2(1, -1), + }; + EditorNode *editor; UndoRedo *undo_redo; CanvasItemEditor *canvas_item_editor; @@ -63,6 +74,8 @@ class CollisionShape2DEditor : public Control { int edit_handle; bool pressed; Variant original; + Transform2D original_transform; + Point2 last_point; Variant get_handle_value(int idx) const; void set_handle(int idx, Point2 &p_point); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 6a56cd31d1..6f246c1661 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -224,7 +224,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { void CPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons")); + menu->set_icon(epoints->get_theme_icon(SNAME("CPUParticles2D"), SNAME("EditorIcons"))); file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); } } @@ -253,8 +253,8 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (const String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index f41ccfa86b..fc52cd0f99 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -41,7 +41,7 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { void CPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons")); + options->set_icon(get_theme_icon(SNAME("CPUParticles3D"), SNAME("EditorIcons"))); } } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 706243fe25..07ff0eb346 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -393,7 +393,8 @@ int CurveEditor::get_point_at(Vector2 pos) const { } const Curve &curve = **_curve_ref; - const float r = _hover_radius * _hover_radius; + const float true_hover_radius = Math::round(_hover_radius * EDSCALE); + const float r = true_hover_radius * true_hover_radius; for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 p = get_view_pos(curve.get_point_position(i)); @@ -519,8 +520,8 @@ void CurveEditor::set_hover_point_index(int index) { } void CurveEditor::update_view_transform() { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); const real_t margin = font->get_height(font_size) + 2 * EDSCALE; @@ -558,7 +559,7 @@ Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const { Vector2 point_pos = get_view_pos(_curve_ref->get_point_position(i)); Vector2 control_pos = get_view_pos(_curve_ref->get_point_position(i) + dir); - return point_pos + _tangents_length * (control_pos - point_pos).normalized(); + return point_pos + Math::round(_tangents_length * EDSCALE) * (control_pos - point_pos).normalized(); } Vector2 CurveEditor::get_view_pos(Vector2 world_pos) const { @@ -635,7 +636,7 @@ void CurveEditor::_draw() { // Background Vector2 view_size = get_rect().size; - draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), view_size)); + draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), view_size)); // Grid @@ -644,8 +645,8 @@ void CurveEditor::_draw() { Vector2 min_edge = get_world_pos(Vector2(0, view_size.y)); Vector2 max_edge = get_world_pos(Vector2(view_size.x, 0)); - const Color grid_color0 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.15); - const Color grid_color1 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.07); + const Color grid_color0 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.15); + const Color grid_color1 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.07); draw_line(Vector2(min_edge.x, curve.get_min_value()), Vector2(max_edge.x, curve.get_min_value()), grid_color0); draw_line(Vector2(max_edge.x, curve.get_max_value()), Vector2(min_edge.x, curve.get_max_value()), grid_color0); draw_line(Vector2(0, min_edge.y), Vector2(0, max_edge.y), grid_color0); @@ -665,10 +666,10 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); float font_height = font->get_height(font_size); - Color text_color = get_theme_color("font_color", "Editor"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); { // X axis @@ -695,7 +696,7 @@ void CurveEditor::_draw() { // Draw tangents for current point if (_selected_point >= 0) { - const Color tangent_color = get_theme_color("accent_color", "Editor"); + const Color tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); int i = _selected_point; Vector2 pos = curve.get_point_position(i); @@ -703,13 +704,13 @@ void CurveEditor::_draw() { if (i != 0) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_LEFT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } if (i != curve.get_point_count() - 1) { Vector2 control_pos = get_tangent_view_pos(i, TANGENT_RIGHT); draw_line(get_view_pos(pos), control_pos, tangent_color, Math::round(EDSCALE)); - draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(2), tangent_color); + draw_rect(Rect2(control_pos, Vector2(1, 1)).grow(Math::round(2 * EDSCALE)), tangent_color); } } @@ -717,8 +718,8 @@ void CurveEditor::_draw() { draw_set_transform_matrix(_world_to_view); - const Color line_color = get_theme_color("font_color", "Editor"); - const Color edge_line_color = get_theme_color("highlight_color", "Editor"); + const Color line_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color edge_line_color = get_theme_color(SNAME("highlight_color"), SNAME("Editor")); CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color); plot_curve_accurate(curve, 4.f / view_size.x, plot_func); @@ -727,12 +728,12 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - const Color point_color = get_theme_color("font_color", "Editor"); - const Color selected_point_color = get_theme_color("accent_color", "Editor"); + const Color point_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); + const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 pos = curve.get_point_position(i); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(3), i == _selected_point ? selected_point_color : point_color); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(3 * EDSCALE)), i == _selected_point ? selected_point_color : point_color); // TODO Circles are prettier. Needs a fix! Or a texture //draw_circle(pos, 2, point_color); } @@ -742,7 +743,7 @@ void CurveEditor::_draw() { if (_hover_point != -1) { const Color hover_color = line_color; Vector2 pos = curve.get_point_position(_hover_point); - draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color, false, Math::round(EDSCALE)); + draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(Math::round(_hover_radius * EDSCALE)), hover_color, false, Math::round(EDSCALE)); } // Help text diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp index 85114d88ae..89073b7189 100644 --- a/editor/plugins/editor_debugger_plugin.cpp +++ b/editor/plugins/editor_debugger_plugin.cpp @@ -34,18 +34,18 @@ void EditorDebuggerPlugin::_breaked(bool p_really_did, bool p_can_debug) { if (p_really_did) { - emit_signal("breaked", p_can_debug); + emit_signal(SNAME("breaked"), p_can_debug); } else { - emit_signal("continued"); + emit_signal(SNAME("continued")); } } void EditorDebuggerPlugin::_started() { - emit_signal("started"); + emit_signal(SNAME("started")); } void EditorDebuggerPlugin::_stopped() { - emit_signal("stopped"); + emit_signal(SNAME("stopped")); } void EditorDebuggerPlugin::_bind_methods() { diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index a233d66d82..81c340e9a4 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -490,11 +490,11 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set<String> control_flow_keywords; Set<String> keywords; - for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - if (scr->get_language()->is_control_flow_keyword(E->get())) { - control_flow_keywords.insert(E->get()); + for (const String &E : kwors) { + if (scr->get_language()->is_control_flow_keyword(E)) { + control_flow_keywords.insert(E); } else { - keywords.insert(E->get()); + keywords.insert(E); } } diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp index e385a84087..22c9cc9ab1 100644 --- a/editor/plugins/font_editor_plugin.cpp +++ b/editor/plugins/font_editor_plugin.cpp @@ -34,7 +34,7 @@ void FontDataPreview::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Color text_color = get_theme_color("font_color", "Label"); + Color text_color = get_theme_color(SNAME("font_color"), SNAME("Label")); Color line_color = text_color; line_color.a *= 0.6; Vector2 pos = (get_size() - line->get_size()) / 2; @@ -127,7 +127,7 @@ FontDataPreview::FontDataPreview() { void FontDataEditor::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { int split_width = get_name_split_ratio() * get_size().width; - button->set_size(Size2(get_theme_icon("Add", "EditorIcons")->get_width(), get_size().height)); + button->set_size(Size2(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_width(), get_size().height)); if (is_layout_rtl()) { if (le != nullptr) { fit_child_in_rect(le, Rect2(Vector2(split_width, 0), Size2(split_width, get_size().height))); @@ -145,7 +145,7 @@ void FontDataEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { int split_width = get_name_split_ratio() * get_size().width; - Color dark_color = get_theme_color("dark_color_2", "Editor"); + Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); if (is_layout_rtl()) { draw_rect(Rect2(Vector2(0, 0), Size2(split_width, get_size().height)), dark_color); } else { @@ -154,9 +154,9 @@ void FontDataEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED) { if (le != nullptr) { - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } else { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } queue_sort(); } @@ -187,12 +187,12 @@ void FontDataEditor::init_lang_add() { le->set_editable(true); add_child(le); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::add_lang)); } void FontDataEditor::init_lang_edit() { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::remove_lang)); chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_lang)); } @@ -204,12 +204,12 @@ void FontDataEditor::init_script_add() { le->set_editable(true); add_child(le); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::add_script)); } void FontDataEditor::init_script_edit() { - button->set_icon(get_theme_icon("Remove", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); button->connect("pressed", callable_mp(this, &FontDataEditor::remove_script)); chk->connect("toggled", callable_mp(this, &FontDataEditor::toggle_script)); } diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 37f900280b..5184e837ce 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -329,7 +329,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { void GPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); - menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons")); + menu->set_icon(menu->get_theme_icon(SNAME("GPUParticles2D"), SNAME("EditorIcons"))); file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); } } @@ -361,8 +361,8 @@ GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { file = memnew(EditorFileDialog); List<String> ext; ImageLoader::get_recognized_extensions(&ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + "; " + E->get().to_upper()); + for (const String &E : ext) { + file->add_filter("*." + E + "; " + E.to_upper()); } file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 571bcf9c4a..8576082597 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -230,7 +230,7 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) { void GPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons")); + options->set_icon(options->get_popup()->get_theme_icon(SNAME("GPUParticles3D"), SNAME("EditorIcons"))); get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); } } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index a2dee4a1dc..a4436525fb 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -83,13 +83,13 @@ void GPUParticlesCollisionSDFEditorPlugin::_notification(int p_what) { Color color; if (size_mb <= 16.0 + CMP_EPSILON) { // Fast. - color = bake_info->get_theme_color("success_color", "Editor"); + color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); } else if (size_mb <= 64.0 + CMP_EPSILON) { // Medium. - color = bake_info->get_theme_color("warning_color", "Editor"); + color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); } else { // Slow. - color = bake_info->get_theme_color("error_color", "Editor"); + color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); } bake_info->add_theme_color_override("font_color", color); @@ -131,7 +131,7 @@ void GPUParticlesCollisionSDFEditorPlugin::_sdf_save_path_and_bake(const String if (col_sdf) { Ref<Image> bake_img = col_sdf->bake(); if (bake_img.is_null()) { - EditorNode::get_singleton()->show_warning("Bake Error."); + EditorNode::get_singleton()->show_warning(TTR("Bake Error.")); return; } @@ -174,7 +174,7 @@ GPUParticlesCollisionSDFEditorPlugin::GPUParticlesCollisionSDFEditorPlugin(Edito bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake SDF")); bake->connect("pressed", callable_mp(this, &GPUParticlesCollisionSDFEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/plugins/input_event_editor_plugin.cpp b/editor/plugins/input_event_editor_plugin.cpp index f1aa10844b..d3d2de92f5 100644 --- a/editor/plugins/input_event_editor_plugin.cpp +++ b/editor/plugins/input_event_editor_plugin.cpp @@ -86,7 +86,7 @@ InputEventConfigContainer::InputEventConfigContainer() { mc->add_child(hb); open_config_button = memnew(Button); - open_config_button->set_text("Configure"); + open_config_button->set_text(TTR("Configure")); open_config_button->connect("pressed", callable_mp(this, &InputEventConfigContainer::_configure_pressed)); hb->add_child(open_config_button); diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 1ea6630622..3207a989bd 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -243,8 +243,8 @@ void ItemListEditor::_node_removed(Node *p_node) { void ItemListEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) { - add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - del_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + del_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } else if (p_notification == NOTIFICATION_READY) { get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed)); } diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp index 484fdabfe1..b4a70cd31d 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.cpp +++ b/editor/plugins/lightmap_gi_editor_plugin.cpp @@ -119,7 +119,7 @@ LightmapGIEditorPlugin::LightmapGIEditorPlugin(EditorNode *p_node) { editor = p_node; bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake Lightmaps")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 17a634ee14..94966d4fe6 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -42,22 +42,22 @@ void MaterialEditor::_notification(int p_what) { if (first_enter) { //it's in propertyeditor so.. could be moved around - light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons")); + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); - sphere_switch->set_normal_texture(get_theme_icon("MaterialPreviewSphereOff", "EditorIcons")); - sphere_switch->set_pressed_texture(get_theme_icon("MaterialPreviewSphere", "EditorIcons")); - box_switch->set_normal_texture(get_theme_icon("MaterialPreviewCubeOff", "EditorIcons")); - box_switch->set_pressed_texture(get_theme_icon("MaterialPreviewCube", "EditorIcons")); + sphere_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewSphereOff"), SNAME("EditorIcons"))); + sphere_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewSphere"), SNAME("EditorIcons"))); + box_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewCubeOff"), SNAME("EditorIcons"))); + box_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewCube"), SNAME("EditorIcons"))); first_enter = false; } } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -265,15 +265,15 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + for (const PropertyInfo &E : params) { // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself - Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); + Ref<Texture2D> texture = mat->get_texture_by_name(E.name); if (texture.is_valid()) { - smat->set_shader_param(E->get().name, texture); + smat->set_shader_param(E.name, texture); } else { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } } @@ -309,9 +309,9 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -346,9 +346,9 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -383,9 +383,9 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -420,9 +420,9 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); @@ -457,9 +457,9 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> & List<PropertyInfo> params; RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); - smat->set_shader_param(E->get().name, value); + for (const PropertyInfo &E : params) { + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name); + smat->set_shader_param(E.name, value); } smat->set_render_priority(mat->get_render_priority()); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index fcc6b84efb..39ab3215ff 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -55,10 +55,10 @@ void MeshEditor::_notification(int p_what) { if (first_enter) { //it's in propertyeditor so. could be moved around - light_1_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_theme_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_theme_icon("MaterialPreviewLight2Off", "EditorIcons")); + light_1_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight1"), SNAME("EditorIcons"))); + light_1_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight1Off"), SNAME("EditorIcons"))); + light_2_switch->set_normal_texture(get_theme_icon(SNAME("MaterialPreviewLight2"), SNAME("EditorIcons"))); + light_2_switch->set_pressed_texture(get_theme_icon(SNAME("MaterialPreviewLight2Off"), SNAME("EditorIcons"))); first_enter = false; } } diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 7434accc1a..9a2b222f21 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -90,8 +90,8 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->create_action(TTR("Create Static Trimesh Body")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get()); + for (Node *E : selection) { + MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E); if (!instance) { continue; } @@ -332,7 +332,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { Vector<Vector2> uv = a[p_layer == 0 ? Mesh::ARRAY_TEX_UV : Mesh::ARRAY_TEX_UV2]; if (uv.size() == 0) { - err_dialog->set_text(TTR("Model has no UV in this layer")); + err_dialog->set_text(vformat(TTR("Mesh has no UV in layer %d."), p_layer + 1)); err_dialog->popup_centered(); return; } @@ -382,9 +382,10 @@ void MeshInstance3DEditor::_debug_uv_draw() { } debug_uv->set_clip_contents(true); - debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), Color(0.2, 0.2, 0.0)); + debug_uv->draw_rect(Rect2(Vector2(), debug_uv->get_size()), get_theme_color(SNAME("dark_color_3"), SNAME("Editor"))); debug_uv->draw_set_transform(Vector2(), 0, debug_uv->get_size()); - debug_uv->draw_multiline(uv_lines, Color(1.0, 0.8, 0.7)); + // Use a translucent color to allow overlapping triangles to be visible. + debug_uv->draw_multiline(uv_lines, get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.5), Math::round(EDSCALE)); } void MeshInstance3DEditor::_create_outline_mesh() { @@ -441,7 +442,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Mesh")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshInstance3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 5d1d29cbc8..b3f92c9d95 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -122,23 +122,23 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, List<uint32_t> shapes; sb->get_shape_owners(&shapes); - for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) { - if (sb->is_shape_owner_disabled(E->get())) { + for (uint32_t &E : shapes) { + if (sb->is_shape_owner_disabled(E)) { continue; } - //Transform3D shape_transform = sb->shape_owner_get_transform(E->get()); + //Transform3D shape_transform = sb->shape_owner_get_transform(E); //shape_transform.set_origin(shape_transform.get_origin() - phys_offset); - for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k); + for (int k = 0; k < sb->shape_owner_get_shape_count(E); k++) { + Ref<Shape3D> collision = sb->shape_owner_get_shape(E, k); if (!collision.is_valid()) { continue; } MeshLibrary::ShapeData shape_data; shape_data.shape = collision; - shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get()); + shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E); collisions.push_back(shape_data); } } @@ -254,7 +254,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { Node3DEditor::get_singleton()->add_control_to_menu_panel(menu); menu->set_position(Point2(1, 1)); menu->set_text(TTR("Mesh Library")); - menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshLibrary", "EditorIcons")); + menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshLibrary"), SNAME("EditorIcons"))); menu->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM); menu->get_popup()->add_item(TTR("Remove Selected Item"), MENU_OPTION_REMOVE_ITEM); menu->get_popup()->add_separator(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 48b885930f..5514bccabb 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -268,7 +268,7 @@ MultiMeshEditor::MultiMeshEditor() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text("MultiMesh"); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MultiMeshInstance3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Populate Surface")); options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option)); diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 2a399f4b03..2138f943da 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -33,7 +33,9 @@ #include "core/math/convex_hull.h" #include "core/math/geometry_2d.h" #include "core/math/geometry_3d.h" +#include "editor/plugins/node_3d_editor_plugin.h" #include "scene/3d/audio_stream_player_3d.h" +#include "scene/3d/camera_3d.h" #include "scene/3d/collision_polygon_3d.h" #include "scene/3d/collision_shape_3d.h" #include "scene/3d/cpu_particles_3d.h" @@ -106,58 +108,122 @@ void EditorNode3DGizmo::clear() { void EditorNode3DGizmo::redraw() { if (get_script_instance() && get_script_instance()->has_method("_redraw")) { get_script_instance()->call("_redraw"); - return; + } else { + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->redraw(this); } - ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->redraw(this); + if (Node3DEditor::get_singleton()->is_current_selected_gizmo(this)) { + Node3DEditor::get_singleton()->update_transform_gizmo(); + } } -String EditorNode3DGizmo::get_handle_name(int p_idx) const { +String EditorNode3DGizmo::get_handle_name(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { - return get_script_instance()->call("_get_handle_name", p_idx); + return get_script_instance()->call("_get_handle_name", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, ""); - return gizmo_plugin->get_handle_name(this, p_idx); + return gizmo_plugin->get_handle_name(this, p_id); } -bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const { +bool EditorNode3DGizmo::is_handle_highlighted(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { - return get_script_instance()->call("_is_handle_highlighted", p_idx); + return get_script_instance()->call("_is_handle_highlighted", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, false); - return gizmo_plugin->is_handle_highlighted(this, p_idx); + return gizmo_plugin->is_handle_highlighted(this, p_id); } -Variant EditorNode3DGizmo::get_handle_value(int p_idx) { +Variant EditorNode3DGizmo::get_handle_value(int p_id) const { if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { - return get_script_instance()->call("_get_handle_value", p_idx); + return get_script_instance()->call("_get_handle_value", p_id); } ERR_FAIL_COND_V(!gizmo_plugin, Variant()); - return gizmo_plugin->get_handle_value(this, p_idx); + return gizmo_plugin->get_handle_value(this, p_id); } -void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void EditorNode3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const { if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { - get_script_instance()->call("_set_handle", p_idx, p_camera, p_point); + get_script_instance()->call("_set_handle", p_id, p_camera, p_point); return; } ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); + gizmo_plugin->set_handle(this, p_id, p_camera, p_point); } -void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void EditorNode3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) const { if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { - get_script_instance()->call("_commit_handle", p_idx, p_restore, p_cancel); + get_script_instance()->call("_commit_handle", p_id, p_restore, p_cancel); + return; + } + + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->commit_handle(this, p_id, p_restore, p_cancel); +} + +int EditorNode3DGizmo::subgizmos_intersect_ray(Camera3D *p_camera, const Vector2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) { + return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point); + } + + ERR_FAIL_COND_V(!gizmo_plugin, -1); + return gizmo_plugin->subgizmos_intersect_ray(this, p_camera, p_point); +} + +Vector<int> EditorNode3DGizmo::subgizmos_intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) { + Array frustum; + for (int i = 0; i < p_frustum.size(); i++) { + frustum[i] = p_frustum[i]; + } + return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum); + } + + ERR_FAIL_COND_V(!gizmo_plugin, Vector<int>()); + return gizmo_plugin->subgizmos_intersect_frustum(this, p_camera, p_frustum); +} + +Transform3D EditorNode3DGizmo::get_subgizmo_transform(int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) { + return get_script_instance()->call("_get_subgizmo_transform", p_id); + } + + ERR_FAIL_COND_V(!gizmo_plugin, Transform3D()); + return gizmo_plugin->get_subgizmo_transform(this, p_id); +} + +void EditorNode3DGizmo::set_subgizmo_transform(int p_id, Transform3D p_transform) const { + if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) { + get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform); return; } ERR_FAIL_COND(!gizmo_plugin); - gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); + gizmo_plugin->set_subgizmo_transform(this, p_id, p_transform); +} + +void EditorNode3DGizmo::commit_subgizmos(const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) { + Array ids; + for (int i = 0; i < p_ids.size(); i++) { + ids[i] = p_ids[i]; + } + + Array restore; + for (int i = 0; i < p_restore.size(); i++) { + restore[i] = p_restore[i]; + } + + get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel); + return; + } + + ERR_FAIL_COND(!gizmo_plugin); + gizmo_plugin->commit_subgizmos(this, p_ids, p_restore, p_cancel); } void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) { @@ -180,17 +246,17 @@ void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) RS::get_singleton()->instance_geometry_set_flag(instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); } -void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { +void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material, const Transform3D &p_xform, const Ref<SkinReference> &p_skin_reference) { ERR_FAIL_COND(!spatial_node); Instance ins; - ins.billboard = p_billboard; ins.mesh = p_mesh; ins.skin_reference = p_skin_reference; ins.material = p_material; + ins.xform = p_xform; if (valid) { ins.create_instance(spatial_node, hidden); - RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform() * ins.xform); if (ins.material.is_valid()) { RS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); } @@ -245,7 +311,6 @@ void EditorNode3DGizmo::add_vertices(const Vector<Vector3> &p_vertices, const Re } } - ins.billboard = p_billboard; ins.mesh = mesh; if (valid) { ins.create_instance(spatial_node, hidden); @@ -307,8 +372,6 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, mesh->set_custom_aabb(AABB(Vector3(-selectable_icon_size, -selectable_icon_size, -selectable_icon_size) * 100.0f, Vector3(selectable_icon_size, selectable_icon_size, selectable_icon_size) * 200.0f)); ins.mesh = mesh; - ins.unscaled = true; - ins.billboard = true; if (valid) { ins.create_instance(spatial_node, hidden); RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); @@ -331,7 +394,7 @@ void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) { } } -void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) { +void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids, bool p_billboard, bool p_secondary) { billboard_handle = p_billboard; if (!is_selected() || !is_editable()) { @@ -340,8 +403,16 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< ERR_FAIL_COND(!spatial_node); - Instance ins; + if (p_ids.is_empty()) { + ERR_FAIL_COND_MSG((!handles.is_empty() && !handle_ids.is_empty()) || (!secondary_handles.is_empty() && !secondary_handle_ids.is_empty()), "Fail"); + } else { + ERR_FAIL_COND_MSG(handles.size() != handle_ids.size() || secondary_handles.size() != secondary_handle_ids.size(), "Fail"); + } + bool is_current_hover_gizmo = Node3DEditor::get_singleton()->get_current_hover_gizmo() == this; + int current_hover_handle = Node3DEditor::get_singleton()->get_current_hover_gizmo_handle(); + + Instance ins; Ref<ArrayMesh> mesh = memnew(ArrayMesh); Array a; @@ -357,7 +428,8 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< col = Color(0, 0, 1, 0.9); } - if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i) { + int id = p_ids.is_empty() ? i : p_ids[i]; + if (!is_current_hover_gizmo || current_hover_handle != id) { col.a = 0.8; } @@ -379,29 +451,31 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< } ins.mesh = mesh; - ins.billboard = p_billboard; ins.extra_margin = true; if (valid) { ins.create_instance(spatial_node, hidden); RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); - if (!p_secondary) { - int chs = handles.size(); - handles.resize(chs + p_handles.size()); - for (int i = 0; i < p_handles.size(); i++) { - handles.write[i + chs] = p_handles[i]; - } - } else { - int chs = secondary_handles.size(); - secondary_handles.resize(chs + p_handles.size()); - for (int i = 0; i < p_handles.size(); i++) { - secondary_handles.write[i + chs] = p_handles[i]; + + Vector<Vector3> &h = p_secondary ? secondary_handles : handles; + int current_size = h.size(); + h.resize(current_size + p_handles.size()); + for (int i = 0; i < p_handles.size(); i++) { + h.write[current_size + i] = p_handles[i]; + } + + if (!p_ids.is_empty()) { + Vector<int> &ids = p_secondary ? secondary_handle_ids : handle_ids; + current_size = ids.size(); + ids.resize(current_size + p_ids.size()); + for (int i = 0; i < p_ids.size(); i++) { + ids.write[current_size + i] = p_ids[i]; } } } -void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) { +void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) { ERR_FAIL_COND(!spatial_node); BoxMesh box_mesh; @@ -419,8 +493,7 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Ref<ArrayMesh> m = memnew(ArrayMesh); m->add_surface_from_arrays(box_mesh.surface_get_primitive_type(0), arrays); - m->surface_set_material(0, p_material); - add_mesh(m); + add_mesh(m, p_material, p_xform); } bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) { @@ -485,13 +558,15 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector Transform3D it = t.affine_inverse(); Vector<Plane> transformed_frustum; + int plane_count = p_frustum.size(); + transformed_frustum.resize(plane_count); - for (int i = 0; i < p_frustum.size(); i++) { - transformed_frustum.push_back(it.xform(p_frustum[i])); + for (int i = 0; i < plane_count; i++) { + transformed_frustum.write[i] = it.xform(p_frustum[i]); } - Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(p_frustum.ptr(), p_frustum.size()); - if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), transformed_frustum.size(), convex_points.ptr(), convex_points.size(), mesh_scale)) { + Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(transformed_frustum.ptr(), plane_count); + if (collision_mesh->inside_convex_shape(transformed_frustum.ptr(), plane_count, convex_points.ptr(), convex_points.size(), mesh_scale)) { return true; } } @@ -499,70 +574,77 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector return false; } -bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) { - ERR_FAIL_COND_V(!spatial_node, false); - ERR_FAIL_COND_V(!valid, false); +void EditorNode3DGizmo::handles_intersect_ray(Camera3D *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id) { + r_id = -1; - if (hidden && !gizmo_plugin->is_selectable_when_hidden()) { - return false; + ERR_FAIL_COND(!spatial_node); + ERR_FAIL_COND(!valid); + + if (hidden) { + return; } - if (r_gizmo_handle && !hidden) { - Transform3D t = spatial_node->get_global_transform(); - if (billboard_handle) { - t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); - } + Transform3D camera_xform = p_camera->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); + if (billboard_handle) { + t.set_look_at(t.origin, t.origin - camera_xform.basis.get_axis(2), camera_xform.basis.get_axis(1)); + } - float min_d = 1e20; - int idx = -1; + float min_d = 1e20; - for (int i = 0; i < secondary_handles.size(); i++) { - Vector3 hpos = t.xform(secondary_handles[i]); - Vector2 p = p_camera->unproject_position(hpos); + for (int i = 0; i < secondary_handles.size(); i++) { + Vector3 hpos = t.xform(secondary_handles[i]); + Vector2 p = p_camera->unproject_position(hpos); - if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); - if (dp < min_d) { - r_pos = t.xform(hpos); - r_normal = p_camera->get_transform().basis.get_axis(2); - min_d = dp; - idx = i + handles.size(); + if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { + real_t dp = p_camera->get_transform().origin.distance_to(hpos); + if (dp < min_d) { + min_d = dp; + if (secondary_handle_ids.is_empty()) { + r_id = i; + } else { + r_id = secondary_handle_ids[i]; } } } + } - if (p_sec_first && idx != -1) { - *r_gizmo_handle = idx; - return true; - } + if (r_id != -1 && p_shift_pressed) { + return; + } - min_d = 1e20; + min_d = 1e20; - for (int i = 0; i < handles.size(); i++) { - Vector3 hpos = t.xform(handles[i]); - Vector2 p = p_camera->unproject_position(hpos); + for (int i = 0; i < handles.size(); i++) { + Vector3 hpos = t.xform(handles[i]); + Vector2 p = p_camera->unproject_position(hpos); - if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); - if (dp < min_d) { - r_pos = t.xform(hpos); - r_normal = p_camera->get_transform().basis.get_axis(2); - min_d = dp; - idx = i; + if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { + real_t dp = p_camera->get_transform().origin.distance_to(hpos); + if (dp < min_d) { + min_d = dp; + if (handle_ids.is_empty()) { + r_id = i; + } else { + r_id = handle_ids[i]; } } } + } +} - if (idx >= 0) { - *r_gizmo_handle = idx; - return true; - } +bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal) { + ERR_FAIL_COND_V(!spatial_node, false); + ERR_FAIL_COND_V(!valid, false); + + if (hidden && !gizmo_plugin->is_selectable_when_hidden()) { + return false; } if (selectable_icon_size > 0.0f) { Transform3D t = spatial_node->get_global_transform(); Vector3 camera_position = p_camera->get_camera_transform().origin; - if (camera_position.distance_squared_to(t.origin) > 0.01) { + if (!camera_position.is_equal_approx(t.origin)) { t.set_look_at(t.origin, camera_position); } @@ -578,7 +660,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Transform3D orig_camera_transform = p_camera->get_camera_transform(); - if (orig_camera_transform.origin.distance_squared_to(t.origin) > 0.01 && + if (!orig_camera_transform.origin.is_equal_approx(t.origin) && ABS(orig_camera_transform.basis.get_axis(Vector3::AXIS_Z).dot(Vector3(0, 1, 0))) < 0.99) { p_camera->look_at(t.origin); } @@ -674,6 +756,25 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, return false; } +bool EditorNode3DGizmo::is_subgizmo_selected(int p_id) const { + Node3DEditor *ed = Node3DEditor::get_singleton(); + ERR_FAIL_COND_V(!ed, false); + return ed->is_current_selected_gizmo(this) && ed->is_subgizmo_selected(p_id); +} + +Vector<int> EditorNode3DGizmo::get_subgizmo_selection() const { + Vector<int> ret; + + Node3DEditor *ed = Node3DEditor::get_singleton(); + ERR_FAIL_COND_V(!ed, ret); + + if (ed->is_current_selected_gizmo(this)) { + ret = ed->get_subgizmo_selection(); + } + + return ret; +} + void EditorNode3DGizmo::create() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(valid); @@ -690,7 +791,7 @@ void EditorNode3DGizmo::transform() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { - RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform() * instances[i].xform); } } @@ -724,38 +825,46 @@ void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) { void EditorNode3DGizmo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "material", "transform", "skeleton"), &EditorNode3DGizmo::add_mesh, DEFVAL(Variant()), DEFVAL(Transform3D()), DEFVAL(Ref<SkinReference>())); ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments); ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorNode3DGizmo::add_collision_triangles); ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorNode3DGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "ids", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorNode3DGizmo::_set_spatial_node); ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorNode3DGizmo::get_spatial_node); ClassDB::bind_method(D_METHOD("get_plugin"), &EditorNode3DGizmo::get_plugin); ClassDB::bind_method(D_METHOD("clear"), &EditorNode3DGizmo::clear); ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorNode3DGizmo::set_hidden); + ClassDB::bind_method(D_METHOD("is_subgizmo_selected"), &EditorNode3DGizmo::is_subgizmo_selected); + ClassDB::bind_method(D_METHOD("get_subgizmo_selection"), &EditorNode3DGizmo::get_subgizmo_selection); BIND_VMETHOD(MethodInfo("_redraw")); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", PropertyInfo(Variant::INT, "index"))); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", PropertyInfo(Variant::INT, "index"))); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", PropertyInfo(Variant::INT, "id"))); - MethodInfo hvget(Variant::NIL, "_get_handle_value", PropertyInfo(Variant::INT, "index")); + MethodInfo hvget(Variant::NIL, "_get_handle_value", PropertyInfo(Variant::INT, "id")); hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; BIND_VMETHOD(hvget); - BIND_VMETHOD(MethodInfo("_set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); - MethodInfo cm = MethodInfo("_commit_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + BIND_VMETHOD(MethodInfo("_set_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + MethodInfo cm = MethodInfo("_commit_handle", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); cm.default_arguments.push_back(false); BIND_VMETHOD(cm); + + BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum"))); + BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform"))); + MethodInfo cs = MethodInfo("_commit_subgizmos", PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cs.default_arguments.push_back(false); + BIND_VMETHOD(cs); } EditorNode3DGizmo::EditorNode3DGizmo() { valid = false; billboard_handle = false; hidden = false; - base = nullptr; selected = false; - instantiated = false; spatial_node = nullptr; gizmo_plugin = nullptr; selectable_icon_size = -1.0f; @@ -768,10 +877,362 @@ EditorNode3DGizmo::~EditorNode3DGizmo() { clear(); } -Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3()); +///// + +void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { + Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + + Vector<Ref<StandardMaterial3D>> mats; + + for (int i = 0; i < 4; i++) { + bool selected = i % 2 == 1; + bool instantiated = i < 2; + + Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - return handles[p_idx]; + Color color = instantiated ? instantiated_color : p_color; + + if (!selected) { + color.a *= 0.3; + } + + material->set_albedo(color); + material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1); + material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + + if (p_use_vertex_color) { + material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + } + + if (p_billboard) { + material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + } + + if (p_on_top && selected) { + material->set_on_top_of_alpha(); + } + + mats.push_back(material); + } + + materials[p_name] = mats; +} + +void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { + Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + + Vector<Ref<StandardMaterial3D>> icons; + + for (int i = 0; i < 4; i++) { + bool selected = i % 2 == 1; + bool instantiated = i < 2; + + Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + + Color color = instantiated ? instantiated_color : p_albedo; + + if (!selected) { + color.a *= 0.85; + } + + icon->set_albedo(color); + + icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); + icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture); + icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true); + icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN); + + if (p_on_top && selected) { + icon->set_on_top_of_alpha(); + } + + icons.push_back(icon); + } + + materials[p_name] = icons; +} + +void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref<Texture2D> &p_icon) { + Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + + handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); + Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon(SNAME("Editor3DHandle"), SNAME("EditorIcons")); + handle_material->set_point_size(handle_t->get_width()); + handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); + handle_material->set_albedo(Color(1, 1, 1)); + handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + handle_material->set_on_top_of_alpha(); + if (p_billboard) { + handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + handle_material->set_on_top_of_alpha(); + } + handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + + materials[p_name] = Vector<Ref<StandardMaterial3D>>(); + materials[p_name].push_back(handle_material); +} + +void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { + materials[p_name] = Vector<Ref<StandardMaterial3D>>(); + materials[p_name].push_back(p_material); +} + +Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) { + ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>()); + ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>()); + + if (p_gizmo.is_null() || materials[p_name].size() == 1) { + return materials[p_name][0]; + } + + int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); + + Ref<StandardMaterial3D> mat = materials[p_name][index]; + + if (current_state == ON_TOP && p_gizmo->is_selected()) { + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); + } else { + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); + } + + return mat; +} + +String EditorNode3DGizmoPlugin::get_gizmo_name() const { + if (get_script_instance() && get_script_instance()->has_method("_get_gizmo_name")) { + return get_script_instance()->call("_get_gizmo_name"); + } + return TTR("Nameless gizmo"); +} + +int EditorNode3DGizmoPlugin::get_priority() const { + if (get_script_instance() && get_script_instance()->has_method("_get_priority")) { + return get_script_instance()->call("_get_priority"); + } + return 0; +} + +Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_get_gizmo")) { + return get_script_instance()->call("_get_gizmo", p_spatial); + } + + Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial); + + if (ref.is_null()) { + return ref; + } + + ref->set_plugin(this); + ref->set_spatial_node(p_spatial); + ref->set_hidden(current_state == HIDDEN); + + current_gizmos.push_back(ref.ptr()); + return ref; +} + +void EditorNode3DGizmoPlugin::_bind_methods() { +#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo") + + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); + BIND_VMETHOD(MethodInfo(GIZMO_REF, "_create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); + + ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); + ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); + + ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); + + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_gizmo_name")); + BIND_VMETHOD(MethodInfo(Variant::INT, "_get_priority")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_be_hidden")); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_selectable_when_hidden")); + + BIND_VMETHOD(MethodInfo("_redraw", GIZMO_REF)); + BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + + MethodInfo hvget(Variant::NIL, "_get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "id")); + hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; + BIND_VMETHOD(hvget); + + BIND_VMETHOD(MethodInfo("_set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + MethodInfo cm = MethodInfo("_commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cm.default_arguments.push_back(false); + BIND_VMETHOD(cm); + + BIND_VMETHOD(MethodInfo(Variant::INT, "_subgizmos_intersect_ray", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo(Variant::PACKED_INT32_ARRAY, "_subgizmos_intersect_frustum", GIZMO_REF, PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::ARRAY, "frustum"))); + BIND_VMETHOD(MethodInfo(Variant::TRANSFORM3D, "_get_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id"))); + BIND_VMETHOD(MethodInfo("_set_subgizmo_transform", GIZMO_REF, PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::TRANSFORM3D, "transform"))); + MethodInfo cs = MethodInfo("_commit_subgizmos", GIZMO_REF, PropertyInfo(Variant::PACKED_INT32_ARRAY, "ids"), PropertyInfo(Variant::ARRAY, "restore"), PropertyInfo(Variant::BOOL, "cancel")); + cs.default_arguments.push_back(false); + BIND_VMETHOD(cs); + +#undef GIZMO_REF +} + +bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_has_gizmo")) { + return get_script_instance()->call("_has_gizmo", p_spatial); + } + return false; +} + +Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { + if (get_script_instance() && get_script_instance()->has_method("_create_gizmo")) { + return get_script_instance()->call("_create_gizmo", p_spatial); + } + + Ref<EditorNode3DGizmo> ref; + if (has_gizmo(p_spatial)) { + ref.instantiate(); + } + return ref; +} + +bool EditorNode3DGizmoPlugin::can_be_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("_can_be_hidden")) { + return get_script_instance()->call("_can_be_hidden"); + } + return true; +} + +bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const { + if (get_script_instance() && get_script_instance()->has_method("_is_selectable_when_hidden")) { + return get_script_instance()->call("_is_selectable_when_hidden"); + } + return false; +} + +void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + if (get_script_instance() && get_script_instance()->has_method("_redraw")) { + Ref<EditorNode3DGizmo> ref(p_gizmo); + get_script_instance()->call("_redraw", ref); + } +} + +bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { + return get_script_instance()->call("_is_handle_highlighted", p_gizmo, p_id); + } + return false; +} + +String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { + return get_script_instance()->call("_get_handle_name", p_gizmo, p_id); + } + return ""; +} + +Variant EditorNode3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { + return get_script_instance()->call("_get_handle_value", p_gizmo, p_id); + } + return Variant(); +} + +void EditorNode3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { + get_script_instance()->call("_set_handle", p_gizmo, p_id, p_camera, p_point); + } +} + +void EditorNode3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { + get_script_instance()->call("_commit_handle", p_gizmo, p_id, p_restore, p_cancel); + } +} + +int EditorNode3DGizmoPlugin::subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_ray")) { + return get_script_instance()->call("_subgizmos_intersect_ray", p_camera, p_point); + } + return -1; +} + +Vector<int> EditorNode3DGizmoPlugin::subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const { + if (get_script_instance() && get_script_instance()->has_method("_subgizmos_intersect_frustum")) { + Array frustum; + for (int i = 0; i < p_frustum.size(); i++) { + frustum[i] = p_frustum[i]; + } + return get_script_instance()->call("_subgizmos_intersect_frustum", p_camera, frustum); + } + + return Vector<int>(); +} + +Transform3D EditorNode3DGizmoPlugin::get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (get_script_instance() && get_script_instance()->has_method("_get_subgizmo_transform")) { + return get_script_instance()->call("_get_subgizmo_transform", p_id); + } + + return Transform3D(); +} + +void EditorNode3DGizmoPlugin::set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) const { + if (get_script_instance() && get_script_instance()->has_method("_set_subgizmo_transform")) { + get_script_instance()->call("_set_subgizmo_transform", p_id, p_transform); + } +} + +void EditorNode3DGizmoPlugin::commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel) const { + if (get_script_instance() && get_script_instance()->has_method("_commit_subgizmos")) { + Array ids; + for (int i = 0; i < p_ids.size(); i++) { + ids[i] = p_ids[i]; + } + + Array restore; + for (int i = 0; i < p_restore.size(); i++) { + restore[i] = p_restore[i]; + } + + get_script_instance()->call("_commit_subgizmos", ids, restore, p_cancel); + } +} + +void EditorNode3DGizmoPlugin::set_state(int p_state) { + current_state = p_state; + for (int i = 0; i < current_gizmos.size(); ++i) { + current_gizmos[i]->set_hidden(current_state == HIDDEN); + } +} + +int EditorNode3DGizmoPlugin::get_state() const { + return current_state; +} + +void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) { + current_gizmos.erase(p_gizmo); +} + +EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { + current_state = VISIBLE; +} + +EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { + for (int i = 0; i < current_gizmos.size(); ++i) { + current_gizmos[i]->set_plugin(nullptr); + current_gizmos[i]->get_spatial_node()->remove_gizmo(current_gizmos[i]); + } + if (Node3DEditor::get_singleton()) { + Node3DEditor::get_singleton()->update_all_gizmos(); + } } //// light gizmo @@ -782,9 +1243,9 @@ Light3DGizmoPlugin::Light3DGizmoPlugin() { create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true); create_material("lines_billboard", Color(1, 1, 1), true, false, true); - create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoDirectionalLight", "EditorIcons")); - create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLight", "EditorIcons")); - create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoSpotLight", "EditorIcons")); + create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoDirectionalLight"), SNAME("EditorIcons"))); + create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLight"), SNAME("EditorIcons"))); + create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoSpotLight"), SNAME("EditorIcons"))); create_handle_material("handles"); create_handle_material("handles_billboard", true); @@ -802,20 +1263,20 @@ int Light3DGizmoPlugin::get_priority() const { return -1; } -String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (p_idx == 0) { +String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + if (p_id == 0) { return "Radius"; } else { return "Aperture"; } } -Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant Light3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); - if (p_idx == 0) { + if (p_id == 0) { return light->get_param(Light3D::PARAM_RANGE); } - if (p_idx == 1) { + if (p_id == 1) { return light->get_param(Light3D::PARAM_SPOT_ANGLE); } @@ -849,7 +1310,7 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec return Math::rad2deg(a); } -void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Light3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Transform3D gt = light->get_global_transform(); Transform3D gi = gt.affine_inverse(); @@ -858,7 +1319,7 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer Vector3 ray_dir = p_camera->project_ray_normal(p_point); Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - if (p_idx == 0) { + if (p_id == 0) { if (Object::cast_to<SpotLight3D>(light)) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb); @@ -887,24 +1348,24 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer } } - } else if (p_idx == 1) { + } else if (p_id == 1) { float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt); light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99)); } } -void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Light3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_cancel) { - light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); + light->set_param(p_id == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); - } else if (p_idx == 0) { + } else if (p_id == 0) { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE)); ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore); ur->commit_action(); - } else if (p_idx == 1) { + } else if (p_id == 1) { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE)); @@ -996,7 +1457,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; handles.push_back(Vector3(r, 0, 0)); - p_gizmo->add_handles(handles, get_material("handles_billboard"), true); + p_gizmo->add_handles(handles, get_material("handles_billboard"), Vector<int>(), true); } if (Object::cast_to<SpotLight3D>(light)) { @@ -1050,7 +1511,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); - create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons")); + create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("Gizmo3DSamplePlayer"), SNAME("EditorIcons"))); create_material("stream_player_3d_material_primary", gizmo_color); create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35)); create_handle_material("handles"); @@ -1068,16 +1529,16 @@ int AudioStreamPlayer3DGizmoPlugin::get_priority() const { return -1; } -String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return "Emission Radius"; } -Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); return player->get_emission_angle(); } -void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void AudioStreamPlayer3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); Transform3D gt = player->get_global_transform(); @@ -1114,7 +1575,7 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int } } -void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void AudioStreamPlayer3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -1203,7 +1664,7 @@ int Camera3DGizmoPlugin::get_priority() const { return -1; } -String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1213,7 +1674,7 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in } } -Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant Camera3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1223,7 +1684,7 @@ Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_ } } -void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Camera3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); Transform3D gt = camera->get_global_transform(); @@ -1252,7 +1713,7 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came } } -void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Camera3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1558,7 +2019,7 @@ Position3DGizmoPlugin::Position3DGizmoPlugin() { // Use a darkened axis color for the negative axis. // This makes it possible to see in which direction the Position3D node is rotated // (which can be important depending on how it's used). - const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor"); + const Color color_x = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); cursor_colors.push_back(color_x); cursor_colors.push_back(color_x); // FIXME: Use less strong darkening factor once GH-48573 is fixed. @@ -1566,13 +2027,13 @@ Position3DGizmoPlugin::Position3DGizmoPlugin() { cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_x.lerp(Color(0, 0, 0), 0.75)); - const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor"); + const Color color_y = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_y.lerp(Color(0, 0, 0), 0.75)); - const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor"); + const Color color_z = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z); cursor_colors.push_back(color_z.lerp(Color(0, 0, 0), 0.75)); @@ -1761,7 +2222,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } Ref<ArrayMesh> m = surface_tool->commit(); - p_gizmo->add_mesh(m, false, skel->register_skin(Ref<Skin>())); + p_gizmo->add_mesh(m, Ref<Material>(), Transform3D(), skel->register_skin(Ref<Skin>())); } //// @@ -2102,23 +2563,23 @@ void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->add_collision_triangles(tm); } -String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return "SoftBody3D pin point"; } -Variant SoftBody3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - return Variant(soft_body->is_point_pinned(p_idx)); + return Variant(soft_body->is_point_pinned(p_id)); } -void SoftBody3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void SoftBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - soft_body->pin_point_toggle(p_idx); + soft_body->pin_point_toggle(p_id); } -bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const { +bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const { SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); - return soft_body->is_point_pinned(idx); + return soft_body->is_point_pinned(p_id); } /////////// @@ -2143,8 +2604,8 @@ int VisibleOnScreenNotifier3DGizmoPlugin::get_priority() const { return -1; } -String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Size X"; case 1: @@ -2162,20 +2623,20 @@ String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DG return ""; } -Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); return notifier->get_aabb(); } -void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); Transform3D gt = notifier->get_global_transform(); Transform3D gi = gt.affine_inverse(); - bool move = p_idx >= 3; - p_idx = p_idx % 3; + bool move = p_id >= 3; + p_id = p_id % 3; AABB aabb = notifier->get_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2186,25 +2647,25 @@ void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; if (move) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; + aabb.position[p_id] = d - 1.0 - aabb.size[p_id] * 0.5; notifier->set_aabb(aabb); } else { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx] - ofs[p_idx]; + float d = ra[p_id] - ofs[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2213,13 +2674,13 @@ void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo d = 0.001; } //resize - aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d; - aabb.size[p_idx] = d * 2; + aabb.position[p_id] = (aabb.position[p_id] + aabb.size[p_id] * 0.5) - d; + aabb.size[p_id] = d * 2; notifier->set_aabb(aabb); } } -void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2284,7 +2745,7 @@ void VisibleOnScreenNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// CPUParticles3DGizmoPlugin::CPUParticles3DGizmoPlugin() { - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles3D", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoCPUParticles3D"), SNAME("EditorIcons"))); } bool CPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -2315,7 +2776,7 @@ GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { create_material("particles_material", gizmo_color); gizmo_color.a = 0.1; create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGPUParticles3D", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoGPUParticles3D"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -2335,8 +2796,8 @@ bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Size X"; case 1: @@ -2354,19 +2815,19 @@ String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_giz return ""; } -Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant GPUParticles3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); return particles->get_visibility_aabb(); } -void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void GPUParticles3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); Transform3D gt = particles->get_global_transform(); Transform3D gi = gt.affine_inverse(); - bool move = p_idx >= 3; - p_idx = p_idx % 3; + bool move = p_id >= 3; + p_id = p_id % 3; AABB aabb = particles->get_visibility_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2377,25 +2838,25 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx Vector3 ofs = aabb.position + aabb.size * 0.5; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; if (move) { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; + aabb.position[p_id] = d - 1.0 - aabb.size[p_id] * 0.5; particles->set_visibility_aabb(aabb); } else { Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx] - ofs[p_idx]; + float d = ra[p_id] - ofs[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2404,13 +2865,13 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx d = 0.001; } //resize - aabb.position[p_idx] = (aabb.position[p_idx] + aabb.size[p_idx] * 0.5) - d; - aabb.size[p_idx] = d * 2; + aabb.position[p_id] = (aabb.position[p_id] + aabb.size[p_id] * 0.5) - d; + aabb.size[p_id] = d * 2; particles->set_visibility_aabb(aabb); } } -void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticles3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2475,8 +2936,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// -//// - GPUParticlesCollision3DGizmoPlugin::GPUParticlesCollision3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particle_collision", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); @@ -2498,7 +2957,7 @@ int GPUParticlesCollision3DGizmoPlugin::get_priority() const { return -1; } -String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { @@ -2512,7 +2971,7 @@ String GPUParticlesCollision3DGizmoPlugin::get_handle_name(const EditorNode3DGiz return ""; } -Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { const Node3D *cs = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(cs) || Object::cast_to<GPUParticlesAttractorSphere>(cs)) { @@ -2526,7 +2985,7 @@ Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo * return Variant(); } -void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void GPUParticlesCollision3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Node3D *sn = p_gizmo->get_spatial_node(); Transform3D gt = sn->get_global_transform(); @@ -2554,10 +3013,10 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, if (Object::cast_to<GPUParticlesCollisionBox>(sn) || Object::cast_to<GPUParticlesAttractorBox>(sn) || Object::cast_to<GPUParticlesAttractorVectorField>(sn) || Object::cast_to<GPUParticlesCollisionSDF>(sn) || Object::cast_to<GPUParticlesCollisionHeightField>(sn)) { Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2567,12 +3026,12 @@ void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, } Vector3 he = sn->call("get_extents"); - he[p_idx] = d; + he[p_id] = d; sn->call("set_extents", he); } } -void GPUParticlesCollision3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticlesCollision3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Node3D *sn = p_gizmo->get_spatial_node(); if (Object::cast_to<GPUParticlesCollisionSphere>(sn) || Object::cast_to<GPUParticlesAttractorSphere>(sn)) { @@ -2746,7 +3205,7 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { gizmo_color.a = 0.1; create_material("reflection_probe_solid_material", gizmo_color); - create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoReflectionProbe", "EditorIcons")); + create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoReflectionProbe"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -2762,8 +3221,8 @@ int ReflectionProbeGizmoPlugin::get_priority() const { return -1; } -String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -2781,18 +3240,18 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi return ""; } -Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant ReflectionProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); return AABB(probe->get_extents(), probe->get_origin_offset()); } -void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void ReflectionProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); Transform3D gt = probe->get_global_transform(); Transform3D gi = gt.affine_inverse(); - if (p_idx < 3) { + if (p_id < 3) { Vector3 extents = probe->get_extents(); Vector3 ray_from = p_camera->project_ray_origin(p_point); @@ -2801,11 +3260,11 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2814,13 +3273,13 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; probe->set_extents(extents); } else { - p_idx -= 3; + p_id -= 3; Vector3 origin = probe->get_origin_offset(); - origin[p_idx] = 0; + origin[p_id] = 0; Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2828,22 +3287,22 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb); // Adjust the actual position to account for the gizmo handle position - float d = ra[p_idx] + 0.25; + float d = ra[p_id] + 0.25; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } - origin[p_idx] = d; + origin[p_id] = d; probe->set_origin_offset(origin); } } -void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void ReflectionProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); AABB restore = p_restore; @@ -2947,8 +3406,8 @@ int DecalGizmoPlugin::get_priority() const { return -1; } -String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -2960,12 +3419,12 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p return ""; } -Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant DecalGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); return decal->get_extents(); } -void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void DecalGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); Transform3D gt = decal->get_global_transform(); @@ -2979,11 +3438,11 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -2992,11 +3451,11 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; decal->set_extents(extents); } -void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void DecalGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); Vector3 restore = p_restore; @@ -3055,7 +3514,6 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> material = get_material("decal_material", p_gizmo); p_gizmo->add_lines(lines, material); - p_gizmo->add_handles(handles, get_material("handles")); } @@ -3072,7 +3530,7 @@ VoxelGIGizmoPlugin::VoxelGIGizmoPlugin() { gizmo_color.a = 0.05; create_material("voxel_gi_solid_material", gizmo_color); - create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoVoxelGI", "EditorIcons")); + create_icon_material("voxel_gi_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoVoxelGI"), SNAME("EditorIcons"))); create_handle_material("handles"); } @@ -3088,8 +3546,8 @@ int VoxelGIGizmoPlugin::get_priority() const { return -1; } -String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { +String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { + switch (p_id) { case 0: return "Extents X"; case 1: @@ -3101,12 +3559,12 @@ String VoxelGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int return ""; } -Variant VoxelGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant VoxelGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); return probe->get_extents(); } -void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void VoxelGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); Transform3D gt = probe->get_global_transform(); @@ -3120,11 +3578,11 @@ void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -3133,11 +3591,11 @@ void VoxelGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer d = 0.001; } - extents[p_idx] = d; + extents[p_id] = d; probe->set_extents(extents); } -void VoxelGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void VoxelGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { VoxelGI *probe = Object::cast_to<VoxelGI>(p_gizmo->get_spatial_node()); Vector3 restore = p_restore; @@ -3254,21 +3712,21 @@ LightmapGIGizmoPlugin::LightmapGIGizmoPlugin() { add_material("lightmap_probe_material", mat); - create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLightmapGI", "EditorIcons")); + create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_theme_icon(SNAME("GizmoLightmapGI"), SNAME("EditorIcons"))); } -String LightmapGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String LightmapGIGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return ""; } -Variant LightmapGIGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant LightmapGIGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { return Variant(); } -void LightmapGIGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void LightmapGIGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { } -void LightmapGIGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void LightmapGIGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { } bool LightmapGIGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -3439,18 +3897,18 @@ LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() { create_material("lightprobe_lines", gizmo_color); } -String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { return ""; } -Variant LightmapProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant LightmapProbeGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { return Variant(); } -void LightmapProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void LightmapProbeGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { } -void LightmapProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void LightmapProbeGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { } bool LightmapProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -3555,8 +4013,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { List<uint32_t> owners; co->get_shape_owners(&owners); - for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) { - uint32_t owner_id = E->get(); + for (uint32_t &owner_id : owners) { Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. @@ -3570,7 +4027,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SurfaceTool st; st.append_from(s->get_debug_mesh(), 0, xform); - p_gizmo->add_mesh(st.commit(), false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(st.commit(), material); p_gizmo->add_collision_segments(s->get_debug_mesh_lines()); } } @@ -3600,7 +4057,7 @@ int CollisionShape3DGizmoPlugin::get_priority() const { return -1; } -String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const { const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3617,11 +4074,11 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g } if (Object::cast_to<CapsuleShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; + return p_id == 0 ? "Radius" : "Height"; } if (Object::cast_to<CylinderShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; + return p_id == 0 ? "Radius" : "Height"; } if (Object::cast_to<RayShape3D>(*s)) { @@ -3631,7 +4088,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g return ""; } -Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { +Variant CollisionShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3651,12 +4108,12 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo if (Object::cast_to<CapsuleShape3D>(*s)) { Ref<CapsuleShape3D> cs2 = s; - return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); + return p_id == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<CylinderShape3D>(*s)) { Ref<CylinderShape3D> cs2 = s; - return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); + return p_id == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<RayShape3D>(*s)) { @@ -3667,7 +4124,7 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo return Variant(); } -void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3717,11 +4174,11 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i if (Object::cast_to<BoxShape3D>(*s)) { Vector3 axis; - axis[p_idx] = 1.0; + axis[p_id] = 1.0; Ref<BoxShape3D> bs = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); - float d = ra[p_idx]; + float d = ra[p_id]; if (Node3DEditor::get_singleton()->is_snap_enabled()) { d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap()); } @@ -3731,18 +4188,18 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } Vector3 he = bs->get_size(); - he[p_idx] = d * 2; + he[p_id] = d * 2; bs->set_size(he); } if (Object::cast_to<CapsuleShape3D>(*s)) { Vector3 axis; - axis[p_idx == 0 ? 0 : 2] = 1.0; + axis[p_id == 0 ? 0 : 2] = 1.0; Ref<CapsuleShape3D> cs2 = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); - if (p_idx == 1) { + if (p_id == 1) { d -= cs2->get_radius(); } @@ -3754,16 +4211,16 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { cs2->set_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { cs2->set_height(d * 2.0); } } if (Object::cast_to<CylinderShape3D>(*s)) { Vector3 axis; - axis[p_idx == 0 ? 0 : 1] = 1.0; + axis[p_id == 0 ? 0 : 1] = 1.0; Ref<CylinderShape3D> cs2 = s; Vector3 ra, rb; Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); @@ -3776,15 +4233,15 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i d = 0.001; } - if (p_idx == 0) { + if (p_id == 0) { cs2->set_radius(d); - } else if (p_idx == 1) { + } else if (p_id == 1) { cs2->set_height(d * 2.0); } } } -void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void CollisionShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel) const { CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3823,7 +4280,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CapsuleShape3D>(*s)) { Ref<CapsuleShape3D> ss = s; if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { ss->set_radius(p_restore); } else { ss->set_height(p_restore); @@ -3832,7 +4289,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Capsule Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); ur->add_undo_method(ss.ptr(), "set_radius", p_restore); @@ -3848,7 +4305,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int if (Object::cast_to<CylinderShape3D>(*s)) { Ref<CylinderShape3D> ss = s; if (p_cancel) { - if (p_idx == 0) { + if (p_id == 0) { ss->set_radius(p_restore); } else { ss->set_height(p_restore); @@ -3857,7 +4314,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx == 0) { + if (p_id == 0) { ur->create_action(TTR("Change Cylinder Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); ur->add_undo_method(ss.ptr(), "set_radius", p_restore); @@ -4153,7 +4610,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { if (Object::cast_to<ConcavePolygonShape3D>(*s)) { Ref<ConcavePolygonShape3D> cs2 = s; Ref<ArrayMesh> mesh = cs2->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(mesh, material); p_gizmo->add_collision_segments(cs2->get_debug_mesh_lines()); } @@ -4174,7 +4631,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<HeightMapShape3D> hms = s; Ref<ArrayMesh> mesh = hms->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); + p_gizmo->add_mesh(mesh, material); } } @@ -4289,9 +4746,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 *tw = tmeshfaces.ptrw(); int tidx = 0; - for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); - + for (const Face3 &f : faces) { for (int j = 0; j < 3; j++) { tw[tidx++] = f.vertex[j]; _EdgeKey ek; @@ -4589,7 +5044,7 @@ Joint3DGizmoPlugin::Joint3DGizmoPlugin() { update_timer->set_wait_time(1.0 / 120.0); update_timer->connect("timeout", callable_mp(this, &Joint3DGizmoPlugin::incremental_update_gizmos)); update_timer->set_autostart(true); - EditorNode::get_singleton()->call_deferred("add_child", update_timer); + EditorNode::get_singleton()->call_deferred(SNAME("add_child"), update_timer); } void Joint3DGizmoPlugin::incremental_update_gizmos() { diff --git a/editor/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 6f071859ec..61ee3a95a9 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -28,13 +28,156 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SPATIAL_EDITOR_GIZMOS_H -#define SPATIAL_EDITOR_GIZMOS_H +#ifndef NODE_3D_EDITOR_GIZMOS_H +#define NODE_3D_EDITOR_GIZMOS_H -#include "editor/plugins/node_3d_editor_plugin.h" -#include "scene/3d/camera_3d.h" +#include "core/templates/ordered_hash_map.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/skeleton_3d.h" class Camera3D; +class Timer; +class EditorNode3DGizmoPlugin; + +class EditorNode3DGizmo : public Node3DGizmo { + GDCLASS(EditorNode3DGizmo, Node3DGizmo); + + struct Instance { + RID instance; + Ref<ArrayMesh> mesh; + Ref<Material> material; + Ref<SkinReference> skin_reference; + bool extra_margin = false; + Transform3D xform; + + void create_instance(Node3D *p_base, bool p_hidden = false); + }; + + bool selected; + + Vector<Vector3> collision_segments; + Ref<TriangleMesh> collision_mesh; + + Vector<Vector3> handles; + Vector<int> handle_ids; + Vector<Vector3> secondary_handles; + Vector<int> secondary_handle_ids; + + float selectable_icon_size; + bool billboard_handle; + + bool valid; + bool hidden; + Vector<Instance> instances; + Node3D *spatial_node; + + void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } + +protected: + static void _bind_methods(); + + EditorNode3DGizmoPlugin *gizmo_plugin; + +public: + void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); + void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); + void add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material = Ref<Material>(), const Transform3D &p_xform = Transform3D(), const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>()); + void add_collision_segments(const Vector<Vector3> &p_lines); + void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); + void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); + void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false); + void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D()); + + virtual bool is_handle_highlighted(int p_id) const; + virtual String get_handle_name(int p_id) const; + virtual Variant get_handle_value(int p_id) const; + virtual void set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const; + virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false) const; + + virtual int subgizmos_intersect_ray(Camera3D *p_camera, const Vector2 &p_point) const; + virtual Vector<int> subgizmos_intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) const; + virtual Transform3D get_subgizmo_transform(int p_id) const; + virtual void set_subgizmo_transform(int p_id, Transform3D p_transform) const; + virtual void commit_subgizmos(const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) const; + + void set_selected(bool p_selected) { selected = p_selected; } + bool is_selected() const { return selected; } + + void set_spatial_node(Node3D *p_node); + Node3D *get_spatial_node() const { return spatial_node; } + Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; } + bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum); + void handles_intersect_ray(Camera3D *p_camera, const Vector2 &p_point, bool p_shift_pressed, int &r_id); + bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal); + bool is_subgizmo_selected(int p_id) const; + Vector<int> get_subgizmo_selection() const; + + virtual void clear() override; + virtual void create() override; + virtual void transform() override; + virtual void redraw() override; + virtual void free() override; + + virtual bool is_editable() const; + + void set_hidden(bool p_hidden); + void set_plugin(EditorNode3DGizmoPlugin *p_plugin); + + EditorNode3DGizmo(); + ~EditorNode3DGizmo(); +}; + +class EditorNode3DGizmoPlugin : public Resource { + GDCLASS(EditorNode3DGizmoPlugin, Resource); + +public: + static const int VISIBLE = 0; + static const int HIDDEN = 1; + static const int ON_TOP = 2; + +protected: + int current_state; + List<EditorNode3DGizmo *> current_gizmos; + HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; + + static void _bind_methods(); + virtual bool has_gizmo(Node3D *p_spatial); + virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial); + +public: + void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); + void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); + void create_handle_material(const String &p_name, bool p_billboard = false, const Ref<Texture2D> &p_texture = nullptr); + void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); + + Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>()); + + virtual String get_gizmo_name() const; + virtual int get_priority() const; + virtual bool can_be_hidden() const; + virtual bool is_selectable_when_hidden() const; + + virtual void redraw(EditorNode3DGizmo *p_gizmo); + virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const; + virtual void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const; + + virtual int subgizmos_intersect_ray(const EditorNode3DGizmo *p_gizmo, Camera3D *p_camera, const Vector2 &p_point) const; + virtual Vector<int> subgizmos_intersect_frustum(const EditorNode3DGizmo *p_gizmo, const Camera3D *p_camera, const Vector<Plane> &p_frustum) const; + virtual Transform3D get_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id) const; + virtual void set_subgizmo_transform(const EditorNode3DGizmo *p_gizmo, int p_id, Transform3D p_transform) const; + virtual void commit_subgizmos(const EditorNode3DGizmo *p_gizmo, const Vector<int> &p_ids, const Vector<Transform3D> &p_restore, bool p_cancel = false) const; + + Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial); + void set_state(int p_state); + int get_state() const; + void unregister_gizmo(EditorNode3DGizmo *p_gizmo); + + EditorNode3DGizmoPlugin(); + virtual ~EditorNode3DGizmoPlugin(); +}; class Light3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Light3DGizmoPlugin, EditorNode3DGizmoPlugin); @@ -44,10 +187,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; Light3DGizmoPlugin(); @@ -61,10 +204,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; AudioStreamPlayer3DGizmoPlugin(); @@ -78,10 +221,10 @@ public: String get_gizmo_name() const override; int get_priority() const override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; void redraw(EditorNode3DGizmo *p_gizmo) override; Camera3DGizmoPlugin(); @@ -210,10 +353,10 @@ public: bool is_selectable_when_hidden() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) override; - bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; + bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id) const override; SoftBody3DGizmoPlugin(); }; @@ -227,10 +370,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; VisibleOnScreenNotifier3DGizmoPlugin(); }; @@ -257,10 +400,10 @@ public: bool is_selectable_when_hidden() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; GPUParticles3DGizmoPlugin(); }; @@ -274,10 +417,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; GPUParticlesCollision3DGizmoPlugin(); }; @@ -291,10 +434,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; ReflectionProbeGizmoPlugin(); }; @@ -308,10 +451,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; DecalGizmoPlugin(); }; @@ -325,10 +468,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; VoxelGIGizmoPlugin(); }; @@ -342,10 +485,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; LightmapGIGizmoPlugin(); }; @@ -359,10 +502,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; LightmapProbeGizmoPlugin(); }; @@ -388,10 +531,10 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const override; - Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const override; - void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + Variant get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id) const override; + void set_handle(const EditorNode3DGizmo *p_gizmo, int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, const Variant &p_restore, bool p_cancel = false) const override; CollisionShape3DGizmoPlugin(); }; @@ -489,4 +632,4 @@ public: Joint3DGizmoPlugin(); }; -#endif // SPATIAL_EDITOR_GIZMOS_H +#endif // NODE_3D_EDITOR_GIZMOS_H diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index afb566dac8..ebd6615ac1 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -35,20 +35,20 @@ #include "core/math/camera_matrix.h" #include "core/math/math_funcs.h" #include "core/os/keyboard.h" -#include "core/string/print_string.h" #include "core/templates/sort_array.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/editor_node.h" -#include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "editor/node_3d_editor_gizmos.h" #include "editor/plugins/animation_player_editor_plugin.h" +#include "editor/plugins/node_3d_editor_gizmos.h" #include "editor/plugins/script_editor_plugin.h" #include "scene/3d/camera_3d.h" #include "scene/3d/collision_shape_3d.h" +#include "scene/3d/light_3d.h" #include "scene/3d/mesh_instance_3d.h" #include "scene/3d/physics_body_3d.h" #include "scene/3d/visual_instance_3d.h" +#include "scene/3d/world_environment.h" #include "scene/gui/center_container.h" #include "scene/gui/subviewport_container.h" #include "scene/resources/packed_scene.h" @@ -58,7 +58,6 @@ #define GIZMO_ARROW_SIZE 0.35 #define GIZMO_RING_HALF_WIDTH 0.1 -#define GIZMO_SCALE_DEFAULT 0.15 #define GIZMO_PLANE_SIZE 0.2 #define GIZMO_PLANE_DST 0.3 #define GIZMO_CIRCLE_SIZE 1.1 @@ -92,9 +91,9 @@ void ViewportRotationControl::_notification(int p_what) { axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT); axis_colors.clear(); - axis_colors.push_back(get_theme_color("axis_x_color", "Editor")); - axis_colors.push_back(get_theme_color("axis_y_color", "Editor")); - axis_colors.push_back(get_theme_color("axis_z_color", "Editor")); + axis_colors.push_back(get_theme_color(SNAME("axis_x_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_y_color"), SNAME("Editor"))); + axis_colors.push_back(get_theme_color(SNAME("axis_z_color"), SNAME("Editor"))); update(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { @@ -143,7 +142,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) { if (front) { String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z"); draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c); - draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size("rotation_control_size", "EditorFonts"), Color(0.3, 0.3, 0.3)); + draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.3, 0.3, 0.3)); } else { draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS * (0.55 + (0.2 * (1.0 + p_axis.z_axis))), c); } @@ -436,16 +435,29 @@ Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const { } void Node3DEditorViewport::_clear_selected() { - editor_selection->clear(); -} - -void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) { - if (clicked.is_null()) { - return; + _edit.gizmo = Ref<EditorNode3DGizmo>(); + _edit.gizmo_handle = -1; + _edit.gizmo_initial_value = Variant(); + + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + + if (se && se->gizmo.is_valid()) { + se->subgizmos.clear(); + se->gizmo->redraw(); + se->gizmo.unref(); + spatial_editor->update_transform_gizmo(); + } else { + editor_selection->clear(); + Node3DEditor::get_singleton()->edit(nullptr); } +} - Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked)); +void Node3DEditorViewport::_select_clicked(bool p_allow_locked) { + Node *node = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); Node3D *selected = Object::cast_to<Node3D>(node); + clicked = ObjectID(); + if (!selected) { return; } @@ -462,43 +474,27 @@ void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_ } if (p_allow_locked || !_is_node_locked(selected)) { - _select(selected, clicked_wants_append, true); - } -} - -void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { - // Add or remove a single node from the selection - if (p_append && p_single) { - if (editor_selection->is_selected(p_node)) { - // Already in the selection, remove it from the selected nodes - editor_selection->remove_node(p_node); + if (clicked_wants_append) { + if (editor_selection->is_selected(selected)) { + editor_selection->remove_node(selected); + } else { + editor_selection->add_node(selected); + } } else { - // Add the item to the selection - editor_selection->add_node(p_node); - } - } else if (p_append && !p_single) { - // Add the item to the selection - editor_selection->add_node(p_node); - } else { - // No append; single select - editor_selection->clear(); - editor_selection->add_node(p_node); - // Reselect - if (Engine::get_singleton()->is_editor_hint()) { - editor->call("edit_node", p_node); + if (!editor_selection->is_selected(selected)) { + editor_selection->clear(); + editor_selection->add_node(selected); + editor->edit_node(selected); + } } - } - if (editor_selection->get_selected_node_list().size() == 1) { - editor->push_item(editor_selection->get_selected_node_list()[0]); + if (editor_selection->get_selected_node_list().size() == 1) { + editor->edit_node(editor_selection->get_selected_node_list()[0]); + } } } -ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) { - if (r_gizmo_handle) { - *r_gizmo_handle = -1; - } - +ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos) { Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink(); @@ -514,7 +510,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b ObjectID closest; Node *item = nullptr; float closest_dist = 1e20; - int selected_handle = -1; for (int i = 0; i < instances.size(); i++) { Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); @@ -523,38 +518,40 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b continue; } - Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); + Vector<Ref<Node3DGizmo>> gizmos = spat->get_gizmos(); - if ((!seg.is_valid()) || found_gizmos.has(seg)) { - continue; - } + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; - found_gizmos.insert(seg); - Vector3 point; - Vector3 normal; + if ((!seg.is_valid()) || found_gizmos.has(seg)) { + continue; + } - int handle = -1; - bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal, &handle, p_alt_select); + found_gizmos.insert(seg); + Vector3 point; + Vector3 normal; - if (!inters) { - continue; - } + bool inters = seg->intersect_ray(camera, shrinked_pos, point, normal); - float dist = pos.distance_to(point); + if (!inters) { + continue; + } - if (dist < 0) { - continue; - } + float dist = pos.distance_to(point); - if (dist < closest_dist) { - item = Object::cast_to<Node>(spat); - if (item != edited_scene) { - item = edited_scene->get_deepest_editable_node(item); + if (dist < 0) { + continue; } - closest = item->get_instance_id(); - closest_dist = dist; - selected_handle = handle; + if (dist < closest_dist) { + item = Object::cast_to<Node>(spat); + if (item != edited_scene) { + item = edited_scene->get_deepest_editable_node(item); + } + + closest = item->get_instance_id(); + closest_dist = dist; + } } } @@ -562,23 +559,15 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b return ObjectID(); } - if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) { - if (r_gizmo_handle) { - *r_gizmo_handle = selected_handle; - } - } - return closest; } -void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select, bool p_include_locked_nodes) { +void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked_nodes) { Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Ref<EditorNode3DGizmo>> found_gizmos; - - r_includes_current = false; + Set<Node3D *> found_nodes; for (int i = 0; i < instances.size(); i++) { Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); @@ -587,53 +576,48 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu continue; } - Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); - - if (!seg.is_valid()) { + if (found_nodes.has(spat)) { continue; } - if (found_gizmos.has(seg)) { + if (!p_include_locked_nodes && _is_node_locked(spat)) { continue; } - found_gizmos.insert(seg); - Vector3 point; - Vector3 normal; + Vector<Ref<Node3DGizmo>> gizmos = spat->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; - int handle = -1; - bool inters = seg->intersect_ray(camera, p_pos, point, normal, nullptr, p_alt_select); + if (!seg.is_valid()) { + continue; + } - if (!inters) { - continue; - } + Vector3 point; + Vector3 normal; - float dist = pos.distance_to(point); + bool inters = seg->intersect_ray(camera, p_pos, point, normal); - if (dist < 0) { - continue; - } + if (!inters) { + continue; + } - if (!p_include_locked_nodes && _is_node_locked(spat)) { - continue; - } + float dist = pos.distance_to(point); - if (editor_selection->is_selected(spat)) { - r_includes_current = true; - } + if (dist < 0) { + continue; + } - _RayResult res; - res.item = spat; - res.depth = dist; - res.handle = handle; - results.push_back(res); - } + found_nodes.insert(spat); - if (results.is_empty()) { - return; + _RayResult res; + res.item = spat; + res.depth = dist; + r_results.push_back(res); + break; + } } - results.sort(); + r_results.sort(); } Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { @@ -656,6 +640,9 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { void Node3DEditorViewport::_select_region() { if (cursor.region_begin == cursor.region_end) { + if (!clicked_wants_append) { + _clear_selected(); + } return; //nothing really } @@ -702,7 +689,66 @@ void Node3DEditorViewport::_select_region() { far.d += get_zfar(); frustum.push_back(far); + if (spatial_editor->get_single_selected_node()) { + Node3D *single_selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(single_selected); + + Ref<EditorNode3DGizmo> old_gizmo; + if (!clicked_wants_append) { + se->subgizmos.clear(); + old_gizmo = se->gizmo; + se->gizmo.unref(); + } + + bool found_subgizmos = false; + Vector<Ref<Node3DGizmo>> gizmos = single_selected->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; + if (!seg.is_valid()) { + continue; + } + + if (se->gizmo.is_valid() && se->gizmo != seg) { + continue; + } + + Vector<int> subgizmos = seg->subgizmos_intersect_frustum(camera, frustum); + if (!subgizmos.is_empty()) { + se->gizmo = seg; + for (int i = 0; i < subgizmos.size(); i++) { + int subgizmo_id = subgizmos[i]; + if (!se->subgizmos.has(subgizmo_id)) { + se->subgizmos.insert(subgizmo_id, se->gizmo->get_subgizmo_transform(subgizmo_id)); + } + } + found_subgizmos = true; + break; + } + } + + if (!clicked_wants_append || found_subgizmos) { + if (se->gizmo.is_valid()) { + se->gizmo->redraw(); + } + + if (old_gizmo != se->gizmo && old_gizmo.is_valid()) { + old_gizmo->redraw(); + } + + spatial_editor->update_transform_gizmo(); + } + + if (found_subgizmos) { + return; + } + } + + if (!clicked_wants_append) { + _clear_selected(); + } + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world_3d()->get_scenario()); + Set<Node3D *> found_nodes; Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); @@ -713,6 +759,12 @@ void Node3DEditorViewport::_select_region() { continue; } + if (found_nodes.has(sp)) { + continue; + } + + found_nodes.insert(sp); + Node *item = Object::cast_to<Node>(sp); if (item != edited_scene) { item = edited_scene->get_deepest_editable_node(item); @@ -731,28 +783,31 @@ void Node3DEditorViewport::_select_region() { item = sel; } - if (selected.find(item) != -1) { - continue; - } - if (_is_node_locked(item)) { continue; } - Ref<EditorNode3DGizmo> seg = sp->get_gizmo(); + Vector<Ref<Node3DGizmo>> gizmos = sp->get_gizmos(); + for (int j = 0; j < gizmos.size(); j++) { + Ref<EditorNode3DGizmo> seg = gizmos[j]; + if (!seg.is_valid()) { + continue; + } - if (!seg.is_valid()) { - continue; + if (seg->intersect_frustum(camera, frustum)) { + selected.push_back(item); + } } + } - if (seg->intersect_frustum(camera, frustum)) { - selected.push_back(item); + for (int i = 0; i < selected.size(); i++) { + if (!editor_selection->is_selected(selected[i])) { + editor_selection->add_node(selected[i]); } } - bool single = selected.size() == 1; - for (int i = 0; i < selected.size(); i++) { - _select(selected[i], true, single); + if (editor_selection->get_selected_node_list().size() == 1) { + editor->edit_node(editor_selection->get_selected_node_list()[0]); } } @@ -779,21 +834,34 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { spatial_editor->update_transform_gizmo(); _edit.center = spatial_editor->get_gizmo_transform().origin; - List<Node *> &selection = editor_selection->get_selected_node_list(); + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; + if (se && se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + int subgizmo_id = E->key(); + se->subgizmos[subgizmo_id] = se->gizmo->get_subgizmo_transform(subgizmo_id); } + se->original_local = selected->get_transform(); + se->original = selected->get_global_transform(); + } else { + List<Node *> &selection = editor_selection->get_selected_node_list(); - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; - } + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } + + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - se->original = se->sp->get_global_gizmo_transform(); - se->original_local = se->sp->get_local_gizmo_transform(); + if (!sel_item) { + continue; + } + + sel_item->original_local = sel_item->sp->get_local_gizmo_transform(); + sel_item->original = sel_item->sp->get_global_gizmo_transform(); + } } } @@ -829,7 +897,7 @@ static int _get_key_modifier(Ref<InputEventWithModifiers> e) { return 0; } -bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { +bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { if (!spatial_editor->is_gizmo_visible()) { return false; } @@ -1023,6 +1091,88 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high return false; } +void Node3DEditorViewport::_transform_gizmo_apply(Node3D *p_node, const Transform3D &p_transform, bool p_local) { + if (p_transform.basis.determinant() == 0) { + return; + } + + if (p_local) { + p_node->set_transform(p_transform); + } else { + p_node->set_global_transform(p_transform); + } +} + +Transform3D Node3DEditorViewport::_compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local) { + switch (p_mode) { + case TRANSFORM_SCALE: { + if (p_local) { + Basis g = p_original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(p_motion); + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + local_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + + Vector3 local_scale = p_original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + Transform3D local_t = p_original_local; + local_t.basis.set_euler_scale(p_original_local.basis.get_rotation_euler(), local_scale); + return local_t; + } else { + Transform3D base = Transform3D(Basis(), _edit.center); + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + + Transform3D r; + r.basis.scale(p_motion + Vector3(1, 1, 1)); + return base * (r * (base.inverse() * p_original)); + } + } + case TRANSFORM_TRANSLATE: { + if (p_local) { + if (_edit.snap || spatial_editor->is_snap_enabled()) { + Basis g = p_original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(p_motion); + local_motion.snap(Vector3(p_extra, p_extra, p_extra)); + + p_motion = g.xform(local_motion); + } + + } else { + if (_edit.snap || spatial_editor->is_snap_enabled()) { + p_motion.snap(Vector3(p_extra, p_extra, p_extra)); + } + } + + // Apply translation + Transform3D t = p_original; + t.origin += p_motion; + return t; + } + case TRANSFORM_ROTATE: { + if (p_local) { + Basis rot = Basis(p_motion, p_extra); + + Vector3 scale = p_original_local.basis.get_scale(); + Vector3 euler = (p_original_local.get_basis().orthonormalized() * rot).get_euler(); + Transform3D t; + t.basis.set_euler_scale(euler, scale); + t.origin = p_original_local.origin; + return t; + } else { + Transform3D r; + r.basis.rotate(p_motion, p_extra); + Transform3D base = Transform3D(Basis(), _edit.center); + return base * r * base.inverse() * p_original; + } + } + default: { + ERR_FAIL_V_MSG(Transform3D(), "Invalid mode in '_compute_transform'"); + } + } +} + void Node3DEditorViewport::_surface_mouse_enter() { if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) { surface->grab_focus(); @@ -1046,7 +1196,7 @@ bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) { } void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { - _find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->is_shift_pressed(), spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); + _find_items_at_pos(b->get_position(), selection_results, spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); Node *scene = editor->get_edited_scene(); @@ -1066,10 +1216,8 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { selection_results.clear(); if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); - clicked = ObjectID(); + _select_clicked(spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); } - } else if (!selection_results.is_empty()) { NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); StringName root_name = root_path.get_name(root_path.get_name_count() - 1); @@ -1143,7 +1291,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> b = p_event; if (b.is_valid()) { - emit_signal("clicked", this); + emit_signal(SNAME("clicked"), this); float zoom_factor = 1 + (ZOOM_FREELOOK_MULTIPLIER - 1) * b->get_factor(); switch (b->get_button_index()) { @@ -1187,8 +1335,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1198,7 +1346,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - sp->set_global_transform(se->original); + if (se->gizmo.is_valid()) { + Vector<int> ids; + Vector<Transform3D> restore; + + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + ids.push_back(GE->key()); + restore.push_back(GE->value()); + } + + se->gizmo->commit_subgizmos(ids, restore, true); + spatial_editor->update_transform_gizmo(); + } else { + sp->set_global_transform(se->original); + } } surface->update(); set_message(TTR("Transform Aborted."), 3); @@ -1270,37 +1431,92 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.snap = spatial_editor->is_snap_enabled(); _edit.mode = TRANSFORM_NONE; - //gizmo has priority over everything - - bool can_select_gizmos = true; + bool can_select_gizmos = spatial_editor->get_single_selected_node(); { int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS); - can_select_gizmos = view_menu->get_popup()->is_item_checked(idx); + can_select_gizmos = can_select_gizmos && view_menu->get_popup()->is_item_checked(idx); } - if (can_select_gizmos && spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); - if (seg.is_valid()) { - int handle = -1; - Vector3 point; - Vector3 normal; - bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, b->is_shift_pressed()); - if (inters && handle != -1) { + // Gizmo handles + if (can_select_gizmos) { + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + bool intersected_handle = false; + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + + if ((!seg.is_valid())) { + continue; + } + + int gizmo_handle = -1; + seg->handles_intersect_ray(camera, _edit.mouse_pos, b->is_shift_pressed(), gizmo_handle); + if (gizmo_handle != -1) { _edit.gizmo = seg; - _edit.gizmo_handle = handle; - _edit.gizmo_initial_value = seg->get_handle_value(handle); + _edit.gizmo_handle = gizmo_handle; + _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle); + intersected_handle = true; break; } } + + if (intersected_handle) { + break; + } } - if (_gizmo_select(_edit.mouse_pos)) { + // Transform gizmo + if (_transform_gizmo_select(_edit.mouse_pos)) { break; } + // Subgizmos + if (can_select_gizmos) { + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(spatial_editor->get_single_selected_node()); + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + bool intersected_subgizmo = false; + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + + if ((!seg.is_valid())) { + continue; + } + + int subgizmo_id = seg->subgizmos_intersect_ray(camera, _edit.mouse_pos); + if (subgizmo_id != -1) { + ERR_CONTINUE(!se); + if (b->is_shift_pressed()) { + if (se->subgizmos.has(subgizmo_id)) { + se->subgizmos.erase(subgizmo_id); + } else { + se->subgizmos.insert(subgizmo_id, seg->get_subgizmo_transform(subgizmo_id)); + } + } else { + se->subgizmos.clear(); + se->subgizmos.insert(subgizmo_id, seg->get_subgizmo_transform(subgizmo_id)); + } + + if (se->subgizmos.is_empty()) { + se->gizmo = Ref<EditorNode3DGizmo>(); + } else { + se->gizmo = seg; + } + + seg->redraw(); + spatial_editor->update_transform_gizmo(); + intersected_subgizmo = true; + break; + } + } + + if (intersected_subgizmo) { + break; + } + } + clicked = ObjectID(); - clicked_includes_current = false; if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->is_command_pressed()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) { /* HANDLE ROTATION */ @@ -1333,40 +1549,19 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; } - // todo scale - - int gizmo_handle = -1; - - clicked = _select_ray(b->get_position(), b->is_shift_pressed(), clicked_includes_current, &gizmo_handle, b->is_shift_pressed()); + clicked = _select_ray(b->get_position()); //clicking is always deferred to either move or release clicked_wants_append = b->is_shift_pressed(); if (clicked.is_null()) { - if (!clicked_wants_append) { - _clear_selected(); - } - //default to regionselect cursor.region_select = true; cursor.region_begin = b->get_position(); cursor.region_end = b->get_position(); } - if (clicked.is_valid() && gizmo_handle >= 0) { - Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); - if (spa) { - Ref<EditorNode3DGizmo> seg = spa->get_gizmo(); - if (seg.is_valid()) { - _edit.gizmo = seg; - _edit.gizmo_handle = gizmo_handle; - _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle); - break; - } - } - } - surface->update(); } else { if (_edit.gizmo.is_valid()) { @@ -1374,47 +1569,57 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { _edit.gizmo = Ref<EditorNode3DGizmo>(); break; } + if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true); - // Processing was deferred. - clicked = ObjectID(); + _select_clicked(false); } if (cursor.region_select) { - if (!clicked_wants_append) { - _clear_selected(); - } - _select_region(); cursor.region_select = false; surface->update(); } if (_edit.mode != TRANSFORM_NONE) { - static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" }; - undo_redo->create_action(_transform_name[_edit.mode]); + Node3D *selected = spatial_editor->get_single_selected_node(); + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - List<Node *> &selection = editor_selection->get_selected_node_list(); + if (se && se->gizmo.is_valid()) { + Vector<int> ids; + Vector<Transform3D> restore; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + ids.push_back(GE->key()); + restore.push_back(GE->value()); } - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; - } + se->gizmo->commit_subgizmos(ids, restore, false); + spatial_editor->update_transform_gizmo(); + } else { + static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" }; + undo_redo->create_action(_transform_name[_edit.mode]); + + List<Node *> &selection = editor_selection->get_selected_node_list(); + + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } - undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); - undo_redo->add_undo_method(sp, "set_global_transform", se->original); + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (!sel_item) { + continue; + } + + undo_redo->add_do_method(sp, "set_global_transform", sp->get_global_gizmo_transform()); + undo_redo->add_undo_method(sp, "set_global_transform", sel_item->original); + } + undo_redo->commit_action(); } - undo_redo->commit_action(); _edit.mode = TRANSFORM_NONE; set_message(""); } - surface->update(); } @@ -1429,31 +1634,39 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (m.is_valid()) { _edit.mouse_pos = m->get_position(); - if (spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); - if (seg.is_valid()) { - int selected_handle = -1; - - int handle = -1; - Vector3 point; - Vector3 normal; - bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, false); - if (inters && handle != -1) { - selected_handle = handle; + if (spatial_editor->get_single_selected_node()) { + Vector<Ref<Node3DGizmo>> gizmos = spatial_editor->get_single_selected_node()->get_gizmos(); + + Ref<EditorNode3DGizmo> found_gizmo; + int found_handle = -1; + + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; } - if (selected_handle != spatial_editor->get_over_gizmo_handle()) { - spatial_editor->set_over_gizmo_handle(selected_handle); - spatial_editor->get_selected()->update_gizmo(); - if (selected_handle != -1) { - spatial_editor->select_gizmo_highlight_axis(-1); - } + seg->handles_intersect_ray(camera, _edit.mouse_pos, false, found_handle); + + if (found_handle != -1) { + found_gizmo = seg; + break; } } + + if (found_gizmo.is_valid()) { + spatial_editor->select_gizmo_highlight_axis(-1); + } + + if (found_gizmo != spatial_editor->get_current_hover_gizmo() || found_handle != spatial_editor->get_current_hover_gizmo_handle()) { + spatial_editor->set_current_hover_gizmo(found_gizmo); + spatial_editor->set_current_hover_gizmo_handle(found_handle); + spatial_editor->get_single_selected_node()->update_gizmos(); + } } - if (spatial_editor->get_over_gizmo_handle() == -1 && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) { - _gizmo_select(_edit.mouse_pos, true); + if (spatial_editor->get_current_hover_gizmo().is_null() && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) { + _transform_gizmo_select(_edit.mouse_pos, true); } NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); @@ -1477,11 +1690,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } else { const bool movement_threshold_passed = _edit.original_mouse_pos.distance_to(_edit.mouse_pos) > 8 * EDSCALE; if (clicked.is_valid() && movement_threshold_passed) { - if (!clicked_includes_current) { - _select_clicked(clicked_wants_append, true); - // Processing was deferred. - } - _compute_edit(_edit.mouse_pos); clicked = ObjectID(); @@ -1576,8 +1784,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion = Vector3(scale, scale, scale); } - List<Node *> &selection = editor_selection->get_selected_node_list(); - // Disable local transformation for TRANSFORM_VIEW bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); @@ -1590,8 +1796,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Scaling: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1605,44 +1812,22 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D original = se->original; - Transform3D original_local = se->original_local; - Transform3D base = Transform3D(Basis(), _edit.center); - Transform3D t; - Vector3 local_scale; - - if (local_coords) { - Basis g = original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(motion); - - if (_edit.snap || spatial_editor->is_snap_enabled()) { - local_motion.snap(Vector3(snap, snap, snap)); - } - - local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); - - // Prevent scaling to 0 it would break the gizmo - Basis check = original_local.basis; - check.scale(local_scale); - if (check.determinant() != 0) { - // Apply scale - sp->set_scale(local_scale); + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original * xform, xform, motion, snap, local_coords); + if (!local_coords) { + new_xform = se->original.affine_inverse() * new_xform; + } + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); } - } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - motion.snap(Vector3(snap, snap, snap)); - } - - Transform3D r; - r.basis.scale(motion + Vector3(1, 1, 1)); - t = base * (r * (base.inverse() * original)); - - // Apply scale - sp->set_global_transform(t); + Transform3D new_xform = _compute_transform(TRANSFORM_SCALE, se->original, se->original_local, motion, snap, local_coords); + _transform_gizmo_apply(se->sp, new_xform, local_coords); } } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -1699,8 +1884,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } - List<Node *> &selection = editor_selection->get_selected_node_list(); - // Disable local transformation for TRANSFORM_VIEW bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); @@ -1712,8 +1895,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(TTR("Translating: ") + "(" + String::num(motion_snapped.x, snap_step_decimals) + ", " + String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1727,30 +1911,20 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D original = se->original; - Transform3D t; - - if (local_coords) { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - Basis g = original.basis.orthonormalized(); - Vector3 local_motion = g.inverse().xform(motion); - local_motion.snap(Vector3(snap, snap, snap)); - - motion = g.xform(local_motion); + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original * xform, xform, motion, snap, local_coords); + new_xform = se->original.affine_inverse() * new_xform; + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); } - } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { - motion.snap(Vector3(snap, snap, snap)); - } + Transform3D new_xform = _compute_transform(TRANSFORM_TRANSLATE, se->original, se->original_local, motion, snap, local_coords); + _transform_gizmo_apply(se->sp, new_xform, false); } - - // Apply translation - t = original; - t.origin += motion; - sp->set_global_transform(t); } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -1804,12 +1978,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { set_message(vformat(TTR("Rotating %s degrees."), String::num(angle, snap_step_decimals))); angle = Math::deg2rad(angle); - List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -1823,32 +1996,24 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform3D t; - - if (local_coords) { - Transform3D original_local = se->original_local; - Basis rot = Basis(axis, angle); - - t.basis = original_local.get_basis().orthonormalized() * rot; - t.origin = original_local.origin; - - // Apply rotation - sp->set_transform(t); - sp->set_scale(original_local.basis.get_scale()); // re-apply original scale + Vector3 compute_axis = local_coords ? axis : plane.normal; + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + Transform3D xform = GE->get(); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original * xform, xform, compute_axis, angle, local_coords); + if (!local_coords) { + new_xform = se->original.affine_inverse() * new_xform; + } + se->gizmo->set_subgizmo_transform(GE->key(), new_xform); + } } else { - Transform3D original = se->original; - Transform3D r; - Transform3D base = Transform3D(Basis(), _edit.center); - - r.basis.rotate(plane.normal, angle); - t = base * r * base.inverse() * original; - - // Apply rotation - sp->set_global_transform(t); + Transform3D new_xform = _compute_transform(TRANSFORM_ROTATE, se->original, se->original_local, compute_axis, angle, local_coords); + _transform_gizmo_apply(se->sp, new_xform, local_coords); } } + spatial_editor->update_transform_gizmo(); surface->update(); } break; @@ -2047,13 +2212,13 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } - spatial_editor->emit_signal("transform_key_request", sp, "", sp->get_transform()); + spatial_editor->emit_signal(SNAME("transform_key_request"), sp, "", sp->get_transform()); } set_message(TTR("Animation Key Inserted.")); @@ -2069,7 +2234,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (k->get_keycode() == KEY_SPACE) { if (!k->is_pressed()) { - emit_signal("toggle_maximize_view", this); + emit_signal(SNAME("toggle_maximize_view"), this); } } } @@ -2423,12 +2588,12 @@ void Node3DEditorViewport::_notification(int p_what) { } else { set_freelook_active(false); } - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); rotation_control->set_visible(EditorSettings::get_singleton()->get("editors/3d/navigation/show_viewport_rotation_gizmo")); } if (p_what == NOTIFICATION_RESIZED) { - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); } if (p_what == NOTIFICATION_PROCESS) { @@ -2446,7 +2611,7 @@ void Node3DEditorViewport::_notification(int p_what) { Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root(); if (previewing_cinema && scene_root != nullptr) { - Camera3D *cam = scene_root->get_viewport()->get_camera(); + Camera3D *cam = scene_root->get_viewport()->get_camera_3d(); if (cam != nullptr && cam != previewing) { //then switch the viewport's camera to the scene's viewport camera if (previewing != nullptr) { @@ -2641,31 +2806,31 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_THEME_CHANGED) { - view_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); - preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons")); + view_menu->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + preview_camera->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); - view_menu->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + view_menu->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + view_menu->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - preview_camera->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + preview_camera->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("hover", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("pressed", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); - frame_time_gradient->set_color(0, get_theme_color("success_color", "Editor")); - frame_time_gradient->set_color(1, get_theme_color("warning_color", "Editor")); - frame_time_gradient->set_color(2, get_theme_color("error_color", "Editor")); + frame_time_gradient->set_color(0, get_theme_color(SNAME("success_color"), SNAME("Editor"))); + frame_time_gradient->set_color(1, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); + frame_time_gradient->set_color(2, get_theme_color(SNAME("error_color"), SNAME("Editor"))); - info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - cpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - gpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); - locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles")); + info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + gpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); + locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("Information3dViewport"), SNAME("EditorStyles"))); } } @@ -2706,7 +2871,7 @@ void Node3DEditorViewport::_draw() { if (surface->has_focus()) { Size2 size = surface->get_size(); Rect2 r = Rect2(Point2(), size); - get_theme_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r); + get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles"))->draw(surface->get_canvas_item(), r); } if (cursor.region_select) { @@ -2714,11 +2879,11 @@ void Node3DEditorViewport::_draw() { surface->draw_rect( selection_rect, - get_theme_color("box_selection_fill_color", "Editor")); + get_theme_color(SNAME("box_selection_fill_color"), SNAME("Editor"))); surface->draw_rect( selection_rect, - get_theme_color("box_selection_stroke_color", "Editor"), + get_theme_color(SNAME("box_selection_stroke_color"), SNAME("Editor")), false, Math::round(EDSCALE)); } @@ -2726,8 +2891,8 @@ void Node3DEditorViewport::_draw() { RID ci = surface->get_canvas_item(); if (message_time > 0) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); Point2 msgpos = Point2(5, get_size().y - 20); font->draw_string(ci, msgpos + Point2(1, 1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); font->draw_string(ci, msgpos + Point2(-1, -1), message, HALIGN_LEFT, -1, font_size, Color(0, 0, 0, 0.8)); @@ -2740,16 +2905,16 @@ void Node3DEditorViewport::_draw() { Color handle_color; switch (_edit.plane) { case TRANSFORM_X_AXIS: - handle_color = get_theme_color("axis_x_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case TRANSFORM_Y_AXIS: - handle_color = get_theme_color("axis_y_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case TRANSFORM_Z_AXIS: - handle_color = get_theme_color("axis_z_color", "Editor"); + handle_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: - handle_color = get_theme_color("accent_color", "Editor"); + handle_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); break; } handle_color = handle_color.from_hsv(handle_color.get_h(), 0.25, 1.0, 1); @@ -2804,9 +2969,9 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, 1.0 - logscale_t, - get_theme_icon("ViewportSpeed", "EditorIcons"), - get_theme_font("font", "Label"), - get_theme_font_size("font_size", "Label"), + get_theme_icon(SNAME("ViewportSpeed"), SNAME("EditorIcons")), + get_theme_font(SNAME("font"), SNAME("Label")), + get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision))); } @@ -2826,9 +2991,9 @@ void Node3DEditorViewport::_draw() { draw_indicator_bar( *surface, logscale_t, - get_theme_icon("ViewportZoom", "EditorIcons"), - get_theme_font("font", "Label"), - get_theme_font_size("font_size", "Label"), + get_theme_icon(SNAME("ViewportZoom"), SNAME("EditorIcons")), + get_theme_font(SNAME("font"), SNAME("Label")), + get_theme_font_size(SNAME("font_size"), SNAME("Label")), vformat("%s u", String::num(cursor.distance).pad_decimals(precision))); } } @@ -2911,8 +3076,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { undo_redo->create_action(TTR("Align Transform with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -2947,8 +3112,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Align Rotation with View")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -2982,7 +3147,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false); orthogonal = false; auto_orthogonal = false; - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); _update_name(); } break; @@ -2991,7 +3156,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true); orthogonal = true; auto_orthogonal = false; - call_deferred("update_transform_gizmo_view"); + call_deferred(SNAME("update_transform_gizmo_view")); _update_name(); } break; @@ -3316,8 +3481,7 @@ void Node3DEditorViewport::_selection_result_pressed(int p_result) { clicked = selection_results[p_result].item->get_instance_id(); if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); - clicked = ObjectID(); + _select_clicked(spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT); } } @@ -3344,7 +3508,7 @@ void Node3DEditorViewport::update_transform_gizmo_view() { Transform3D camera_xform = camera->get_transform(); - if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { + if (xform.origin.is_equal_approx(camera_xform.origin)) { for (int i = 0; i < 3; i++) { RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); @@ -3601,8 +3765,8 @@ void Node3DEditorViewport::focus_selection() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -3612,6 +3776,13 @@ void Node3DEditorViewport::focus_selection() { continue; } + if (se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *GE = se->subgizmos.front(); GE; GE = GE->next()) { + center += se->gizmo->get_subgizmo_transform(GE->key()).origin; + count++; + } + } + center += sp->get_global_gizmo_transform().origin; count++; } @@ -3635,58 +3806,16 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 world_ray = _get_ray(p_pos); Vector3 world_pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world_3d()->get_scenario()); - Set<Ref<EditorNode3DGizmo>> found_gizmos; - - float closest_dist = MAX_DISTANCE; - Vector3 point = world_pos + world_ray * MAX_DISTANCE; - Vector3 normal = Vector3(0.0, 0.0, 0.0); - - for (int i = 0; i < instances.size(); i++) { - MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i])); - - if (!mesh_instance) { - continue; - } - - Ref<EditorNode3DGizmo> seg = mesh_instance->get_gizmo(); - if ((!seg.is_valid()) || found_gizmos.has(seg)) { - continue; - } - - found_gizmos.insert(seg); - - Vector3 hit_point; - Vector3 hit_normal; - bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, nullptr, false); - - if (!inters) { - continue; - } - - float dist = world_pos.distance_to(hit_point); - - if (dist < 0) { - continue; - } + PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state(); + PhysicsDirectSpaceState3D::RayResult result; - if (dist < closest_dist) { - closest_dist = dist; - point = hit_point; - normal = hit_normal; - } - } - Vector3 offset = Vector3(); - for (int i = 0; i < 3; i++) { - if (normal[i] > 0.0) { - offset[i] = (preview_bounds->get_size()[i] - (preview_bounds->get_size()[i] + preview_bounds->get_position()[i])); - } else if (normal[i] < 0.0) { - offset[i] = -(preview_bounds->get_size()[i] + preview_bounds->get_position()[i]); - } + if (ss->intersect_ray(world_pos, world_pos + world_ray * MAX_DISTANCE, result)) { + point = result.position; } - return point + offset; + + return point; } AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_top_level_transform) { @@ -3978,9 +4107,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito _edit.mode = TRANSFORM_NONE; _edit.plane = TRANSFORM_VIEW; - _edit.edited_gizmo = 0; _edit.snap = true; - _edit.gizmo_handle = 0; + _edit.gizmo_handle = -1; index = p_index; editor = p_editor; @@ -3988,7 +4116,6 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito editor_selection = editor->get_editor_selection(); undo_redo = editor->get_undo_redo(); - clicked_includes_current = false; orthogonal = false; auto_orthogonal = false; lock_rotation = false; @@ -4011,7 +4138,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito surface->set_anchors_and_offsets_preset(Control::PRESET_WIDE); surface->set_clip_contents(true); camera = memnew(Camera3D); - camera->set_disable_gizmo(true); + camera->set_disable_gizmos(true); camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER) | (1 << MISC_TOOL_LAYER)); viewport->add_child(camera); camera->make_current(); @@ -4140,6 +4267,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito preview_camera = memnew(CheckBox); preview_camera->set_text(TTR("Preview")); + preview_camera->set_shortcut(ED_SHORTCUT("spatial_editor/toggle_camera_preview", TTR("Toggle Camera Preview"), KEY_MASK_CMD | KEY_P)); vbox->add_child(preview_camera); preview_camera->set_h_size_flags(0); preview_camera->hide(); @@ -4257,8 +4385,8 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { if (mb->is_pressed()) { Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4303,8 +4431,8 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) { Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4343,18 +4471,18 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer"); - Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer"); + Ref<Texture2D> h_grabber = get_theme_icon(SNAME("grabber"), SNAME("HSplitContainer")); + Ref<Texture2D> v_grabber = get_theme_icon(SNAME("grabber"), SNAME("VSplitContainer")); - Ref<Texture2D> hdiag_grabber = get_theme_icon("GuiViewportHdiagsplitter", "EditorIcons"); - Ref<Texture2D> vdiag_grabber = get_theme_icon("GuiViewportVdiagsplitter", "EditorIcons"); - Ref<Texture2D> vh_grabber = get_theme_icon("GuiViewportVhsplitter", "EditorIcons"); + Ref<Texture2D> hdiag_grabber = get_theme_icon(SNAME("GuiViewportHdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vdiag_grabber = get_theme_icon(SNAME("GuiViewportVdiagsplitter"), SNAME("EditorIcons")); + Ref<Texture2D> vh_grabber = get_theme_icon(SNAME("GuiViewportVhsplitter"), SNAME("EditorIcons")); Vector2 size = get_size(); - int h_sep = get_theme_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4440,9 +4568,9 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } return; } - int h_sep = get_theme_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant(SNAME("separation"), SNAME("HSplitContainer")); - int v_sep = get_theme_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant(SNAME("separation"), SNAME("VSplitContainer")); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4580,43 +4708,54 @@ void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { } void Node3DEditor::update_transform_gizmo() { - List<Node *> &selection = editor_selection->get_selected_node_list(); - AABB center; - bool first = true; + int count = 0; + bool local_gizmo_coords = are_local_coords_enabled(); + Vector3 gizmo_center; Basis gizmo_basis; - bool local_gizmo_coords = are_local_coords_enabled(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); - if (!sp) { - continue; - } + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; - Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); - if (!se) { - continue; + if (se && se->gizmo.is_valid()) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + Transform3D xf = se->sp->get_global_transform() * se->gizmo->get_subgizmo_transform(E->key()); + gizmo_center += xf.origin; + if (count == 0 && local_gizmo_coords) { + gizmo_basis = xf.basis; + gizmo_basis.orthonormalize(); + } + count++; } + } else { + List<Node *> &selection = editor_selection->get_selected_node_list(); + for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { + Node3D *sp = Object::cast_to<Node3D>(E->get()); + if (!sp) { + continue; + } - Transform3D xf = se->sp->get_global_gizmo_transform(); + if (sp->has_meta("_edit_lock_")) { + continue; + } - if (first) { - center.position = xf.origin; - first = false; - if (local_gizmo_coords) { + Node3DEditorSelectedItem *sel_item = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (!sel_item) { + continue; + } + + Transform3D xf = sel_item->sp->get_global_transform(); + gizmo_center += xf.origin; + if (count == 0 && local_gizmo_coords) { gizmo_basis = xf.basis; gizmo_basis.orthonormalize(); } - } else { - center.expand_to(xf.origin); - gizmo_basis = Basis(); + count++; } } - Vector3 pcenter = center.position + center.size * 0.5; - gizmo.visible = !first; - gizmo.transform.origin = pcenter; - gizmo.transform.basis = gizmo_basis; + gizmo.visible = count > 0; + gizmo.transform.origin = (count > 0) ? gizmo_center / count : Vector3(); + gizmo.transform.basis = (count == 1) ? gizmo_basis : Basis(); for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { viewports[i]->update_transform_gizmo_view(); @@ -4627,7 +4766,7 @@ void _update_all_gizmos(Node *p_node) { for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { Node3D *spatial_node = Object::cast_to<Node3D>(p_node->get_child(i)); if (spatial_node) { - spatial_node->update_gizmo(); + spatial_node->update_gizmos(); } _update_all_gizmos(p_node->get_child(i)); @@ -4661,7 +4800,9 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { RS::get_singleton()->instance_geometry_set_cast_shadows_setting( si->sbox_instance, RS::SHADOW_CASTING_SETTING_OFF); - RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::MISC_TOOL_LAYER); + // Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting. + // It's still possible to approximately guess what is selected by looking at the manipulation gizmo position. + RS::get_singleton()->instance_set_layer_mask(si->sbox_instance, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER); RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); si->sbox_instance_xray = RenderingServer::get_singleton()->instance_create2( selection_box_xray->get_rid(), @@ -4669,7 +4810,9 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { RS::get_singleton()->instance_geometry_set_cast_shadows_setting( si->sbox_instance_xray, RS::SHADOW_CASTING_SETTING_OFF); - RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::MISC_TOOL_LAYER); + // Use the Edit layer to hide the selection box when View Gizmos is disabled, since it is a bit distracting. + // It's still possible to approximately guess what is selected by looking at the manipulation gizmo position. + RS::get_singleton()->instance_set_layer_mask(si->sbox_instance_xray, 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER); RS::get_singleton()->instance_geometry_set_flag(si->sbox_instance, RS::INSTANCE_FLAG_IGNORE_OCCLUSION_CULLING, true); return si; @@ -4946,22 +5089,38 @@ void Node3DEditor::set_state(const Dictionary &p_state) { void Node3DEditor::edit(Node3D *p_spatial) { if (p_spatial != selected) { if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); - if (seg.is_valid()) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } seg->set_selected(false); - selected->update_gizmo(); } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); + } + + selected->update_gizmos(); } selected = p_spatial; - over_gizmo_handle = -1; + current_hover_gizmo = Ref<EditorNode3DGizmo>(); + current_hover_gizmo_handle = -1; if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); - if (seg.is_valid()) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } seg->set_selected(true); - selected->update_gizmo(); } + selected->update_gizmos(); } } } @@ -4999,8 +5158,8 @@ void Node3DEditor::_xform_dialog_action() { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (!sp) { continue; } @@ -5060,13 +5219,13 @@ void Node3DEditor::_menu_gizmo_toggled(int p_option) { const int state = gizmos_menu->get_item_state(idx); switch (state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon(SNAME("visibility_hidden"))); break; } @@ -5236,8 +5395,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5261,8 +5420,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5286,8 +5445,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5310,8 +5469,8 @@ void Node3DEditor::_menu_item_pressed(int p_option) { undo_redo->create_action(TTR("Ungroup Selected")); List<Node *> &selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *spatial = Object::cast_to<Node3D>(E); if (!spatial || !spatial->is_inside_tree()) { continue; } @@ -5353,13 +5512,13 @@ void Node3DEditor::_init_indicators() { Color origin_color; switch (i) { case 0: - origin_color = get_theme_color("axis_x_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case 1: - origin_color = get_theme_color("axis_y_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case 2: - origin_color = get_theme_color("axis_z_color", "Editor"); + origin_color = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: origin_color = Color(); @@ -5387,35 +5546,37 @@ void Node3DEditor::_init_indicators() { } Ref<Shader> grid_shader = memnew(Shader); - grid_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded; \n" - "uniform bool orthogonal; \n" - "uniform float grid_size; \n" - "\n" - "void vertex() { \n" - " // From FLAG_SRGB_VERTEX_COLOR \n" - " if (!OUTPUT_IS_SRGB) { \n" - " COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = COLOR.rgb; \n" - " vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; \n" - " float angle_fade = abs(dot(dir, NORMAL)); \n" - " angle_fade = smoothstep(0.05, 0.2, angle_fade); \n" - " \n" - " vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; \n" - " vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; \n" - " vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; \n" - " vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); \n" - " float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); \n" - " dist_fade = smoothstep(0.02, 0.3, dist_fade); \n" - " \n" - " ALPHA = COLOR.a * dist_fade * angle_fade; \n" - "}"); + grid_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded; + +uniform bool orthogonal; +uniform float grid_size; + +void vertex() { + // From FLAG_SRGB_VERTEX_COLOR. + if (!OUTPUT_IS_SRGB) { + COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); + } +} + +void fragment() { + ALBEDO = COLOR.rgb; + vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; + float angle_fade = abs(dot(dir, NORMAL)); + angle_fade = smoothstep(0.05, 0.2, angle_fade); + + vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; + vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; + vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; + vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); + float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); + dist_fade = smoothstep(0.02, 0.3, dist_fade); + + ALPHA = COLOR.a * dist_fade * angle_fade; +} +)"); for (int i = 0; i < 3; i++) { grid_mat[i].instantiate(); @@ -5454,13 +5615,13 @@ void Node3DEditor::_init_indicators() { Color col; switch (i) { case 0: - col = get_theme_color("axis_x_color", "Editor"); + col = get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); break; case 1: - col = get_theme_color("axis_y_color", "Editor"); + col = get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); break; case 2: - col = get_theme_color("axis_z_color", "Editor"); + col = get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); break; default: col = Color(); @@ -5626,33 +5787,35 @@ void Node3DEditor::_init_indicators() { Ref<Shader> rotate_shader = memnew(Shader); - rotate_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " vec3 n = mv * VERTEX; \n" - " float orientation = dot(vec3(0,0,-1),n); \n" - " if (orientation <= 0.005) { \n" - " VERTEX += NORMAL*0.02; \n" - " } \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + rotate_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + vec3 n = mv * VERTEX; + float orientation = dot(vec3(0, 0, -1), n); + if (orientation <= 0.005) { + VERTEX += NORMAL * 0.02; + } +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial); rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX); @@ -5672,34 +5835,36 @@ void Node3DEditor::_init_indicators() { Ref<ShaderMaterial> border_mat = rotate_mat->duplicate(); Ref<Shader> border_shader = memnew(Shader); - border_shader->set_code( - "\n" - "shader_type spatial; \n" - "render_mode unshaded, depth_test_disabled; \n" - "uniform vec4 albedo; \n" - "\n" - "mat3 orthonormalize(mat3 m) { \n" - " vec3 x = normalize(m[0]); \n" - " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n" - " vec3 z = m[2] - x * dot(x, m[2]); \n" - " z = normalize(z - y * (dot(y,m[2]))); \n" - " return mat3(x,y,z); \n" - "} \n" - "\n" - "void vertex() { \n" - " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n" - " mv = inverse(mv); \n" - " VERTEX += NORMAL*0.008; \n" - " vec3 camera_dir_local = mv * vec3(0,0,1); \n" - " vec3 camera_up_local = mv * vec3(0,1,0); \n" - " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n" - " VERTEX = rotation_matrix * VERTEX; \n" - "} \n" - "\n" - "void fragment() { \n" - " ALBEDO = albedo.rgb; \n" - " ALPHA = albedo.a; \n" - "}"); + border_shader->set_code(R"( +shader_type spatial; + +render_mode unshaded, depth_test_disabled; + +uniform vec4 albedo; + +mat3 orthonormalize(mat3 m) { + vec3 x = normalize(m[0]); + vec3 y = normalize(m[1] - x * dot(x, m[1])); + vec3 z = m[2] - x * dot(x, m[2]); + z = normalize(z - y * (dot(y,m[2]))); + return mat3(x,y,z); +} + +void vertex() { + mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); + mv = inverse(mv); + VERTEX += NORMAL*0.008; + vec3 camera_dir_local = mv * vec3(0,0,1); + vec3 camera_up_local = mv * vec3(0,1,0); + mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); + VERTEX = rotation_matrix * VERTEX; +} + +void fragment() { + ALBEDO = albedo.rgb; + ALPHA = albedo.a; +} +)"); border_mat->set_shader(border_shader); border_mat->set_shader_param("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); @@ -5819,13 +5984,13 @@ void Node3DEditor::_update_gizmos_menu() { TTR("Click to toggle between visibility states.\n\nOpen eye: Gizmo is visible.\nClosed eye: Gizmo is hidden.\nHalf-open eye: Gizmo is also visible through opaque surfaces (\"x-ray\").")); switch (plugin_state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_hidden"))); break; } } @@ -5840,13 +6005,13 @@ void Node3DEditor::_update_gizmos_menu_theme() { const int idx = gizmos_menu->get_item_index(i); switch (plugin_state) { case EditorNode3DGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_visible"))); break; case EditorNode3DGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_xray"))); break; case EditorNode3DGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon(SNAME("visibility_hidden"))); break; } } @@ -6026,13 +6191,27 @@ void Node3DEditor::update_grid() { _init_grid(); } -bool Node3DEditor::is_any_freelook_active() const { - for (unsigned int i = 0; i < VIEWPORTS_COUNT; ++i) { - if (viewports[i]->is_freelook_active()) { - return true; +void Node3DEditor::_selection_changed() { + _refresh_menu_icons(); + if (selected && editor_selection->get_selected_node_list().size() != 1) { + Vector<Ref<Node3DGizmo>> gizmos = selected->get_gizmos(); + for (int i = 0; i < gizmos.size(); i++) { + Ref<EditorNode3DGizmo> seg = gizmos[i]; + if (!seg.is_valid()) { + continue; + } + seg->set_selected(false); + } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); } + selected->update_gizmos(); + selected = nullptr; } - return false; + update_transform_gizmo(); } void Node3DEditor::_refresh_menu_icons() { @@ -6045,14 +6224,14 @@ void Node3DEditor::_refresh_menu_icons() { all_locked = false; all_grouped = false; } else { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_lock_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_lock_")) { all_locked = false; break; } } - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_group_")) { + for (Node *E : selection) { + if (Object::cast_to<Node3D>(E) && !Object::cast_to<Node3D>(E)->has_meta("_edit_group_")) { all_grouped = false; break; } @@ -6105,8 +6284,8 @@ void Node3DEditor::snap_selected_nodes_to_floor() { List<Node *> &selection = editor_selection->get_selected_node_list(); Dictionary snap_data; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); + for (Node *E : selection) { + Node3D *sp = Object::cast_to<Node3D>(E); if (sp) { Vector3 from = Vector3(); Vector3 position_offset = Vector3(); @@ -6253,7 +6432,7 @@ void Node3DEditor::_add_sun_to_scene(bool p_already_added_environment) { ERR_FAIL_COND(!base); Node *new_sun = preview_sun->duplicate(); - undo_redo->create_action("Add Preview Sun to Scene"); + undo_redo->create_action(TTR("Add Preview Sun to Scene")); undo_redo->add_do_method(base, "add_child", new_sun); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -6283,7 +6462,7 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { WorldEnvironment *new_env = memnew(WorldEnvironment); new_env->set_environment(preview_environment->get_environment()->duplicate(true)); - undo_redo->create_action("Add Preview Environment to Scene"); + undo_redo->create_action(TTR("Add Preview Environment to Scene")); undo_redo->add_do_method(base, "add_child", new_env); // Move to the beginning of the scene tree since more "global" nodes // generally look better when placed at the top. @@ -6294,93 +6473,113 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { undo_redo->commit_action(); } +void Node3DEditor::_update_theme() { + tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + + tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); + tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels2Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon(SNAME("Panels3"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons"))); + view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons"))); + + sun_button->set_icon(get_theme_icon(SNAME("DirectionalLight3D"), SNAME("EditorIcons"))); + environ_button->set_icon(get_theme_icon(SNAME("WorldEnvironment"), SNAME("EditorIcons"))); + sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + + sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); +} + void Node3DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - - tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon("Camera3D", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons")); - - _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - - _refresh_menu_icons(); - - get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed)); - get_tree()->connect("node_added", callable_mp(this, &Node3DEditor::_node_added)); - EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); - editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); - - editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false)); - editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true)); - - sun_button->set_icon(get_theme_icon("DirectionalLight3D", "EditorIcons")); - environ_button->set_icon(get_theme_icon("WorldEnvironment", "EditorIcons")); - sun_environ_settings->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons")); + switch (p_what) { + case NOTIFICATION_READY: { + _menu_item_pressed(MENU_VIEW_USE_1_VIEWPORT); - _update_preview_environment(); - sun_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - environ_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); + _refresh_menu_icons(); - sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); - environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); - } else if (p_what == NOTIFICATION_ENTER_TREE) { - _register_all_gizmos(); - _update_gizmos_menu(); - _init_indicators(); - } else if (p_what == NOTIFICATION_THEME_CHANGED) { - _update_gizmos_menu_theme(); - sun_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - environ_title->add_theme_font_override("font", get_theme_font("title_font", "Window")); - } else if (p_what == NOTIFICATION_EXIT_TREE) { - _finish_indicators(); - } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon("ListSelect", "EditorIcons")); - tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon("Lock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon("Unlock", "EditorIcons")); - tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon("Group", "EditorIcons")); - tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon("Ungroup", "EditorIcons")); - - tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon("Object", "EditorIcons")); - tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon("Snap", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_theme_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_theme_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon("Panels4", "EditorIcons")); - - // Update grid color by rebuilding grid. - _finish_grid(); - _init_grid(); - } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { - EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); + get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed)); + get_tree()->connect("node_added", callable_mp(this, &Node3DEditor::_node_added)); + EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &Node3DEditor::_refresh_menu_icons)); + editor_selection->connect("selection_changed", callable_mp(this, &Node3DEditor::_selection_changed)); + + editor->connect("stop_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(false)); + editor->connect("play_pressed", callable_mp(this, &Node3DEditor::_update_camera_override_button), make_binds(true)); - debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false); + _update_preview_environment(); + + sun_state->set_custom_minimum_size(sun_vb->get_combined_minimum_size()); + environ_state->set_custom_minimum_size(environ_vb->get_combined_minimum_size()); + } break; + case NOTIFICATION_ENTER_TREE: { + _update_theme(); + _register_all_gizmos(); + _update_gizmos_menu(); + _init_indicators(); + } break; + case NOTIFICATION_EXIT_TREE: { + _finish_indicators(); + } break; + case NOTIFICATION_THEME_CHANGED: { + _update_theme(); + _update_gizmos_menu_theme(); + sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + environ_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window"))); + } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + // Update grid color by rebuilding grid. + _finish_grid(); + _init_grid(); + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { + EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); + + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false); + } + } break; + } +} + +bool Node3DEditor::is_subgizmo_selected(int p_id) { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + if (se) { + return se->subgizmos.has(p_id); + } + return false; +} + +bool Node3DEditor::is_current_selected_gizmo(const EditorNode3DGizmo *p_gizmo) { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + if (se) { + return se->gizmo == p_gizmo; + } + return false; +} + +Vector<int> Node3DEditor::get_subgizmo_selection() { + Node3DEditorSelectedItem *se = selected ? editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected) : nullptr; + + Vector<int> ret; + if (se) { + for (Map<int, Transform3D>::Element *E = se->subgizmos.front(); E; E = E->next()) { + ret.push_back(E->key()); } } + return ret; } void Node3DEditor::add_control_to_menu_panel(Control *p_control) { @@ -6410,23 +6609,43 @@ void Node3DEditor::_request_gizmo(Object *p_obj) { if (!sp) { return; } - if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_ancestor_of(sp)))) { - Ref<EditorNode3DGizmo> seg; + bool is_selected = (sp == selected); + + if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_ancestor_of(sp)))) { for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) { - seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp); + Ref<EditorNode3DGizmo> seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp); if (seg.is_valid()) { - sp->set_gizmo(seg); + sp->add_gizmo(seg); - if (sp == selected) { - seg->set_selected(true); - selected->update_gizmo(); + if (is_selected != seg->is_selected()) { + seg->set_selected(is_selected); } - - break; } } + sp->update_gizmos(); + } +} + +void Node3DEditor::_clear_subgizmo_selection(Object *p_obj) { + Node3D *sp = nullptr; + if (p_obj) { + sp = Object::cast_to<Node3D>(p_obj); + } else { + sp = selected; + } + + if (!sp) { + return; + } + + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); + if (se) { + se->subgizmos.clear(); + se->gizmo.unref(); + sp->update_gizmos(); + update_transform_gizmo(); } } @@ -6515,7 +6734,13 @@ void Node3DEditor::_node_removed(Node *p_node) { } if (p_node == selected) { + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(selected); + if (se) { + se->gizmo.unref(); + se->subgizmos.clear(); + } selected = nullptr; + update_transform_gizmo(); } } @@ -6553,6 +6778,7 @@ void Node3DEditor::_bind_methods() { ClassDB::bind_method("_unhandled_key_input", &Node3DEditor::_unhandled_key_input); ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data); ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo); + ClassDB::bind_method("_clear_subgizmo_selection", &Node3DEditor::_clear_subgizmo_selection); ClassDB::bind_method("_refresh_menu_icons", &Node3DEditor::_refresh_menu_icons); ADD_SIGNAL(MethodInfo("transform_key_request")); @@ -6768,8 +6994,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q)); tool_button[TOOL_MODE_SELECT]->set_shortcut_context(this); - tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Show list of all nodes at position clicked, including locked.")); - + tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate selected node around pivot.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.")); hbc_menu->add_child(memnew(VSeparator)); tool_button[TOOL_MODE_MOVE] = memnew(Button); @@ -7129,7 +7354,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01")); EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true); - over_gizmo_handle = -1; + current_hover_gizmo_handle = -1; { //sun popup @@ -7160,9 +7385,21 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { sun_direction->connect("draw", callable_mp(this, &Node3DEditor::_sun_direction_draw)); sun_direction->set_default_cursor_shape(CURSOR_MOVE); - String sun_dir_shader_code = "shader_type canvas_item; uniform vec3 sun_direction; uniform vec3 sun_color; void fragment() { vec3 n; n.xy = UV * 2.0 - 1.0; n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); COLOR.rgb = dot(n,sun_direction) * sun_color; COLOR.a = 1.0 - smoothstep(0.99,1.0,length(n.xy)); }"; sun_direction_shader.instantiate(); - sun_direction_shader->set_code(sun_dir_shader_code); + sun_direction_shader->set_code(R"( +shader_type canvas_item; + +uniform vec3 sun_direction; +uniform vec3 sun_color; + +void fragment() { + vec3 n; + n.xy = UV * 2.0 - 1.0; + n.z = sqrt(max(0.0, 1.0 - dot(n.xy, n.xy))); + COLOR.rgb = dot(n, sun_direction) * sun_color; + COLOR.a = 1.0 - smoothstep(0.99, 1.0, length(n.xy)); +} +)"); sun_direction_material.instantiate(); sun_direction_material->set_shader(sun_direction_shader); sun_direction_material->set_shader_param("sun_direction", Vector3(0, 0, 1)); @@ -7431,303 +7668,3 @@ Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) { Node3DEditorPlugin::~Node3DEditorPlugin() { } - -void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); - - Vector<Ref<StandardMaterial3D>> mats; - - for (int i = 0; i < 4; i++) { - bool selected = i % 2 == 1; - bool instantiated = i < 2; - - Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - Color color = instantiated ? instantiated_color : p_color; - - if (!selected) { - color.a *= 0.3; - } - - material->set_albedo(color); - material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1); - material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); - - if (p_use_vertex_color) { - material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - } - - if (p_billboard) { - material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - } - - if (p_on_top && selected) { - material->set_on_top_of_alpha(); - } - - mats.push_back(material); - } - - materials[p_name] = mats; -} - -void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); - - Vector<Ref<StandardMaterial3D>> icons; - - for (int i = 0; i < 4; i++) { - bool selected = i % 2 == 1; - bool instantiated = i < 2; - - Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - Color color = instantiated ? instantiated_color : p_albedo; - - if (!selected) { - color.a *= 0.85; - } - - icon->set_albedo(color); - - icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED); - icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); - icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture); - icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true); - icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN); - - if (p_on_top && selected) { - icon->set_on_top_of_alpha(); - } - - icons.push_back(icon); - } - - materials[p_name] = icons; -} - -void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref<Texture2D> &p_icon) { - Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - - handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); - handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); - Ref<Texture2D> handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon("Editor3DHandle", "EditorIcons"); - handle_material->set_point_size(handle_t->get_width()); - handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); - handle_material->set_albedo(Color(1, 1, 1)); - handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); - handle_material->set_on_top_of_alpha(); - if (p_billboard) { - handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); - handle_material->set_on_top_of_alpha(); - } - handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); - - materials[p_name] = Vector<Ref<StandardMaterial3D>>(); - materials[p_name].push_back(handle_material); -} - -void EditorNode3DGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { - materials[p_name] = Vector<Ref<StandardMaterial3D>>(); - materials[p_name].push_back(p_material); -} - -Ref<StandardMaterial3D> EditorNode3DGizmoPlugin::get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo) { - ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>()); - ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>()); - - if (p_gizmo.is_null() || materials[p_name].size() == 1) { - return materials[p_name][0]; - } - - int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); - - Ref<StandardMaterial3D> mat = materials[p_name][index]; - - if (current_state == ON_TOP && p_gizmo->is_selected()) { - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); - } else { - mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); - } - - return mat; -} - -String EditorNode3DGizmoPlugin::get_gizmo_name() const { - if (get_script_instance() && get_script_instance()->has_method("_get_gizmo_name")) { - return get_script_instance()->call("_get_gizmo_name"); - } - return TTR("Nameless gizmo"); -} - -int EditorNode3DGizmoPlugin::get_priority() const { - if (get_script_instance() && get_script_instance()->has_method("_get_priority")) { - return get_script_instance()->call("_get_priority"); - } - return 0; -} - -Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::get_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("get_gizmo")) { - return get_script_instance()->call("get_gizmo", p_spatial); - } - - Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial); - - if (ref.is_null()) { - return ref; - } - - ref->set_plugin(this); - ref->set_spatial_node(p_spatial); - ref->set_hidden(current_state == HIDDEN); - - current_gizmos.push_back(ref.ptr()); - return ref; -} - -void EditorNode3DGizmoPlugin::_bind_methods() { -#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorNode3DGizmo") - - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_has_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); - BIND_VMETHOD(MethodInfo(GIZMO_REF, "_create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Node3D"))); - - ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); - ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); - - ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material, DEFVAL(Ref<EditorNode3DGizmo>())); - - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_gizmo_name")); - BIND_VMETHOD(MethodInfo(Variant::INT, "_get_priority")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_can_be_hidden")); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_selectable_when_hidden")); - - BIND_VMETHOD(MethodInfo("_redraw", GIZMO_REF)); - BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_handle_name", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); - - MethodInfo hvget(Variant::NIL, "_get_handle_value", GIZMO_REF, PropertyInfo(Variant::INT, "index")); - hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; - BIND_VMETHOD(hvget); - - BIND_VMETHOD(MethodInfo("_set_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); - MethodInfo cm = MethodInfo("_commit_handle", GIZMO_REF, PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); - cm.default_arguments.push_back(false); - BIND_VMETHOD(cm); - - BIND_VMETHOD(MethodInfo(Variant::BOOL, "_is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); - -#undef GIZMO_REF -} - -bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("_has_gizmo")) { - return get_script_instance()->call("_has_gizmo", p_spatial); - } - return false; -} - -Ref<EditorNode3DGizmo> EditorNode3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { - if (get_script_instance() && get_script_instance()->has_method("_create_gizmo")) { - return get_script_instance()->call("_create_gizmo", p_spatial); - } - - Ref<EditorNode3DGizmo> ref; - if (has_gizmo(p_spatial)) { - ref.instantiate(); - } - return ref; -} - -bool EditorNode3DGizmoPlugin::can_be_hidden() const { - if (get_script_instance() && get_script_instance()->has_method("_can_be_hidden")) { - return get_script_instance()->call("_can_be_hidden"); - } - return true; -} - -bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const { - if (get_script_instance() && get_script_instance()->has_method("_is_selectable_when_hidden")) { - return get_script_instance()->call("_is_selectable_when_hidden"); - } - return false; -} - -void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - if (get_script_instance() && get_script_instance()->has_method("_redraw")) { - Ref<EditorNode3DGizmo> ref(p_gizmo); - get_script_instance()->call("_redraw", ref); - } -} - -String EditorNode3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_get_handle_name")) { - return get_script_instance()->call("_get_handle_name", p_gizmo, p_idx); - } - return ""; -} - -Variant EditorNode3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_get_handle_value")) { - return get_script_instance()->call("_get_handle_value", p_gizmo, p_idx); - } - return Variant(); -} - -void EditorNode3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - if (get_script_instance() && get_script_instance()->has_method("_set_handle")) { - get_script_instance()->call("_set_handle", p_gizmo, p_idx, p_camera, p_point); - } -} - -void EditorNode3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - if (get_script_instance() && get_script_instance()->has_method("_commit_handle")) { - get_script_instance()->call("_commit_handle", p_gizmo, p_idx, p_restore, p_cancel); - } -} - -bool EditorNode3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("_is_handle_highlighted")) { - return get_script_instance()->call("_is_handle_highlighted", p_gizmo, p_idx); - } - return false; -} - -void EditorNode3DGizmoPlugin::set_state(int p_state) { - current_state = p_state; - for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_hidden(current_state == HIDDEN); - } -} - -int EditorNode3DGizmoPlugin::get_state() const { - return current_state; -} - -void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) { - current_gizmos.erase(p_gizmo); -} - -EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { - current_state = VISIBLE; -} - -EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { - for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_plugin(nullptr); - current_gizmos[i]->get_spatial_node()->set_gizmo(nullptr); - } - if (Node3DEditor::get_singleton()) { - Node3DEditor::get_singleton()->update_all_gizmos(); - } -} diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index fa0f4e950f..0c7a0d14a2 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -34,6 +34,7 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/editor_scale.h" +#include "editor/plugins/node_3d_editor_gizmos.h" #include "scene/3d/light_3d.h" #include "scene/3d/visual_instance_3d.h" #include "scene/3d/world_environment.h" @@ -43,96 +44,10 @@ class Camera3D; class Node3DEditor; -class EditorNode3DGizmoPlugin; class Node3DEditorViewport; class SubViewportContainer; - -class EditorNode3DGizmo : public Node3DGizmo { - GDCLASS(EditorNode3DGizmo, Node3DGizmo); - - bool selected; - bool instantiated; - -public: - void set_selected(bool p_selected) { selected = p_selected; } - bool is_selected() const { return selected; } - - struct Instance { - RID instance; - Ref<ArrayMesh> mesh; - Ref<Material> material; - Ref<SkinReference> skin_reference; - RID skeleton; - bool billboard = false; - bool unscaled = false; - bool can_intersect = false; - bool extra_margin = false; - - void create_instance(Node3D *p_base, bool p_hidden = false); - }; - - Vector<Vector3> collision_segments; - Ref<TriangleMesh> collision_mesh; - - struct Handle { - Vector3 pos; - bool billboard = false; - }; - - Vector<Vector3> handles; - Vector<Vector3> secondary_handles; - float selectable_icon_size; - bool billboard_handle; - - bool valid; - bool hidden; - Node3D *base; - Vector<Instance> instances; - Node3D *spatial_node; - EditorNode3DGizmoPlugin *gizmo_plugin; - - void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } - -protected: - static void _bind_methods(); - -public: - void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); - void add_vertices(const Vector<Vector3> &p_vertices, const Ref<Material> &p_material, Mesh::PrimitiveType p_primitive_type, bool p_billboard = false, const Color &p_modulate = Color(1, 1, 1)); - void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>()); - void add_collision_segments(const Vector<Vector3> &p_lines); - void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); - void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); - void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard = false, bool p_secondary = false); - void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3()); - - virtual bool is_handle_highlighted(int p_idx) const; - virtual String get_handle_name(int p_idx) const; - virtual Variant get_handle_value(int p_idx); - virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point); - virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); - - void set_spatial_node(Node3D *p_node); - Node3D *get_spatial_node() const { return spatial_node; } - Ref<EditorNode3DGizmoPlugin> get_plugin() const { return gizmo_plugin; } - Vector3 get_handle_pos(int p_idx) const; - bool intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum); - bool intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = nullptr, bool p_sec_first = false); - - virtual void clear() override; - virtual void create() override; - virtual void transform() override; - virtual void redraw() override; - virtual void free() override; - - virtual bool is_editable() const; - - void set_hidden(bool p_hidden); - void set_plugin(EditorNode3DGizmoPlugin *p_plugin); - - EditorNode3DGizmo(); - ~EditorNode3DGizmo(); -}; +class DirectionalLight3D; +class WorldEnvironment; class ViewportRotationControl : public Control { GDCLASS(ViewportRotationControl, Control); @@ -307,17 +222,15 @@ private: struct _RayResult { Node3D *item = nullptr; float depth = 0; - int handle = 0; _FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; } }; void _update_name(); void _compute_edit(const Point2 &p_point); void _clear_selected(); - void _select_clicked(bool p_append, bool p_single, bool p_allow_locked = false); - void _select(Node *p_node, bool p_append, bool p_single); - ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = nullptr, bool p_alt_select = false); - void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false, bool p_include_locked_nodes = false); + void _select_clicked(bool p_allow_locked); + ObjectID _select_ray(const Point2 &p_pos); + void _find_items_at_pos(const Point2 &p_pos, Vector<_RayResult> &r_results, bool p_include_locked); Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const; Point2 _point_to_screen(const Vector3 &p_point); @@ -329,7 +242,8 @@ private: Vector3 _get_screen_to_space(const Vector3 &p_vector3); void _select_region(); - bool _gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only = false); + bool _transform_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only = false); + void _transform_gizmo_apply(Node3D *p_node, const Transform3D &p_transform, bool p_local); void _nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); void _nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative); @@ -342,7 +256,6 @@ private: ObjectID clicked; Vector<_RayResult> selection_results; - bool clicked_includes_current; bool clicked_wants_append; PopupMenu *selection_menu; @@ -383,15 +296,12 @@ private: Vector3 click_ray; Vector3 click_ray_pos; Vector3 center; - Vector3 orig_gizmo_pos; - int edited_gizmo = 0; Point2 mouse_pos; Point2 original_mouse_pos; bool snap = false; Ref<EditorNode3DGizmo> gizmo; int gizmo_handle = 0; Variant gizmo_initial_value; - Vector3 gizmo_initial_pos; } _edit; struct Cursor { @@ -472,6 +382,8 @@ private: void _project_settings_changed(); + Transform3D _compute_transform(TransformMode p_mode, const Transform3D &p_original, const Transform3D &p_original_local, Vector3 p_motion, double p_extra, bool p_local); + protected: void _notification(int p_what); static void _bind_methods(); @@ -494,7 +406,7 @@ public: AcceptDialog *p_accept); SubViewport *get_viewport_node() { return viewport; } - Camera3D *get_camera() { return camera; } // return the default camera object. + Camera3D *get_camera_3d() { return camera; } // return the default camera object. Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index); ~Node3DEditorViewport(); @@ -512,6 +424,8 @@ public: Node3D *sp; RID sbox_instance; RID sbox_instance_xray; + Ref<EditorNode3DGizmo> gizmo; + Map<int, Transform3D> subgizmos; // map ID -> initial transform Node3DEditorSelectedItem() { sp = nullptr; @@ -617,7 +531,9 @@ private: Ref<StandardMaterial3D> plane_gizmo_color_hl[3]; Ref<ShaderMaterial> rotate_gizmo_color_hl[3]; - int over_gizmo_handle; + Ref<Node3DGizmo> current_hover_gizmo; + int current_hover_gizmo_handle; + float snap_translate_value; float snap_rotate_value; float snap_scale_value; @@ -688,7 +604,6 @@ private: LineEdit *snap_translate; LineEdit *snap_rotate; LineEdit *snap_scale; - PanelContainer *menu_panel; LineEdit *xform_translate[3]; LineEdit *xform_rotate[3]; @@ -734,6 +649,7 @@ private: Node3D *selected; void _request_gizmo(Object *p_obj); + void _clear_subgizmo_selection(Object *p_obj = nullptr); static Node3DEditor *singleton; @@ -746,8 +662,7 @@ private: Node3DEditor(); - bool is_any_freelook_active() const; - + void _selection_changed(); void _refresh_menu_icons(); // Preview Sun and Environment @@ -808,6 +723,8 @@ private: void _add_sun_to_scene(bool p_already_added_environment = false); void _add_environment_to_scene(bool p_already_added_sun = false); + void _update_theme(); + protected: void _notification(int p_what); //void _gui_input(InputEvent p_event); @@ -861,10 +778,16 @@ public: VSplitContainer *get_shader_split(); HSplitContainer *get_palette_split(); - Node3D *get_selected() { return selected; } + Node3D *get_single_selected_node() { return selected; } + bool is_current_selected_gizmo(const EditorNode3DGizmo *p_gizmo); + bool is_subgizmo_selected(int p_id); + Vector<int> get_subgizmo_selection(); + + Ref<EditorNode3DGizmo> get_current_hover_gizmo() const { return current_hover_gizmo; } + void set_current_hover_gizmo(Ref<EditorNode3DGizmo> p_gizmo) { current_hover_gizmo = p_gizmo; } - int get_over_gizmo_handle() const { return over_gizmo_handle; } - void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; } + void set_current_hover_gizmo_handle(int p_id) { current_hover_gizmo_handle = p_id; } + int get_current_hover_gizmo_handle() const { return current_hover_gizmo_handle; } void set_can_preview(Camera3D *p_preview); @@ -907,50 +830,4 @@ public: ~Node3DEditorPlugin(); }; -class EditorNode3DGizmoPlugin : public Resource { - GDCLASS(EditorNode3DGizmoPlugin, Resource); - -public: - static const int VISIBLE = 0; - static const int HIDDEN = 1; - static const int ON_TOP = 2; - -protected: - int current_state; - List<EditorNode3DGizmo *> current_gizmos; - HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; - - static void _bind_methods(); - virtual bool has_gizmo(Node3D *p_spatial); - virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial); - -public: - void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); - void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); - void create_handle_material(const String &p_name, bool p_billboard = false, const Ref<Texture2D> &p_texture = nullptr); - void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); - - Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>()); - - virtual String get_gizmo_name() const; - virtual int get_priority() const; - virtual bool can_be_hidden() const; - virtual bool is_selectable_when_hidden() const; - - virtual void redraw(EditorNode3DGizmo *p_gizmo); - virtual String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; - virtual Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; - virtual void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); - virtual void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_idx) const; - - Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial); - void set_state(int p_state); - int get_state() const; - void unregister_gizmo(EditorNode3DGizmo *p_gizmo); - - EditorNode3DGizmoPlugin(); - virtual ~EditorNode3DGizmoPlugin(); -}; - #endif // NODE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.cpp b/editor/plugins/occluder_instance_3d_editor_plugin.cpp index b0cafd83be..ab88b9f00d 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.cpp +++ b/editor/plugins/occluder_instance_3d_editor_plugin.cpp @@ -98,7 +98,7 @@ OccluderInstance3DEditorPlugin::OccluderInstance3DEditorPlugin(EditorNode *p_nod editor = p_node; bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake Occluders")); bake->hide(); bake->connect("pressed", Callable(this, "_bake")); diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index 2ac90762e3..fd42bce06e 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -49,10 +49,10 @@ void OpenTypeFeaturesEditor::update_property() { void OpenTypeFeaturesEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_theme_color("accent_color", "Editor"); + Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - button->set_icon(get_theme_icon("Remove", "EditorIcons")); - button->set_size(get_theme_icon("Remove", "EditorIcons")->get_size()); + button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size()); spin->set_custom_label_color(true, base); } } @@ -106,7 +106,7 @@ void OpenTypeFeaturesAdd::update_property() { bool have_ss = false; bool have_cv = false; bool have_cu = false; - Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font("font")->get_feature_list(); + Dictionary features = Object::cast_to<Control>(get_edited_object())->get_theme_font(SNAME("font"))->get_feature_list(); for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) { String ftr_name = TS->tag_to_name(*ftr); if (ftr_name.begins_with("stylistic_set_")) { @@ -142,8 +142,8 @@ void OpenTypeFeaturesAdd::_features_menu() { void OpenTypeFeaturesAdd::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { set_label(""); - button->set_icon(get_theme_icon("Add", "EditorIcons")); - button->set_size(get_theme_icon("Add", "EditorIcons")->get_size()); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button->set_size(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))->get_size()); } } diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 838e67b5e7..8866e8c53e 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -364,12 +364,12 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - const Ref<Texture2D> path_sharp_handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture2D> path_smooth_handle = get_theme_icon("EditorPathSmoothHandle", "EditorIcons"); + const Ref<Texture2D> path_sharp_handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> path_smooth_handle = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons")); // Both handle icons must be of the same size const Size2 handle_size = path_sharp_handle->get_size(); - const Ref<Texture2D> curve_handle = get_theme_icon("EditorCurveHandle", "EditorIcons"); + const Ref<Texture2D> curve_handle = get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons")); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -411,7 +411,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } @@ -481,7 +481,7 @@ void Path2DEditor::_mode_selected(int p_mode) { Vector2 begin = node->get_curve()->get_point_position(0); Vector2 end = node->get_curve()->get_point_position(node->get_curve()->get_point_count() - 1); - if (begin.distance_to(end) < CMP_EPSILON) { + if (begin.is_equal_approx(end)) { return; } @@ -534,7 +534,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(sep); curve_edit = memnew(Button); curve_edit->set_flat(true); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); curve_edit->set_toggle_mode(true); curve_edit->set_focus_mode(Control::FOCUS_NONE); curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Left Click: Split Segment (in curve)") + "\n" + TTR("Right Click: Delete Point")); @@ -542,7 +542,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_edit); curve_edit_curve = memnew(Button); curve_edit_curve->set_flat(true); - curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCurve", "EditorIcons")); + curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCurve"), SNAME("EditorIcons"))); curve_edit_curve->set_toggle_mode(true); curve_edit_curve->set_focus_mode(Control::FOCUS_NONE); curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)")); @@ -550,7 +550,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_edit_curve); curve_create = memnew(Button); curve_create->set_flat(true); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); curve_create->set_toggle_mode(true); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)")); @@ -558,7 +558,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_create); curve_del = memnew(Button); curve_del->set_flat(true); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); curve_del->set_toggle_mode(true); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); @@ -566,7 +566,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { base_hb->add_child(curve_del); curve_close = memnew(Button); curve_close->set_flat(true); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); curve_close->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(ACTION_CLOSE)); diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 82b51f8a06..63b89aea35 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -36,20 +36,20 @@ #include "node_3d_editor_plugin.h" #include "scene/resources/curve.h" -String Path3DGizmo::get_handle_name(int p_idx) const { +String Path3DGizmo::get_handle_name(int p_id) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return ""; } - if (p_idx < c->get_point_count()) { - return TTR("Curve Point #") + itos(p_idx); + if (p_id < c->get_point_count()) { + return TTR("Curve Point #") + itos(p_id); } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; String n = TTR("Curve Point #") + itos(idx); if (t == 0) { n += " In"; @@ -60,21 +60,21 @@ String Path3DGizmo::get_handle_name(int p_idx) const { return n; } -Variant Path3DGizmo::get_handle_value(int p_idx) { +Variant Path3DGizmo::get_handle_value(int p_id) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return Variant(); } - if (p_idx < c->get_point_count()) { - original = c->get_point_position(p_idx); + if (p_id < c->get_point_count()) { + original = c->get_point_position(p_id); return original; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; Vector3 ofs; if (t == 0) { @@ -88,7 +88,7 @@ Variant Path3DGizmo::get_handle_value(int p_idx) { return ofs; } -void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { +void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -100,7 +100,7 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin Vector3 ray_dir = p_camera->project_ray_normal(p_point); // Setting curve point positions - if (p_idx < c->get_point_count()) { + if (p_id < c->get_point_count()) { Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2)); Vector3 inters; @@ -112,16 +112,16 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin } Vector3 local = gi.xform(inters); - c->set_point_position(p_idx, local); + c->set_point_position(p_id, local); } return; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; Vector3 base = c->get_point_position(idx); @@ -157,7 +157,7 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin } } -void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void Path3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -165,27 +165,27 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_idx < c->get_point_count()) { + if (p_id < c->get_point_count()) { if (p_cancel) { - c->set_point_position(p_idx, p_restore); + c->set_point_position(p_id, p_restore); return; } ur->create_action(TTR("Set Curve Point Position")); - ur->add_do_method(c.ptr(), "set_point_position", p_idx, c->get_point_position(p_idx)); - ur->add_undo_method(c.ptr(), "set_point_position", p_idx, p_restore); + ur->add_do_method(c.ptr(), "set_point_position", p_id, c->get_point_position(p_id)); + ur->add_undo_method(c.ptr(), "set_point_position", p_id, p_restore); ur->commit_action(); return; } - p_idx = p_idx - c->get_point_count() + 1; + p_id = p_id - c->get_point_count() + 1; - int idx = p_idx / 2; - int t = p_idx % 2; + int idx = p_id / 2; + int t = p_id % 2; if (t == 0) { if (p_cancel) { - c->set_point_in(p_idx, p_restore); + c->set_point_in(p_id, p_restore); return; } @@ -282,7 +282,7 @@ void Path3DGizmo::redraw() { add_handles(handles, handles_material); } if (sec_handles.size()) { - add_handles(sec_handles, sec_handles_material, false, true); + add_handles(sec_handles, sec_handles_material, Vector<int>(), false, true); } } } @@ -453,14 +453,14 @@ void Path3DEditorPlugin::edit(Object *p_object) { path = Object::cast_to<Path3D>(p_object); if (path) { if (path->get_curve().is_valid()) { - path->get_curve()->emit_signal("changed"); + path->get_curve()->emit_signal(SNAME("changed")); } } } else { Path3D *pre = path; path = nullptr; if (pre) { - pre->get_curve()->emit_signal("changed"); + pre->get_curve()->emit_signal(SNAME("changed")); } } //collision_polygon_editor->edit(Object::cast_to<Node>(p_object)); @@ -490,7 +490,7 @@ void Path3DEditorPlugin::make_visible(bool p_visible) { Path3D *pre = path; path = nullptr; if (pre && pre->get_curve().is_valid()) { - pre->get_curve()->emit_signal("changed"); + pre->get_curve()->emit_signal(SNAME("changed")); } } } @@ -562,7 +562,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(sep); curve_edit = memnew(Button); curve_edit->set_flat(true); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); curve_edit->set_toggle_mode(true); curve_edit->hide(); curve_edit->set_focus_mode(Control::FOCUS_NONE); @@ -570,7 +570,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_edit); curve_create = memnew(Button); curve_create->set_flat(true); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); curve_create->set_toggle_mode(true); curve_create->hide(); curve_create->set_focus_mode(Control::FOCUS_NONE); @@ -578,7 +578,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_create); curve_del = memnew(Button); curve_del->set_flat(true); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); @@ -586,7 +586,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew(Button); curve_close->set_flat(true); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveClose"), SNAME("EditorIcons"))); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); @@ -644,6 +644,6 @@ Path3DGizmoPlugin::Path3DGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); create_material("path_material", path_color); create_material("path_thin_material", Color(0.5, 0.5, 0.5)); - create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorPathSmoothHandle", "EditorIcons")); - create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorCurveHandle", "EditorIcons")); + create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons"))); + create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon(SNAME("EditorCurveHandle"), SNAME("EditorIcons"))); } diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 13870d7591..5902500526 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -31,7 +31,9 @@ #ifndef PATH_EDITOR_PLUGIN_H #define PATH_EDITOR_PLUGIN_H -#include "editor/node_3d_editor_gizmos.h" +#include "editor/editor_plugin.h" +#include "editor/plugins/node_3d_editor_gizmos.h" +#include "scene/3d/camera_3d.h" #include "scene/3d/path_3d.h" class Path3DGizmo : public EditorNode3DGizmo { @@ -44,9 +46,9 @@ class Path3DGizmo : public EditorNode3DGizmo { public: virtual String get_handle_name(int p_idx) const override; - virtual Variant get_handle_value(int p_idx) override; - virtual void set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) override; - virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false) override; + virtual Variant get_handle_value(int p_id) const override; + virtual void set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) const override; + virtual void commit_handle(int p_id, const Variant &p_restore, bool p_cancel = false) const override; virtual void redraw() override; Path3DGizmo(Path3D *p_path = nullptr); diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index 4b52512933..f92f50f826 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -60,7 +60,7 @@ PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : spatial_editor_hb->add_child(button_transform_joint); button_transform_joint->set_text(TTR("Move Joint")); - button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon("PhysicalBone3D", "EditorIcons")); + button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon(SNAME("PhysicalBone3D"), SNAME("EditorIcons"))); button_transform_joint->set_toggle_mode(true); button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 1a13a028c8..b420372eff 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -64,27 +64,27 @@ void Polygon2DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + bone_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { - button_uv->set_icon(get_theme_icon("Uv", "EditorIcons")); - - uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon("EditInternal", "EditorIcons")); - uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon("RemoveInternal", "EditorIcons")); - uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); - uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); - uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon("ToolScale", "EditorIcons")); - uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon("Close", "EditorIcons")); - uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon("Bucket", "EditorIcons")); - uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon("Clear", "EditorIcons")); - - b_snap_grid->set_icon(get_theme_icon("Grid", "EditorIcons")); - b_snap_enable->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); - uv_icon_zoom->set_texture(get_theme_icon("Zoom", "EditorIcons")); + button_uv->set_icon(get_theme_icon(SNAME("Uv"), SNAME("EditorIcons"))); + + uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_theme_icon(SNAME("EditInternal"), SNAME("EditorIcons"))); + uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_theme_icon(SNAME("RemoveInternal"), SNAME("EditorIcons"))); + uv_button[UV_MODE_EDIT_POINT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + uv_button[UV_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + uv_button[UV_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + uv_button[UV_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); + uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); + + b_snap_grid->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); + b_snap_enable->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons"))); + uv_icon_zoom->set_texture(get_theme_icon(SNAME("Zoom"), SNAME("EditorIcons"))); uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); @@ -1015,7 +1015,7 @@ void Polygon2DEditor::_uv_draw() { } // All UV points are sharp, so use the sharp handle icon - Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); + Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 488aa8c861..cbea2405b8 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -40,7 +40,7 @@ void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { void ResourcePreloaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - load->set_icon(get_theme_icon("Folder", "EditorIcons")); + load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } if (p_what == NOTIFICATION_READY) { @@ -181,21 +181,21 @@ void ResourcePreloaderEditor::_update_library() { preloader->get_resource_list(&rnames); List<String> names; - for (List<StringName>::Element *E = rnames.front(); E; E = E->next()) { - names.push_back(E->get()); + for (const StringName &E : rnames) { + names.push_back(E); } names.sort(); - for (List<String>::Element *E = names.front(); E; E = E->next()) { + for (const String &E : names) { TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); ti->set_selectable(0, true); - ti->set_text(0, E->get()); - ti->set_metadata(0, E->get()); + ti->set_text(0, E); + ti->set_metadata(0, E); - RES r = preloader->get_resource(E->get()); + RES r = preloader->get_resource(E); ERR_CONTINUE(r.is_null()); @@ -208,11 +208,11 @@ void ResourcePreloaderEditor::_update_library() { ti->set_selectable(1, false); if (type == "PackedScene") { - ti->add_button(1, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); } else { - ti->add_button(1, get_theme_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); } - ti->add_button(1, get_theme_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove")); + ti->add_button(1, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_REMOVE, false, TTR("Remove")); } //player->add_resource("default",resource); diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index 120b0bc0bb..ed91f174d1 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -70,8 +70,8 @@ void EditorPropertyRootMotion::_node_assign() { List<StringName> animations; player->get_animation_list(&animations); - for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); + for (const StringName &E : animations) { + Ref<Animation> anim = player->get_animation(E); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); } @@ -149,7 +149,7 @@ void EditorPropertyRootMotion::_node_assign() { ti->set_text(0, F->get()); ti->set_selectable(0, true); ti->set_editable(0, false); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, accum); } else { ti = parenthood[accum]; @@ -158,7 +158,7 @@ void EditorPropertyRootMotion::_node_assign() { ti->set_selectable(0, true); ti->set_text(0, concat); - ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); + ti->set_icon(0, get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons"))); ti->set_metadata(0, path); if (path == current) { ti->select(0); @@ -234,7 +234,7 @@ void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { void EditorPropertyRootMotion::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")); clear->set_icon(t); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 498d5b0711..668a15da37 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -103,8 +103,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color"); List<StringName> types; ClassDB::get_class_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); + for (const StringName &E : types) { + String n = E; if (n.begins_with("_")) { n = n.substr(1, n.length()); } @@ -115,8 +115,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color usertype_color = EDITOR_GET("text_editor/highlighting/user_type_color"); List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); - for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), usertype_color); + for (const StringName &E : global_classes) { + highlighter->add_keyword_color(E, usertype_color); } /* Autoloads. */ @@ -134,8 +134,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color"); List<String> core_types; script->get_language()->get_core_type_words(&core_types); - for (List<String>::Element *E = core_types.front(); E; E = E->next()) { - highlighter->add_keyword_color(E->get(), basetype_color); + for (const String &E : core_types) { + highlighter->add_keyword_color(E, basetype_color); } /* Reserved words. */ @@ -143,11 +143,11 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); List<String> keywords; script->get_language()->get_reserved_words(&keywords); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (script->get_language()->is_control_flow_keyword(E->get())) { - highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keywords) { + if (script->get_language()->is_control_flow_keyword(E)) { + highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - highlighter->add_keyword_color(E->get(), keyword_color); + highlighter->add_keyword_color(E, keyword_color); } } @@ -157,9 +157,9 @@ void EditorStandardSyntaxHighlighter::_update_cache() { if (instance_base != StringName()) { List<PropertyInfo> plist; ClassDB::get_property_list(instance_base, &plist); - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - String name = E->get().name; - if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) { + for (const PropertyInfo &E : plist) { + String name = E.name; + if (E.usage & PROPERTY_USAGE_CATEGORY || E.usage & PROPERTY_USAGE_GROUP || E.usage & PROPERTY_USAGE_SUBGROUP) { continue; } if (name.find("/") != -1) { @@ -170,8 +170,8 @@ void EditorStandardSyntaxHighlighter::_update_cache() { List<String> clist; ClassDB::get_integer_constant_list(instance_base, &clist); - for (List<String>::Element *E = clist.front(); E; E = E->next()) { - highlighter->add_member_keyword_color(E->get(), member_variable_color); + for (const String &E : clist) { + highlighter->add_member_keyword_color(E, member_variable_color); } } @@ -179,8 +179,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); List<String> comments; script->get_language()->get_comment_delimiters(&comments); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, comment_color, end == ""); @@ -190,8 +189,7 @@ void EditorStandardSyntaxHighlighter::_update_cache() { const Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); List<String> strings; script->get_language()->get_string_delimiters(&strings); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); highlighter->add_color_region(beg, end, string_color, end == ""); @@ -355,7 +353,7 @@ void ScriptEditorQuickOpen::_confirmed() { } int line = ti->get_text(0).get_slice(":", 1).to_int(); - emit_signal("goto_line", line - 1); + emit_signal(SNAME("goto_line"), line - 1); hide(); } @@ -368,7 +366,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_VISIBILITY_CHANGED: { - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); @@ -577,7 +575,7 @@ void ScriptEditor::_go_to_tab(int p_idx) { } if (Object::cast_to<EditorHelp>(c)) { script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class()); - script_icon->set_texture(get_theme_icon("Help", "EditorIcons")); + script_icon->set_texture(get_theme_icon(SNAME("Help"), SNAME("EditorIcons"))); if (is_visible_in_tree()) { Object::cast_to<EditorHelp>(c)->set_focused(); } @@ -631,7 +629,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { // clear button if (p_idx == recent_scripts->get_item_count() - 1) { EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", Array()); - call_deferred("_update_recent_scripts"); + call_deferred(SNAME("_update_recent_scripts")); return; } @@ -946,7 +944,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { _update_script_names(); if (!pending_auto_reload && auto_reload_running_scripts) { - call_deferred("_live_auto_reload_running_scripts"); + call_deferred(SNAME("_live_auto_reload_running_scripts")); pending_auto_reload = true; } } @@ -997,7 +995,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { script_editor->_reload_scripts(); need_reload = false; } else { - disk_changed->call_deferred("popup_centered_ratio", 0.5); + disk_changed->call_deferred(SNAME("popup_centered_ratio"), 0.5); } } @@ -1155,7 +1153,7 @@ void ScriptEditor::_menu_option(int p_option) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); - script_editor->call_deferred("_menu_option", p_option); + script_editor->call_deferred(SNAME("_menu_option"), p_option); previous_scripts.push_back(path); //repeat the operation return; } @@ -1486,23 +1484,23 @@ void ScriptEditor::_notification(int p_what) { case NOTIFICATION_TRANSLATION_CHANGED: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_THEME_CHANGED: { - help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); - site_search->set_icon(get_theme_icon("Instance", "EditorIcons")); + help_search->set_icon(get_theme_icon(SNAME("HelpSearch"), SNAME("EditorIcons"))); + site_search->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - script_forward->set_icon(get_theme_icon("Back", "EditorIcons")); - script_back->set_icon(get_theme_icon("Forward", "EditorIcons")); + script_forward->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + script_back->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - script_forward->set_icon(get_theme_icon("Forward", "EditorIcons")); - script_back->set_icon(get_theme_icon("Back", "EditorIcons")); + script_forward->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + script_back->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } - members_overview_alphabeta_sort_button->set_icon(get_theme_icon("Sort", "EditorIcons")); + members_overview_alphabeta_sort_button->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - filter_scripts->set_right_icon(get_theme_icon("Search", "EditorIcons")); - filter_methods->set_right_icon(get_theme_icon("Search", "EditorIcons")); + filter_scripts->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + filter_methods->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); recent_scripts->set_as_minsize(); @@ -1576,11 +1574,11 @@ void ScriptEditor::edited_scene_changed() { } void ScriptEditor::notify_script_close(const Ref<Script> &p_script) { - emit_signal("script_close", p_script); + emit_signal(SNAME("script_close"), p_script); } void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { - emit_signal("editor_script_changed", p_script); + emit_signal(SNAME("editor_script_changed"), p_script); } void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { @@ -1796,8 +1794,8 @@ void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled"); int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size"); - Color hot_color = get_theme_color("accent_color", "Editor"); - Color cold_color = get_theme_color("font_color", "Editor"); + Color hot_color = get_theme_color(SNAME("accent_color"), SNAME("Editor")); + Color cold_color = get_theme_color(SNAME("font_color"), SNAME("Editor")); for (int i = 0; i < script_list->get_item_count(); i++) { int c = script_list->get_item_metadata(i); @@ -1946,7 +1944,7 @@ void ScriptEditor::_update_script_names() { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh) { String name = eh->get_class(); - Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -2554,8 +2552,8 @@ void ScriptEditor::_tree_changed() { } waiting_update_names = true; - call_deferred("_update_script_names"); - call_deferred("_update_script_connections"); + call_deferred(SNAME("_update_script_names")); + call_deferred(SNAME("_update_script_connections")); } void ScriptEditor::_script_split_dragged(float) { @@ -2581,7 +2579,7 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); if (eh) { preview_name = eh->get_class(); - preview_icon = get_theme_icon("Help", "EditorIcons"); + preview_icon = get_theme_icon(SNAME("Help"), SNAME("EditorIcons")); } if (!preview_icon.is_null()) { @@ -3362,7 +3360,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { filename = memnew(Label); filename->set_clip_text(true); filename->set_h_size_flags(SIZE_EXPAND_FILL); - filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); buttons_hbox->add_child(filename); members_overview_alphabeta_sort_button = memnew(Button); @@ -3612,8 +3610,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { ScriptServer::edit_request_func = _open_script_request; - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); - tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("ScriptEditor", "EditorStyles")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"))); } ScriptEditor::~ScriptEditor() { diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index cc0fbcc634..65459d159d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -50,9 +50,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n List<Connection> all_connections; p_nodes[i]->get_signals_connected_to_this(&all_connections); - for (List<Connection>::Element *E = all_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (const Connection &connection : all_connections) { if (connection.callable.get_method() != p_method) { continue; } @@ -66,7 +64,7 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n node_item->set_text(1, connection.signal.get_name()); Control *p = Object::cast_to<Control>(get_parent()); - node_item->set_icon(1, p->get_theme_icon("Slot", "EditorIcons")); + node_item->set_icon(1, p->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); node_item->set_selectable(1, false); node_item->set_editable(1, false); @@ -116,8 +114,8 @@ Vector<String> ScriptTextEditor::get_functions() { if (script->get_language()->validate(text, script->get_path(), &fnc)) { //if valid rewrite functions to latest functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (const String &E : fnc) { + functions.push_back(E); } } @@ -147,7 +145,7 @@ void ScriptTextEditor::set_edited_resource(const RES &p_res) { code_editor->get_text_editor()->clear_undo_history(); code_editor->get_text_editor()->tag_saved_version(); - emit_signal("name_changed"); + emit_signal(SNAME("name_changed")); code_editor->update_line_and_column(); } @@ -203,8 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> strings; script->get_language()->get_string_delimiters(&strings); text_edit->clear_string_delimiters(); - for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); + for (const String &string : strings) { String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); text_edit->add_string_delimiter(beg, end, end == ""); @@ -213,8 +210,7 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> comments; script->get_language()->get_comment_delimiters(&comments); text_edit->clear_comment_delimiters(); - for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); + for (const String &comment : comments) { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); text_edit->add_comment_delimiter(beg, end, end == ""); @@ -417,8 +413,8 @@ void ScriptTextEditor::_validate_script() { } functions.clear(); - for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); + for (const String &E : fnc) { + functions.push_back(E); } script_is_valid = true; } @@ -432,15 +428,13 @@ void ScriptTextEditor::_validate_script() { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); - for (List<Connection>::Element *E = missing_connections.front(); E; E = E->next()) { - Connection connection = E->get(); - + for (const Connection &connection : missing_connections) { String base_path = base->get_name(); String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.signal.get_object())); String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())); warnings_panel->push_cell(); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path)); warnings_panel->pop(); // Color. warnings_panel->pop(); // Cell. @@ -456,16 +450,14 @@ void ScriptTextEditor::_validate_script() { // Add script warnings. warnings_panel->push_table(3); - for (List<ScriptLanguage::Warning>::Element *E = warnings.front(); E; E = E->next()) { - ScriptLanguage::Warning w = E->get(); - + for (const ScriptLanguage::Warning &w : warnings) { Dictionary ignore_meta; ignore_meta["line"] = w.start_line; ignore_meta["code"] = w.string_code.to_lower(); warnings_panel->push_cell(); warnings_panel->push_meta(ignore_meta); warnings_panel->push_color( - warnings_panel->get_theme_color("accent_color", "Editor").lerp(warnings_panel->get_theme_color("mono_color", "Editor"), 0.5)); + warnings_panel->get_theme_color(SNAME("accent_color"), SNAME("Editor")).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), SNAME("Editor")), 0.5)); warnings_panel->add_text(TTR("[Ignore]")); warnings_panel->pop(); // Color. warnings_panel->pop(); // Meta ignore. @@ -473,7 +465,7 @@ void ScriptTextEditor::_validate_script() { warnings_panel->push_cell(); warnings_panel->push_meta(w.start_line - 1); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(TTR("Line") + " " + itos(w.start_line)); warnings_panel->add_text(" (" + w.string_code + "):"); warnings_panel->pop(); // Color. @@ -488,12 +480,10 @@ void ScriptTextEditor::_validate_script() { errors_panel->clear(); errors_panel->push_table(2); - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - ScriptLanguage::ScriptError err = E->get(); - + for (const ScriptLanguage::ScriptError &err : errors) { errors_panel->push_cell(); errors_panel->push_meta(err.line - 1); - errors_panel->push_color(warnings_panel->get_theme_color("error_color", "Editor")); + errors_panel->push_color(warnings_panel->get_theme_color(SNAME("error_color"), SNAME("Editor"))); errors_panel->add_text(TTR("Line") + " " + itos(err.line) + ":"); errors_panel->pop(); // Color. errors_panel->pop(); // Meta goto. @@ -511,8 +501,8 @@ void ScriptTextEditor::_validate_script() { if (errors.is_empty()) { te->set_line_background_color(i, Color(0, 0, 0, 0)); } else { - for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) { - bool error_line = i == E->get().line - 1; + for (const ScriptLanguage::ScriptError &E : errors) { + bool error_line = i == E.line - 1; te->set_line_background_color(i, error_line ? marked_line_color : Color(0, 0, 0, 0)); if (error_line) { break; @@ -535,8 +525,8 @@ void ScriptTextEditor::_validate_script() { } } - emit_signal("name_changed"); - emit_signal("edited_script_changed"); + emit_signal(SNAME("name_changed")); + emit_signal(SNAME("edited_script_changed")); } void ScriptTextEditor::_update_bookmark_list() { @@ -725,7 +715,7 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) { _edit_option(breakpoints_menu->get_item_id(p_idx)); } else { code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx)); - code_editor->get_text_editor()->call_deferred("center_viewport_to_cursor"); //Need to be deferred, because goto uses call_deferred(). + code_editor->get_text_editor()->call_deferred(SNAME("center_viewport_to_cursor")); //Need to be deferred, because goto uses call_deferred(). } } @@ -760,14 +750,14 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c switch (result.type) { case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { if (result.script.is_valid()) { - emit_signal("request_open_script_at_line", result.script, result.location - 1); + emit_signal(SNAME("request_open_script_at_line"), result.script, result.location - 1); } else { - emit_signal("request_save_history"); + emit_signal(SNAME("request_save_history")); goto_line_centered(result.location - 1); } } break; case ScriptLanguage::LookupResult::RESULT_CLASS: { - emit_signal("go_to_help", "class_name:" + result.class_name); + emit_signal(SNAME("go_to_help"), "class_name:" + result.class_name); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: { StringName cname = result.class_name; @@ -782,11 +772,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_constant:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_constant:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY: { - emit_signal("go_to_help", "class_property:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_property:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: { @@ -801,7 +791,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_method:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_method:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: { @@ -817,11 +807,11 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } - emit_signal("go_to_help", "class_enum:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_enum:" + result.class_name + ":" + result.class_member); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE: { - emit_signal("go_to_help", "class_global:" + result.class_name + ":" + result.class_member); + emit_signal(SNAME("go_to_help"), "class_global:" + result.class_name + ":" + result.class_member); } break; } } else if (ProjectSettings::get_singleton()->has_autoload(p_symbol)) { @@ -910,8 +900,7 @@ void ScriptTextEditor::_update_connected_methods() { List<Connection> connections; nodes[i]->get_signals_connected_to_this(&connections); - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Connection connection = E->get(); + for (const Connection &connection : connections) { if (!(connection.flags & CONNECT_PERSIST)) { continue; } @@ -934,7 +923,7 @@ void ScriptTextEditor::_update_connected_methods() { if (name == connection.callable.get_method()) { line = functions[j].get_slice(":", 1).to_int() - 1; text_edit->set_line_gutter_metadata(line, connection_gutter, connection.callable.get_method()); - text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon("Slot", "EditorIcons")); + text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons"))); text_edit->set_line_gutter_clickable(line, connection_gutter, true); methods_found.insert(connection.callable.get_method()); break; @@ -1004,27 +993,27 @@ void ScriptTextEditor::_edit_option(int p_op) { switch (p_op) { case EDIT_UNDO: { tx->undo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_REDO: { tx->redo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_CUT: { tx->cut(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_COPY: { tx->copy(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_PASTE: { tx->paste(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_SELECT_ALL: { tx->select_all(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_MOVE_LINE_UP: { code_editor->move_lines_up(); @@ -1163,12 +1152,12 @@ void ScriptTextEditor::_edit_option(int p_op) { // Yep, because it doesn't make sense to instance this dialog for every single script open... // So this will be delegated to the ScriptEditor. - emit_signal("search_in_files_requested", selected_text); + emit_signal(SNAME("search_in_files_requested"), selected_text); } break; case REPLACE_IN_FILES: { String selected_text = code_editor->get_text_editor()->get_selection_text(); - emit_signal("replace_in_files_requested", selected_text); + emit_signal(SNAME("replace_in_files_requested"), selected_text); } break; case SEARCH_LOCATE_FUNCTION: { quick_open->popup_dialog(get_functions()); @@ -1262,7 +1251,7 @@ void ScriptTextEditor::_edit_option(int p_op) { text = tx->get_word_under_cursor(); } if (text != "") { - emit_signal("request_help", text); + emit_signal(SNAME("request_help"), text); } } break; case LOOKUP_SYMBOL: { @@ -1286,8 +1275,7 @@ void ScriptTextEditor::_edit_option_toggle_inline_comment() { List<String> comment_delimiters; script->get_language()->get_comment_delimiters(&comment_delimiters); - for (List<String>::Element *E = comment_delimiters.front(); E; E = E->next()) { - String script_delimiter = E->get(); + for (const String &script_delimiter : comment_delimiters) { if (script_delimiter.find(" ") == -1) { delimiter = script_delimiter; break; @@ -1686,16 +1674,16 @@ void ScriptTextEditor::_enable_code_editor() { editor_box->add_child(warnings_panel); warnings_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); warnings_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); warnings_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_warning_clicked)); editor_box->add_child(errors_panel); errors_panel->add_theme_font_override( - "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); + "normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); errors_panel->add_theme_font_size_override( - "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + "normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); errors_panel->connect("meta_clicked", callable_mp(this, &ScriptTextEditor::_error_clicked)); add_child(context_menu); @@ -1819,7 +1807,7 @@ ScriptTextEditor::ScriptTextEditor() { code_editor->get_text_editor()->set_gutter_name(connection_gutter, "connection_gutter"); code_editor->get_text_editor()->set_gutter_draw(connection_gutter, false); code_editor->get_text_editor()->set_gutter_overwritable(connection_gutter, true); - code_editor->get_text_editor()->set_gutter_type(connection_gutter, TextEdit::GUTTER_TPYE_ICON); + code_editor->get_text_editor()->set_gutter_type(connection_gutter, TextEdit::GUTTER_TYPE_ICON); warnings_panel = memnew(RichTextLabel); warnings_panel->set_custom_minimum_size(Size2(0, 100 * EDSCALE)); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index c1216a9732..2c45b96106 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -63,8 +63,8 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { get_text_editor()->set_text(p_shader->get_code()); get_text_editor()->clear_undo_history(); - get_text_editor()->call_deferred("set_h_scroll", 0); - get_text_editor()->call_deferred("set_v_scroll", 0); + get_text_editor()->call_deferred(SNAME("set_h_scroll"), 0); + get_text_editor()->call_deferred(SNAME("set_v_scroll"), 0); _validate_script(); _line_col_changed(); @@ -118,11 +118,11 @@ void ShaderTextEditor::_load_theme_settings() { const Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); const Color control_flow_keyword_color = EDITOR_GET("text_editor/highlighting/control_flow_keyword_color"); - for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keywords) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } @@ -144,8 +144,8 @@ void ShaderTextEditor::_load_theme_settings() { const Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color"); - for (List<String>::Element *E = built_ins.front(); E; E = E->next()) { - syntax_highlighter->add_keyword_color(E->get(), member_variable_color); + for (const String &E : built_ins) { + syntax_highlighter->add_keyword_color(E, member_variable_color); } // Colorize comments. @@ -160,8 +160,8 @@ void ShaderTextEditor::_load_theme_settings() { if (warnings_panel) { // Warnings panel - warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); - warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size("main_size", "EditorFonts")); + warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("main"), SNAME("EditorFonts"))); + warnings_panel->add_theme_font_size_override("normal_font_size", EditorNode::get_singleton()->get_gui_base()->get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts"))); } } @@ -242,7 +242,7 @@ void ShaderTextEditor::_validate_script() { } else { set_warning_count(0); } - emit_signal("script_changed"); + emit_signal(SNAME("script_changed")); } void ShaderTextEditor::_update_warning_panel() { @@ -266,7 +266,7 @@ void ShaderTextEditor::_update_warning_panel() { // First cell. warnings_panel->push_cell(); warnings_panel->push_meta(w.get_line() - 1); - warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); warnings_panel->add_text(TTR("Line") + " " + itos(w.get_line())); warnings_panel->add_text(" (" + w.get_name() + "):"); warnings_panel->pop(); // Color. @@ -380,7 +380,7 @@ void ShaderEditor::_menu_option(int p_option) { } break; } if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) { - shader_editor->get_text_editor()->call_deferred("grab_focus"); + shader_editor->get_text_editor()->call_deferred(SNAME("grab_focus")); } } @@ -484,7 +484,7 @@ void ShaderEditor::_check_for_external_edit() { if (use_autoreload) { _reload_shader_from_disk(); } else { - disk_changed->call_deferred("popup_centered"); + disk_changed->call_deferred(SNAME("popup_centered")); } } } @@ -728,7 +728,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { help_menu = memnew(MenuButton); help_menu->set_text(TTR("Help")); help_menu->set_switch_on_hover(true); - help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_theme_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); + help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Online Docs"), HELP_DOCS); help_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); add_child(main_container); @@ -737,7 +737,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { hbc->add_child(edit_menu); hbc->add_child(goto_menu); hbc->add_child(help_menu); - hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); + hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); VSplitContainer *editor_box = memnew(VSplitContainer); main_container->add_child(editor_box); @@ -770,7 +770,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { disk_changed->add_child(vbc); Label *dl = memnew(Label); - dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?")); + dl->set_text(TTR("This shader has been modified on disk.\nWhat action should be taken?")); vbc->add_child(dl); disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index 85ccc5b798..1e62261244 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -55,7 +55,7 @@ void ShaderFileEditor::_version_selected(int p_option) { RD::ShaderStage stage = RD::SHADER_STAGE_MAX; int first_found = -1; - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_txt); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(version_txt); ERR_FAIL_COND(bytecode.is_null()); for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { @@ -66,9 +66,9 @@ void ShaderFileEditor::_version_selected(int p_option) { Ref<Texture2D> icon; if (bytecode->get_stage_compile_error(RD::ShaderStage(i)) != String()) { - icon = get_theme_icon("ImportFail", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - icon = get_theme_icon("ImportCheck", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); } stages[i]->set_icon(icon); @@ -95,7 +95,7 @@ void ShaderFileEditor::_version_selected(int p_option) { String error = bytecode->get_stage_compile_error(stage); - error_text->push_font(get_theme_font("source", "EditorFonts")); + error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); if (error == String()) { error_text->add_text(TTR("Shader stage compiled without errors.")); @@ -111,7 +111,7 @@ void ShaderFileEditor::_update_options() { stage_hb->hide(); versions->hide(); error_text->clear(); - error_text->push_font(get_theme_font("source", "EditorFonts")); + error_text->push_font(get_theme_font(SNAME("source"), SNAME("EditorFonts"))); error_text->add_text(vformat(TTR("File structure for '%s' contains unrecoverable errors:\n\n"), shader_file->get_path().get_file())); error_text->add_text(shader_file->get_base_error()); return; @@ -142,7 +142,7 @@ void ShaderFileEditor::_update_options() { Ref<Texture2D> icon; - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_list[i]); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(version_list[i]); ERR_FAIL_COND(bytecode.is_null()); bool failed = false; @@ -154,9 +154,9 @@ void ShaderFileEditor::_update_options() { } if (failed) { - icon = get_theme_icon("ImportFail", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); } else { - icon = get_theme_icon("ImportCheck", "EditorIcons"); + icon = get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons")); } versions->add_item(title, icon); @@ -175,7 +175,7 @@ void ShaderFileEditor::_update_options() { return; } - Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(current_version); + Ref<RDShaderSPIRV> bytecode = shader_file->get_spirv(current_version); ERR_FAIL_COND(bytecode.is_null()); int first_valid = -1; int current = -1; diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 44916e1d46..7ef680d7ef 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -96,7 +96,7 @@ Skeleton2DEditor::Skeleton2DEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Skeleton2D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton2D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton2D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Make Rest Pose (From Bones)"), MENU_OPTION_MAKE_REST); options->get_popup()->add_separator(); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 0b04c2e50e..4202d8b611 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -44,7 +44,7 @@ #include "scene/resources/sphere_shape_3d.h" void BoneTransformEditor::create_editors() { - const Color section_color = get_theme_color("prop_subsection", "Editor"); + const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); section = memnew(EditorInspectorSection); section->setup("trf_properties", label, this, section_color, true); @@ -53,7 +53,7 @@ void BoneTransformEditor::create_editors() { key_button = memnew(Button); key_button->set_text(TTR("Key Transform")); key_button->set_visible(keyable); - key_button->set_icon(get_theme_icon("Key", "EditorIcons")); + key_button->set_icon(get_theme_icon(SNAME("Key"), SNAME("EditorIcons"))); key_button->set_flat(true); section->get_vbox()->add_child(key_button); @@ -113,19 +113,19 @@ void BoneTransformEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_SORT_CHILDREN: { - const Ref<Font> font = get_theme_font("font", "Tree"); - int font_size = get_theme_font_size("font_size", "Tree"); + const Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Tree")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Tree")); Point2 buffer; - buffer.x += get_theme_constant("inspector_margin", "Editor"); + buffer.x += get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); buffer.y += font->get_height(font_size); - buffer.y += get_theme_constant("vseparation", "Tree"); + buffer.y += get_theme_constant(SNAME("vseparation"), SNAME("Tree")); const float vector_height = translation_property->get_size().y; const float transform_height = transform_property->get_size().y; const float button_height = key_button->get_size().y; - const float width = get_size().x - get_theme_constant("inspector_margin", "Editor"); + const float width = get_size().x - get_theme_constant(SNAME("inspector_margin"), SNAME("Editor")); Vector<Rect2> input_rects; if (keyable && section->get_vbox()->is_visible()) { input_rects.push_back(Rect2(key_button->get_position() + buffer, Size2(width, button_height))); @@ -155,7 +155,7 @@ void BoneTransformEditor::_notification(int p_what) { break; } case NOTIFICATION_DRAW: { - const Color dark_color = get_theme_color("dark_color_2", "Editor"); + const Color dark_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor")); for (int i = 0; i < 5; ++i) { draw_rect(background_rects[i], dark_color); @@ -552,7 +552,7 @@ void Skeleton3DEditor::update_joint_tree() { items.insert(-1, root); const Vector<int> &joint_porder = skeleton->get_bone_process_orders(); - Ref<Texture> bone_icon = get_theme_icon("BoneAttachment3D", "EditorIcons"); + Ref<Texture> bone_icon = get_theme_icon(SNAME("BoneAttachment3D"), SNAME("EditorIcons")); for (int i = 0; i < joint_porder.size(); ++i) { const int b_idx = joint_porder[i]; @@ -584,13 +584,13 @@ void Skeleton3DEditor::create_editors() { Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Skeleton3D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton3D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Skeleton3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON); options->get_popup()->connect("id_pressed", callable_mp(this, &Skeleton3DEditor::_on_click_option)); - const Color section_color = get_theme_color("prop_subsection", "Editor"); + const Color section_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor")); EditorInspectorSection *bones_section = memnew(EditorInspectorSection); bones_section->setup("bones", "Bones", skeleton, section_color, true); diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index 2da49c1c0b..85632cf481 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -83,7 +83,7 @@ void SkeletonIK3DEditorPlugin::_bind_methods() { SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) { editor = p_node; play_btn = memnew(Button); - play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons")); + play_btn->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); play_btn->set_text(TTR("Play IK")); play_btn->set_toggle_mode(true); play_btn->hide(); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index ef328bcfe2..0f889ce33d 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -506,7 +506,7 @@ Sprite2DEditor::Sprite2DEditor() { CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Sprite2D")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Sprite2D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Sprite2D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Convert to Mesh2D"), MENU_OPTION_CONVERT_TO_MESH_2D); options->get_popup()->add_item(TTR("Convert to Polygon2D"), MENU_OPTION_CONVERT_TO_POLYGON_2D); @@ -521,7 +521,7 @@ Sprite2DEditor::Sprite2DEditor() { debug_uv_dialog = memnew(ConfirmationDialog); debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D")); - debug_uv_dialog->set_title("Mesh 2D Preview"); + debug_uv_dialog->set_title(TTR("Mesh 2D Preview")); VBoxContainer *vb = memnew(VBoxContainer); debug_uv_dialog->add_child(vb); ScrollContainer *scroll = memnew(ScrollContainer); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 70c7b3072b..42f7d23da2 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -65,13 +65,11 @@ void SpriteFramesEditor::_sheet_preview_draw() { int x = i * width; split_sheet_preview->draw_line(Point2(x, 0), Point2(x, size.height), Color(1, 1, 1, a)); split_sheet_preview->draw_line(Point2(x + 1, 0), Point2(x + 1, size.height), Color(0, 0, 0, a)); - - for (int j = 1; j < v; j++) { - int y = j * height; - - split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a)); - split_sheet_preview->draw_line(Point2(0, y + 1), Point2(size.width, y + 1), Color(0, 0, 0, a)); - } + } + for (int i = 1; i < v; i++) { + int y = i * height; + split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a)); + split_sheet_preview->draw_line(Point2(0, y + 1), Point2(size.width, y + 1), Color(0, 0, 0, a)); } if (frames_selected.size() == 0) { @@ -80,7 +78,7 @@ void SpriteFramesEditor::_sheet_preview_draw() { return; } - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) { int idx = E->get(); @@ -308,27 +306,27 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { void SpriteFramesEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - load->set_icon(get_theme_icon("Load", "EditorIcons")); - load_sheet->set_icon(get_theme_icon("SpriteSheet", "EditorIcons")); - copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - paste->set_icon(get_theme_icon("ActionPaste", "EditorIcons")); - empty->set_icon(get_theme_icon("InsertBefore", "EditorIcons")); - empty2->set_icon(get_theme_icon("InsertAfter", "EditorIcons")); - move_up->set_icon(get_theme_icon("MoveLeft", "EditorIcons")); - move_down->set_icon(get_theme_icon("MoveRight", "EditorIcons")); - _delete->set_icon(get_theme_icon("Remove", "EditorIcons")); - zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); - new_anim->set_icon(get_theme_icon("New", "EditorIcons")); - remove_anim->set_icon(get_theme_icon("Remove", "EditorIcons")); - split_sheet_zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - split_sheet_zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - split_sheet_zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); + load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + paste->set_icon(get_theme_icon(SNAME("ActionPaste"), SNAME("EditorIcons"))); + empty->set_icon(get_theme_icon(SNAME("InsertBefore"), SNAME("EditorIcons"))); + empty2->set_icon(get_theme_icon(SNAME("InsertAfter"), SNAME("EditorIcons"))); + move_up->set_icon(get_theme_icon(SNAME("MoveLeft"), SNAME("EditorIcons"))); + move_down->set_icon(get_theme_icon(SNAME("MoveRight"), SNAME("EditorIcons"))); + _delete->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); + new_anim->set_icon(get_theme_icon(SNAME("New"), SNAME("EditorIcons"))); + remove_anim->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); + split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up. @@ -367,8 +365,8 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ int count = 0; - for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) { - undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); + for (const Ref<Texture2D> &E : resources) { + undo_redo->add_do_method(frames, "add_frame", edited_anim, E, p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); count++; } @@ -626,10 +624,10 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->add_do_method(frames, "rename_animation", edited_anim, name); undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", edited_anim); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", edited_anim); } undo_redo->add_do_method(this, "_update_library"); @@ -657,10 +655,10 @@ void SpriteFramesEditor::_animation_add() { undo_redo->add_do_method(this, "_update_library"); undo_redo->add_undo_method(this, "_update_library"); - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); - undo_redo->add_do_method(E->get(), "set_animation", name); - undo_redo->add_undo_method(E->get(), "set_animation", current); + for (Node *E : nodes) { + String current = E->call("get_animation"); + undo_redo->add_do_method(E, "set_animation", name); + undo_redo->add_undo_method(E, "set_animation", current); } edited_anim = name; @@ -790,8 +788,8 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - String name = E->get(); + for (const StringName &E : anim_names) { + String name = E; TreeItem *it = animations->create_item(anim_root); @@ -800,7 +798,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { it->set_text(0, name); it->set_editable(0, true); - if (E->get() == edited_anim) { + if (E == edited_anim) { it->select(0); } } diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index 5fd173cae3..75c47bda2e 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -38,6 +38,7 @@ void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { SubViewport *sub_viewport = Object::cast_to<SubViewport>(p_object); TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); + // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); add_custom_control(sub_viewport_preview); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 5766646f7d..faf287b9bd 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -100,7 +100,7 @@ void TextEditor::set_edited_resource(const RES &p_res) { code_editor->get_text_editor()->clear_undo_history(); code_editor->get_text_editor()->tag_saved_version(); - emit_signal("name_changed"); + emit_signal(SNAME("name_changed")); code_editor->update_line_and_column(); } @@ -149,8 +149,8 @@ void TextEditor::reload_text() { } void TextEditor::_validate_script() { - emit_signal("name_changed"); - emit_signal("edited_script_changed"); + emit_signal(SNAME("name_changed")); + emit_signal(SNAME("edited_script_changed")); } void TextEditor::_update_bookmark_list() { @@ -291,27 +291,27 @@ void TextEditor::_edit_option(int p_op) { switch (p_op) { case EDIT_UNDO: { tx->undo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_REDO: { tx->redo(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_CUT: { tx->cut(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_COPY: { tx->copy(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_PASTE: { tx->paste(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_SELECT_ALL: { tx->select_all(); - tx->call_deferred("grab_focus"); + tx->call_deferred(SNAME("grab_focus")); } break; case EDIT_MOVE_LINE_UP: { code_editor->move_lines_up(); @@ -378,12 +378,12 @@ void TextEditor::_edit_option(int p_op) { // Yep, because it doesn't make sense to instance this dialog for every single script open... // So this will be delegated to the ScriptEditor. - emit_signal("search_in_files_requested", selected_text); + emit_signal(SNAME("search_in_files_requested"), selected_text); } break; case REPLACE_IN_FILES: { String selected_text = code_editor->get_text_editor()->get_selection_text(); - emit_signal("replace_in_files_requested", selected_text); + emit_signal(SNAME("replace_in_files_requested"), selected_text); } break; case SEARCH_GOTO_LINE: { goto_line_dialog->popup_find_line(tx); diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp index 696aa88e23..3987cdd6a0 100644 --- a/editor/plugins/texture_3d_editor_plugin.cpp +++ b/editor/plugins/texture_3d_editor_plugin.cpp @@ -50,7 +50,7 @@ void Texture3DEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -77,16 +77,17 @@ void Texture3DEditor::_update_material() { } void Texture3DEditor::_make_shaders() { - String shader_3d = "" - "shader_type canvas_item;\n" - "uniform sampler3D tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shader.instantiate(); - shader->set_code(shader_3d); + shader->set_code(R"( +shader_type canvas_item; + +uniform sampler3D tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); material.instantiate(); material->set_shader(shader); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 6ee652098d..44db06bcfd 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -36,11 +36,30 @@ TextureRect *TexturePreview::get_texture_display() { return texture_display; } -TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { - Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); +void TexturePreview::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + if (!is_inside_tree()) { + // TODO: This is a workaround because `NOTIFICATION_THEME_CHANGED` + // is getting called for some reason when the `TexturePreview` is + // getting destroyed, which causes `get_theme_font()` to return `nullptr`. + // See https://github.com/godotengine/godot/issues/50743. + break; + } + + if (metadata_label) { + Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts")); + metadata_label->add_theme_font_override("font", metadata_label_font); + } + + checkerboard->set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons"))); + } break; + } +} - TextureRect *checkerboard = memnew(TextureRect); - checkerboard->set_texture(theme->get_icon("Checkerboard", "EditorIcons")); +TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { + checkerboard = memnew(TextureRect); checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); checkerboard->set_texture_repeat(CanvasItem::TEXTURE_REPEAT_ENABLED); checkerboard->set_custom_minimum_size(Size2(0.0, 256.0) * EDSCALE); @@ -54,7 +73,7 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { add_child(texture_display); if (p_show_metadata) { - Label *metadata_label = memnew(Label); + metadata_label = memnew(Label); String format; if (Object::cast_to<ImageTexture>(*p_texture)) { @@ -67,15 +86,13 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { metadata_label->set_text(itos(p_texture->get_width()) + "x" + itos(p_texture->get_height()) + " " + format); + // It's okay that these colors are static since the grid color is static too. + metadata_label->add_theme_color_override("font_color", Color::named("white")); + metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); + metadata_label->add_theme_font_size_override("font_size", 16 * EDSCALE); metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); metadata_label->add_theme_constant_override("outline_size", 2 * EDSCALE); - Ref<Font> metadata_label_font = theme->get_font("expression", "EditorFonts"); - metadata_label->add_theme_font_override("font", metadata_label_font); - - // it's okay that these colors are static since the grid color is static too - metadata_label->add_theme_color_override("font_color", Color::named("white")); - metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); metadata_label->add_theme_constant_override("shadow_as_outline", 1); metadata_label->set_h_size_flags(Control::SIZE_SHRINK_END); diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 165090be93..36a5513ea6 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -39,7 +39,13 @@ class TexturePreview : public MarginContainer { GDCLASS(TexturePreview, MarginContainer); private: - TextureRect *texture_display; + TextureRect *texture_display = nullptr; + + TextureRect *checkerboard = nullptr; + Label *metadata_label = nullptr; + +protected: + void _notification(int p_what); public: TextureRect *get_texture_display(); diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 3f46cd64a2..80359452ac 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -58,7 +58,7 @@ void TextureLayeredEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -104,43 +104,46 @@ void TextureLayeredEditor::_update_material() { } void TextureLayeredEditor::_make_shaders() { - String shader_2d_array = "" - "shader_type canvas_item;\n" - "uniform sampler2DArray tex;\n" - "uniform float layer;\n" - "void fragment() {\n" - " COLOR = textureLod(tex,vec3(UV,layer),0.0);\n" - "}"; - shaders[0].instantiate(); - shaders[0]->set_code(shader_2d_array); - - String shader_cube = "" - "shader_type canvas_item;\n" - "uniform samplerCube tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,n,0.0);\n" - "}"; + shaders[0]->set_code(R"( +shader_type canvas_item; + +uniform sampler2DArray tex; +uniform float layer; + +void fragment() { + COLOR = textureLod(tex, vec3(UV, layer), 0.0); +} +)"); shaders[1].instantiate(); - shaders[1]->set_code(shader_cube); - - String shader_cube_array = "" - "shader_type canvas_item;\n" - "uniform samplerCubeArray tex;\n" - "uniform vec3 normal;\n" - "uniform mat3 rot;\n" - "uniform float layer;\n" - "void fragment() {\n" - " vec3 n = rot * normalize(vec3(normal.xy*(UV * 2.0 - 1.0),normal.z));\n" - " COLOR = textureLod(tex,vec4(n,layer),0.0);\n" - "}"; + shaders[1]->set_code(R"( +shader_type canvas_item; + +uniform samplerCube tex; +uniform vec3 normal; +uniform mat3 rot; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, n, 0.0); +} +)"); shaders[2].instantiate(); - shaders[2]->set_code(shader_cube_array); + shaders[2]->set_code(R"( +shader_type canvas_item; + +uniform samplerCubeArray tex; +uniform vec3 normal; +uniform mat3 rot; +uniform float layer; + +void fragment() { + vec3 n = rot * normalize(vec3(normal.xy * (UV * 2.0 - 1.0), normal.z)); + COLOR = textureLod(tex, vec4(n, layer), 0.0); +} +)"); for (int i = 0; i < 3; i++) { materials[i].instantiate(); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index d0ba68138b..b277f2ab42 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -47,14 +47,14 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { edit_draw->draw_line( from, to, - EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor").inverted() * Color(1, 1, 1, 0.5), + EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5), Math::round(2 * EDSCALE)); while ((to - from).length_squared() > 200) { edit_draw->draw_line( from, from + line, - EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"), + EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")), Math::round(2 * EDSCALE)); from += line * 2; @@ -144,8 +144,7 @@ void TextureRegionEditor::_region_draw() { } } } else if (snap_mode == SNAP_AUTOSLICE) { - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 r = E->get(); + for (const Rect2 &r : autoslice_cache) { Vector2 endpoints[4] = { mtx.basis_xform(r.position), mtx.basis_xform(r.position + Vector2(r.size.x, 0)), @@ -159,7 +158,7 @@ void TextureRegionEditor::_region_draw() { } } - Ref<Texture2D> select_handle = get_theme_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); Rect2 scroll_rect(Point2(), base_tex->get_size()); @@ -175,7 +174,7 @@ void TextureRegionEditor::_region_draw() { mtx.basis_xform(raw_endpoints[2]), mtx.basis_xform(raw_endpoints[3]) }; - Color color = get_theme_color("mono_color", "Editor"); + Color color = get_theme_color(SNAME("mono_color"), SNAME("Editor")); for (int i = 0; i < 4; i++) { int prev = (i + 3) % 4; int next = (i + 1) % 4; @@ -328,9 +327,9 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) { Vector2 point = mtx.affine_inverse().xform(Vector2(mb->get_position().x, mb->get_position().y)); - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - if (E->get().has_point(point)) { - rect = E->get(); + for (const Rect2 &E : autoslice_cache) { + if (E.has_point(point)) { + rect = E; if (Input::get_singleton()->is_key_pressed(KEY_CTRL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { Rect2 r; if (node_sprite) { @@ -749,12 +748,12 @@ void TextureRegionEditor::_update_autoslice() { for (int x = 0; x < texture->get_width(); x++) { if (texture->is_pixel_opaque(x, y)) { bool found = false; - for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { - Rect2 grown = E->get().grow(1.5); + for (Rect2 &E : autoslice_cache) { + Rect2 grown = E.grow(1.5); if (grown.has_point(Point2(x, y))) { - E->get().expand_to(Point2(x, y)); - E->get().expand_to(Point2(x + 1, y + 1)); - x = E->get().position.x + E->get().size.x - 1; + E.expand_to(Point2(x, y)); + E.expand_to(Point2(x + 1, y + 1)); + x = E.position.x + E.size.x - 1; bool merged = true; while (merged) { merged = false; @@ -764,12 +763,12 @@ void TextureRegionEditor::_update_autoslice() { autoslice_cache.erase(F->prev()); queue_erase = false; } - if (F == E) { + if (F->get() == E) { continue; } - if (E->get().grow(1).intersects(F->get())) { - E->get().expand_to(F->get().position); - E->get().expand_to(F->get().position + F->get().size); + if (E.grow(1).intersects(F->get())) { + E.expand_to(F->get().position); + E.expand_to(F->get().position + F->get().size); if (F->prev()) { F = F->prev(); autoslice_cache.erase(F->next()); @@ -799,12 +798,12 @@ void TextureRegionEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; case NOTIFICATION_READY: { - zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); - zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); + zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); + zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE); hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index b628bc1a04..6bcc65e30c 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -65,8 +65,8 @@ void ThemeItemImportTree::_update_items_tree() { tree_icon_items.clear(); tree_stylebox_items.clear(); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String type_name = (String)E->get(); + for (const StringName &E : types) { + String type_name = (String)E; TreeItem *type_node = import_items_tree->create_item(root); type_node->set_meta("_can_be_imported", false); @@ -89,12 +89,12 @@ void ThemeItemImportTree::_update_items_tree() { names.clear(); filtered_names.clear(); - base_theme->get_theme_item_list(dt, E->get(), &names); + base_theme->get_theme_item_list(dt, E, &names); bool data_type_has_filtered_items = false; - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - String item_name = (String)F->get(); + for (const StringName &F : names) { + String item_name = (String)F; bool is_item_matching_filter = (item_name.findn(filter_text) > -1); if (!filter_text.is_empty() && !is_matching_filter && !is_item_matching_filter) { continue; @@ -105,7 +105,7 @@ void ThemeItemImportTree::_update_items_tree() { has_filtered_items = true; data_type_has_filtered_items = true; } - filtered_names.push_back(F->get()); + filtered_names.push_back(F); } if (filtered_names.size() == 0) { @@ -127,7 +127,7 @@ void ThemeItemImportTree::_update_items_tree() { switch (dt) { case Theme::DATA_TYPE_COLOR: - data_type_node->set_icon(0, get_theme_icon("Color", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Colors")); item_list = &tree_color_items; @@ -135,7 +135,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_CONSTANT: - data_type_node->set_icon(0, get_theme_icon("MemberConstant", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Constants")); item_list = &tree_constant_items; @@ -143,7 +143,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT: - data_type_node->set_icon(0, get_theme_icon("Font", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Fonts")); item_list = &tree_font_items; @@ -151,7 +151,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_FONT_SIZE: - data_type_node->set_icon(0, get_theme_icon("FontSize", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Font Sizes")); item_list = &tree_font_size_items; @@ -159,7 +159,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_ICON: - data_type_node->set_icon(0, get_theme_icon("ImageTexture", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Icons")); item_list = &tree_icon_items; @@ -167,7 +167,7 @@ void ThemeItemImportTree::_update_items_tree() { break; case Theme::DATA_TYPE_STYLEBOX: - data_type_node->set_icon(0, get_theme_icon("StyleBoxFlat", "EditorIcons")); + data_type_node->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); data_type_node->set_text(0, TTR("Styleboxes")); item_list = &tree_stylebox_items; @@ -182,10 +182,10 @@ void ThemeItemImportTree::_update_items_tree() { bool data_type_any_checked_with_data = false; filtered_names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *F = filtered_names.front(); F; F = F->next()) { + for (const StringName &F : filtered_names) { TreeItem *item_node = import_items_tree->create_item(data_type_node); item_node->set_meta("_can_be_imported", true); - item_node->set_text(0, F->get()); + item_node->set_text(0, F); item_node->set_cell_mode(IMPORT_ITEM, TreeItem::CELL_MODE_CHECK); item_node->set_checked(IMPORT_ITEM, false); item_node->set_editable(IMPORT_ITEM, true); @@ -754,7 +754,7 @@ void ThemeItemImportTree::_import_selected() { return; } - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); ProgressDialog::get_singleton()->add_task("import_theme_items", TTR("Importing Theme Items"), selected_items.size() + 2); @@ -821,7 +821,7 @@ void ThemeItemImportTree::_import_selected() { ProgressDialog::get_singleton()->task_step("import_theme_items", TTR("Finalizing"), idx++); ProgressDialog::get_singleton()->end_task("import_theme_items"); - emit_signal("items_imported"); + emit_signal(SNAME("items_imported")); } void ThemeItemImportTree::set_edited_theme(const Ref<Theme> &p_theme) { @@ -854,47 +854,47 @@ void ThemeItemImportTree::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - select_icons_warning_icon->set_texture(get_theme_icon("StatusWarning", "EditorIcons")); - select_icons_warning->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + select_icons_warning_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + select_icons_warning->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); // Bottom panel buttons. - import_collapse_types_button->set_icon(get_theme_icon("CollapseTree", "EditorIcons")); - import_expand_types_button->set_icon(get_theme_icon("ExpandTree", "EditorIcons")); + import_collapse_types_button->set_icon(get_theme_icon(SNAME("CollapseTree"), SNAME("EditorIcons"))); + import_expand_types_button->set_icon(get_theme_icon(SNAME("ExpandTree"), SNAME("EditorIcons"))); - import_select_all_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - import_select_full_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - import_deselect_all_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); + import_select_all_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + import_select_full_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + import_deselect_all_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); // Side panel buttons. - select_colors_icon->set_texture(get_theme_icon("Color", "EditorIcons")); - deselect_all_colors_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_colors_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_colors_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_constants_icon->set_texture(get_theme_icon("MemberConstant", "EditorIcons")); - deselect_all_constants_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_constants_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_constants_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_fonts_icon->set_texture(get_theme_icon("Font", "EditorIcons")); - deselect_all_fonts_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_fonts_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_fonts_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_font_sizes_icon->set_texture(get_theme_icon("FontSize", "EditorIcons")); - deselect_all_font_sizes_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_font_sizes_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_font_sizes_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_icons_icon->set_texture(get_theme_icon("ImageTexture", "EditorIcons")); - deselect_all_icons_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_icons_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_icons_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); - - select_styleboxes_icon->set_texture(get_theme_icon("StyleBoxFlat", "EditorIcons")); - deselect_all_styleboxes_button->set_icon(get_theme_icon("ThemeDeselectAll", "EditorIcons")); - select_all_styleboxes_button->set_icon(get_theme_icon("ThemeSelectAll", "EditorIcons")); - select_full_styleboxes_button->set_icon(get_theme_icon("ThemeSelectFull", "EditorIcons")); + select_colors_icon->set_texture(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + deselect_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_colors_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_constants_icon->set_texture(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + deselect_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_constants_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_fonts_icon->set_texture(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + deselect_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_fonts_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_font_sizes_icon->set_texture(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + deselect_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_font_sizes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_icons_icon->set_texture(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + deselect_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_icons_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); + + select_styleboxes_icon->set_texture(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + deselect_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeDeselectAll"), SNAME("EditorIcons"))); + select_all_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectAll"), SNAME("EditorIcons"))); + select_full_styleboxes_button->set_icon(get_theme_icon(SNAME("ThemeSelectFull"), SNAME("EditorIcons"))); } break; } } @@ -1236,16 +1236,16 @@ void ThemeItemEditorDialog::_update_edit_types() { bool item_reselected = false; edit_type_list->clear(); int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - edit_type_list->add_item(E->get(), item_icon); + edit_type_list->add_item(E, item_icon); - if (E->get() == edited_item_type) { + if (E == edited_item_type) { edit_type_list->select(e_idx); item_reselected = true; } @@ -1313,16 +1313,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *color_root = edit_items_tree->create_item(root); color_root->set_metadata(0, Theme::DATA_TYPE_COLOR); - color_root->set_icon(0, get_theme_icon("Color", "EditorIcons")); + color_root->set_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); color_root->set_text(0, TTR("Colors")); - color_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); + color_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Color Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(color_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1334,16 +1334,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *constant_root = edit_items_tree->create_item(root); constant_root->set_metadata(0, Theme::DATA_TYPE_CONSTANT); - constant_root->set_icon(0, get_theme_icon("MemberConstant", "EditorIcons")); + constant_root->set_icon(0, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); constant_root->set_text(0, TTR("Constants")); - constant_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); + constant_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Constant Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(constant_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1355,16 +1355,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_root = edit_items_tree->create_item(root); font_root->set_metadata(0, Theme::DATA_TYPE_FONT); - font_root->set_icon(0, get_theme_icon("Font", "EditorIcons")); + font_root->set_icon(0, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); font_root->set_text(0, TTR("Fonts")); - font_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); + font_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1376,16 +1376,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *font_size_root = edit_items_tree->create_item(root); font_size_root->set_metadata(0, Theme::DATA_TYPE_FONT_SIZE); - font_size_root->set_icon(0, get_theme_icon("FontSize", "EditorIcons")); + font_size_root->set_icon(0, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); font_size_root->set_text(0, TTR("Font Sizes")); - font_size_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); + font_size_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Font Size Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(font_size_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1397,16 +1397,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *icon_root = edit_items_tree->create_item(root); icon_root->set_metadata(0, Theme::DATA_TYPE_ICON); - icon_root->set_icon(0, get_theme_icon("ImageTexture", "EditorIcons")); + icon_root->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); icon_root->set_text(0, TTR("Icons")); - icon_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); + icon_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All Icon Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(icon_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1418,16 +1418,16 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) { if (names.size() > 0) { TreeItem *stylebox_root = edit_items_tree->create_item(root); stylebox_root->set_metadata(0, Theme::DATA_TYPE_STYLEBOX); - stylebox_root->set_icon(0, get_theme_icon("StyleBoxFlat", "EditorIcons")); + stylebox_root->set_icon(0, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); stylebox_root->set_text(0, TTR("Styleboxes")); - stylebox_root->add_button(0, get_theme_icon("Clear", "EditorIcons"), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); + stylebox_root->add_button(0, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_DATA_TYPE, false, TTR("Remove All StyleBox Items")); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { TreeItem *item = edit_items_tree->create_item(stylebox_root); - item->set_text(0, E->get()); - item->add_button(0, get_theme_icon("Edit", "EditorIcons"), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); - item->add_button(0, get_theme_icon("Remove", "EditorIcons"), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); + item->set_text(0, E); + item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item")); + item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item")); } } } @@ -1459,13 +1459,16 @@ void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_colu _update_edit_item_tree(edited_item_type); } -void ThemeItemEditorDialog::_add_theme_type() { - edited_theme->add_icon_type(edit_add_type_value->get_text()); - edited_theme->add_stylebox_type(edit_add_type_value->get_text()); - edited_theme->add_font_type(edit_add_type_value->get_text()); - edited_theme->add_font_size_type(edit_add_type_value->get_text()); - edited_theme->add_color_type(edit_add_type_value->get_text()); - edited_theme->add_constant_type(edit_add_type_value->get_text()); +void ThemeItemEditorDialog::_add_theme_type(const String &p_new_text) { + const String new_type = edit_add_type_value->get_text().strip_edges(); + edit_add_type_value->clear(); + + edited_theme->add_icon_type(new_type); + edited_theme->add_stylebox_type(new_type); + edited_theme->add_font_type(new_type); + edited_theme->add_font_size_type(new_type); + edited_theme->add_color_type(new_type); + edited_theme->add_constant_type(new_type); _update_edit_types(); // Force emit a change so that other parts of the editor can update. @@ -1500,12 +1503,12 @@ void ThemeItemEditorDialog::_add_theme_item(Theme::DataType p_data_type, String void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, String p_item_type) { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); edited_theme->get_theme_item_list(p_data_type, p_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(p_data_type, E->get(), p_item_type); + for (const StringName &E : names) { + edited_theme->clear_theme_item(p_data_type, E, p_item_type); } // Allow changes to be reported now that the operation is finished. @@ -1515,7 +1518,7 @@ void ThemeItemEditorDialog::_remove_data_type_items(Theme::DataType p_data_type, void ThemeItemEditorDialog::_remove_class_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1523,9 +1526,9 @@ void ThemeItemEditorDialog::_remove_class_items() { names.clear(); Theme::get_default()->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (edited_theme->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + if (edited_theme->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1539,7 +1542,7 @@ void ThemeItemEditorDialog::_remove_class_items() { void ThemeItemEditorDialog::_remove_custom_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1547,9 +1550,9 @@ void ThemeItemEditorDialog::_remove_custom_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!Theme::get_default()->has_theme_item_nocheck(data_type, E->get(), edited_item_type)) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + if (!Theme::get_default()->has_theme_item_nocheck(data_type, E, edited_item_type)) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } } @@ -1563,7 +1566,7 @@ void ThemeItemEditorDialog::_remove_custom_items() { void ThemeItemEditorDialog::_remove_all_items() { List<StringName> names; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); for (int dt = 0; dt < Theme::DATA_TYPE_MAX; dt++) { @@ -1571,8 +1574,8 @@ void ThemeItemEditorDialog::_remove_all_items() { names.clear(); edited_theme->get_theme_item_list(data_type, edited_item_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - edited_theme->clear_theme_item(data_type, E->get(), edited_item_type); + for (const StringName &E : names) { + edited_theme->clear_theme_item(data_type, E, edited_item_type); } } @@ -1718,21 +1721,21 @@ void ThemeItemEditorDialog::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - edit_items_add_color->set_icon(get_theme_icon("Color", "EditorIcons")); - edit_items_add_constant->set_icon(get_theme_icon("MemberConstant", "EditorIcons")); - edit_items_add_font->set_icon(get_theme_icon("Font", "EditorIcons")); - edit_items_add_font_size->set_icon(get_theme_icon("FontSize", "EditorIcons")); - edit_items_add_icon->set_icon(get_theme_icon("ImageTexture", "EditorIcons")); - edit_items_add_stylebox->set_icon(get_theme_icon("StyleBoxFlat", "EditorIcons")); + edit_items_add_color->set_icon(get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + edit_items_add_constant->set_icon(get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + edit_items_add_font->set_icon(get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + edit_items_add_font_size->set_icon(get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + edit_items_add_icon->set_icon(get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + edit_items_add_stylebox->set_icon(get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); - edit_items_remove_class->set_icon(get_theme_icon("Control", "EditorIcons")); - edit_items_remove_custom->set_icon(get_theme_icon("ThemeRemoveCustomItems", "EditorIcons")); - edit_items_remove_all->set_icon(get_theme_icon("ThemeRemoveAllItems", "EditorIcons")); + edit_items_remove_class->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + edit_items_remove_custom->set_icon(get_theme_icon(SNAME("ThemeRemoveCustomItems"), SNAME("EditorIcons"))); + edit_items_remove_all->set_icon(get_theme_icon(SNAME("ThemeRemoveAllItems"), SNAME("EditorIcons"))); - import_another_theme_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + import_another_theme_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); - tc->add_theme_style_override("tab_selected", get_theme_stylebox("tab_selected_odd", "TabContainer")); - tc->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + tc->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); + tc->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); } break; } } @@ -1776,11 +1779,12 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { edit_dialog_side_vb->add_child(edit_add_type_hb); edit_add_type_value = memnew(LineEdit); edit_add_type_value->set_h_size_flags(Control::SIZE_EXPAND_FILL); + edit_add_type_value->connect("text_submitted", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); edit_add_type_hb->add_child(edit_add_type_value); Button *edit_add_type_button = memnew(Button); edit_add_type_button->set_text(TTR("Add")); edit_add_type_hb->add_child(edit_add_type_button); - edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type)); + edit_add_type_button->connect("pressed", callable_mp(this, &ThemeItemEditorDialog::_add_theme_type), varray("")); VBoxContainer *edit_items_vb = memnew(VBoxContainer); edit_items_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1923,8 +1927,8 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() { import_another_theme_dialog->set_title(TTR("Select Another Theme Resource:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - import_another_theme_dialog->add_filter("*." + E->get() + "; Theme Resource"); + for (const String &E : ext) { + import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); } import_another_file_hb->add_child(import_another_theme_dialog); import_another_theme_dialog->connect("file_selected", callable_mp(this, &ThemeItemEditorDialog::_select_another_theme_cbk)); @@ -1951,7 +1955,7 @@ void ThemeTypeDialog::_dialog_about_to_show() { } void ThemeTypeDialog::ok_pressed() { - emit_signal("type_selected", add_type_filter->get_text().strip_edges()); + emit_signal(SNAME("type_selected"), add_type_filter->get_text().strip_edges()); } void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { @@ -1965,26 +1969,26 @@ void ThemeTypeDialog::_update_add_type_options(const String &p_filter) { names.sort_custom<StringName::AlphCompare>(); Vector<StringName> unique_names; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { + for (const StringName &E : names) { // Filter out undesired values. - if (!p_filter.is_subsequence_ofi(String(E->get()))) { + if (!p_filter.is_subsequence_ofi(String(E))) { continue; } // Skip duplicate values. - if (unique_names.has(E->get())) { + if (unique_names.has(E)) { continue; } - unique_names.append(E->get()); + unique_names.append(E); Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - add_type_options->add_item(E->get(), item_icon); + add_type_options->add_item(E, item_icon); } } @@ -1997,12 +2001,12 @@ void ThemeTypeDialog::_add_type_options_cbk(int p_index) { } void ThemeTypeDialog::_add_type_dialog_entered(const String &p_value) { - emit_signal("type_selected", p_value.strip_edges()); + emit_signal(SNAME("type_selected"), p_value.strip_edges()); hide(); } void ThemeTypeDialog::_add_type_dialog_activated(int p_index) { - emit_signal("type_selected", add_type_options->get_item_text(p_index)); + emit_signal(SNAME("type_selected"), add_type_options->get_item_text(p_index)); hide(); } @@ -2128,16 +2132,16 @@ void ThemeTypeEditor::_update_type_list() { bool item_reselected = false; int e_idx = 0; - for (List<StringName>::Element *E = theme_types.front(); E; E = E->next()) { + for (const StringName &E : theme_types) { Ref<Texture2D> item_icon; - if (E->get() == "") { - item_icon = get_theme_icon("NodeDisabled", "EditorIcons"); + if (E == "") { + item_icon = get_theme_icon(SNAME("NodeDisabled"), SNAME("EditorIcons")); } else { - item_icon = EditorNode::get_singleton()->get_class_icon(E->get(), "NodeDisabled"); + item_icon = EditorNode::get_singleton()->get_class_icon(E, "NodeDisabled"); } - theme_type_list->add_icon_item(item_icon, E->get()); + theme_type_list->add_icon_item(item_icon, E); - if (E->get() == edited_type) { + if (E == edited_type) { theme_type_list->select(e_idx); item_reselected = true; } @@ -2178,8 +2182,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ (Theme::get_default().operator->()->*get_list_func)(default_type, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = false; + for (const StringName &E : names) { + items[E] = false; } } @@ -2187,8 +2191,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ names.clear(); (edited_theme.operator->()->*get_list_func)(p_type_name, &names); names.sort_custom<StringName::AlphCompare>(); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - items[E->get()] = true; + for (const StringName &E : names) { + items[E] = true; } } @@ -2199,8 +2203,8 @@ OrderedHashMap<StringName, bool> ThemeTypeEditor::_get_type_items(String p_type_ keys.sort_custom<StringName::AlphCompare>(); OrderedHashMap<StringName, bool> ordered_items; - for (List<StringName>::Element *E = keys.front(); E; E = E->next()) { - ordered_items[E->get()] = items[E->get()]; + for (const StringName &E : keys) { + ordered_items[E] = items[E]; } return ordered_items; @@ -2230,21 +2234,21 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_name_edit->hide(); Button *item_rename_button = memnew(Button); - item_rename_button->set_icon(get_theme_icon("Edit", "EditorIcons")); + item_rename_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); item_rename_button->set_tooltip(TTR("Rename Item")); item_rename_button->set_flat(true); item_name_container->add_child(item_rename_button); item_rename_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_cbk), varray(p_data_type, p_item_name, item_name_container)); Button *item_remove_button = memnew(Button); - item_remove_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + item_remove_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); item_remove_button->set_tooltip(TTR("Remove Item")); item_remove_button->set_flat(true); item_name_container->add_child(item_remove_button); item_remove_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_remove_cbk), varray(p_data_type, p_item_name)); Button *item_rename_confirm_button = memnew(Button); - item_rename_confirm_button->set_icon(get_theme_icon("ImportCheck", "EditorIcons")); + item_rename_confirm_button->set_icon(get_theme_icon(SNAME("ImportCheck"), SNAME("EditorIcons"))); item_rename_confirm_button->set_tooltip(TTR("Confirm Item Rename")); item_rename_confirm_button->set_flat(true); item_name_container->add_child(item_rename_confirm_button); @@ -2252,17 +2256,17 @@ HBoxContainer *ThemeTypeEditor::_create_property_control(Theme::DataType p_data_ item_rename_confirm_button->hide(); Button *item_rename_cancel_button = memnew(Button); - item_rename_cancel_button->set_icon(get_theme_icon("ImportFail", "EditorIcons")); + item_rename_cancel_button->set_icon(get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"))); item_rename_cancel_button->set_tooltip(TTR("Cancel Item Rename")); item_rename_cancel_button->set_flat(true); item_name_container->add_child(item_rename_cancel_button); item_rename_cancel_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_rename_canceled), varray(p_data_type, p_item_name, item_name_container)); item_rename_cancel_button->hide(); } else { - item_name->add_theme_color_override("font_color", get_theme_color("disabled_font_color", "Editor")); + item_name->add_theme_color_override("font_color", get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); Button *item_override_button = memnew(Button); - item_override_button->set_icon(get_theme_icon("Add", "EditorIcons")); + item_override_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); item_override_button->set_tooltip(TTR("Override Item")); item_override_button->set_flat(true); item_name_container->add_child(item_override_button); @@ -2471,7 +2475,7 @@ void ThemeTypeEditor::_update_type_items() { pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); pin_leader_button->set_pressed(true); - pin_leader_button->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); pin_leader_button->set_tooltip(TTR("Unpin this StyleBox as a main style.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_unpin_leading_stylebox)); @@ -2516,7 +2520,7 @@ void ThemeTypeEditor::_update_type_items() { Button *pin_leader_button = memnew(Button); pin_leader_button->set_flat(true); pin_leader_button->set_toggle_mode(true); - pin_leader_button->set_icon(get_theme_icon("Pin", "EditorIcons")); + pin_leader_button->set_icon(get_theme_icon(SNAME("Pin"), SNAME("EditorIcons"))); pin_leader_button->set_tooltip(TTR("Pin this StyleBox as a main style. Editing its properties will update the same properties in all other StyleBoxes of this type.")); item_control->add_child(pin_leader_button); pin_leader_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_pin_leading_stylebox), varray(item_editor, E.key())); @@ -2570,60 +2574,60 @@ void ThemeTypeEditor::_add_default_type_items() { } updating = true; - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); { names.clear(); Theme::get_default()->get_icon_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_icon(E->get(), edited_type)) { - edited_theme->set_icon(E->get(), edited_type, Ref<Texture2D>()); + for (const StringName &E : names) { + if (!edited_theme->has_icon(E, edited_type)) { + edited_theme->set_icon(E, edited_type, Ref<Texture2D>()); } } } { names.clear(); Theme::get_default()->get_stylebox_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_stylebox(E->get(), edited_type)) { - edited_theme->set_stylebox(E->get(), edited_type, Ref<StyleBox>()); + for (const StringName &E : names) { + if (!edited_theme->has_stylebox(E, edited_type)) { + edited_theme->set_stylebox(E, edited_type, Ref<StyleBox>()); } } } { names.clear(); Theme::get_default()->get_font_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font(E->get(), edited_type)) { - edited_theme->set_font(E->get(), edited_type, Ref<Font>()); + for (const StringName &E : names) { + if (!edited_theme->has_font(E, edited_type)) { + edited_theme->set_font(E, edited_type, Ref<Font>()); } } } { names.clear(); Theme::get_default()->get_font_size_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_font_size(E->get(), edited_type)) { - edited_theme->set_font_size(E->get(), edited_type, Theme::get_default()->get_font_size(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_font_size(E, edited_type)) { + edited_theme->set_font_size(E, edited_type, Theme::get_default()->get_font_size(E, default_type)); } } } { names.clear(); Theme::get_default()->get_color_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_color(E->get(), edited_type)) { - edited_theme->set_color(E->get(), edited_type, Theme::get_default()->get_color(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_color(E, edited_type)) { + edited_theme->set_color(E, edited_type, Theme::get_default()->get_color(E, default_type)); } } } { names.clear(); Theme::get_default()->get_constant_list(default_type, &names); - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (!edited_theme->has_constant(E->get(), edited_type)) { - edited_theme->set_constant(E->get(), edited_type, Theme::get_default()->get_constant(E->get(), default_type)); + for (const StringName &E : names) { + if (!edited_theme->has_constant(E, edited_type)) { + edited_theme->set_constant(E, edited_type, Theme::get_default()->get_constant(E, default_type)); } } } @@ -2872,18 +2876,18 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { return; } - // Prevent changes from immediatelly being reported while the operation is still ongoing. + // Prevent changes from immediately being reported while the operation is still ongoing. edited_theme->_freeze_change_propagation(); List<StringName> names; edited_theme->get_stylebox_list(edited_type, &names); List<Ref<StyleBox>> styleboxes; - for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - if (E->get() == leading_stylebox.item_name) { + for (const StringName &E : names) { + if (E == leading_stylebox.item_name) { continue; } - Ref<StyleBox> sb = edited_theme->get_stylebox(E->get(), edited_type); + Ref<StyleBox> sb = edited_theme->get_stylebox(E, edited_type); if (sb->get_class() == leading_stylebox.stylebox->get_class()) { styleboxes.push_back(sb); } @@ -2891,20 +2895,20 @@ void ThemeTypeEditor::_update_stylebox_from_leading() { List<PropertyInfo> props; leading_stylebox.stylebox->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant value = leading_stylebox.stylebox->get(E->get().name); - Variant ref_value = leading_stylebox.ref_stylebox->get(E->get().name); + Variant value = leading_stylebox.stylebox->get(E.name); + Variant ref_value = leading_stylebox.ref_stylebox->get(E.name); if (value == ref_value) { continue; } - for (List<Ref<StyleBox>>::Element *F = styleboxes.front(); F; F = F->next()) { - Ref<StyleBox> sb = F->get(); - sb->set(E->get().name, value); + for (const Ref<StyleBox> &F : styleboxes) { + Ref<StyleBox> sb = F; + sb->set(E.name, value); } } @@ -2942,20 +2946,20 @@ void ThemeTypeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - add_type_button->set_icon(get_theme_icon("Add", "EditorIcons")); + add_type_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); - data_type_tabs->set_tab_icon(0, get_theme_icon("Color", "EditorIcons")); - data_type_tabs->set_tab_icon(1, get_theme_icon("MemberConstant", "EditorIcons")); - data_type_tabs->set_tab_icon(2, get_theme_icon("Font", "EditorIcons")); - data_type_tabs->set_tab_icon(3, get_theme_icon("FontSize", "EditorIcons")); - data_type_tabs->set_tab_icon(4, get_theme_icon("ImageTexture", "EditorIcons")); - data_type_tabs->set_tab_icon(5, get_theme_icon("StyleBoxFlat", "EditorIcons")); - data_type_tabs->set_tab_icon(6, get_theme_icon("Tools", "EditorIcons")); + data_type_tabs->set_tab_icon(0, get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(1, get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(2, get_theme_icon(SNAME("Font"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(3, get_theme_icon(SNAME("FontSize"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(4, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(5, get_theme_icon(SNAME("StyleBoxFlat"), SNAME("EditorIcons"))); + data_type_tabs->set_tab_icon(6, get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); - data_type_tabs->add_theme_style_override("tab_selected", get_theme_stylebox("tab_selected_odd", "TabContainer")); - data_type_tabs->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + data_type_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("tab_selected_odd"), SNAME("TabContainer"))); + data_type_tabs->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); - type_variation_button->set_icon(get_theme_icon("Add", "EditorIcons")); + type_variation_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; } } @@ -3139,7 +3143,7 @@ void ThemeEditor::_preview_scene_dialog_cbk(const String &p_path) { return; } - _add_preview_tab(preview_tab, p_path.get_file(), get_theme_icon("PackedScene", "EditorIcons")); + _add_preview_tab(preview_tab, p_path.get_file(), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); preview_tab->connect("scene_invalidated", callable_mp(this, &ThemeEditor::_remove_preview_tab_invalid), varray(preview_tab)); preview_tab->connect("scene_reloaded", callable_mp(this, &ThemeEditor::_update_preview_tab), varray(preview_tab)); } @@ -3149,7 +3153,7 @@ void ThemeEditor::_add_preview_tab(ThemeEditorPreview *p_preview_tab, const Stri preview_tabs->add_tab(p_preview_name, p_icon); preview_tabs_content->add_child(p_preview_tab); - preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("close", "Tabs")); + preview_tabs->set_tab_right_button(preview_tabs->get_tab_count() - 1, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("close"), SNAME("Tabs"))); p_preview_tab->connect("control_picked", callable_mp(this, &ThemeEditor::_preview_control_picked)); preview_tabs->set_current_tab(preview_tabs->get_tab_count() - 1); @@ -3212,11 +3216,11 @@ void ThemeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox("ThemeEditorPreviewFG", "EditorStyles")); - preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox("ThemeEditorPreviewBG", "EditorStyles")); - preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox("panel_odd", "TabContainer")); + preview_tabs->add_theme_style_override("tab_selected", get_theme_stylebox(SNAME("ThemeEditorPreviewFG"), SNAME("EditorStyles"))); + preview_tabs->add_theme_style_override("tab_unselected", get_theme_stylebox(SNAME("ThemeEditorPreviewBG"), SNAME("EditorStyles"))); + preview_tabs_content->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel_odd"), SNAME("TabContainer"))); - add_preview_button->set_icon(get_theme_icon("Add", "EditorIcons")); + add_preview_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); } break; } } @@ -3297,8 +3301,8 @@ ThemeEditor::ThemeEditor() { preview_scene_dialog->set_title(TTR("Select UI Scene:")); List<String> ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); - for (List<String>::Element *E = ext.front(); E; E = E->next()) { - preview_scene_dialog->add_filter("*." + E->get() + "; Scene"); + for (const String &E : ext) { + preview_scene_dialog->add_filter("*." + E + "; Scene"); } main_hs->add_child(preview_scene_dialog); preview_scene_dialog->connect("file_selected", callable_mp(this, &ThemeEditor::_preview_scene_dialog_cbk)); @@ -3339,12 +3343,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_font_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_font_list(E->get(), &names); + edited_theme->get_font_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (font_item == edited_theme->get_font(F->get(), E->get())) { + for (const StringName &F : names) { + if (font_item == edited_theme->get_font(F, E)) { belongs_to_theme = true; break; } @@ -3356,12 +3360,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_stylebox_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_stylebox_list(E->get(), &names); + edited_theme->get_stylebox_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (stylebox_item == edited_theme->get_stylebox(F->get(), E->get())) { + for (const StringName &F : names) { + if (stylebox_item == edited_theme->get_stylebox(F, E)) { belongs_to_theme = true; break; } @@ -3373,12 +3377,12 @@ bool ThemeEditorPlugin::handles(Object *p_node) const { List<StringName> names; edited_theme->get_icon_type_list(&types); - for (List<StringName>::Element *E = types.front(); E; E = E->next()) { + for (const StringName &E : types) { names.clear(); - edited_theme->get_icon_list(E->get(), &names); + edited_theme->get_icon_list(E, &names); - for (List<StringName>::Element *F = names.front(); F; F = F->next()) { - if (icon_item == edited_theme->get_icon(F->get(), E->get())) { + for (const StringName &F : names) { + if (icon_item == edited_theme->get_icon(F, E)) { belongs_to_theme = true; break; } diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 3c114a375a..e78b244a42 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -239,7 +239,7 @@ class ThemeItemEditorDialog : public AcceptDialog { void _update_edit_item_tree(String p_item_type); void _item_tree_button_pressed(Object *p_item, int p_column, int p_id); - void _add_theme_type(); + void _add_theme_type(const String &p_new_text); void _add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type); void _remove_data_type_items(Theme::DataType p_data_type, String p_item_type); void _remove_class_items(); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index f7bf6106b7..801ee0eac2 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -151,7 +151,7 @@ void ThemeEditorPreview::_gui_input_picker_overlay(const Ref<InputEvent> &p_even theme_type = hovered_control->get_class_name(); } - emit_signal("control_picked", theme_type); + emit_signal(SNAME("control_picked"), theme_type); picker_button->set_pressed(false); picker_overlay->set_visible(false); } @@ -182,12 +182,12 @@ void ThemeEditorPreview::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); - theme_cache.preview_picker_overlay = get_theme_stylebox("preview_picker_overlay", "ThemeEditor"); - theme_cache.preview_picker_overlay_color = get_theme_color("preview_picker_overlay_color", "ThemeEditor"); - theme_cache.preview_picker_label = get_theme_stylebox("preview_picker_label", "ThemeEditor"); - theme_cache.preview_picker_font = get_theme_font("status_source", "EditorFonts"); + theme_cache.preview_picker_overlay = get_theme_stylebox(SNAME("preview_picker_overlay"), SNAME("ThemeEditor")); + theme_cache.preview_picker_overlay_color = get_theme_color(SNAME("preview_picker_overlay_color"), SNAME("ThemeEditor")); + theme_cache.preview_picker_label = get_theme_stylebox(SNAME("preview_picker_label"), SNAME("ThemeEditor")); + theme_cache.preview_picker_font = get_theme_font(SNAME("status_source"), SNAME("EditorFonts")); } break; case NOTIFICATION_PROCESS: { time_left -= get_process_delta_time(); @@ -428,7 +428,7 @@ void SceneThemeEditorPreview::_reload_scene() { if (loaded_scene->get_path().is_empty() || !ResourceLoader::exists(loaded_scene->get_path())) { EditorNode::get_singleton()->show_warning(TTR("Invalid path, the PackedScene resource was probably moved or removed.")); - emit_signal("scene_invalidated"); + emit_signal(SNAME("scene_invalidated")); return; } @@ -441,19 +441,19 @@ void SceneThemeEditorPreview::_reload_scene() { Node *instance = loaded_scene->instantiate(); if (!instance || !Object::cast_to<Control>(instance)) { EditorNode::get_singleton()->show_warning(TTR("Invalid PackedScene resource, must have a Control node at its root.")); - emit_signal("scene_invalidated"); + emit_signal(SNAME("scene_invalidated")); return; } preview_content->add_child(instance); - emit_signal("scene_reloaded"); + emit_signal(SNAME("scene_reloaded")); } void SceneThemeEditorPreview::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - reload_scene_button->set_icon(get_theme_icon("Reload", "EditorIcons")); + reload_scene_button->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); } break; } } diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp new file mode 100644 index 0000000000..bbafc7802b --- /dev/null +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -0,0 +1,320 @@ +/*************************************************************************/ +/* atlas_merging_dialog.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "atlas_merging_dialog.h" + +#include "editor/editor_scale.h" + +#include "scene/gui/control.h" +#include "scene/gui/split_container.h" + +void AtlasMergingDialog::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { + _set(p_property, p_value); +} + +void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns) { + merged.instantiate(); + merged_mapping.clear(); + + if (p_atlas_sources.size() >= 2) { + Ref<Image> output_image; + output_image.instantiate(); + output_image->create(1, 1, false, Image::FORMAT_RGBA8); + + // Compute the new texture region size. + Vector2i new_texture_region_size; + for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { + Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; + new_texture_region_size = new_texture_region_size.max(atlas_source->get_texture_region_size()); + } + + // Generate the merged TileSetAtlasSource. + Vector2i atlas_offset; + int line_height = 0; + for (int source_index = 0; source_index < p_atlas_sources.size(); source_index++) { + Ref<TileSetAtlasSource> atlas_source = p_atlas_sources[source_index]; + merged_mapping.push_back(Map<Vector2i, Vector2i>()); + + // Layout the tiles. + Vector2i atlas_size; + + for (int tile_index = 0; tile_index < atlas_source->get_tiles_count(); tile_index++) { + Vector2i tile_id = atlas_source->get_tile_id(tile_index); + atlas_size = atlas_size.max(tile_id + atlas_source->get_tile_size_in_atlas(tile_id)); + + Rect2i new_tile_rect_in_altas = Rect2i(atlas_offset + tile_id, atlas_source->get_tile_size_in_atlas(tile_id)); + + // Create tiles and alternatives, then copy their properties. + for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_id); alternative_index++) { + int alternative_id = atlas_source->get_alternative_tile_id(tile_id, alternative_index); + if (alternative_id == 0) { + merged->create_tile(new_tile_rect_in_altas.position, new_tile_rect_in_altas.size); + } else { + merged->create_alternative_tile(new_tile_rect_in_altas.position, alternative_index); + } + + // Copy the properties. + TileData *original_tile_data = Object::cast_to<TileData>(atlas_source->get_tile_data(tile_id, alternative_id)); + List<PropertyInfo> properties; + original_tile_data->get_property_list(&properties); + for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + const StringName &property_name = E->get().name; + merged->set(property_name, original_tile_data->get(property_name)); + } + + // Add to the mapping. + merged_mapping[source_index][tile_id] = new_tile_rect_in_altas.position; + } + + // Copy the texture. + Rect2i src_rect = atlas_source->get_tile_texture_region(tile_id); + Rect2 dst_rect_wide = Rect2i(new_tile_rect_in_altas.position * new_texture_region_size, new_tile_rect_in_altas.size * new_texture_region_size); + if (dst_rect_wide.get_end().x > output_image->get_width() || dst_rect_wide.get_end().y > output_image->get_height()) { + output_image->crop(MAX(dst_rect_wide.get_end().x, output_image->get_width()), MAX(dst_rect_wide.get_end().y, output_image->get_height())); + } + output_image->blit_rect(atlas_source->get_texture()->get_image(), src_rect, (dst_rect_wide.get_position() + dst_rect_wide.get_end()) / 2 - src_rect.size / 2); + } + + // Compute the atlas offset. + line_height = MAX(atlas_size.y, line_height); + atlas_offset.x += atlas_size.x; + if (atlas_offset.x >= p_max_columns) { + atlas_offset.x = 0; + atlas_offset.y += line_height; + line_height = 0; + } + } + + Ref<ImageTexture> output_image_texture; + output_image_texture.instantiate(); + output_image_texture->create_from_image(output_image); + + merged->set_texture(output_image_texture); + merged->set_texture_region_size(new_texture_region_size); + } +} + +void AtlasMergingDialog::_update_texture() { + Vector<int> selected = atlas_merging_atlases_list->get_selected_items(); + if (selected.size() >= 2) { + Vector<Ref<TileSetAtlasSource>> to_merge; + for (int i = 0; i < selected.size(); i++) { + int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); + to_merge.push_back(tile_set->get_source(source_id)); + } + _generate_merged(to_merge, next_line_after_column); + preview->set_texture(merged->get_texture()); + preview->show(); + select_2_atlases_label->hide(); + get_ok_button()->set_disabled(false); + merge_button->set_disabled(false); + } else { + _generate_merged(Vector<Ref<TileSetAtlasSource>>(), next_line_after_column); + preview->set_texture(Ref<Texture2D>()); + preview->hide(); + select_2_atlases_label->show(); + get_ok_button()->set_disabled(true); + merge_button->set_disabled(true); + } +} + +void AtlasMergingDialog::_merge_confirmed(String p_path) { + ERR_FAIL_COND(!merged.is_valid()); + + Ref<ImageTexture> output_image_texture = merged->get_texture(); + output_image_texture->get_image()->save_png(p_path); + + Ref<Texture2D> new_texture_resource = ResourceLoader::load(p_path, "Texture2D"); + merged->set_texture(new_texture_resource); + + undo_redo->create_action("Merge TileSetAtlasSource"); + int next_id = tile_set->get_next_source_id(); + undo_redo->add_do_method(*tile_set, "add_source", merged, next_id); + undo_redo->add_undo_method(*tile_set, "remove_source", next_id); + + if (delete_original_atlases) { + // Delete originals if needed. + Vector<int> selected = atlas_merging_atlases_list->get_selected_items(); + for (int i = 0; i < selected.size(); i++) { + int source_id = atlas_merging_atlases_list->get_item_metadata(selected[i]); + Ref<TileSetAtlasSource> tas = tile_set->get_source(source_id); + undo_redo->add_do_method(*tile_set, "remove_source", source_id); + undo_redo->add_undo_method(*tile_set, "add_source", tas, source_id); + + // Add the tile proxies. + for (int tile_index = 0; tile_index < tas->get_tiles_count(); tile_index++) { + Vector2i tile_id = tas->get_tile_id(tile_index); + undo_redo->add_do_method(*tile_set, "set_coords_level_tile_proxy", source_id, tile_id, next_id, merged_mapping[i][tile_id]); + if (tile_set->has_coords_level_tile_proxy(source_id, tile_id)) { + Array a = tile_set->get_coords_level_tile_proxy(source_id, tile_id); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", a[0], a[1]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_coords_level_tile_proxy", source_id, tile_id); + } + } + } + } + undo_redo->commit_action(); + commited_actions_count++; + + hide(); +} + +void AtlasMergingDialog::ok_pressed() { + delete_original_atlases = false; + editor_file_dialog->popup_file_dialog(); +} + +void AtlasMergingDialog::cancel_pressed() { + for (int i = 0; i < commited_actions_count; i++) { + undo_redo->undo(); + } + commited_actions_count = 0; +} + +void AtlasMergingDialog::custom_action(const String &p_action) { + if (p_action == "merge") { + delete_original_atlases = true; + editor_file_dialog->popup_file_dialog(); + } +} + +bool AtlasMergingDialog::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "next_line_after_column" && p_value.get_type() == Variant::INT) { + next_line_after_column = p_value; + _update_texture(); + return true; + } + return false; +} + +bool AtlasMergingDialog::_get(const StringName &p_name, Variant &r_ret) const { + if (p_name == "next_line_after_column") { + r_ret = next_line_after_column; + return true; + } + return false; +} + +void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) { + ERR_FAIL_COND(!p_tile_set.is_valid()); + tile_set = p_tile_set; + + atlas_merging_atlases_list->clear(); + for (int i = 0; i < p_tile_set->get_source_count(); i++) { + int source_id = p_tile_set->get_source_id(i); + Ref<TileSetAtlasSource> atlas_source = p_tile_set->get_source(source_id); + if (atlas_source.is_valid()) { + Ref<Texture2D> texture = atlas_source->get_texture(); + if (texture.is_valid()) { + String item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + atlas_merging_atlases_list->add_item(item_text, texture); + atlas_merging_atlases_list->set_item_metadata(atlas_merging_atlases_list->get_item_count() - 1, source_id); + } + } + } + + get_ok_button()->set_disabled(true); + merge_button->set_disabled(true); + + commited_actions_count = 0; +} + +AtlasMergingDialog::AtlasMergingDialog() { + // Atlas merging window. + set_title(TTR("Atlas Merging")); + set_hide_on_ok(false); + + // Ok buttons + get_ok_button()->set_text(TTR("Merge (Keep original Atlases)")); + get_ok_button()->set_disabled(true); + merge_button = add_button(TTR("Merge"), true, "merge"); + merge_button->set_disabled(true); + + HSplitContainer *atlas_merging_h_split_container = memnew(HSplitContainer); + atlas_merging_h_split_container->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_h_split_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + add_child(atlas_merging_h_split_container); + + // Atlas sources item list. + atlas_merging_atlases_list = memnew(ItemList); + atlas_merging_atlases_list->set_fixed_icon_size(Size2i(60, 60) * EDSCALE); + atlas_merging_atlases_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_atlases_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_atlases_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); + atlas_merging_atlases_list->set_custom_minimum_size(Size2(100, 200)); + atlas_merging_atlases_list->set_select_mode(ItemList::SELECT_MULTI); + atlas_merging_atlases_list->connect("multi_selected", callable_mp(this, &AtlasMergingDialog::_update_texture).unbind(2)); + atlas_merging_h_split_container->add_child(atlas_merging_atlases_list); + + VBoxContainer *atlas_merging_right_panel = memnew(VBoxContainer); + atlas_merging_right_panel->set_h_size_flags(Control::SIZE_EXPAND_FILL); + atlas_merging_h_split_container->add_child(atlas_merging_right_panel); + + // Settings. + Label *settings_label = memnew(Label); + settings_label->set_text(TTR("Settings:")); + atlas_merging_right_panel->add_child(settings_label); + + columns_editor_property = memnew(EditorPropertyInteger); + columns_editor_property->set_label(TTR("Next Line After Column")); + columns_editor_property->set_object_and_property(this, "next_line_after_column"); + columns_editor_property->update_property(); + columns_editor_property->connect("property_changed", callable_mp(this, &AtlasMergingDialog::_property_changed)); + atlas_merging_right_panel->add_child(columns_editor_property); + + // Preview. + Label *preview_label = memnew(Label); + preview_label->set_text(TTR("Preview:")); + atlas_merging_right_panel->add_child(preview_label); + + preview = memnew(TextureRect); + preview->set_h_size_flags(Control::SIZE_EXPAND_FILL); + preview->set_v_size_flags(Control::SIZE_EXPAND_FILL); + preview->set_expand(true); + preview->hide(); + preview->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); + atlas_merging_right_panel->add_child(preview); + + select_2_atlases_label = memnew(Label); + select_2_atlases_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); + select_2_atlases_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); + select_2_atlases_label->set_align(Label::ALIGN_CENTER); + select_2_atlases_label->set_valign(Label::VALIGN_CENTER); + select_2_atlases_label->set_text(TTR("Please select two atlases or more.")); + atlas_merging_right_panel->add_child(select_2_atlases_label); + + // The file dialog to choose the texture path. + editor_file_dialog = memnew(EditorFileDialog); + editor_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); + editor_file_dialog->add_filter("*.png"); + editor_file_dialog->connect("file_selected", callable_mp(this, &AtlasMergingDialog::_merge_confirmed)); + add_child(editor_file_dialog); +} diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h new file mode 100644 index 0000000000..7cb54bc17e --- /dev/null +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -0,0 +1,86 @@ +/*************************************************************************/ +/* atlas_merging_dialog.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef ATLAS_MERGING_DIALOG_H +#define ATLAS_MERGING_DIALOG_H + +#include "editor/editor_node.h" +#include "editor/editor_properties.h" + +#include "scene/gui/dialogs.h" +#include "scene/gui/item_list.h" +#include "scene/gui/texture_rect.h" +#include "scene/resources/tile_set.h" + +class AtlasMergingDialog : public ConfirmationDialog { + GDCLASS(AtlasMergingDialog, ConfirmationDialog); + +private: + int commited_actions_count = 0; + bool delete_original_atlases = true; + Ref<TileSetAtlasSource> merged; + LocalVector<Map<Vector2i, Vector2i>> merged_mapping; + Ref<TileSet> tile_set; + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + // Settings. + int next_line_after_column = 30; + + // GUI. + ItemList *atlas_merging_atlases_list; + EditorPropertyVector2i *texture_region_size_editor_property; + EditorPropertyInteger *columns_editor_property; + TextureRect *preview; + Label *select_2_atlases_label; + EditorFileDialog *editor_file_dialog; + Button *merge_button; + + void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); + + void _generate_merged(Vector<Ref<TileSetAtlasSource>> p_atlas_sources, int p_max_columns); + void _update_texture(); + void _merge_confirmed(String p_path); + +protected: + virtual void ok_pressed() override; + virtual void cancel_pressed() override; + virtual void custom_action(const String &) override; + + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + +public: + void update_tile_set(Ref<TileSet> p_tile_set); + + AtlasMergingDialog(); +}; + +#endif // ATLAS_MERGING_DIALOG_H diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index 374a255df3..84e40e2ffa 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -41,25 +41,31 @@ #include "editor/editor_settings.h" void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) { - bool ctrl = Input::get_singleton()->is_key_pressed(KEY_CTRL); - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { drag_type = DRAG_TYPE_NONE; - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN) { - // Zoom out - zoom_widget->set_zoom_by_increments(-2); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); - } - if (ctrl && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) { - // Zoom in - zoom_widget->set_zoom_by_increments(2); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); - _update_zoom_and_panning(true); - accept_event(); + Vector2i scroll_vec = Vector2((mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT), (mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP) - (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN)); + if (scroll_vec != Vector2()) { + if (mb->is_ctrl_pressed()) { + if (mb->is_shift_pressed()) { + panning.x += 32 * mb->get_factor() * scroll_vec.y; + panning.y += 32 * mb->get_factor() * scroll_vec.x; + } else { + panning.y += 32 * mb->get_factor() * scroll_vec.y; + panning.x += 32 * mb->get_factor() * scroll_vec.x; + } + + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + + } else if (!mb->is_shift_pressed()) { + zoom_widget->set_zoom_by_increments(scroll_vec.y * 2); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); + _update_zoom_and_panning(true); + accept_event(); + } } if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE || mb->get_button_index() == MOUSE_BUTTON_RIGHT) { @@ -77,7 +83,7 @@ void TileAtlasView::_gui_input(const Ref<InputEvent> &p_event) { if (drag_type == DRAG_TYPE_PAN) { panning += mm->get_relative(); _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); accept_event(); } } @@ -176,14 +182,14 @@ void TileAtlasView::_update_zoom_and_panning(bool p_zoom_on_mouse_pos) { void TileAtlasView::_zoom_widget_changed() { _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); } void TileAtlasView::_center_view() { panning = Vector2(); button_center_view->set_disabled(true); _update_zoom_and_panning(); - emit_signal("transform_changed", zoom_widget->get_zoom(), panning); + emit_signal(SNAME("transform_changed"), zoom_widget->get_zoom(), panning); } void TileAtlasView::_base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event) { @@ -382,13 +388,13 @@ void TileAtlasView::_draw_alternatives() { } void TileAtlasView::_draw_background_left() { - Ref<Texture2D> texture = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_left->set_size(base_tiles_root_control->get_custom_minimum_size()); background_left->draw_texture_rect(texture, Rect2(Vector2(), background_left->get_size()), true); } void TileAtlasView::_draw_background_right() { - Ref<Texture2D> texture = get_theme_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> texture = get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")); background_right->set_size(alternative_tiles_root_control->get_custom_minimum_size()); background_right->draw_texture_rect(texture, Rect2(Vector2(), background_right->get_size()), true); } @@ -535,7 +541,7 @@ void TileAtlasView::update() { void TileAtlasView::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: - button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); break; } } @@ -564,11 +570,12 @@ TileAtlasView::TileAtlasView() { zoom_widget->connect("zoom_changed", callable_mp(this, &TileAtlasView::_zoom_widget_changed).unbind(1)); button_center_view = memnew(Button); - button_center_view->set_icon(get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); button_center_view->connect("pressed", callable_mp(this, &TileAtlasView::_center_view)); button_center_view->set_flat(true); button_center_view->set_disabled(true); + button_center_view->set_tooltip(TTR("Center View")); add_child(button_center_view); center_container = memnew(CenterContainer); diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index bafc2b3985..b2046f4322 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -47,7 +47,7 @@ class TileAtlasView : public Control { private: TileSet *tile_set; TileSetAtlasSource *tile_set_atlas_source; - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; enum DragType { DRAG_TYPE_NONE, diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index d9d0e48fb3..bab55df65a 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -113,8 +113,8 @@ void GenericTilePolygonEditor::_base_control_draw() { real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); Color grid_color = EditorSettings::get_singleton()->get("editors/tiles_editor/grid_color"); - const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); + const Ref<Texture2D> handle = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons")); + const Ref<Texture2D> add_handle = get_theme_icon(SNAME("EditorHandleAdd"), SNAME("EditorIcons")); Size2 tile_size = tile_set->get_tile_size(); @@ -195,8 +195,8 @@ void GenericTilePolygonEditor::_base_control_draw() { // Draw the text on top of the selected point. if (tinted_polygon_index >= 0) { - Ref<Font> font = get_theme_font("font", "Label"); - int font_size = get_theme_font_size("font_size", "Label"); + Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label")); String text = multiple_polygon_mode ? vformat("%d:%d", tinted_polygon_index, tinted_point_index) : vformat("%d", tinted_point_index); Size2 text_size = font->get_string_size(text, font_size); base_control->draw_string(font, xform.xform(polygons[tinted_polygon_index][tinted_point_index]) - text_size * 0.5, text, HALIGN_LEFT, -1, font_size, Color(1.0, 1.0, 1.0, 0.5)); @@ -413,7 +413,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_undo_method(this, "remove_polygon", added); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else { // Create a new point. drag_type = DRAG_TYPE_CREATE_POINT; @@ -460,7 +460,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(base_control, "update"); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } } } else { @@ -471,7 +471,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_undo_method(this, "set_polygon", drag_polygon_index, drag_old_polygon); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else if (drag_type == DRAG_TYPE_CREATE_POINT) { Point2 point = xform.affine_inverse().xform(mb->get_position()); float distance = grab_threshold * 2; @@ -507,7 +507,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref<InputEvent> p_event) undo_redo->add_do_method(base_control, "update"); undo_redo->add_undo_method(base_control, "update"); undo_redo->commit_action(false); - emit_signal("polygons_changed"); + emit_signal(SNAME("polygons_changed")); } else { drag_type = DRAG_TYPE_PAN; drag_last_pos = mb->get_position(); @@ -615,12 +615,12 @@ void GenericTilePolygonEditor::set_multiple_polygon_mode(bool p_multiple_polygon void GenericTilePolygonEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: - button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); - button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); - button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); - button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons")); - button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Snap", "EditorIcons")); - button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("GuiTabMenu", "EditorIcons")); + button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveCreate"), SNAME("EditorIcons"))); + button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveEdit"), SNAME("EditorIcons"))); + button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CurveDelete"), SNAME("EditorIcons"))); + button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); + button_pixel_snap->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + button_advanced_menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("GuiTabMenu"), SNAME("EditorIcons"))); break; } } @@ -702,7 +702,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { root->add_child(editor_zoom_widget); button_center_view = memnew(Button); - button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CenterView", "EditorIcons")); + button_center_view->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("CenterView"), SNAME("EditorIcons"))); button_center_view->set_anchors_and_offsets_preset(Control::PRESET_TOP_RIGHT, Control::PRESET_MODE_MINSIZE, 5); button_center_view->connect("pressed", callable_mp(this, &GenericTilePolygonEditor::_center_view)); button_center_view->set_flat(true); @@ -963,7 +963,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2 Rect2 rect = p_transform.xform(Rect2(Vector2(-size / 2, -size / 2), Vector2(size, size))); p_canvas_item->draw_rect(rect, value); } else { - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); String text; switch (value.get_type()) { case Variant::INT: @@ -1039,9 +1039,9 @@ void TileDataDefaultEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - tile_bool_checked = get_theme_icon("TileChecked", "EditorIcons"); - tile_bool_unchecked = get_theme_icon("TileUnchecked", "EditorIcons"); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + tile_bool_checked = get_theme_icon(SNAME("TileChecked"), SNAME("EditorIcons")); + tile_bool_unchecked = get_theme_icon(SNAME("TileUnchecked"), SNAME("EditorIcons")); break; default: break; @@ -1050,7 +1050,7 @@ void TileDataDefaultEditor::_notification(int p_what) { TileDataDefaultEditor::TileDataDefaultEditor() { label = memnew(Label); - label->set_text("Painting:"); + label->set_text(TTR("Painting:")); add_child(label); toolbar->add_child(memnew(VSeparator)); @@ -1099,7 +1099,7 @@ void TileDataPositionEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(value)) - position_icon->get_size() / 2, color); } @@ -1113,7 +1113,7 @@ void TileDataYSortEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2D Color selection_color = Color().from_hsv(Math::fposmod(grid_color.get_h() + 0.5, 1.0), grid_color.get_s(), grid_color.get_v(), 1.0); color = selection_color; } - Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon("EditorPosition", "EditorIcons"); + Ref<Texture2D> position_icon = TileSetEditor::get_singleton()->get_theme_icon(SNAME("EditorPosition"), SNAME("EditorIcons")); p_canvas_item->draw_texture(position_icon, p_transform.xform(Vector2(0, tile_data->get_y_sort_origin())) - position_icon->get_size() / 2, color); } @@ -1244,7 +1244,7 @@ void TileDataCollisionEditor::_polygons_changed() { } } - // Remove uneeded properties and their editors. + // Remove unneeded properties and their editors. for (int i = polygon_editor->get_polygon_count(); dummy_object->has_dummy_property(vformat("polygon_%d_one_way", i)); i++) { dummy_object->remove_dummy_property(vformat("polygon_%d_one_way", i)); } @@ -1458,7 +1458,7 @@ void TileDataTerrainsEditor::_property_value_changed(StringName p_property, Vari } _update_terrain_selector(); } - emit_signal("needs_redraw"); + emit_signal(SNAME("needs_redraw")); } void TileDataTerrainsEditor::_tile_set_changed() { @@ -1521,7 +1521,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); if (coords != hovered_coords) { @@ -1693,7 +1693,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(TileAtlasView *p_til } // Dim terrains with wrong terrain set. - Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font("bold", "EditorFonts"); + Ref<Font> font = TileSetEditor::get_singleton()->get_theme_font(SNAME("bold"), SNAME("EditorFonts")); for (int i = 0; i < p_tile_set_atlas_source->get_tiles_count(); i++) { Vector2i coords = p_tile_set_atlas_source->get_tile_id(i); for (int j = 1; j < p_tile_set_atlas_source->get_alternative_tiles_count(coords); j++) { @@ -2303,7 +2303,7 @@ void TileDataTerrainsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); break; default: break; diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 86bd115ac2..4a4e81dae3 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -47,27 +47,20 @@ void TileMapEditorTilesPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - select_tool_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - paint_tool_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - line_tool_button->set_icon(get_theme_icon("CurveLinear", "EditorIcons")); - rect_tool_button->set_icon(get_theme_icon("Rectangle", "EditorIcons")); - bucket_tool_button->set_icon(get_theme_icon("Bucket", "EditorIcons")); + select_tool_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + paint_tool_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + line_tool_button->set_icon(get_theme_icon(SNAME("CurveLinear"), SNAME("EditorIcons"))); + rect_tool_button->set_icon(get_theme_icon(SNAME("Rectangle"), SNAME("EditorIcons"))); + bucket_tool_button->set_icon(get_theme_icon(SNAME("Bucket"), SNAME("EditorIcons"))); - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - toggle_grid_button->set_icon(get_theme_icon("Grid", "EditorIcons")); - - missing_atlas_texture_icon = get_theme_icon("TileSet", "EditorIcons"); - - toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); + missing_atlas_texture_icon = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); break; case NOTIFICATION_VISIBILITY_CHANGED: _stop_dragging(); break; - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: - toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); - break; } } @@ -85,10 +78,6 @@ void TileMapEditorTilesPlugin::_on_scattering_spinbox_changed(double p_value) { scattering = p_value; } -void TileMapEditorTilesPlugin::_on_grid_toggled(bool p_pressed) { - EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed); -} - void TileMapEditorTilesPlugin::_update_toolbar() { // Stop draggig if needed. _stop_dragging(); @@ -168,22 +157,22 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { if (atlas_source) { texture = atlas_source->get_texture(); if (texture.is_valid()) { - item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); + item_text = vformat("%s (ID: %d)", texture->get_path().get_file(), source_id); } else { - item_text = vformat("No Texture Atlas Source (id:%d)", source_id); + item_text = vformat("No Texture Atlas Source (ID: %d)", source_id); } } // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = get_theme_icon("PackedScene", "EditorIcons"); - item_text = vformat(TTR("Scene Collection Source (id:%d)"), source_id); + texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); + item_text = vformat(TTR("Scene Collection Source (ID: %d)"), source_id); } // Use default if not valid. if (item_text.is_empty()) { - item_text = vformat(TTR("Unknown Type Source (id:%d)"), source_id); + item_text = vformat(TTR("Unknown Type Source (ID: %d)"), source_id); } if (!texture.is_valid()) { texture = missing_atlas_texture_icon; @@ -200,11 +189,11 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { } else { sources_list->set_current(0); } - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } // Synchronize - TilesEditor::get_singleton()->set_atlas_sources_lists_current(sources_list->get_current()); + TilesEditor::get_singleton()->set_sources_lists_current(sources_list->get_current()); } void TileMapEditorTilesPlugin::_update_bottom_panel() { @@ -302,11 +291,11 @@ void TileMapEditorTilesPlugin::_update_scenes_collection_view() { int item_index = 0; if (scene.is_valid()) { - item_index = scene_tiles_list->add_item(vformat("%s (path:%s id:%d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); + item_index = scene_tiles_list->add_item(vformat("%s (Path: %s, ID: %d)", scene->get_path().get_file().get_basename(), scene->get_path(), scene_id)); Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon("PackedScene", "EditorIcons")); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -410,7 +399,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", E->get(), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_do_method(tile_map, "set_cell", E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", E->get(), tile_map->get_cell_source_id(E->get()), tile_map->get_cell_atlas_coords(E->get()), tile_map->get_cell_alternative_tile(E->get())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -441,7 +430,7 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!tile_map_selection.is_empty()) { undo_redo->create_action(TTR("Delete tiles")); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { - undo_redo->add_do_method(tile_map, "set_cell", E->get(), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + undo_redo->add_do_method(tile_map, "set_cell", E->get(), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); undo_redo->add_undo_method(tile_map, "set_cell", E->get(), tile_map->get_cell_source_id(E->get()), tile_map->get_cell_atlas_coords(E->get()), tile_map->get_cell_alternative_tile(E->get())); } undo_redo->add_undo_method(this, "_set_tile_map_selection", _get_tile_map_selection()); @@ -462,12 +451,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p case DRAG_TYPE_PAINT: { Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_last_mouse_pos, mpos); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -478,12 +467,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!drag_modified.has(line[i])) { Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -516,8 +505,8 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_modified.clear(); for (Set<Vector2i>::Element *E = tile_map_selection.front(); E; E = E->next()) { Vector2i coords = E->get(); - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); - tile_map->set_cell(coords, -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + drag_modified.insert(coords, tile_map->get_cell(coords)); + tile_map->set_cell(coords, TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); } } else { // Select tiles @@ -536,12 +525,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p drag_modified.clear(); Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, mpos, mpos); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -562,12 +551,12 @@ bool TileMapEditorTilesPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p if (!drag_modified.has(line[i])) { Map<Vector2i, TileMapCell> to_draw = _draw_bucket_fill(line[i], bucket_continuous_checkbox->is_pressed()); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } Vector2i coords = E->key(); if (!drag_modified.has(coords)) { - drag_modified.insert(coords, TileMapCell(tile_map->get_cell_source_id(coords), tile_map->get_cell_atlas_coords(coords), tile_map->get_cell_alternative_tile(coords))); + drag_modified.insert(coords, tile_map->get_cell(coords)); } tile_map->set_cell(coords, E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -634,7 +623,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - tile_shape_size / 2, tile_shape_size)); tile_set->draw_tile_shape(p_overlay, cell_region, Color(1.0, 1.0, 1.0), false); } @@ -648,7 +637,7 @@ void TileMapEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p_over for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { to_draw.insert(coords); } } @@ -871,7 +860,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_line(Vector2 p_start_ // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; Map<Vector2i, TileMapCell> output; @@ -923,7 +912,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_rect(Vector2i p_start // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; // Compute the offset to align things to the bottom or right. @@ -974,7 +963,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // Get or create the pattern. TileMapPattern erase_pattern; - erase_pattern.set_cell(Vector2i(0, 0), -1, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); + erase_pattern.set_cell(Vector2i(0, 0), TileSet::INVALID_SOURCE, TileSetSource::INVALID_ATLAS_COORDS, TileSetSource::INVALID_TILE_ALTERNATIVE); TileMapPattern *pattern = erase_button->is_pressed() ? &erase_pattern : selection_pattern; Map<Vector2i, TileMapCell> output; @@ -983,7 +972,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i // If we are filling empty tiles, compute the tilemap boundaries. Rect2i boundaries; - if (source.source_id == -1) { + if (source.source_id == TileSet::INVALID_SOURCE) { boundaries = tile_map->get_used_rect(); } @@ -999,7 +988,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source.source_id == tile_map->get_cell_source_id(coords) && source.get_atlas_coords() == tile_map->get_cell_atlas_coords(coords) && source.alternative_tile == tile_map->get_cell_alternative_tile(coords) && - (source.source_id != -1 || boundaries.has_point(coords))) { + (source.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!erase_button->is_pressed() && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1027,7 +1016,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i } else { // Replace all tiles like the source. TypedArray<Vector2i> to_check; - if (source.source_id == -1) { + if (source.source_id == TileSet::INVALID_SOURCE) { Rect2i rect = tile_map->get_used_rect(); if (rect.size.x <= 0 || rect.size.y <= 0) { rect = Rect2i(p_coords, Vector2i(1, 1)); @@ -1045,7 +1034,7 @@ Map<Vector2i, TileMapCell> TileMapEditorTilesPlugin::_draw_bucket_fill(Vector2i if (source.source_id == tile_map->get_cell_source_id(coords) && source.get_atlas_coords() == tile_map->get_cell_atlas_coords(coords) && source.alternative_tile == tile_map->get_cell_alternative_tile(coords) && - (source.source_id != -1 || boundaries.has_point(coords))) { + (source.source_id != TileSet::INVALID_SOURCE || boundaries.has_point(coords))) { if (!erase_button->is_pressed() && random_tile_checkbox->is_pressed()) { // Paint a random tile. output.insert(coords, _pick_random_tile(pattern)); @@ -1102,7 +1091,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { tile_map_selection.erase(coords); } } else { - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { tile_map_selection.insert(coords); } } @@ -1173,7 +1162,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { for (int x = rect.position.x; x < rect.get_end().x; x++) { for (int y = rect.position.y; y < rect.get_end().y; y++) { Vector2i coords = Vector2i(x, y); - if (tile_map->get_cell_source_id(coords) != -1) { + if (tile_map->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { coords_array.push_back(coords); } } @@ -1198,7 +1187,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { Map<Vector2i, TileMapCell> to_draw = _draw_line(drag_start_mouse_pos, drag_start_mouse_pos, mpos); undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); @@ -1210,7 +1199,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { Map<Vector2i, TileMapCell> to_draw = _draw_rect(tile_map->world_to_map(drag_start_mouse_pos), tile_map->world_to_map(mpos)); undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = to_draw.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { + if (!erase_button->is_pressed() && E->get().source_id == TileSet::INVALID_SOURCE) { continue; } undo_redo->add_do_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); @@ -1221,9 +1210,6 @@ void TileMapEditorTilesPlugin::_stop_dragging() { case DRAG_TYPE_BUCKET: { undo_redo->create_action(TTR("Paint tiles")); for (Map<Vector2i, TileMapCell>::Element *E = drag_modified.front(); E; E = E->next()) { - if (!erase_button->is_pressed() && E->get().source_id == -1) { - continue; - } undo_redo->add_do_method(tile_map, "set_cell", E->key(), tile_map->get_cell_source_id(E->key()), tile_map->get_cell_atlas_coords(E->key()), tile_map->get_cell_alternative_tile(E->key())); undo_redo->add_undo_method(tile_map, "set_cell", E->key(), E->get().source_id, E->get().get_atlas_coords(), E->get().alternative_tile); } @@ -1249,7 +1235,7 @@ void TileMapEditorTilesPlugin::_stop_dragging() { void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); if (!tile_map) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1260,7 +1246,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { Ref<TileSet> tile_set = tile_map->get_tileset(); if (!tile_set.is_valid()) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1271,7 +1257,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { int source_index = sources_list->get_current(); if (source_index < 0 || source_index >= sources_list->get_item_count()) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_selection.clear(); @@ -1287,7 +1273,7 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { !tile_set->has_source(hovered_tile.source_id) || !tile_set->get_source(hovered_tile.source_id)->has_tile(hovered_tile.get_atlas_coords()) || !tile_set->get_source(hovered_tile.source_id)->has_alternative_tile(hovered_tile.get_atlas_coords(), hovered_tile.alternative_tile)) { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; } @@ -1403,7 +1389,7 @@ void TileMapEditorTilesPlugin::_update_tileset_selection_from_selection_pattern( TypedArray<Vector2i> used_cells = selection_pattern->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = used_cells[i]; - if (selection_pattern->get_cell_source_id(coords) != -1) { + if (selection_pattern->get_cell_source_id(coords) != TileSet::INVALID_SOURCE) { tile_set_selection.insert(TileMapCell(selection_pattern->get_cell_source_id(coords), selection_pattern->get_cell_atlas_coords(coords), selection_pattern->get_cell_alternative_tile(coords))); } } @@ -1475,7 +1461,7 @@ void TileMapEditorTilesPlugin::_tile_atlas_control_draw() { } void TileMapEditorTilesPlugin::_tile_atlas_control_mouse_exited() { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; @@ -1634,7 +1620,7 @@ void TileMapEditorTilesPlugin::_tile_alternatives_control_draw() { } void TileMapEditorTilesPlugin::_tile_alternatives_control_mouse_exited() { - hovered_tile.source_id = -1; + hovered_tile.source_id = TileSet::INVALID_SOURCE; hovered_tile.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); hovered_tile.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; tile_set_dragging_selection = false; @@ -1856,18 +1842,6 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { _on_random_tile_checkbox_toggled(false); - // Wide empty separation control. - Control *h_empty_space = memnew(Control); - h_empty_space->set_h_size_flags(SIZE_EXPAND_FILL); - toolbar->add_child(h_empty_space); - - // Grid toggle. - toggle_grid_button = memnew(Button); - toggle_grid_button->set_flat(true); - toggle_grid_button->set_toggle_mode(true); - toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditorTilesPlugin::_on_grid_toggled)); - toolbar->add_child(toggle_grid_button); - // Default tool. paint_tool_button->set_pressed(true); _update_toolbar(); @@ -1897,8 +1871,8 @@ TileMapEditorTilesPlugin::TileMapEditorTilesPlugin() { sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_fix_selected_and_hovered).unbind(1)); sources_list->connect("item_selected", callable_mp(this, &TileMapEditorTilesPlugin::_update_bottom_panel).unbind(1)); - sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_atlas_sources_lists_current)); - sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_atlas_sources_list), varray(sources_list)); + sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_sources_lists_current)); + sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_sources_list), varray(sources_list)); atlas_sources_split_container->add_child(sources_list); // Tile atlas source. @@ -1955,9 +1929,9 @@ void TileMapEditorTerrainsPlugin::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - paint_tool_button->set_icon(get_theme_icon("Edit", "EditorIcons")); - picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); - erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + paint_tool_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + picker_button->set_icon(get_theme_icon(SNAME("ColorPick"), SNAME("EditorIcons"))); + erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); break; } } @@ -2967,7 +2941,7 @@ void TileMapEditorTerrainsPlugin::_update_terrains_cache() { } TileMapCell empty_cell; - empty_cell.source_id = -1; + empty_cell.source_id = TileSet::INVALID_SOURCE; empty_cell.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); empty_cell.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; per_terrain_terrains_tile_patterns_tiles[i][empty_pattern].insert(empty_cell); @@ -2995,13 +2969,13 @@ void TileMapEditorTerrainsPlugin::_update_terrains_tree() { TreeItem *terrain_set_tree_item = terrains_tree->create_item(); String matches; if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS_AND_SIDES) { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchCornersAndSides", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchCornersAndSides"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners and Sides")); } else if (tile_set->get_terrain_set_mode(terrain_set_index) == TileSet::TERRAIN_MODE_MATCH_CORNERS) { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchCorners", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchCorners"), SNAME("EditorIcons"))); matches = String(TTR("Matches Corners Only")); } else { - terrain_set_tree_item->set_icon(0, get_theme_icon("TerrainMatchSides", "EditorIcons")); + terrain_set_tree_item->set_icon(0, get_theme_icon(SNAME("TerrainMatchSides"), SNAME("EditorIcons"))); matches = String(TTR("Matches Sides Only")); } terrain_set_tree_item->set_text(0, vformat("Terrain Set %d (%s)", terrain_set_index, matches)); @@ -3187,8 +3161,11 @@ void TileMapEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - missing_tile_texture = get_theme_icon("StatusWarning", "EditorIcons"); - warning_pattern_texture = get_theme_icon("WarningPattern", "EditorIcons"); + missing_tile_texture = get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); + warning_pattern_texture = get_theme_icon(SNAME("WarningPattern"), SNAME("EditorIcons")); + advanced_menu_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + toggle_grid_button->set_icon(get_theme_icon(SNAME("Grid"), SNAME("EditorIcons"))); + toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); break; case NOTIFICATION_INTERNAL_PROCESS: if (is_visible_in_tree() && tileset_changed_needs_update) { @@ -3198,6 +3175,44 @@ void TileMapEditor::_notification(int p_what) { tileset_changed_needs_update = false; } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: + toggle_grid_button->set_pressed(EditorSettings::get_singleton()->get("editors/tiles_editor/display_grid")); + break; + } +} + +void TileMapEditor::_on_grid_toggled(bool p_pressed) { + EditorSettings::get_singleton()->set("editors/tiles_editor/display_grid", p_pressed); +} + +void TileMapEditor::_advanced_menu_button_id_pressed(int p_id) { + TileMap *tile_map = Object::cast_to<TileMap>(ObjectDB::get_instance(tile_map_id)); + if (!tile_map) { + return; + } + + Ref<TileSet> tile_set = tile_map->get_tileset(); + if (!tile_set.is_valid()) { + return; + } + + if (p_id == 0) { // Replace Tile Proxies + undo_redo->create_action(TTR("Replace Tiles with Proxies")); + TypedArray<Vector2i> used_cells = tile_map->get_used_cells(); + for (int i = 0; i < used_cells.size(); i++) { + Vector2i cell_coords = used_cells[i]; + TileMapCell from = tile_map->get_cell(cell_coords); + Array to_array = tile_set->map_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile); + TileMapCell to; + to.source_id = to_array[0]; + to.set_atlas_coords(to_array[1]); + to.alternative_tile = to_array[2]; + if (from != to) { + undo_redo->add_do_method(tile_map, "set_cell", cell_coords, to.source_id, to.get_atlas_coords(), to.alternative_tile); + undo_redo->add_undo_method(tile_map, "set_cell", cell_coords, from.source_id, from.get_atlas_coords(), from.alternative_tile); + } + } + undo_redo->commit_action(); } } @@ -3348,7 +3363,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Vector2i tile_shape_size = tile_set->get_tile_size(); // Draw tiles with invalid IDs in the grid. - float icon_ratio = MIN(missing_tile_texture->get_size().x / tile_set->get_tile_size().x, missing_tile_texture->get_size().y / tile_set->get_tile_size().y) / 3; TypedArray<Vector2i> used_cells = tile_map->get_used_cells(); for (int i = 0; i < used_cells.size(); i++) { Vector2i coords = used_cells[i]; @@ -3364,25 +3378,33 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { if (!source || !source->has_tile(tile_atlas_coords) || !source->has_alternative_tile(tile_atlas_coords, tile_alternative_tile)) { // Generate a random color from the hashed values of the tiles. - Array to_hash; - to_hash.push_back(tile_source_id); - to_hash.push_back(tile_atlas_coords); - to_hash.push_back(tile_alternative_tile); - uint32_t hash = RandomPCG(to_hash.hash()).rand(); - - Color color; - color = color.from_hsv( - (float)((hash >> 24) & 0xFF) / 256.0, - Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0), - Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0), - 0.8); - - // Draw the scaled tile. - Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - Vector2(tile_shape_size) / 2, Vector2(tile_shape_size))); - tile_set->draw_tile_shape(p_overlay, cell_region, color, true, warning_pattern_texture); + Array a = tile_set->map_tile_proxy(tile_source_id, tile_atlas_coords, tile_alternative_tile); + if (int(a[0]) == tile_source_id && Vector2i(a[1]) == tile_atlas_coords && int(a[2]) == tile_alternative_tile) { + // Only display the pattern if we have no proxy tile. + Array to_hash; + to_hash.push_back(tile_source_id); + to_hash.push_back(tile_atlas_coords); + to_hash.push_back(tile_alternative_tile); + uint32_t hash = RandomPCG(to_hash.hash()).rand(); + + Color color; + color = color.from_hsv( + (float)((hash >> 24) & 0xFF) / 256.0, + Math::lerp(0.5, 1.0, (float)((hash >> 16) & 0xFF) / 256.0), + Math::lerp(0.5, 1.0, (float)((hash >> 8) & 0xFF) / 256.0), + 0.8); + + // Draw the scaled tile. + Rect2 cell_region = xform.xform(Rect2(tile_map->map_to_world(coords) - Vector2(tile_shape_size) / 2, Vector2(tile_shape_size))); + tile_set->draw_tile_shape(p_overlay, cell_region, color, true, warning_pattern_texture); + } // Draw the warning icon. - Rect2 rect = Rect2(xform.xform(tile_map->map_to_world(coords)) - (icon_ratio * missing_tile_texture->get_size() * xform.get_scale() / 2), icon_ratio * missing_tile_texture->get_size() * xform.get_scale()); + int min_axis = missing_tile_texture->get_size().min_axis(); + Vector2 icon_size; + icon_size[min_axis] = tile_set->get_tile_size()[min_axis] / 3; + icon_size[(min_axis + 1) % 2] = (icon_size[min_axis] * missing_tile_texture->get_size()[(min_axis + 1) % 2] / missing_tile_texture->get_size()[min_axis]); + Rect2 rect = Rect2(xform.xform(tile_map->map_to_world(coords)) - (icon_size * xform.get_scale() / 2), icon_size * xform.get_scale()); p_overlay->draw_texture_rect(missing_tile_texture, rect); } } @@ -3438,7 +3460,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } // Draw the IDs for debug. - /*Ref<Font> font = get_theme_font("font", "Label"); + /*Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label")); for (int x = displayed_rect.position.x; x < (displayed_rect.position.x + displayed_rect.size.x); x++) { for (int y = displayed_rect.position.y; y < (displayed_rect.position.y + displayed_rect.size.y); y++) { p_overlay->draw_string(font, xform.xform(tile_map->map_to_world(Vector2(x, y))) + Vector2i(-tile_shape_size.x / 2, 0), vformat("%s", Vector2(x, y))); @@ -3502,6 +3524,26 @@ TileMapEditor::TileMapEditor() { tilemap_toolbar->add_child(tile_map_editor_plugins[i]->get_toolbar()); } + // Wide empty separation control. + Control *h_empty_space = memnew(Control); + h_empty_space->set_h_size_flags(SIZE_EXPAND_FILL); + tilemap_toolbar->add_child(h_empty_space); + + // Grid toggle. + toggle_grid_button = memnew(Button); + toggle_grid_button->set_flat(true); + toggle_grid_button->set_toggle_mode(true); + toggle_grid_button->set_tooltip(TTR("Toggle grid visibility.")); + toggle_grid_button->connect("toggled", callable_mp(this, &TileMapEditor::_on_grid_toggled)); + tilemap_toolbar->add_child(toggle_grid_button); + + // Advanced settings menu button. + advanced_menu_button = memnew(MenuButton); + advanced_menu_button->set_flat(true); + advanced_menu_button->get_popup()->add_item(TTR("Automatically Replace Tiles with Proxies")); + advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileMapEditor::_advanced_menu_button_id_pressed)); + tilemap_toolbar->add_child(advanced_menu_button); + missing_tileset_label = memnew(Label); missing_tileset_label->set_text(TTR("The edited TileMap node has no TileSet resource.")); missing_tileset_label->set_h_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index a6f4ec3021..236774a06b 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -82,9 +82,6 @@ private: void _on_random_tile_checkbox_toggled(bool p_pressed); void _on_scattering_spinbox_changed(double p_value); - Button *toggle_grid_button; - void _on_grid_toggled(bool p_pressed); - void _update_toolbar(); ///// Tilemap editing. ///// @@ -300,6 +297,7 @@ class TileMapEditor : public VBoxContainer { GDCLASS(TileMapEditor, VBoxContainer); private: + UndoRedo *undo_redo = EditorNode::get_undo_redo(); bool tileset_changed_needs_update = false; ObjectID tile_map_id; @@ -309,6 +307,12 @@ private: // Toolbar. HBoxContainer *tilemap_toolbar; + Button *toggle_grid_button; + void _on_grid_toggled(bool p_pressed); + + MenuButton *advanced_menu_button; + void _advanced_menu_button_id_pressed(int p_id); + // Bottom panel Label *missing_tileset_label; Tabs *tabs; diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp new file mode 100644 index 0000000000..e5e7efa531 --- /dev/null +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp @@ -0,0 +1,476 @@ +/*************************************************************************/ +/* tile_proxies_manager_dialog.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "tile_proxies_manager_dialog.h" + +#include "editor/editor_scale.h" + +void TileProxiesManagerDialog::_right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list) { + ItemList *item_list = Object::cast_to<ItemList>(p_item_list); + popup_menu->set_size(Vector2(1, 1)); + popup_menu->set_position(get_position() + item_list->get_global_mouse_position()); + popup_menu->popup(); +} + +void TileProxiesManagerDialog::_menu_id_pressed(int p_id) { + if (p_id == 0) { + // Delete. + _delete_selected_bindings(); + } +} + +void TileProxiesManagerDialog::_delete_selected_bindings() { + undo_redo->create_action("Remove Tile Proxies"); + + Vector<int> source_level_selected = source_level_list->get_selected_items(); + for (int i = 0; i < source_level_selected.size(); i++) { + int key = source_level_list->get_item_metadata(source_level_selected[i]); + int val = tile_set->get_source_level_tile_proxy(key); + undo_redo->add_do_method(*tile_set, "remove_source_level_tile_proxy", key); + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", key, val); + } + + Vector<int> coords_level_selected = coords_level_list->get_selected_items(); + for (int i = 0; i < coords_level_selected.size(); i++) { + Array key = coords_level_list->get_item_metadata(coords_level_selected[i]); + Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]); + undo_redo->add_do_method(*tile_set, "remove_coords_level_tile_proxy", key[0], key[1]); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", key[0], key[1], val[0], val[1]); + } + + Vector<int> alternative_level_selected = alternative_level_list->get_selected_items(); + for (int i = 0; i < alternative_level_selected.size(); i++) { + Array key = alternative_level_list->get_item_metadata(alternative_level_selected[i]); + Array val = tile_set->get_coords_level_tile_proxy(key[0], key[1]); + undo_redo->add_do_method(*tile_set, "remove_alternative_level_tile_proxy", key[0], key[1], key[2]); + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", key[0], key[1], key[2], val[0], val[1], val[2]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); + + commited_actions_count += 1; +} + +void TileProxiesManagerDialog::_update_lists() { + source_level_list->clear(); + coords_level_list->clear(); + alternative_level_list->clear(); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s", proxy[0]).rpad(5) + "-> " + vformat("%s", proxy[1]); + int id = source_level_list->add_item(text); + source_level_list->set_item_metadata(id, proxy[0]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s, %s", proxy[0], proxy[1]).rpad(17) + "-> " + vformat("%s, %s", proxy[2], proxy[3]); + int id = coords_level_list->add_item(text); + coords_level_list->set_item_metadata(id, proxy.slice(0, 2)); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + String text = vformat("%s, %s, %s", proxy[0], proxy[1], proxy[2]).rpad(24) + "-> " + vformat("%s, %s, %s", proxy[3], proxy[4], proxy[5]); + int id = alternative_level_list->add_item(text); + alternative_level_list->set_item_metadata(id, proxy.slice(0, 3)); + } +} + +void TileProxiesManagerDialog::_update_enabled_property_editors() { + if (from.source_id == TileSet::INVALID_SOURCE) { + from.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); + to.set_atlas_coords(TileSetSource::INVALID_ATLAS_COORDS); + from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + coords_from_property_editor->hide(); + coords_to_property_editor->hide(); + alternative_from_property_editor->hide(); + alternative_to_property_editor->hide(); + } else if (from.get_atlas_coords().x == -1 || from.get_atlas_coords().y == -1) { + from.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + to.alternative_tile = TileSetSource::INVALID_TILE_ALTERNATIVE; + coords_from_property_editor->show(); + coords_to_property_editor->show(); + alternative_from_property_editor->hide(); + alternative_to_property_editor->hide(); + } else { + coords_from_property_editor->show(); + coords_to_property_editor->show(); + alternative_from_property_editor->show(); + alternative_to_property_editor->show(); + } + + source_from_property_editor->update_property(); + source_to_property_editor->update_property(); + coords_from_property_editor->update_property(); + coords_to_property_editor->update_property(); + alternative_from_property_editor->update_property(); + alternative_to_property_editor->update_property(); +} + +void TileProxiesManagerDialog::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) { + _set(p_path, p_value); +} + +void TileProxiesManagerDialog::_add_button_pressed() { + if (from.source_id != TileSet::INVALID_SOURCE && to.source_id != TileSet::INVALID_SOURCE) { + Vector2i from_coords = from.get_atlas_coords(); + Vector2i to_coords = to.get_atlas_coords(); + if (from_coords.x >= 0 && from_coords.y >= 0 && to_coords.x >= 0 && to_coords.y >= 0) { + if (from.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE && to.alternative_tile != TileSetSource::INVALID_TILE_ALTERNATIVE) { + undo_redo->create_action("Create Alternative-level Tile Proxy"); + undo_redo->add_do_method(*tile_set, "set_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile, to.source_id, to.get_atlas_coords(), to.alternative_tile); + if (tile_set->has_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile)) { + Array a = tile_set->get_alternative_level_tile_proxy(from.source_id, from.get_atlas_coords(), from.alternative_tile); + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", to.source_id, to.get_atlas_coords(), to.alternative_tile, a[0], a[1], a[2]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_alternative_level_tile_proxy", from.source_id, from.get_atlas_coords(), from.alternative_tile); + } + } else { + undo_redo->create_action("Create Coords-level Tile Proxy"); + undo_redo->add_do_method(*tile_set, "set_coords_level_tile_proxy", from.source_id, from.get_atlas_coords(), to.source_id, to.get_atlas_coords()); + if (tile_set->has_coords_level_tile_proxy(from.source_id, from.get_atlas_coords())) { + Array a = tile_set->get_coords_level_tile_proxy(from.source_id, from.get_atlas_coords()); + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", to.source_id, to.get_atlas_coords(), a[0], a[1]); + } else { + undo_redo->add_undo_method(*tile_set, "remove_coords_level_tile_proxy", from.source_id, from.get_atlas_coords()); + } + } + } else { + undo_redo->create_action("Create source-level Tile Proxy"); + undo_redo->add_do_method(*tile_set, "set_source_level_tile_proxy", from.source_id, to.source_id); + if (tile_set->has_source_level_tile_proxy(from.source_id)) { + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", to.source_id, tile_set->get_source_level_tile_proxy(from.source_id)); + } else { + undo_redo->add_undo_method(*tile_set, "remove_source_level_tile_proxy", from.source_id); + } + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); + commited_actions_count++; + } +} + +void TileProxiesManagerDialog::_clear_invalid_button_pressed() { + undo_redo->create_action("Delete All Invalid Tile Proxies"); + + undo_redo->add_do_method(*tile_set, "cleanup_invalid_tile_proxies"); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); +} + +void TileProxiesManagerDialog::_clear_all_button_pressed() { + undo_redo->create_action("Delete All Tile Proxies"); + + undo_redo->add_do_method(*tile_set, "clear_tile_proxies"); + + Array proxies = tile_set->get_source_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_source_level_tile_proxy", proxy[0], proxy[1]); + } + + proxies = tile_set->get_coords_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_coords_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3]); + } + + proxies = tile_set->get_alternative_level_tile_proxies(); + for (int i = 0; i < proxies.size(); i++) { + Array proxy = proxies[i]; + undo_redo->add_undo_method(*tile_set, "set_alternative_level_tile_proxy", proxy[0], proxy[1], proxy[2], proxy[3], proxy[4], proxy[5]); + } + undo_redo->add_do_method(this, "_update_lists"); + undo_redo->add_undo_method(this, "_update_lists"); + undo_redo->commit_action(); +} + +bool TileProxiesManagerDialog::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "from_source") { + from.source_id = MAX(int(p_value), -1); + } else if (p_name == "from_coords") { + from.set_atlas_coords(Vector2i(p_value).max(Vector2i(-1, -1))); + } else if (p_name == "from_alternative") { + from.alternative_tile = MAX(int(p_value), -1); + } else if (p_name == "to_source") { + to.source_id = MAX(int(p_value), 0); + } else if (p_name == "to_coords") { + to.set_atlas_coords(Vector2i(p_value).max(Vector2i(0, 0))); + } else if (p_name == "to_alternative") { + to.alternative_tile = MAX(int(p_value), 0); + } else { + return false; + } + _update_enabled_property_editors(); + return true; +} + +bool TileProxiesManagerDialog::_get(const StringName &p_name, Variant &r_ret) const { + if (p_name == "from_source") { + r_ret = from.source_id; + } else if (p_name == "from_coords") { + r_ret = from.get_atlas_coords(); + } else if (p_name == "from_alternative") { + r_ret = from.alternative_tile; + } else if (p_name == "to_source") { + r_ret = to.source_id; + } else if (p_name == "to_coords") { + r_ret = to.get_atlas_coords(); + } else if (p_name == "to_alternative") { + r_ret = to.alternative_tile; + } else { + return false; + } + return true; +} + +void TileProxiesManagerDialog::_unhandled_key_input(Ref<InputEvent> p_event) { + ERR_FAIL_COND(p_event.is_null()); + + if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) { + if (!is_inside_tree() || !is_visible()) { + return; + } + + if (popup_menu->activate_item_by_event(p_event, false)) { + set_input_as_handled(); + } + } +} + +void TileProxiesManagerDialog::cancel_pressed() { + for (int i = 0; i < commited_actions_count; i++) { + undo_redo->undo(); + } + commited_actions_count = 0; +} + +void TileProxiesManagerDialog::_bind_methods() { + ClassDB::bind_method(D_METHOD("_update_lists"), &TileProxiesManagerDialog::_update_lists); + ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &TileProxiesManagerDialog::_unhandled_key_input); +} + +void TileProxiesManagerDialog::update_tile_set(Ref<TileSet> p_tile_set) { + ERR_FAIL_COND(!p_tile_set.is_valid()); + tile_set = p_tile_set; + commited_actions_count = 0; + _update_lists(); +} + +TileProxiesManagerDialog::TileProxiesManagerDialog() { + // Tile proxy management window. + set_title(TTR("Tile Proxies Management")); + set_process_unhandled_key_input(true); + + to.source_id = 0; + to.set_atlas_coords(Vector2i()); + to.alternative_tile = 0; + + VBoxContainer *vbox_container = memnew(VBoxContainer); + vbox_container->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vbox_container->set_v_size_flags(Control::SIZE_EXPAND_FILL); + add_child(vbox_container); + + Label *source_level_label = memnew(Label); + source_level_label->set_text(TTR("Source-level proxies")); + vbox_container->add_child(source_level_label); + + source_level_list = memnew(ItemList); + source_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + source_level_list->set_select_mode(ItemList::SELECT_MULTI); + source_level_list->set_allow_rmb_select(true); + source_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(source_level_list)); + vbox_container->add_child(source_level_list); + + Label *coords_level_label = memnew(Label); + coords_level_label->set_text(TTR("Coords-level proxies")); + vbox_container->add_child(coords_level_label); + + coords_level_list = memnew(ItemList); + coords_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + coords_level_list->set_select_mode(ItemList::SELECT_MULTI); + coords_level_list->set_allow_rmb_select(true); + coords_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(coords_level_list)); + vbox_container->add_child(coords_level_list); + + Label *alternative_level_label = memnew(Label); + alternative_level_label->set_text(TTR("Alternative-level proxies")); + vbox_container->add_child(alternative_level_label); + + alternative_level_list = memnew(ItemList); + alternative_level_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); + alternative_level_list->set_select_mode(ItemList::SELECT_MULTI); + alternative_level_list->set_allow_rmb_select(true); + alternative_level_list->connect("item_rmb_selected", callable_mp(this, &TileProxiesManagerDialog::_right_clicked), varray(alternative_level_list)); + vbox_container->add_child(alternative_level_list); + + popup_menu = memnew(PopupMenu); + popup_menu->add_shortcut(ED_GET_SHORTCUT("ui_text_delete")); + popup_menu->connect("id_pressed", callable_mp(this, &TileProxiesManagerDialog::_menu_id_pressed)); + add_child(popup_menu); + + // Add proxy panel. + HSeparator *h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); + + Label *add_label = memnew(Label); + add_label->set_text(TTR("Add a new tile proxy:")); + vbox_container->add_child(add_label); + + HBoxContainer *hboxcontainer = memnew(HBoxContainer); + vbox_container->add_child(hboxcontainer); + + // From + VBoxContainer *vboxcontainer_from = memnew(VBoxContainer); + vboxcontainer_from->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hboxcontainer->add_child(vboxcontainer_from); + + source_from_property_editor = memnew(EditorPropertyInteger); + source_from_property_editor->set_label(TTR("From Source")); + source_from_property_editor->set_object_and_property(this, "from_source"); + source_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + source_from_property_editor->set_selectable(false); + source_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + source_from_property_editor->setup(-1, 99999, 1, true, false); + vboxcontainer_from->add_child(source_from_property_editor); + + coords_from_property_editor = memnew(EditorPropertyVector2i); + coords_from_property_editor->set_label(TTR("From Coords")); + coords_from_property_editor->set_object_and_property(this, "from_coords"); + coords_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + coords_from_property_editor->set_selectable(false); + coords_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + coords_from_property_editor->setup(-1, 99999, true); + coords_from_property_editor->hide(); + vboxcontainer_from->add_child(coords_from_property_editor); + + alternative_from_property_editor = memnew(EditorPropertyInteger); + alternative_from_property_editor->set_label(TTR("From Alternative")); + alternative_from_property_editor->set_object_and_property(this, "from_alternative"); + alternative_from_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + alternative_from_property_editor->set_selectable(false); + alternative_from_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + alternative_from_property_editor->setup(-1, 99999, 1, true, false); + alternative_from_property_editor->hide(); + vboxcontainer_from->add_child(alternative_from_property_editor); + + // To + VBoxContainer *vboxcontainer_to = memnew(VBoxContainer); + vboxcontainer_to->set_h_size_flags(Control::SIZE_EXPAND_FILL); + hboxcontainer->add_child(vboxcontainer_to); + + source_to_property_editor = memnew(EditorPropertyInteger); + source_to_property_editor->set_label(TTR("To Source")); + source_to_property_editor->set_object_and_property(this, "to_source"); + source_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + source_to_property_editor->set_selectable(false); + source_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + source_to_property_editor->setup(-1, 99999, 1, true, false); + vboxcontainer_to->add_child(source_to_property_editor); + + coords_to_property_editor = memnew(EditorPropertyVector2i); + coords_to_property_editor->set_label(TTR("To Coords")); + coords_to_property_editor->set_object_and_property(this, "to_coords"); + coords_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + coords_to_property_editor->set_selectable(false); + coords_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + coords_to_property_editor->setup(-1, 99999, true); + coords_to_property_editor->hide(); + vboxcontainer_to->add_child(coords_to_property_editor); + + alternative_to_property_editor = memnew(EditorPropertyInteger); + alternative_to_property_editor->set_label(TTR("To Alternative")); + alternative_to_property_editor->set_object_and_property(this, "to_alternative"); + alternative_to_property_editor->connect("property_changed", callable_mp(this, &TileProxiesManagerDialog::_property_changed)); + alternative_to_property_editor->set_selectable(false); + alternative_to_property_editor->set_h_size_flags(Control::SIZE_EXPAND_FILL); + alternative_to_property_editor->setup(-1, 99999, 1, true, false); + alternative_to_property_editor->hide(); + vboxcontainer_to->add_child(alternative_to_property_editor); + + Button *add_button = memnew(Button); + add_button->set_text(TTR("Add")); + add_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + add_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_add_button_pressed)); + vbox_container->add_child(add_button); + + h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); + + // Generic actions. + Label *generic_actions_label = memnew(Label); + generic_actions_label->set_text(TTR("Global actions:")); + vbox_container->add_child(generic_actions_label); + + hboxcontainer = memnew(HBoxContainer); + vbox_container->add_child(hboxcontainer); + + Button *clear_invalid_button = memnew(Button); + clear_invalid_button->set_text(TTR("Clear Invalid")); + clear_invalid_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + clear_invalid_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_invalid_button_pressed)); + hboxcontainer->add_child(clear_invalid_button); + + Button *clear_all_button = memnew(Button); + clear_all_button->set_text(TTR("Clear All")); + clear_all_button->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + clear_all_button->connect("pressed", callable_mp(this, &TileProxiesManagerDialog::_clear_all_button_pressed)); + hboxcontainer->add_child(clear_all_button); + + h_separator = memnew(HSeparator); + vbox_container->add_child(h_separator); +} diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.h b/editor/plugins/tiles/tile_proxies_manager_dialog.h new file mode 100644 index 0000000000..f6898e960b --- /dev/null +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.h @@ -0,0 +1,90 @@ +/*************************************************************************/ +/* tile_proxies_manager_dialog.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef TILE_PROXIES_MANAGER_DIALOG_H +#define TILE_PROXIES_MANAGER_DIALOG_H + +#include "editor/editor_node.h" +#include "editor/editor_properties.h" + +#include "scene/gui/dialogs.h" +#include "scene/gui/item_list.h" +#include "scene/resources/tile_set.h" + +class TileProxiesManagerDialog : public ConfirmationDialog { + GDCLASS(TileProxiesManagerDialog, ConfirmationDialog); + +private: + int commited_actions_count = 0; + Ref<TileSet> tile_set; + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + + TileMapCell from; + TileMapCell to; + + // GUI + ItemList *source_level_list; + ItemList *coords_level_list; + ItemList *alternative_level_list; + + EditorPropertyInteger *source_from_property_editor; + EditorPropertyVector2i *coords_from_property_editor; + EditorPropertyInteger *alternative_from_property_editor; + EditorPropertyInteger *source_to_property_editor; + EditorPropertyVector2i *coords_to_property_editor; + EditorPropertyInteger *alternative_to_property_editor; + + PopupMenu *popup_menu; + void _right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list); + void _menu_id_pressed(int p_id); + void _delete_selected_bindings(); + void _update_lists(); + void _update_enabled_property_editors(); + void _property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing); + void _add_button_pressed(); + + void _clear_invalid_button_pressed(); + void _clear_all_button_pressed(); + +protected: + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _unhandled_key_input(Ref<InputEvent> p_event); + virtual void cancel_pressed() override; + static void _bind_methods(); + +public: + void update_tile_set(Ref<TileSet> p_tile_set); + + TileProxiesManagerDialog(); +}; + +#endif // TILE_PROXIES_MANAGER_DIALOG_H diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 9d849a0df5..432f48fa85 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -58,7 +58,7 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::set_id(int p_id) { int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. tile_set->set_source_id(previous_source, p_id); - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); } int TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::get_id() { @@ -69,7 +69,7 @@ bool TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_set(const StringN bool valid = false; tile_set_atlas_source->set(p_name, p_value, &valid); if (valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return valid; } @@ -148,14 +148,14 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na tile_set_atlas_source->move_tile_in_atlas(coords, as_vector2i); tiles.clear(); tiles.insert({ as_vector2i, 0 }); - emit_signal("changed", "atlas_coords"); + emit_signal(SNAME("changed"), "atlas_coords"); return true; } else if (alternative == 0 && p_name == "size_in_atlas") { Vector2i as_vector2i = Vector2i(p_value); ERR_FAIL_COND_V(!tile_set_atlas_source->can_move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i), false); tile_set_atlas_source->move_tile_in_atlas(coords, TileSetSource::INVALID_ATLAS_COORDS, as_vector2i); - emit_signal("changed", "size_in_atlas"); + emit_signal(SNAME("changed"), "size_in_atlas"); return true; } else if (alternative > 0 && p_name == "alternative_id") { int as_int = int(p_value); @@ -172,7 +172,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na tiles.insert({ coords, as_int }); // tiles must be updated before. tile_set_atlas_source->set_alternative_tile_id(coords, previous_alternative_tile, as_int); - emit_signal("changed", "alternative_id"); + emit_signal(SNAME("changed"), "alternative_id"); return true; } } @@ -191,7 +191,7 @@ bool TileSetAtlasSourceEditor::AtlasTileProxyObject::_set(const StringName &p_na } if (any_valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return any_valid; @@ -303,9 +303,9 @@ void TileSetAtlasSourceEditor::AtlasTileProxyObject::_get_property_list(List<Pro } // Add only properties that are common to all tiles. - for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (E->get()->uses == tiles.size()) { - p_list->push_back(E->get()->property_info); + for (const PLData *E : data_list) { + if (E->uses == tiles.size()) { + p_list->push_back(E->property_info); } } } @@ -453,7 +453,7 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editors_tree->add_theme_constant_override("vseparation", 1); tile_data_editors_tree->add_theme_constant_override("hseparation", 3); - Color group_color = get_theme_color("prop_category", "Editor"); + Color group_color = get_theme_color(SNAME("prop_category"), SNAME("Editor")); // List of editors. // --- Rendering --- @@ -660,26 +660,26 @@ void TileSetAtlasSourceEditor::_update_current_tile_data_editor() { } void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() { - if (!has_theme_icon("arrow", "OptionButton")) { + if (!has_theme_icon(SNAME("arrow"), SNAME("OptionButton"))) { return; } RID ci = tile_data_editor_dropdown_button->get_canvas_item(); - Ref<Texture2D> arrow = Control::get_theme_icon("arrow", "OptionButton"); + Ref<Texture2D> arrow = Control::get_theme_icon(SNAME("arrow"), SNAME("OptionButton")); Color clr = Color(1, 1, 1); - if (get_theme_constant("modulate_arrow")) { + if (get_theme_constant(SNAME("modulate_arrow"))) { switch (tile_data_editor_dropdown_button->get_draw_mode()) { case BaseButton::DRAW_PRESSED: - clr = get_theme_color("font_pressed_color"); + clr = get_theme_color(SNAME("font_pressed_color")); break; case BaseButton::DRAW_HOVER: - clr = get_theme_color("font_hover_color"); + clr = get_theme_color(SNAME("font_hover_color")); break; case BaseButton::DRAW_DISABLED: - clr = get_theme_color("font_disabled_color"); + clr = get_theme_color(SNAME("font_disabled_color")); break; default: - clr = get_theme_color("font_color"); + clr = get_theme_color(SNAME("font_color")); } } @@ -687,9 +687,9 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_draw() { Point2 ofs; if (is_layout_rtl()) { - ofs = Point2(get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(get_theme_constant(SNAME("arrow_margin"), SNAME("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2))); } else { - ofs = Point2(size.width - arrow->get_width() - get_theme_constant("arrow_margin", "OptionButton"), int(Math::abs((size.height - arrow->get_height()) / 2))); + ofs = Point2(size.width - arrow->get_width() - get_theme_constant(SNAME("arrow_margin"), SNAME("OptionButton")), int(Math::abs((size.height - arrow->get_height()) / 2))); } arrow->draw(ci, ofs, clr); } @@ -702,7 +702,7 @@ void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() { } void TileSetAtlasSourceEditor::_tile_data_editors_tree_selected() { - tile_data_editors_popup->call_deferred("hide"); + tile_data_editors_popup->call_deferred(SNAME("hide")); _update_current_tile_data_editor(); tile_atlas_control->update(); tile_atlas_control_unscaled->update(); @@ -740,12 +740,12 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { Button *button = memnew(Button); alternative_tiles_control->add_child(button); button->set_flat(true); - button->set_icon(get_theme_icon("Add", "EditorIcons")); + button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button->add_theme_style_override("normal", memnew(StyleBoxEmpty)); button->add_theme_style_override("hover", memnew(StyleBoxEmpty)); button->add_theme_style_override("focus", memnew(StyleBoxEmpty)); button->add_theme_style_override("pressed", memnew(StyleBoxEmpty)); - button->connect("pressed", callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile), varray(tile_id, -1)); + button->connect("pressed", callable_mp(tile_set_atlas_source, &TileSetAtlasSource::create_alternative_tile), varray(tile_id, TileSetSource::INVALID_TILE_ALTERNATIVE)); button->set_rect(Rect2(Vector2(pos.x, pos.y + (y_increment - texture_region_base_size.y) / 2.0), Vector2(texture_region_base_size_min, texture_region_base_size_min))); button->set_expand_icon(true); @@ -1858,7 +1858,7 @@ void TileSetAtlasSourceEditor::_atlas_source_proxy_object_changed(String p_what) if (p_what == "texture" && !atlas_source_proxy_object->get("texture").is_null()) { confirm_auto_create_tiles->popup_centered(); } else if (p_what == "id") { - emit_signal("source_id_changed", atlas_source_proxy_object->get_id()); + emit_signal(SNAME("source_id_changed"), atlas_source_proxy_object->get_id()); } } @@ -2049,16 +2049,16 @@ void TileSetAtlasSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - tool_setup_atlas_source_button->set_icon(get_theme_icon("Tools", "EditorIcons")); - tool_select_button->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); - tool_paint_button->set_icon(get_theme_icon("CanvasItem", "EditorIcons")); + tool_setup_atlas_source_button->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + tool_select_button->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_paint_button->set_icon(get_theme_icon(SNAME("CanvasItem"), SNAME("EditorIcons"))); - tools_settings_erase_button->set_icon(get_theme_icon("Eraser", "EditorIcons")); + tools_settings_erase_button->set_icon(get_theme_icon(SNAME("Eraser"), SNAME("EditorIcons"))); - tool_advanced_menu_buttom->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + tool_advanced_menu_buttom->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); - resize_handle = get_theme_icon("EditorHandle", "EditorIcons"); - resize_handle_disabled = get_theme_icon("EditorHandleDisabled", "EditorIcons"); + resize_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons")); + resize_handle_disabled = get_theme_icon(SNAME("EditorHandleDisabled"), SNAME("EditorIcons")); break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_atlas_source_changed_needs_update) { @@ -2176,7 +2176,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { // -- Dialogs -- confirm_auto_create_tiles = memnew(AcceptDialog); - confirm_auto_create_tiles->set_title(TTR("Create tiles automatically in non-transparent texture regions?")); + confirm_auto_create_tiles->set_title(TTR("Auto Create Tiles in Non-Transparent Texture Regions?")); confirm_auto_create_tiles->set_text(TTR("The atlas's texture was modified.\nWould you like to automatically create tiles in the atlas?")); confirm_auto_create_tiles->get_ok_button()->set_text(TTR("Yes")); confirm_auto_create_tiles->add_cancel_button()->set_text(TTR("No")); @@ -2202,7 +2202,7 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() { tool_setup_atlas_source_button->set_toggle_mode(true); tool_setup_atlas_source_button->set_pressed(true); tool_setup_atlas_source_button->set_button_group(tools_button_group); - tool_setup_atlas_source_button->set_tooltip(TTR("Atlas Setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); + tool_setup_atlas_source_button->set_tooltip(TTR("Atlas setup. Add/Remove tiles tool (use the shift key to create big tiles, control for rectangle editing).")); toolbox->add_child(tool_setup_atlas_source_button); tool_select_button = memnew(Button); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index dbb0756a16..501416c340 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -65,7 +65,7 @@ private: private: Ref<TileSet> tile_set; TileSetAtlasSource *tile_set_atlas_source = nullptr; - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -108,7 +108,7 @@ private: Ref<TileSet> tile_set; TileSetAtlasSource *tile_set_atlas_source = nullptr; - int tile_set_atlas_source_id = -1; + int tile_set_atlas_source_id = TileSet::INVALID_SOURCE; UndoRedo *undo_redo = EditorNode::get_undo_redo(); diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 2c2ebd107f..ba98a7d6b3 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -50,7 +50,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C if (p_from == sources_list) { // Handle dropping a texture in the list of atlas resources. - int source_id = -1; + int source_id = TileSet::INVALID_SOURCE; int added = 0; Dictionary d = p_data; Vector<String> files = d["files"]; @@ -77,7 +77,7 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C } // Update the selected source (thus triggering an update). - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } } @@ -114,11 +114,11 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat return false; } -void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { +void TileSetEditor::_update_sources_list(int force_selected_id) { ERR_FAIL_COND(!tile_set.is_valid()); // Get the previously selected id. - int old_selected = -1; + int old_selected = TileSet::INVALID_SOURCE; if (sources_list->get_current() >= 0) { int source_id = sources_list->get_item_metadata(sources_list->get_current()); if (tile_set->has_source(source_id)) { @@ -126,7 +126,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { } } - int to_select = -1; + int to_select = TileSet::INVALID_SOURCE; if (force_selected_id >= 0) { to_select = force_selected_id; } else if (old_selected >= 0) { @@ -159,7 +159,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { // Scene collection source. TileSetScenesCollectionSource *scene_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source); if (scene_collection_source) { - texture = get_theme_icon("PackedScene", "EditorIcons"); + texture = get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); item_text = vformat(TTR("Scene Collection Source (id:%d)"), source_id); } @@ -181,7 +181,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { if ((int)sources_list->get_item_metadata(i) == to_select) { sources_list->set_current(i); if (old_selected != to_select) { - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } break; } @@ -192,7 +192,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { if (sources_list->get_current() < 0 && sources_list->get_item_count() > 0) { sources_list->set_current(0); if (old_selected != int(sources_list->get_item_metadata(0))) { - sources_list->emit_signal("item_selected", sources_list->get_current()); + sources_list->emit_signal(SNAME("item_selected"), sources_list->get_current()); } } @@ -200,7 +200,7 @@ void TileSetEditor::_update_atlas_sources_list(int force_selected_id) { _source_selected(sources_list->get_current()); // Synchronize the lists. - TilesEditor::get_singleton()->set_atlas_sources_lists_current(sources_list->get_current()); + TilesEditor::get_singleton()->set_sources_lists_current(sources_list->get_current()); } void TileSetEditor::_source_selected(int p_source_index) { @@ -235,6 +235,23 @@ void TileSetEditor::_source_selected(int p_source_index) { } } +void TileSetEditor::_source_delete_pressed() { + ERR_FAIL_COND(!tile_set.is_valid()); + + // Update the selected source. + int to_delete = sources_list->get_item_metadata(sources_list->get_current()); + + Ref<TileSetSource> source = tile_set->get_source(to_delete); + + // Remove the source. + undo_redo->create_action(TTR("Remove source")); + undo_redo->add_do_method(*tile_set, "remove_source", to_delete); + undo_redo->add_undo_method(*tile_set, "add_source", source, to_delete); + undo_redo->commit_action(); + + _update_sources_list(); +} + void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { ERR_FAIL_COND(!tile_set.is_valid()); @@ -251,7 +268,7 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { undo_redo->add_undo_method(*tile_set, "remove_source", source_id); undo_redo->commit_action(); - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } break; case 1: { int source_id = tile_set->get_next_source_id(); @@ -264,44 +281,43 @@ void TileSetEditor::_source_add_id_pressed(int p_id_pressed) { undo_redo->add_undo_method(*tile_set, "remove_source", source_id); undo_redo->commit_action(); - _update_atlas_sources_list(source_id); + _update_sources_list(source_id); } break; default: ERR_FAIL(); } } -void TileSetEditor::_source_delete_pressed() { +void TileSetEditor::_sources_advanced_menu_id_pressed(int p_id_pressed) { ERR_FAIL_COND(!tile_set.is_valid()); - // Update the selected source. - int to_delete = sources_list->get_item_metadata(sources_list->get_current()); - - Ref<TileSetSource> source = tile_set->get_source(to_delete); - - // Remove the source. - undo_redo->create_action(TTR("Remove source")); - undo_redo->add_do_method(*tile_set, "remove_source", to_delete); - undo_redo->add_undo_method(*tile_set, "add_source", source, to_delete); - undo_redo->commit_action(); - - _update_atlas_sources_list(); + switch (p_id_pressed) { + case 0: { + atlas_merging_dialog->update_tile_set(tile_set); + atlas_merging_dialog->popup_centered_ratio(0.5); + } break; + case 1: { + tile_proxies_manager_dialog->update_tile_set(tile_set); + tile_proxies_manager_dialog->popup_centered_ratio(0.5); + } break; + } } void TileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - sources_delete_button->set_icon(get_theme_icon("Remove", "EditorIcons")); - sources_add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - missing_texture_texture = get_theme_icon("TileSet", "EditorIcons"); + sources_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + sources_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + sources_advanced_menu_button->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons"))); + missing_texture_texture = get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons")); break; case NOTIFICATION_INTERNAL_PROCESS: if (tile_set_changed_needs_update) { if (tile_set.is_valid()) { tile_set->set_edited(true); } - _update_atlas_sources_list(); + _update_sources_list(); tile_set_changed_needs_update = false; } break; @@ -414,7 +430,7 @@ void TileSetEditor::edit(Ref<TileSet> p_tile_set) { // Add the listener again. if (tile_set.is_valid()) { tile_set->connect("changed", callable_mp(this, &TileSetEditor::_tile_set_changed)); - _update_atlas_sources_list(); + _update_sources_list(); } tile_set_atlas_source_editor->hide(); @@ -447,8 +463,8 @@ TileSetEditor::TileSetEditor() { sources_list->set_h_size_flags(SIZE_EXPAND_FILL); sources_list->set_v_size_flags(SIZE_EXPAND_FILL); sources_list->connect("item_selected", callable_mp(this, &TileSetEditor::_source_selected)); - sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_atlas_sources_lists_current)); - sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_atlas_sources_list), varray(sources_list)); + sources_list->connect("item_selected", callable_mp(TilesEditor::get_singleton(), &TilesEditor::set_sources_lists_current)); + sources_list->connect("visibility_changed", callable_mp(TilesEditor::get_singleton(), &TilesEditor::synchronize_sources_list), varray(sources_list)); sources_list->set_texture_filter(CanvasItem::TEXTURE_FILTER_NEAREST); sources_list->set_drag_forwarding(this); split_container_left_side->add_child(sources_list); @@ -470,6 +486,19 @@ TileSetEditor::TileSetEditor() { sources_add_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_source_add_id_pressed)); sources_bottom_actions->add_child(sources_add_button); + sources_advanced_menu_button = memnew(MenuButton); + sources_advanced_menu_button->set_flat(true); + sources_advanced_menu_button->get_popup()->add_item(TTR("Open Atlas Merging Tool")); + sources_advanced_menu_button->get_popup()->add_item(TTR("Manage Tile Proxies")); + sources_advanced_menu_button->get_popup()->connect("id_pressed", callable_mp(this, &TileSetEditor::_sources_advanced_menu_id_pressed)); + sources_bottom_actions->add_child(sources_advanced_menu_button); + + atlas_merging_dialog = memnew(AtlasMergingDialog); + add_child(atlas_merging_dialog); + + tile_proxies_manager_dialog = memnew(TileProxiesManagerDialog); + add_child(tile_proxies_manager_dialog); + // Right side container. VBoxContainer *split_container_right_side = memnew(VBoxContainer); split_container_right_side->set_h_size_flags(SIZE_EXPAND_FILL); @@ -489,7 +518,7 @@ TileSetEditor::TileSetEditor() { tile_set_atlas_source_editor = memnew(TileSetAtlasSourceEditor); tile_set_atlas_source_editor->set_h_size_flags(SIZE_EXPAND_FILL); tile_set_atlas_source_editor->set_v_size_flags(SIZE_EXPAND_FILL); - tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_atlas_sources_list)); + tile_set_atlas_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list)); split_container_right_side->add_child(tile_set_atlas_source_editor); tile_set_atlas_source_editor->hide(); @@ -497,7 +526,7 @@ TileSetEditor::TileSetEditor() { tile_set_scenes_collection_source_editor = memnew(TileSetScenesCollectionSourceEditor); tile_set_scenes_collection_source_editor->set_h_size_flags(SIZE_EXPAND_FILL); tile_set_scenes_collection_source_editor->set_v_size_flags(SIZE_EXPAND_FILL); - tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_atlas_sources_list)); + tile_set_scenes_collection_source_editor->connect("source_id_changed", callable_mp(this, &TileSetEditor::_update_sources_list)); split_container_right_side->add_child(tile_set_scenes_collection_source_editor); tile_set_scenes_collection_source_editor->hide(); diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index 9e50aca62f..970e3fabb6 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -31,8 +31,10 @@ #ifndef TILE_SET_EDITOR_H #define TILE_SET_EDITOR_H +#include "atlas_merging_dialog.h" #include "scene/gui/box_container.h" #include "scene/resources/tile_set.h" +#include "tile_proxies_manager_dialog.h" #include "tile_set_atlas_source_editor.h" #include "tile_set_scenes_collection_source_editor.h" @@ -51,16 +53,21 @@ private: UndoRedo *undo_redo = EditorNode::get_undo_redo(); - void _update_atlas_sources_list(int force_selected_id = -1); + void _update_sources_list(int force_selected_id = -1); - // -- Sources management -- + // Sources management. Button *sources_delete_button; MenuButton *sources_add_button; + MenuButton *sources_advanced_menu_button; ItemList *sources_list; Ref<Texture2D> missing_texture_texture; void _source_selected(int p_source_index); - void _source_add_id_pressed(int p_id_pressed); void _source_delete_pressed(); + void _source_add_id_pressed(int p_id_pressed); + void _sources_advanced_menu_id_pressed(int p_id_pressed); + + AtlasMergingDialog *atlas_merging_dialog; + TileProxiesManagerDialog *tile_proxies_manager_dialog; void _tile_set_changed(); diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp index 568d4ca8d7..f74b3bf9c2 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.cpp @@ -48,7 +48,7 @@ void TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::se int previous_source = source_id; source_id = p_id; // source_id must be updated before, because it's used by the source list update. tile_set->set_source_id(previous_source, p_id); - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); } int TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::get_id() { @@ -59,7 +59,7 @@ bool TileSetScenesCollectionSourceEditor::TileSetScenesCollectionProxyObject::_s bool valid = false; tile_set_scenes_collection_source->set(p_name, p_value, &valid); if (valid) { - emit_signal("changed", String(p_name).utf8().get_data()); + emit_signal(SNAME("changed"), String(p_name).utf8().get_data()); } return valid; } @@ -120,7 +120,7 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin ERR_FAIL_COND_V(tile_set_scenes_collection_source->has_scene_tile_id(as_int), false); tile_set_scenes_collection_source->set_scene_tile_id(scene_id, as_int); scene_id = as_int; - emit_signal("changed", "id"); + emit_signal(SNAME("changed"), "id"); for (int i = 0; i < tile_set_scenes_collection_source_editor->scene_tiles_list->get_item_count(); i++) { if (int(tile_set_scenes_collection_source_editor->scene_tiles_list->get_item_metadata(i)) == scene_id) { tile_set_scenes_collection_source_editor->scene_tiles_list->select(i); @@ -130,11 +130,11 @@ bool TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_set(const Strin return true; } else if (p_name == "scene") { tile_set_scenes_collection_source->set_scene_tile_scene(scene_id, p_value); - emit_signal("changed", "scene"); + emit_signal(SNAME("changed"), "scene"); return true; } else if (p_name == "display_placeholder") { tile_set_scenes_collection_source->set_scene_tile_display_placeholder(scene_id, p_value); - emit_signal("changed", "display_placeholder"); + emit_signal(SNAME("changed"), "display_placeholder"); return true; } @@ -186,7 +186,7 @@ void TileSetScenesCollectionSourceEditor::SceneTileProxyObject::_bind_methods() void TileSetScenesCollectionSourceEditor::_scenes_collection_source_proxy_object_changed(String p_what) { if (p_what == "id") { - emit_signal("source_id_changed", scenes_collection_source_proxy_object->get_id()); + emit_signal(SNAME("source_id_changed"), scenes_collection_source_proxy_object->get_id()); } } @@ -284,7 +284,7 @@ void TileSetScenesCollectionSourceEditor::_update_scenes_list() { Variant udata = i; EditorResourcePreview::get_singleton()->queue_edited_resource_preview(scene, this, "_scene_thumbnail_done", udata); } else { - item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon("PackedScene", "EditorIcons")); + item_index = scene_tiles_list->add_item(TTR("Tile with Invalid Scene"), get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); } scene_tiles_list->set_item_metadata(item_index, scene_id); @@ -307,8 +307,8 @@ void TileSetScenesCollectionSourceEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: - scene_tile_add_button->set_icon(get_theme_icon("Add", "EditorIcons")); - scene_tile_delete_button->set_icon(get_theme_icon("Remove", "EditorIcons")); + scene_tile_add_button->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + scene_tile_delete_button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); _update_scenes_list(); break; case NOTIFICATION_INTERNAL_PROCESS: diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index fb111efc17..79b869b511 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -50,7 +50,7 @@ void TilesEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - tileset_tilemap_switch_button->set_icon(get_theme_icon("TileSet", "EditorIcons")); + tileset_tilemap_switch_button->set_icon(get_theme_icon(SNAME("TileSet"), SNAME("EditorIcons"))); } break; case NOTIFICATION_INTERNAL_PROCESS: { if (tile_map_changed_needs_update) { @@ -118,11 +118,11 @@ void TilesEditor::_update_editors() { CanvasItemEditor::get_singleton()->update_viewport(); } -void TilesEditor::set_atlas_sources_lists_current(int p_current) { +void TilesEditor::set_sources_lists_current(int p_current) { atlas_sources_lists_current = p_current; } -void TilesEditor::synchronize_atlas_sources_list(Object *p_current) { +void TilesEditor::synchronize_sources_list(Object *p_current) { ItemList *item_list = Object::cast_to<ItemList>(p_current); ERR_FAIL_COND(!item_list); @@ -131,7 +131,7 @@ void TilesEditor::synchronize_atlas_sources_list(Object *p_current) { item_list->deselect_all(); } else { item_list->set_current(atlas_sources_lists_current); - item_list->emit_signal("item_selected", atlas_sources_lists_current); + item_list->emit_signal(SNAME("item_selected"), atlas_sources_lists_current); } } } diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index 6cc6f51598..f976d68938 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -76,8 +76,8 @@ public: void forward_canvas_draw_over_viewport(Control *p_overlay) { tilemap_editor->forward_canvas_draw_over_viewport(p_overlay); } // To synchronize the atlas sources lists. - void set_atlas_sources_lists_current(int p_current); - void synchronize_atlas_sources_list(Object *p_current); + void set_sources_lists_current(int p_current); + void synchronize_sources_list(Object *p_current); void set_atlas_view_transform(float p_zoom, Vector2 p_scroll); void synchronize_atlas_view(Object *p_current); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 10679ad6f2..5804f54649 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -164,7 +164,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { _refresh_file_diff(); } } - commit_status->set_text("New changes detected"); + commit_status->set_text(TTR("New changes detected")); } } else { WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); @@ -184,11 +184,11 @@ void VersionControlEditorPlugin::_stage_selected() { while (file_entry) { if (file_entry->is_checked(0)) { EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); staged_files_count++; } else { EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); } file_entry = file_entry->get_next(); @@ -210,7 +210,7 @@ void VersionControlEditorPlugin::_stage_all() { TreeItem *file_entry = root->get_first_child(); while (file_entry) { EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); - file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); file_entry->set_checked(0, true); staged_files_count++; @@ -235,16 +235,16 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { diff_file_name->set_text(p_file_path); diff->clear(); - diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font(SNAME("source"), SNAME("EditorFonts"))); for (int i = 0; i < diff_content.size(); i++) { Dictionary line_result = diff_content[i]; if (line_result["status"] == "+") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else if (line_result["status"] == "-") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); } else { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Label"))); } diff->add_text((String)line_result["content"]); @@ -270,9 +270,9 @@ void VersionControlEditorPlugin::_clear_file_diff() { void VersionControlEditorPlugin::_update_stage_status() { String status; if (staged_files_count == 1) { - status = "Stage contains 1 file"; + status = TTR("Stage contains 1 file"); } else { - status = "Stage contains " + String::num_int64(staged_files_count) + " files"; + status = vformat(TTR("Stage contains %d files"), staged_files_count); } commit_status->set_text(status); } @@ -280,9 +280,9 @@ void VersionControlEditorPlugin::_update_stage_status() { void VersionControlEditorPlugin::_update_commit_status() { String status; if (staged_files_count == 1) { - status = "Committed 1 file"; + status = TTR("Committed 1 file"); } else { - status = "Committed " + String::num_int64(staged_files_count) + " files "; + status = vformat(TTR("Committed %d files"), staged_files_count); } commit_status->set_text(status); staged_files_count = 0; @@ -407,7 +407,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { refresh_button = memnew(Button); refresh_button->set_tooltip(TTR("Detect new changes")); refresh_button->set_text(TTR("Refresh")); - refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons")); + refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); stage_tools->add_child(refresh_button); @@ -432,11 +432,11 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { change_type_to_strings[CHANGE_TYPE_DELETED] = TTR("Deleted"); change_type_to_strings[CHANGE_TYPE_TYPECHANGE] = TTR("Typechange"); - change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor"); - change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor"); - change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("disabled_font_color", "Editor"); - change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor"); - change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Editor"); + change_type_to_color[CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("warning_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor")); + change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("font_color"), SNAME("Editor")); stage_buttons = memnew(HSplitContainer); stage_buttons->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN_COLLAPSED); @@ -501,7 +501,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { diff_refresh_button = memnew(Button); diff_refresh_button->set_tooltip(TTR("Detect changes in file diff")); - diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons")); + diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); diff_refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_file_diff)); diff_hbc->add_child(diff_refresh_button); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 85ad03c9bc..46818afe45 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -164,7 +164,7 @@ void VisualShaderGraphPlugin::show_port_preview(VisualShader::Type p_type, int p } void VisualShaderGraphPlugin::update_node_deferred(VisualShader::Type p_type, int p_node_id) { - call_deferred("update_node", p_type, p_node_id); + call_deferred(SNAME("update_node"), p_type, p_node_id); } void VisualShaderGraphPlugin::update_node(VisualShader::Type p_type, int p_node_id) { @@ -335,9 +335,9 @@ void VisualShaderGraphPlugin::register_uniform_name(int p_node_id, LineEdit *p_u } void VisualShaderGraphPlugin::update_theme() { - vector_expanded_color[0] = VisualShaderEditor::get_singleton()->get_theme_color("axis_x_color", "Editor"); // red - vector_expanded_color[1] = VisualShaderEditor::get_singleton()->get_theme_color("axis_y_color", "Editor"); // green - vector_expanded_color[2] = VisualShaderEditor::get_singleton()->get_theme_color("axis_z_color", "Editor"); // blue + vector_expanded_color[0] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); // red + vector_expanded_color[1] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); // green + vector_expanded_color[2] = VisualShaderEditor::get_singleton()->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); // blue } void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { @@ -465,7 +465,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { vsnode->remove_meta("shader_type"); if (custom_editor) { if (vsnode->is_show_prop_names()) { - custom_editor->call_deferred("_show_prop_names", true); + custom_editor->call_deferred(SNAME("_show_prop_names"), true); } break; } @@ -526,8 +526,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityHidden", "EditorIcons")); - preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); + preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, 0, preview); @@ -585,7 +585,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0); node->set_slot(0, true, port_left, type_color[port_left], true, port_right, type_color[port_right]); - VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_set_node_size"), (int)p_type, p_id, size); } if (vsnode->is_use_prop_slots()) { @@ -666,8 +666,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_left) { name_left = vsnode->get_input_port_name(i); port_left = vsnode->get_input_port_type(i); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - if (E->get().to_node == p_id && E->get().to_port == j) { + for (const VisualShader::Connection &E : connections) { + if (E.to_node == p_id && E.to_port == j) { port_left_used = true; } } @@ -733,7 +733,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { name_box->connect("focus_exited", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_port_name_focus_out), varray(name_box, p_id, i, false), CONNECT_DEFERRED); Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_input_port), varray(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -746,7 +746,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) { Label *hint_label = memnew(Label); hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]"); - hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("font_readonly_color", "TextEdit")); + hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("font_readonly_color"), SNAME("TextEdit"))); hint_label->add_theme_style_override("normal", label_style); hb->add_child(hint_label); } @@ -760,7 +760,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (valid_right) { if (is_group) { Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_remove_output_port), varray(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -796,8 +796,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (vsnode->is_output_port_expandable(i)) { TextureButton *expand = memnew(TextureButton); expand->set_toggle_mode(true); - expand->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiTreeArrowDown", "EditorIcons")); - expand->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiTreeArrowRight", "EditorIcons")); + expand->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); + expand->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); expand->set_v_size_flags(Control::SIZE_SHRINK_CENTER); expand->set_pressed(vsnode->_is_output_port_expanded(i)); expand->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_expand_output_port), varray(p_id, i, !vsnode->_is_output_port_expanded(i)), CONNECT_DEFERRED); @@ -806,8 +806,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { if (visual_shader->get_shader_type() == VisualShader::TYPE_FRAGMENT && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityHidden", "EditorIcons")); - preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + preview->set_normal_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); + preview->set_pressed_texture(VisualShaderEditor::get_singleton()->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, j, preview); @@ -873,7 +873,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { String error = vsnode->get_warning(visual_shader->get_mode(), p_type); if (error != String()) { Label *error_label = memnew(Label); - error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); error_label->set_text(error); node->add_child(error_label); } @@ -899,16 +899,16 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_box->set_syntax_highlighter(expression_syntax_highlighter); expression_box->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = VisualShaderEditor::get_singleton()->keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - expression_syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : VisualShaderEditor::get_singleton()->keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + expression_syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - expression_syntax_highlighter->add_keyword_color(E->get(), keyword_color); + expression_syntax_highlighter->add_keyword_color(E, keyword_color); } } - expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font("expression", "EditorFonts")); - expression_box->add_theme_font_size_override("font_size", VisualShaderEditor::get_singleton()->get_theme_font_size("expression_size", "EditorFonts")); + expression_box->add_theme_font_override("font", VisualShaderEditor::get_singleton()->get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + expression_box->add_theme_font_size_override("font_size", VisualShaderEditor::get_singleton()->get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); expression_box->add_theme_color_override("font_color", text_color); expression_syntax_highlighter->set_number_color(number_color); expression_syntax_highlighter->set_symbol_color(symbol_color); @@ -935,7 +935,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } VisualShaderEditor::get_singleton()->_update_created_node(node); if (is_resizable) { - VisualShaderEditor::get_singleton()->call_deferred("_set_node_size", (int)p_type, p_id, size); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_set_node_size"), (int)p_type, p_id, size); } } } @@ -961,7 +961,7 @@ void VisualShaderGraphPlugin::connect_nodes(VisualShader::Type p_type, int p_fro void VisualShaderGraphPlugin::disconnect_nodes(VisualShader::Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) { if (visual_shader->get_shader_type() == p_type) { VisualShaderEditor::get_singleton()->graph->disconnect_node(itos(p_from_node), p_from_port, itos(p_to_node), p_to_port); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { + for (const List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { connections.erase(E); break; @@ -1211,8 +1211,8 @@ void VisualShaderEditor::_update_options_menu() { bool is_first_item = true; - Color unsupported_color = get_theme_color("error_color", "Editor"); - Color supported_color = get_theme_color("warning_color", "Editor"); + Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); static bool low_driver = ProjectSettings::get_singleton()->get("rendering/driver/driver_name") == "GLES2"; @@ -1285,22 +1285,22 @@ void VisualShaderEditor::_update_options_menu() { } switch (options[i].return_type) { case VisualShaderNode::PORT_TYPE_SCALAR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_VECTOR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); break; default: break; @@ -1349,12 +1349,12 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) { return; } - Ref<StyleBox> normal = get_theme_stylebox("normal", "Button"); + Ref<StyleBox> normal = get_theme_stylebox(SNAME("normal"), SNAME("Button")); button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } void VisualShaderEditor::_update_created_node(GraphNode *node) { - const Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); + const Ref<StyleBoxFlat> sb = node->get_theme_stylebox(SNAME("frame"), SNAME("GraphNode")); Color c = sb->get_border_color(); const Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0, 0.85) : Color(0.0, 0.0, 0.0, 0.85); c = mono_color; @@ -1470,11 +1470,11 @@ void VisualShaderEditor::_update_graph() { graph_plugin->make_dirty(false); - for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - int from = E->get().from_node; - int from_idx = E->get().from_port; - int to = E->get().to_node; - int to_idx = E->get().to_port; + for (const VisualShader::Connection &E : connections) { + int from = E.from_node; + int from_idx = E.from_port; + int to = E.to_node; + int to_idx = E.to_port; graph->connect_node(itos(from), from_idx, itos(to), to_idx); } @@ -1634,11 +1634,11 @@ void VisualShaderEditor::_expand_output_port(int p_node, int p_port, bool p_expa List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (p_expand) { @@ -1708,11 +1708,11 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (to_node == p_node) { if (to_port == p_port) { @@ -1757,11 +1757,11 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; - int from_port = E->get().from_port; - int to_node = E->get().to_node; - int to_port = E->get().to_port; + for (const VisualShader::Connection &E : conns) { + int from_node = E.from_node; + int from_port = E.from_port; + int to_node = E.to_node; + int to_port = E.to_port; if (from_node == p_node) { if (from_port == p_port) { @@ -2470,12 +2470,12 @@ void VisualShaderEditor::_add_node(int p_idx, int p_op_idx, String p_resource_pa VisualShaderNodeCurveTexture *curve = Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()); if (curve) { - graph_plugin->call_deferred("update_curve", id_to_use); + graph_plugin->call_deferred(SNAME("update_curve"), id_to_use); } VisualShaderNodeCurveXYZTexture *curve_xyz = Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()); if (curve_xyz) { - graph_plugin->call_deferred("update_curve_xyz", id_to_use); + graph_plugin->call_deferred(SNAME("update_curve_xyz"), id_to_use); } if (p_resource_path.is_empty()) { @@ -2508,7 +2508,7 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t VisualShader::Type type = get_current_shader_type(); drag_buffer.push_back({ type, p_node, p_from, p_to }); if (!drag_dirty) { - call_deferred("_nodes_dragged"); + call_deferred(SNAME("_nodes_dragged")); } drag_dirty = true; } @@ -2518,11 +2518,11 @@ void VisualShaderEditor::_nodes_dragged() { undo_redo->create_action(TTR("Node(s) Moved")); - for (List<DragOp>::Element *E = drag_buffer.front(); E; E = E->next()) { - undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); - undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().to); - undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E->get().type, E->get().node, E->get().from); + for (const DragOp &E : drag_buffer) { + undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", E.type, E.node, E.from); + undo_redo->add_do_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.to); + undo_redo->add_undo_method(graph_plugin.ptr(), "set_node_position", E.type, E.node, E.from); } drag_buffer.clear(); @@ -2544,12 +2544,12 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == to && E->get().to_port == p_to_index) { - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.to_node == to && E.to_port == p_to_index) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } @@ -2597,22 +2597,22 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const int &F : p_nodes) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } Set<String> uniform_names; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get()); + for (const int &F : p_nodes) { + Ref<VisualShaderNode> node = visual_shader->get_node(type, F); - undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get()); - undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F->get()), F->get()); - undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F->get()); + undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F); + undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, node, visual_shader->get_node_position(type, F), F); + undo_redo->add_undo_method(graph_plugin.ptr(), "add_node", type, F); undo_redo->add_do_method(this, "_clear_buffer"); undo_redo->add_undo_method(this, "_clear_buffer"); @@ -2638,28 +2638,28 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) { } List<VisualShader::Connection> used_conns; - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == F->get() || E->get().to_node == F->get()) { + for (const int &F : p_nodes) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == F || E.to_node == F) { bool cancel = false; for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) { - if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) { + if (R->get().from_node == E.from_node && R->get().from_port == E.from_port && R->get().to_node == E.to_node && R->get().to_port == E.to_port) { cancel = true; // to avoid ERR_ALREADY_EXISTS warning break; } } if (!cancel) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - used_conns.push_back(E->get()); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + used_conns.push_back(E); } } } } // delete nodes from the graph - for (const List<int>::Element *F = p_nodes.front(); F; F = F->next()) { - undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F->get()); + for (const int &F : p_nodes) { + undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F); } // update uniform refs if any uniform has been deleted @@ -3032,7 +3032,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { members_dialog->set_position(members_dialog->get_position() - Point2(difference, 0)); } - node_filter->call_deferred("grab_focus"); // still not visible + node_filter->call_deferred(SNAME("grab_focus")); // still not visible node_filter->select_all(); } @@ -3075,11 +3075,11 @@ void VisualShaderEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - highend_label->set_modulate(get_theme_color("vulkan_color", "Editor")); + highend_label->set_modulate(get_theme_color(SNAME("vulkan_color"), SNAME("Editor"))); - node_filter->set_right_icon(Control::get_theme_icon("Search", "EditorIcons")); + node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - preview_shader->set_icon(Control::get_theme_icon("Shader", "EditorIcons")); + preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); @@ -3094,16 +3094,16 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); - for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - if (ShaderLanguage::is_control_flow_keyword(E->get())) { - syntax_highlighter->add_keyword_color(E->get(), control_flow_keyword_color); + for (const String &E : keyword_list) { + if (ShaderLanguage::is_control_flow_keyword(E)) { + syntax_highlighter->add_keyword_color(E, control_flow_keyword_color); } else { - syntax_highlighter->add_keyword_color(E->get(), keyword_color); + syntax_highlighter->add_keyword_color(E, keyword_color); } } - preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); - preview_text->add_theme_font_size_override("font_size", get_theme_font_size("expression_size", "EditorFonts")); + preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); + preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); preview_text->add_theme_color_override("font_color", text_color); syntax_highlighter->set_number_color(number_color); syntax_highlighter->set_symbol_color(symbol_color); @@ -3117,13 +3117,13 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_comment_delimiter("/*", "*/", false); preview_text->add_comment_delimiter("//", "", true); - error_panel->add_theme_style_override("panel", get_theme_stylebox("panel", "Panel")); - error_label->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); - error_label->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts")); - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); + error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); + error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } - tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Tools", "EditorIcons")); + tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -3206,9 +3206,9 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in Map<int, int> connection_remap; Set<int> unsupported_set; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { - connection_remap[E->get()] = id_from; - Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get()); + for (int &E : r_nodes) { + connection_remap[E] = id_from; + Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E); bool unsupported = false; for (int i = 0; i < add_options.size(); i++) { @@ -3220,13 +3220,13 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in } } if (unsupported) { - unsupported_set.insert(E->get()); + unsupported_set.insert(E); continue; } Ref<VisualShaderNode> dupli = node->duplicate(); - undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E->get()) + p_offset, id_from); + undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, dupli, visual_shader->get_node_position(pasted_type, E) + p_offset, id_from); undo_redo->add_do_method(graph_plugin.ptr(), "add_node", type, id_from); // duplicate size, inputs and outputs if node is group @@ -3249,19 +3249,19 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in List<VisualShader::Connection> conns; visual_shader->get_node_connections(pasted_type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (unsupported_set.has(E->get().from_node) || unsupported_set.has(E->get().to_node)) { + for (const VisualShader::Connection &E : conns) { + if (unsupported_set.has(E.from_node) || unsupported_set.has(E.to_node)) { continue; } - if (connection_remap.has(E->get().from_node) && connection_remap.has(E->get().to_node)) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E->get().from_node], E->get().from_port, connection_remap[E->get().to_node], E->get().to_port); + if (connection_remap.has(E.from_node) && connection_remap.has(E.to_node)) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, connection_remap[E.from_node], E.from_port, connection_remap[E.to_node], E.to_port); } } id_from = base_id; - for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { + for (int i = 0; i < r_nodes.size(); i++) { undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_from); undo_redo->add_undo_method(graph_plugin.ptr(), "remove_node", type, id_from); id_from++; @@ -3399,17 +3399,17 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input, if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { - undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_input->get_input_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { + undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -3445,15 +3445,15 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_ if (type_changed) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().from_node == id) { - if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E->get().to_node)->get_input_port_type(E->get().to_port))) { + for (const VisualShader::Connection &E : conns) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { continue; } - undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); - undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -4605,18 +4605,18 @@ public: } void _item_selected(int p_item) { - VisualShaderEditor::get_singleton()->call_deferred("_input_select_item", input, get_item_text(p_item)); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_input_select_item"), input, get_item_text(p_item)); } void setup(const Ref<VisualShaderNodeInput> &p_input) { input = p_input; Ref<Texture2D> type_icon[6] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), }; add_item("[None]"); @@ -4649,20 +4649,20 @@ public: } void _item_selected(int p_item) { - VisualShaderEditor::get_singleton()->call_deferred("_uniform_select_item", uniform_ref, get_item_text(p_item)); + VisualShaderEditor::get_singleton()->call_deferred(SNAME("_uniform_select_item"), uniform_ref, get_item_text(p_item)); } void setup(const Ref<VisualShaderNodeUniformRef> &p_uniform_ref) { uniform_ref = p_uniform_ref; Ref<Texture2D> type_icon[7] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform3D", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Color", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), }; add_item("[None]"); @@ -4825,10 +4825,10 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<PropertyInfo> pinfo; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + for (const PropertyInfo &E : props) { for (int i = 0; i < properties.size(); i++) { - if (E->get().name == String(properties[i])) { - pinfo.push_back(E->get()); + if (E.name == String(properties[i])) { + pinfo.push_back(E); } } } @@ -4870,7 +4870,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par void EditorPropertyShaderMode::_option_selected(int p_which) { //will not use this, instead will do all the logic setting manually - //emit_signal("property_changed", get_edited_property(), p_which); + //emit_signal(SNAME("property_changed"), get_edited_property(), p_which); Ref<VisualShader> visual_shader(Object::cast_to<VisualShader>(get_edited_object())); @@ -4894,9 +4894,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { VisualShader::Type type = VisualShader::Type(i); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); - for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - if (E->get().to_node == VisualShader::NODE_ID_OUTPUT) { - undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port); + for (const VisualShader::Connection &E : conns) { + if (E.to_node == VisualShader::NODE_ID_OUTPUT) { + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); } } } @@ -4918,9 +4918,9 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { List<PropertyInfo> props; visual_shader->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) { - undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name)); + for (const PropertyInfo &E : props) { + if (E.name.begins_with("flags/") || E.name.begins_with("modes/")) { + undo_redo->add_undo_property(visual_shader.ptr(), E.name, visual_shader->get(E.name)); } } @@ -5024,8 +5024,8 @@ void VisualShaderNodePortPreview::_shader_changed() { if (src_mat && src_mat->get_shader().is_valid()) { List<PropertyInfo> params; src_mat->get_shader()->get_param_list(¶ms); - for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - material->set(E->get().name, src_mat->get(E->get().name)); + for (const PropertyInfo &E : params) { + material->set(E.name, src_mat->get(E.name)); } } } diff --git a/editor/plugins/voxel_gi_editor_plugin.cpp b/editor/plugins/voxel_gi_editor_plugin.cpp index 162379a49d..5bbc0c9dd5 100644 --- a/editor/plugins/voxel_gi_editor_plugin.cpp +++ b/editor/plugins/voxel_gi_editor_plugin.cpp @@ -81,13 +81,13 @@ void VoxelGIEditorPlugin::_notification(int p_what) { Color color; if (size_mb <= 16.0 + CMP_EPSILON) { // Fast. - color = bake_info->get_theme_color("success_color", "Editor"); + color = bake_info->get_theme_color(SNAME("success_color"), SNAME("Editor")); } else if (size_mb <= 64.0 + CMP_EPSILON) { // Medium. - color = bake_info->get_theme_color("warning_color", "Editor"); + color = bake_info->get_theme_color(SNAME("warning_color"), SNAME("Editor")); } else { // Slow. - color = bake_info->get_theme_color("error_color", "Editor"); + color = bake_info->get_theme_color(SNAME("error_color"), SNAME("Editor")); } bake_info->add_theme_color_override("font_color", color); @@ -143,7 +143,7 @@ VoxelGIEditorPlugin::VoxelGIEditorPlugin(EditorNode *p_node) { bake_hb->hide(); bake = memnew(Button); bake->set_flat(true); - bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon(SNAME("Bake"), SNAME("EditorIcons"))); bake->set_text(TTR("Bake GI Probe")); bake->connect("pressed", callable_mp(this, &VoxelGIEditorPlugin::_bake)); bake_hb->add_child(bake); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 0b6a3798b3..3441060fad 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -139,7 +139,7 @@ void ProgressDialog::_popup() { Size2 ms = main->get_combined_minimum_size(); ms.width = MAX(500 * EDSCALE, ms.width); - Ref<StyleBox> style = main->get_theme_stylebox("panel", "PopupMenu"); + Ref<StyleBox> style = main->get_theme_stylebox(SNAME("panel"), SNAME("PopupMenu")); ms += style->get_minimum_size(); main->set_offset(SIDE_LEFT, style->get_margin(SIDE_LEFT)); main->set_offset(SIDE_RIGHT, -style->get_margin(SIDE_RIGHT)); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index b639a74132..fcb714bdf7 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -49,8 +49,8 @@ #include "servers/display_server.h" void ProjectExportDialog::_theme_changed() { - duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); + duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); + delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); } void ProjectExportDialog::_notification(int p_what) { @@ -61,8 +61,8 @@ void ProjectExportDialog::_notification(int p_what) { } } break; case NOTIFICATION_READY: { - duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); + duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); + delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip)); _update_export_all(); } break; @@ -340,8 +340,8 @@ void ProjectExportDialog::_update_feature_list() { } } - for (List<String>::Element *E = features.front(); E; E = E->next()) { - fset.insert(E->get()); + for (const String &E : features) { + fset.insert(E); } custom_feature_display->clear(); @@ -567,8 +567,8 @@ void ProjectExportDialog::_duplicate_preset() { preset->set_exclude_filter(current->get_exclude_filter()); preset->set_custom_features(current->get_custom_features()); - for (const List<PropertyInfo>::Element *E = current->get_properties().front(); E; E = E->next()) { - preset->set(E->get().name, current->get(E->get().name)); + for (const PropertyInfo &E : current->get_properties()) { + preset->set(E.name, current->get(E.name)); } EditorExport::get_singleton()->add_export_preset(preset); @@ -730,7 +730,7 @@ void ProjectExportDialog::_fill_resource_tree() { bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> ¤t, bool p_only_scenes) { p_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog")); + p_item->set_icon(0, presets->get_theme_icon(SNAME("folder"), SNAME("FileDialog"))); p_item->set_text(0, p_dir->get_name() + "/"); p_item->set_editable(0, true); p_item->set_metadata(0, p_dir->get_path()); @@ -1153,7 +1153,7 @@ ProjectExportDialog::ProjectExportDialog() { enc_directory = memnew(CheckButton); enc_directory->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_directory_changed)); - enc_directory->set_text("Encrypt Index (File Names and Info)"); + enc_directory->set_text(TTR("Encrypt Index (File Names and Info)")); sec_vb->add_child(enc_directory); enc_in_filters = memnew(LineEdit); @@ -1172,7 +1172,7 @@ ProjectExportDialog::ProjectExportDialog() { script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed)); script_key_error = memnew(Label); script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 hexadecimal characters long)")); - script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); sec_vb->add_margin_child(TTR("Encryption Key (256-bits as hexadecimal):"), script_key); sec_vb->add_child(script_key_error); sections->add_child(sec_vb); @@ -1219,7 +1219,7 @@ ProjectExportDialog::ProjectExportDialog() { export_all_dialog = memnew(ConfirmationDialog); add_child(export_all_dialog); - export_all_dialog->set_title("Export All"); + export_all_dialog->set_title(TTR("Export All")); export_all_dialog->set_text(TTR("Choose an export mode:")); export_all_dialog->get_ok_button()->hide(); export_all_dialog->add_button(TTR("Debug"), true, "debug"); @@ -1241,7 +1241,7 @@ ProjectExportDialog::ProjectExportDialog() { export_error = memnew(Label); main_vb->add_child(export_error); export_error->hide(); - export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); export_templates_error = memnew(HBoxContainer); main_vb->add_child(export_templates_error); @@ -1249,11 +1249,11 @@ ProjectExportDialog::ProjectExportDialog() { Label *export_error2 = memnew(Label); export_templates_error->add_child(export_error2); - export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " "); error_dialog = memnew(AcceptDialog); - error_dialog->set_title("Error"); + error_dialog->set_title(TTR("Error")); error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " "); main_vb->add_child(error_dialog); error_dialog->hide(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 50a763f05a..fd4f22425f 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -113,20 +113,20 @@ private: switch (p_type) { case MESSAGE_ERROR: { - msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color(SNAME("error_color"), SNAME("Editor"))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = msg->get_theme_icon("StatusError", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); } break; case MESSAGE_WARNING: { - msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons")); } break; case MESSAGE_SUCCESS: { msg->set_modulate(Color(1, 1, 1, 0)); - new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons"); + new_icon = msg->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")); } break; } @@ -336,9 +336,9 @@ private: project_path->set_text(sp); _path_text_changed(sp); if (p.ends_with(".zip")) { - install_path->call_deferred("grab_focus"); + install_path->call_deferred(SNAME("grab_focus")); } else { - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } } @@ -346,14 +346,14 @@ private: String sp = p_path.simplify_path(); project_path->set_text(sp); _path_text_changed(sp); - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } void _install_path_selected(const String &p_path) { String sp = p_path.simplify_path(); install_path->set_text(sp); _path_text_changed(sp); - get_ok_button()->call_deferred("grab_focus"); + get_ok_button()->call_deferred(SNAME("grab_focus")); } void _browse_path() { @@ -448,7 +448,7 @@ private: } hide(); - emit_signal("projects_updated"); + emit_signal(SNAME("projects_updated")); } else { if (mode == MODE_IMPORT) { @@ -494,13 +494,13 @@ private: if (!f) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { - f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); + f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=3]"); f->store_line(""); - f->store_line("[sub_resource type=\"Sky\" id=1]"); + f->store_line("[sub_resource type=\"Sky\" id=\"1\"]"); f->store_line(""); f->store_line("[resource]"); f->store_line("background_mode = 2"); - f->store_line("sky = SubResource( 1 )"); + f->store_line("sky = SubResource( \"1\" )"); memdelete(f); } } @@ -617,7 +617,7 @@ private: EditorSettings::get_singleton()->save(); hide(); - emit_signal("project_created", dir); + emit_signal(SNAME("project_created"), dir); } } @@ -640,11 +640,11 @@ private: project_name->clear(); _text_changed(""); - if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) { + if (status_rect->get_texture() == msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { msg->show(); } - if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) { + if (install_status_rect->get_texture() == msg->get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"))) { msg->show(); } } @@ -715,7 +715,7 @@ public: _text_changed(proj); } - project_name->call_deferred("grab_focus"); + project_name->call_deferred(SNAME("grab_focus")); create_dir->hide(); @@ -758,8 +758,8 @@ public: name_container->show(); install_path_container->hide(); rasterizer_container->show(); - project_name->call_deferred("grab_focus"); - project_name->call_deferred("select_all"); + project_name->call_deferred(SNAME("grab_focus")); + project_name->call_deferred(SNAME("select_all")); } else if (mode == MODE_INSTALL) { set_title(TTR("Install Project:") + " " + zip_title); @@ -966,7 +966,7 @@ public: } break; case NOTIFICATION_DRAW: { if (hover) { - draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size())); + draw_style_box(get_theme_stylebox(SNAME("hover"), SNAME("Tree")), Rect2(Point2(), get_size())); } } break; } @@ -1141,7 +1141,7 @@ void ProjectList::_notification(int p_what) { void ProjectList::load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture2D> default_icon = get_theme_icon("DefaultProjectIcon", "EditorIcons"); + Ref<Texture2D> default_icon = get_theme_icon(SNAME("DefaultProjectIcon"), SNAME("EditorIcons")); Ref<Texture2D> icon; if (item.icon != "") { Ref<Image> img; @@ -1238,16 +1238,16 @@ void ProjectList::load_projects() { Set<String> favorites; // Find favourites... - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String property_key = E->get().name; + for (const PropertyInfo &E : properties) { + String property_key = E.name; if (property_key.begins_with("favorite_projects/")) { favorites.insert(property_key); } } - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + for (const PropertyInfo &E : properties) { // This is actually something like "projects/C:::Documents::Godot::Projects::MyGame" - String property_key = E->get().name; + String property_key = E.name; if (!property_key.begins_with("projects/")) { continue; } @@ -1327,8 +1327,8 @@ void ProjectList::create_project_item_control(int p_index) { Item &item = _projects.write[p_index]; ERR_FAIL_COND(item.control != nullptr); // Already created - Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons"); - Color font_color = get_theme_color("font_color", "Tree"); + Ref<Texture2D> favorite_icon = get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons")); + Color font_color = get_theme_color(SNAME("font_color"), SNAME("Tree")); ProjectListItemControl *hb = memnew(ProjectListItemControl); hb->connect("draw", callable_mp(this, &ProjectList::_panel_draw), varray(hb)); @@ -1353,7 +1353,7 @@ void ProjectList::create_project_item_control(int p_index) { TextureRect *tf = memnew(TextureRect); // The project icon may not be loaded by the time the control is displayed, // so use a loading placeholder. - tf->set_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); + tf->set_texture(get_theme_icon(SNAME("ProjectIconLoading"), SNAME("EditorIcons"))); tf->set_v_size_flags(SIZE_SHRINK_CENTER); if (item.missing) { tf->set_modulate(Color(1, 1, 1, 0.5)); @@ -1372,8 +1372,8 @@ void ProjectList::create_project_item_control(int p_index) { ec->set_mouse_filter(MOUSE_FILTER_PASS); vb->add_child(ec); Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project"))); - title->add_theme_font_override("font", get_theme_font("title", "EditorFonts")); - title->add_theme_font_size_override("font_size", get_theme_font_size("title_size", "EditorFonts")); + title->add_theme_font_override("font", get_theme_font(SNAME("title"), SNAME("EditorFonts"))); + title->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("title_size"), SNAME("EditorFonts"))); title->add_theme_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); @@ -1582,8 +1582,8 @@ int ProjectList::refresh_project(const String &dir_path) { String favorite_property_key = "favorite_projects/" + project_key; bool found = false; - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String prop = E->get().name; + for (const PropertyInfo &E : properties) { + String prop = E.name; if (!found && prop == property_key) { found = true; } else if (!is_favourite && prop == favorite_property_key) { @@ -1726,15 +1726,15 @@ void ProjectList::_panel_draw(Node *p_hb) { Control *hb = Object::cast_to<Control>(p_hb); if (is_layout_rtl() && get_v_scrollbar()->is_visible_in_tree()) { - hb->draw_line(Point2(get_v_scrollbar()->get_minimum_size().x, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree")); + hb->draw_line(Point2(get_v_scrollbar()->get_minimum_size().x, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color(SNAME("guide_color"), SNAME("Tree"))); } else { - hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color("guide_color", "Tree")); + hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x, hb->get_size().y + 1), get_theme_color(SNAME("guide_color"), SNAME("Tree"))); } String key = _projects[p_hb->get_index()].project_key; if (_selected_project_keys.has(key)) { - hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size())); + hb->draw_style_box(get_theme_stylebox(SNAME("selected"), SNAME("Tree")), Rect2(Point2(), hb->get_size())); } } @@ -1765,10 +1765,10 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { select_project(clicked_index); } - emit_signal(SIGNAL_SELECTION_CHANGED); + emit_signal(SNAME(SIGNAL_SELECTION_CHANGED)); if (!mb->is_ctrl_pressed() && mb->is_double_click()) { - emit_signal(SIGNAL_PROJECT_ASK_OPEN); + emit_signal(SNAME(SIGNAL_PROJECT_ASK_OPEN)); } } } @@ -1826,7 +1826,7 @@ void ProjectManager::_notification(int p_what) { update(); } break; case NOTIFICATION_ENTER_TREE: { - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); Engine::get_singleton()->set_editor_hint(false); @@ -2188,9 +2188,9 @@ void ProjectManager::_scan_begin(const String &p_base) { _scan_dir(p_base, &projects); print_line("Found " + itos(projects.size()) + " projects."); - for (List<String>::Element *E = projects.front(); E; E = E->next()) { - String proj = get_project_key_from_path(E->get()); - EditorSettings::get_singleton()->set("projects/" + proj, E->get()); + for (const String &E : projects) { + String proj = get_project_key_from_path(E); + EditorSettings::get_singleton()->set("projects/" + proj, E); } EditorSettings::get_singleton()->save(); _load_recent_projects(); @@ -2446,7 +2446,7 @@ ProjectManager::ProjectManager() { Panel *panel = memnew(Panel); add_child(panel); panel->set_anchors_and_offsets_preset(Control::PRESET_WIDE); - panel->add_theme_style_override("panel", get_theme_stylebox("Background", "EditorStyles")); + panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); VBoxContainer *vb = memnew(VBoxContainer); panel->add_child(vb); @@ -2484,7 +2484,7 @@ ProjectManager::ProjectManager() { hb->add_child(search_box); loading_label = memnew(Label(TTR("Loading, please wait..."))); - loading_label->add_theme_font_override("font", get_theme_font("bold", "EditorFonts")); + loading_label->add_theme_font_override("font", get_theme_font(SNAME("bold"), SNAME("EditorFonts"))); loading_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(loading_label); // Hide the label but make it still take up space. This prevents reflows when showing the label. @@ -2510,7 +2510,7 @@ ProjectManager::ProjectManager() { } PanelContainer *pc = memnew(PanelContainer); - pc->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + pc->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); pc->set_v_size_flags(Control::SIZE_EXPAND_FILL); search_tree_vb->add_child(pc); @@ -2618,15 +2618,14 @@ ProjectManager::ProjectManager() { language_btn = memnew(OptionButton); language_btn->set_flat(true); - language_btn->set_icon(get_theme_icon("Environment", "EditorIcons")); + language_btn->set_icon(get_theme_icon(SNAME("Environment"), SNAME("EditorIcons"))); language_btn->set_focus_mode(Control::FOCUS_NONE); language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected)); Vector<String> editor_languages; List<PropertyInfo> editor_settings_properties; EditorSettings::get_singleton()->get_property_list(&editor_settings_properties); - for (List<PropertyInfo>::Element *E = editor_settings_properties.front(); E; E = E->next()) { - PropertyInfo &pi = E->get(); + for (const PropertyInfo &pi : editor_settings_properties) { if (pi.name == "interface/editor/editor_language") { editor_languages = pi.hint_string.split(","); break; diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e76d757516..b8ccab78dd 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -229,16 +229,16 @@ void ProjectSettingsEditor::_add_feature_overrides() { for (int i = 0; i < ee->get_export_platform_count(); i++) { List<String> p; ee->get_export_platform(i)->get_platform_features(&p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (const String &E : p) { + presets.insert(E); } } for (int i = 0; i < ee->get_export_preset_count(); i++) { List<String> p; ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p); - for (List<String>::Element *E = p.front(); E; E = E->next()) { - presets.insert(E->get()); + for (const String &E : p) { + presets.insert(E); } String custom = ee->get_export_preset(i)->get_custom_features(); @@ -391,8 +391,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const undo_redo->create_action(TTR("Update Input Action Order")); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - PropertyInfo prop = E->get(); + for (const PropertyInfo &prop : props) { // Skip builtins and non-inputs if (ProjectSettings::get_singleton()->is_builtin_setting(prop.name) || !prop.name.begins_with("input/")) { continue; @@ -444,9 +443,9 @@ void ProjectSettingsEditor::_update_action_map_editor() { List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); - const Ref<Texture2D> builtin_icon = get_theme_icon("PinPressed", "EditorIcons"); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const String property_name = E->get().name; + const Ref<Texture2D> builtin_icon = get_theme_icon(SNAME("PinPressed"), SNAME("EditorIcons")); + for (const PropertyInfo &E : props) { + const String property_name = E.name; if (!property_name.begins_with("input/")) { continue; @@ -483,18 +482,18 @@ void ProjectSettingsEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { inspector->edit(ps); - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(get_theme_icon("Close", "EditorIcons")); - restart_container->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); - restart_icon->set_texture(get_theme_icon("StatusWarning", "EditorIcons")); - restart_label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); + restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); _update_action_map_editor(); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); } break; } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index ab710a1c21..7338588d56 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -119,16 +119,16 @@ void CustomPropertyEditor::_menu_option(int p_which) { } v = val; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } else if (hint == PROPERTY_HINT_ENUM) { v = menu->get_item_metadata(p_which); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::STRING: { if (hint == PROPERTY_HINT_ENUM) { v = hint_text.get_slice(",", p_which); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::OBJECT: { @@ -143,8 +143,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { } Set<String> valid_extensions; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); + for (const String &E : extensions) { + valid_extensions.insert(E); } file->clear_filters(); @@ -159,13 +159,13 @@ void CustomPropertyEditor::_menu_option(int p_which) { REF r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); + emit_signal(SNAME("resource_edit_request")); hide(); } } break; case OBJ_MENU_CLEAR: { v = Variant(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; @@ -179,9 +179,8 @@ void CustomPropertyEditor::_menu_option(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -198,13 +197,12 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; @@ -214,7 +212,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { } break; case OBJ_MENU_PASTE: { v = EditorSettings::get_singleton()->get_resource_clipboard(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case OBJ_MENU_NEW_SCRIPT: { @@ -248,7 +246,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { Ref<Resource> new_res = conversions[to_type]->convert(v); v = new_res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); break; } ERR_FAIL_COND(inheritors_array.is_empty()); @@ -281,7 +279,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { } v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; } @@ -544,8 +542,8 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: text_edit->set_text(v); text_edit->deselect(); - int button_margin = text_edit->get_theme_constant("button_margin", "Dialogs"); - int margin = text_edit->get_theme_constant("margin", "Dialogs"); + int button_margin = text_edit->get_theme_constant(SNAME("button_margin"), SNAME("Dialogs")); + int margin = text_edit->get_theme_constant(SNAME("margin"), SNAME("Dialogs")); action_buttons[0]->set_anchor(SIDE_LEFT, Control::ANCHOR_END); action_buttons[0]->set_anchor(SIDE_TOP, Control::ANCHOR_END); @@ -1016,13 +1014,13 @@ void CustomPropertyEditor::_file_selected(String p_file) { case Variant::STRING: { if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) { v = ProjectSettings::get_singleton()->localize_path(p_file); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } if (hint == PROPERTY_HINT_GLOBAL_FILE || hint == PROPERTY_HINT_GLOBAL_DIR) { v = p_file; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1037,7 +1035,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { break; } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } break; default: { @@ -1070,7 +1068,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { } v = newval; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); easing_draw->update(); } else if (type == Variant::OBJECT) { @@ -1092,14 +1090,14 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { ERR_FAIL_COND(!Object::cast_to<Resource>(obj)); v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } void CustomPropertyEditor::_color_changed(const Color &p_color) { v = p_color; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_node_path_selected(NodePath p_path) { @@ -1115,7 +1113,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { vt->set_viewport_path_in_scene(get_tree()->get_edited_scene_root()->get_path_to(to_node)); vt->setup_local_to_scene(); v = vt; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); return; } @@ -1140,8 +1138,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } if (!node) { v = p_path; - emit_signal("variant_changed"); - call_deferred("hide"); //to not mess with dialogs + emit_signal(SNAME("variant_changed")); + call_deferred(SNAME("hide")); //to not mess with dialogs return; } @@ -1152,8 +1150,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } v = p_path; - emit_signal("variant_changed"); - call_deferred("hide"); //to not mess with dialogs + emit_signal(SNAME("variant_changed")); + call_deferred(SNAME("hide")); //to not mess with dialogs } void CustomPropertyEditor::_action_pressed(int p_which) { @@ -1164,7 +1162,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { switch (type) { case Variant::BOOL: { v = checks20[0]->is_pressed(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case Variant::INT: { if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || @@ -1181,7 +1179,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } v = f; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; @@ -1218,7 +1216,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->popup_file_dialog(); } else { v = ""; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1234,7 +1232,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->popup_file_dialog(); } else { v = ""; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } @@ -1248,7 +1246,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } else if (p_which == 1) { v = NodePath(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } else if (p_which == 2) { if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) { @@ -1282,7 +1280,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_BREAK(!Object::cast_to<Resource>(obj)); v = obj; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } } else if (p_which == 1) { @@ -1293,8 +1291,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type, &extensions); file->clear_filters(); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); + for (const String &E : extensions) { + file->add_filter("*." + E + " ; " + E.to_upper()); } file->popup_file_dialog(); @@ -1303,13 +1301,13 @@ void CustomPropertyEditor::_action_pressed(int p_which) { RES r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); + emit_signal(SNAME("resource_edit_request")); hide(); } } else if (p_which == 3) { v = Variant(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } else if (p_which == 4) { Ref<Resource> res_orig = v; @@ -1321,9 +1319,8 @@ void CustomPropertyEditor::_action_pressed(int p_which) { res_orig->get_property_list(&property_list); List<Pair<String, Variant>> propvalues; - for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { + for (const PropertyInfo &pi : property_list) { Pair<String, Variant> p; - PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { p.first = pi.name; p.second = res_orig->get(pi.name); @@ -1336,13 +1333,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); + for (const Pair<String, Variant> &p : propvalues) { res->set(p.first, p.second); } v = res; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); hide(); } @@ -1386,7 +1382,7 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) { v = val; easing_draw->update(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } @@ -1396,7 +1392,7 @@ void CustomPropertyEditor::_draw_easing() { Size2 s = easing_draw->get_size(); Rect2 r(Point2(), s); r = r.grow(3); - easing_draw->get_theme_stylebox("normal", "LineEdit")->draw(ci, r); + easing_draw->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))->draw(ci, r); int points = 48; @@ -1404,9 +1400,9 @@ void CustomPropertyEditor::_draw_easing() { float exp = v; bool flip = hint_text == "attenuation"; - Ref<Font> f = easing_draw->get_theme_font("font", "Label"); - int font_size = easing_draw->get_theme_font_size("font_size", "Label"); - Color color = easing_draw->get_theme_color("font_color", "Label"); + Ref<Font> f = easing_draw->get_theme_font(SNAME("font"), SNAME("Label")); + int font_size = easing_draw->get_theme_font_size(SNAME("font_size"), SNAME("Label")); + Color color = easing_draw->get_theme_color(SNAME("font_color"), SNAME("Label")); for (int i = 1; i <= points; i++) { float ifl = i / float(points); @@ -1428,17 +1424,17 @@ void CustomPropertyEditor::_draw_easing() { void CustomPropertyEditor::_text_edit_changed() { v = text_edit->get_text(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_create_dialog_callback() { v = create_dialog->get_selected_type(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_create_selected_property(const String &p_prop) { v = p_prop; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_modified(String p_string) { @@ -1463,7 +1459,7 @@ void CustomPropertyEditor::_modified(String p_string) { } if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::FLOAT: { @@ -1471,14 +1467,14 @@ void CustomPropertyEditor::_modified(String p_string) { String text = TS->parse_number(value_editor[0]->get_text()); v = _parse_real_expression(text); if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } } break; case Variant::STRING: { v = value_editor[0]->get_text(); - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } break; case Variant::VECTOR2: { Vector2 vec; @@ -1603,7 +1599,7 @@ void CustomPropertyEditor::_modified(String p_string) { case Variant::NODE_PATH: { v = NodePath(value_editor[0]->get_text()); if (v != prev_v) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } } break; case Variant::DICTIONARY: { @@ -1642,15 +1638,15 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) { void CustomPropertyEditor::_emit_changed_whole_or_field() { if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } else { - emit_signal("variant_field_changed", field_names[focused_value_editor]); + emit_signal(SNAME("variant_field_changed"), field_names[focused_value_editor]); } } void CustomPropertyEditor::_range_modified(double p_value) { v = p_value; - emit_signal("variant_changed"); + emit_signal(SNAME("variant_changed")); } void CustomPropertyEditor::_focus_enter() { @@ -1684,7 +1680,7 @@ void CustomPropertyEditor::_focus_exit() { } void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { - Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox("panel"); + Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox(SNAME("panel")); int margin_top = sb->get_margin(SIDE_TOP); int margin_left = sb->get_margin(SIDE_LEFT); int margin_bottom = sb->get_margin(SIDE_BOTTOM); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 00652c02c8..a1deae92a4 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -119,77 +119,80 @@ void PropertySelector::_update_search() { bool found = false; Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - search_options->get_theme_icon("Variant", "EditorIcons"), - search_options->get_theme_icon("bool", "EditorIcons"), - search_options->get_theme_icon("int", "EditorIcons"), - search_options->get_theme_icon("float", "EditorIcons"), - search_options->get_theme_icon("String", "EditorIcons"), - search_options->get_theme_icon("Vector2", "EditorIcons"), - search_options->get_theme_icon("Vector2i", "EditorIcons"), - search_options->get_theme_icon("Rect2", "EditorIcons"), - search_options->get_theme_icon("Rect2i", "EditorIcons"), - search_options->get_theme_icon("Vector3", "EditorIcons"), - search_options->get_theme_icon("Vector3i", "EditorIcons"), - search_options->get_theme_icon("Transform2D", "EditorIcons"), - search_options->get_theme_icon("Plane", "EditorIcons"), - search_options->get_theme_icon("Quaternion", "EditorIcons"), - search_options->get_theme_icon("AABB", "EditorIcons"), - search_options->get_theme_icon("Basis", "EditorIcons"), - search_options->get_theme_icon("Transform3D", "EditorIcons"), - search_options->get_theme_icon("Color", "EditorIcons"), - search_options->get_theme_icon("NodePath", "EditorIcons"), - search_options->get_theme_icon("RID", "EditorIcons"), - search_options->get_theme_icon("MiniObject", "EditorIcons"), - search_options->get_theme_icon("Callable", "EditorIcons"), - search_options->get_theme_icon("Signal", "EditorIcons"), - search_options->get_theme_icon("Dictionary", "EditorIcons"), - search_options->get_theme_icon("Array", "EditorIcons"), - search_options->get_theme_icon("PackedByteArray", "EditorIcons"), - search_options->get_theme_icon("PackedInt32Array", "EditorIcons"), - search_options->get_theme_icon("PackedFloat32Array", "EditorIcons"), - search_options->get_theme_icon("PackedStringArray", "EditorIcons"), - search_options->get_theme_icon("PackedVector2Array", "EditorIcons"), - search_options->get_theme_icon("PackedVector3Array", "EditorIcons"), - search_options->get_theme_icon("PackedColorArray", "EditorIcons") + search_options->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("String"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")), + search_options->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons")) }; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().usage == PROPERTY_USAGE_CATEGORY) { + for (const PropertyInfo &E : props) { + if (E.usage == PROPERTY_USAGE_CATEGORY) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name); + category->set_text(0, E.name); category->set_selectable(0, false); Ref<Texture2D> icon; - if (E->get().name == "Script Variables") { - icon = search_options->get_theme_icon("Script", "EditorIcons"); + if (E.name == "Script Variables") { + icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); } else { - icon = EditorNode::get_singleton()->get_class_icon(E->get().name); + icon = EditorNode::get_singleton()->get_class_icon(E.name); } category->set_icon(0, icon); continue; } - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) && !(E->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { + if (!(E.usage & PROPERTY_USAGE_EDITOR) && !(E.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) { continue; } - if (search_box->get_text() != String() && E->get().name.findn(search_text) == -1) { + if (search_box->get_text() != String() && E.name.findn(search_text) == -1) { continue; } - if (type_filter.size() && type_filter.find(E->get().type) == -1) { + if (type_filter.size() && type_filter.find(E.type) == -1) { continue; } TreeItem *item = search_options->create_item(category ? category : root); - item->set_text(0, E->get().name); - item->set_metadata(0, E->get().name); - item->set_icon(0, type_icons[E->get().type]); + item->set_text(0, E.name); + item->set_metadata(0, E.name); + item->set_icon(0, type_icons[E.type]); - if (!found && search_box->get_text() != String() && E->get().name.findn(search_text) != -1) { + if (!found && search_box->get_text() != String() && E.name.findn(search_text) != -1) { item->select(0); found = true; } @@ -228,20 +231,20 @@ void PropertySelector::_update_search() { bool found = false; bool script_methods = false; - for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { - if (E->get().name.begins_with("*")) { + for (MethodInfo &mi : methods) { + if (mi.name.begins_with("*")) { if (category && category->get_first_child() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); - category->set_text(0, E->get().name.replace_first("*", "")); + category->set_text(0, mi.name.replace_first("*", "")); category->set_selectable(0, false); Ref<Texture2D> icon; script_methods = false; - String rep = E->get().name.replace("*", ""); - if (E->get().name == "*Script Methods") { - icon = search_options->get_theme_icon("Script", "EditorIcons"); + String rep = mi.name.replace("*", ""); + if (mi.name == "*Script Methods") { + icon = search_options->get_theme_icon(SNAME("Script"), SNAME("EditorIcons")); script_methods = true; } else { icon = EditorNode::get_singleton()->get_class_icon(rep); @@ -251,16 +254,16 @@ void PropertySelector::_update_search() { continue; } - String name = E->get().name.get_slice(":", 0); - if (!script_methods && name.begins_with("_") && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + String name = mi.name.get_slice(":", 0); + if (!script_methods && name.begins_with("_") && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (virtuals_only && !(E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (virtuals_only && !(mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } - if (!virtuals_only && (E->get().flags & METHOD_FLAG_VIRTUAL)) { + if (!virtuals_only && (mi.flags & METHOD_FLAG_VIRTUAL)) { continue; } @@ -270,8 +273,6 @@ void PropertySelector::_update_search() { TreeItem *item = search_options->create_item(category ? category : root); - MethodInfo mi = E->get(); - String desc; if (mi.name.find(":") != -1) { desc = mi.name.get_slice(":", 1) + " "; @@ -303,11 +304,11 @@ void PropertySelector::_update_search() { desc += ")"; - if (E->get().flags & METHOD_FLAG_CONST) { + if (mi.flags & METHOD_FLAG_CONST) { desc += " const"; } - if (E->get().flags & METHOD_FLAG_VIRTUAL) { + if (mi.flags & METHOD_FLAG_VIRTUAL) { desc += " virtual"; } @@ -334,7 +335,7 @@ void PropertySelector::_confirmed() { if (!ti) { return; } - emit_signal("selected", ti->get_metadata(0)); + emit_signal(SNAME("selected"), ti->get_metadata(0)); hide(); } diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index e8e13bab21..bda7540a23 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -64,7 +64,7 @@ void EditorQuickOpen::_build_search_cache(EditorFileSystemDirectory *p_efsd) { // Store refs to used icons. String ext = file.get_extension(); if (!icons.has(ext)) { - icons.insert(ext, get_theme_icon((has_theme_icon(file_type, "EditorIcons") ? file_type : "Object"), "EditorIcons")); + icons.insert(ext, get_theme_icon((has_theme_icon(file_type, SNAME("EditorIcons")) ? file_type : String("Object")), SNAME("EditorIcons"))); } } } @@ -140,7 +140,7 @@ void EditorQuickOpen::_confirmed() { return; } _cleanup(); - emit_signal("quick_open"); + emit_signal(SNAME("quick_open")); hide(); } @@ -228,7 +228,7 @@ void EditorQuickOpen::_notification(int p_what) { } void EditorQuickOpen::_theme_changed() { - search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); } void EditorQuickOpen::_bind_methods() { diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 87fbbbcfb8..d86e2656d4 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -391,11 +391,11 @@ void RenameDialog::_update_preview(String new_text) { if (new_name == preview_node->get_name()) { // New name is identical to the old one. Don't color it as much to avoid distracting the user. - const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); - const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel"); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("accent_color"), SNAME("Editor")); + const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("default_color"), SNAME("RichTextLabel")); lbl_preview->add_theme_color_override("font_color", accent_color.lerp(text_color, 0.5)); } else { - lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); + lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("success_color"), SNAME("Editor"))); } } @@ -481,7 +481,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * self->has_errors = true; self->lbl_preview_title->set_text(TTR("Regular Expression Error:")); - self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); + self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color(SNAME("error_color"), SNAME("Editor"))); self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } @@ -594,7 +594,7 @@ void RenameDialog::rename() { continue; } - scene_tree_editor->emit_signal("node_prerename", n, new_name); + scene_tree_editor->emit_signal(SNAME("node_prerename"), n, new_name); undo_redo->add_do_method(scene_tree_editor, "_rename_node", n->get_instance_id(), new_name); undo_redo->add_undo_method(scene_tree_editor, "_rename_node", n->get_instance_id(), n->get_name()); } diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index aab046c235..f862260212 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -50,7 +50,7 @@ void ReparentDialog::_cancel() { void ReparentDialog::_reparent() { if (tree->get_selected()) { - emit_signal("reparent", tree->get_selected()->get_path(), keep_transform->is_pressed()); + emit_signal(SNAME("reparent"), tree->get_selected()->get_path(), keep_transform->is_pressed()); hide(); } } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 166b82d744..c4d47c7594 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -229,7 +229,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N editor_data->get_undo_redo().commit_action(); editor->push_item(instances[instances.size() - 1]); for (int i = 0; i < instances.size(); i++) { - emit_signal("node_created", instances[i]); + emit_signal(SNAME("node_created"), instances[i]); } } @@ -263,8 +263,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) List<Node *> owned; base->get_owned_by(base->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } undo_redo->add_do_method(instantiated_scene, "set_owner", edited_scene); undo_redo->add_undo_method(this, "_set_owners", edited_scene, owners); @@ -385,7 +385,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { create_dialog->popup_create(true); if (!p_confirm_override) { - emit_signal("add_node_used"); + emit_signal(SNAME("add_node_used")); } } break; case TOOL_INSTANTIATE: { @@ -402,7 +402,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { quick_open->popup_dialog("PackedScene", true); quick_open->set_title(TTR("Instantiate Child Scene")); if (!p_confirm_override) { - emit_signal("add_node_used"); + emit_signal(SNAME("add_node_used")); } } break; case TOOL_EXPAND_COLLAPSE: { @@ -441,8 +441,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { selection.sort_custom<Node::Comparator>(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap); @@ -462,8 +461,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { bool has_cycle = false; if (edited_scene->get_filename() != String()) { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - if (edited_scene->get_filename() == E->get()->get_filename()) { + for (Node *E : node_clipboard) { + if (edited_scene->get_filename() == E->get_filename()) { has_cycle = true; break; } @@ -496,16 +495,15 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (target_scene != clipboard_source_scene) { if (!clipboard_resource_remap.has(target_scene)) { Map<RES, RES> remap; - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - _create_remap_for_node(E->get(), remap); + for (Node *E : node_clipboard) { + _create_remap_for_node(E, remap); } clipboard_resource_remap[target_scene] = remap; } resource_remap = clipboard_resource_remap[target_scene]; } - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : node_clipboard) { Map<const Node *, Node *> duplimap; Node *dup = node->duplicate_from_editor(duplimap, resource_remap); @@ -544,6 +542,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } + if (reset_create_dialog) { + create_dialog->set_base_type("Node"); + reset_create_dialog = false; + } + Node *selected = scene_tree->get_selected(); if (!selected && !editor_selection->get_selected_node_list().is_empty()) { selected = editor_selection->get_selected_node_list().front()->get(); @@ -622,8 +625,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { int lowest_id = common_parent->get_child_count() - 1; int highest_id = 0; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - int index = E->get()->get_index(); + for (Node *E : selection) { + int index = E->get_index(); if (index > highest_id) { highest_id = index; @@ -632,7 +635,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { lowest_id = index; } - if (E->get()->get_parent() != common_parent) { + if (E->get_parent() != common_parent) { common_parent = nullptr; } } @@ -699,8 +702,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *add_below_node = selection.back()->get(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); + for (Node *node : selection) { Node *parent = node->get_parent(); List<Node *> owned; @@ -719,11 +721,11 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(add_below_node, "add_sibling", dup); - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - if (!duplimap.has(F->get())) { + for (Node *F : owned) { + if (!duplimap.has(F)) { continue; } - Node *d = duplimap[F->get()]; + Node *d = duplimap[F]; editor_data->get_undo_redo().add_do_method(d, "set_owner", node->get_owner()); } editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", dup); @@ -766,8 +768,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> nodes = editor_selection->get_selected_node_list(); Set<Node *> nodeset; - for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - nodeset.insert(E->get()); + for (Node *E : nodes) { + nodeset.insert(E); } reparent_dialog->set_current(nodeset); reparent_dialog->popup_centered_clamped(Size2(350, 700) * EDSCALE); @@ -1057,7 +1059,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (e) { Node *node = e->get(); if (node) { - scene_tree->emit_signal("open", node->get_filename()); + scene_tree->emit_signal(SNAME("open"), node->get_filename()); } } } break; @@ -1090,7 +1092,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (e) { Node *node = e->get(); if (node && node->get_scene_inherited_state().is_valid()) { - scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path()); + scene_tree->emit_signal(SNAME("open"), node->get_scene_inherited_state()->get_path()); } } } break; @@ -1157,6 +1159,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } +void SceneTreeDock::_property_selected(int p_idx) { + ERR_FAIL_NULL(property_drop_node); + _perform_property_drop(property_drop_node, menu_properties->get_item_metadata(p_idx), ResourceLoader::load(resource_drop_path)); + property_drop_node = nullptr; +} + +void SceneTreeDock::_perform_property_drop(Node *p_node, String p_property, RES p_res) { + editor_data->get_undo_redo().create_action(vformat(TTR("Set %s"), p_property)); + editor_data->get_undo_redo().add_do_property(p_node, p_property, p_res); + editor_data->get_undo_redo().add_undo_property(p_node, p_property, p_node->get(p_property)); + editor_data->get_undo_redo().commit_action(); +} + void SceneTreeDock::add_root_node(Node *p_node) { editor_data->get_undo_redo().create_action(TTR("New Scene Root")); editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", p_node); @@ -1198,12 +1213,12 @@ void SceneTreeDock::_notification(int p_what) { spatial_editor_plugin->get_spatial_editor()->connect("item_lock_status_changed", Callable(scene_tree, "_update_tree")); spatial_editor_plugin->get_spatial_editor()->connect("item_group_status_changed", Callable(scene_tree, "_update_tree")); - button_add->set_icon(get_theme_icon("Add", "EditorIcons")); - button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); - button_detach_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); + button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); + button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); // create_root_dialog @@ -1218,7 +1233,7 @@ void SceneTreeDock::_notification(int p_what) { Button *node_shortcuts_toggle = memnew(Button); node_shortcuts_toggle->set_flat(true); node_shortcuts_toggle->set_name("NodeShortcutsToggle"); - node_shortcuts_toggle->set_icon(get_theme_icon("Favorites", "EditorIcons")); + node_shortcuts_toggle->set_icon(get_theme_icon(SNAME("Favorites"), SNAME("EditorIcons"))); node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_tooltip(TTR("Switch to Favorite Nodes")); node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection")); @@ -1238,19 +1253,19 @@ void SceneTreeDock::_notification(int p_what) { button_2d = memnew(Button); beginner_node_shortcuts->add_child(button_2d); button_2d->set_text(TTR("2D Scene")); - button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons")); + button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); button_2d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_2D_SCENE, false)); button_3d = memnew(Button); beginner_node_shortcuts->add_child(button_3d); button_3d->set_text(TTR("3D Scene")); - button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons")); + button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); button_3d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_3D_SCENE, false)); button_ui = memnew(Button); beginner_node_shortcuts->add_child(button_ui); button_ui->set_text(TTR("User Interface")); - button_ui->set_icon(get_theme_icon("Control", "EditorIcons")); + button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_USER_INTERFACE, false)); VBoxContainer *favorite_node_shortcuts = memnew(VBoxContainer); @@ -1260,7 +1275,7 @@ void SceneTreeDock::_notification(int p_what) { button_custom = memnew(Button); node_shortcuts->add_child(button_custom); button_custom->set_text(TTR("Other Node")); - button_custom->set_icon(get_theme_icon("Add", "EditorIcons")); + button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); button_custom->connect("pressed", callable_bind(callable_mp(this, &SceneTreeDock::_tool_selected), TOOL_NEW, false)); node_shortcuts->add_spacer(); @@ -1276,16 +1291,16 @@ void SceneTreeDock::_notification(int p_what) { clear_inherit_confirm->disconnect("confirmed", callable_mp(this, &SceneTreeDock::_tool_selected)); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - button_add->set_icon(get_theme_icon("Add", "EditorIcons")); - button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); - button_detach_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); - button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons")); - button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons")); - button_ui->set_icon(get_theme_icon("Control", "EditorIcons")); - button_custom->set_icon(get_theme_icon("Add", "EditorIcons")); - - filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); + button_add->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_instance->set_icon(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + button_create_script->set_icon(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons"))); + button_detach_script->set_icon(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons"))); + button_2d->set_icon(get_theme_icon(SNAME("Node2D"), SNAME("EditorIcons"))); + button_3d->set_icon(get_theme_icon(SNAME("Node3D"), SNAME("EditorIcons"))); + button_ui->set_icon(get_theme_icon(SNAME("Control"), SNAME("EditorIcons"))); + button_custom->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + + filter->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_PROCESS: { @@ -1366,30 +1381,25 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { } } -void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames) { +void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames) { base_path.push_back(p_node->get_name()); if (new_base_path.size()) { new_base_path.push_back(p_node->get_name()); } - NodePath from(base_path, true); - NodePath to; + NodePath new_path; if (new_base_path.size()) { - to = NodePath(new_base_path, true); + new_path = NodePath(new_base_path, true); } - Pair<NodePath, NodePath> npp; - npp.first = from; - npp.second = to; - - p_renames->push_back(npp); + p_renames->insert(p_node, new_path); for (int i = 0; i < p_node->get_child_count(); i++) { _fill_path_renames(base_path, new_base_path, p_node->get_child(i), p_renames); } } -void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames) { +void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames) { Vector<StringName> base_path; Node *n = p_node->get_parent(); while (n) { @@ -1412,50 +1422,41 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai _fill_path_renames(base_path, new_base_path, p_node, p_renames); } -bool SceneTreeDock::_update_node_path(const NodePath &p_root_path, NodePath &r_node_path, List<Pair<NodePath, NodePath>> *p_renames) { - NodePath root_path_new = p_root_path; - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - if (p_root_path == F->get().first) { - root_path_new = F->get().second; - break; - } - } - - // Goes through all paths to check if it's matching. - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - NodePath rel_path_old = p_root_path.rel_path_to(F->get().first); +bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const { + Node *target_node = p_root_node->get_node_or_null(r_node_path); + ERR_FAIL_NULL_V_MSG(target_node, false, "Found invalid node path '" + String(r_node_path) + "' on node '" + String(scene_root->get_path_to(p_root_node)) + "'"); - // If old path detected, then it needs to be replaced with the new one. - if (r_node_path == rel_path_old) { - NodePath rel_path_new = F->get().second; + // Try to find the target node in modified node paths. + Map<Node *, NodePath>::Element *found_node_path = p_renames->find(target_node); + if (found_node_path) { + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); + NodePath root_path_new = found_root_path ? found_root_path->get() : p_root_node->get_path(); + r_node_path = root_path_new.rel_path_to(found_node_path->get()); - // If not empty, get new relative path. - if (!rel_path_new.is_empty()) { - rel_path_new = root_path_new.rel_path_to(rel_path_new); - } + return true; + } - r_node_path = rel_path_new; - return true; + // Update the path if the base node has changed and has not been deleted. + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(p_root_node); + if (found_root_path) { + NodePath root_path_new = found_root_path->get(); + if (!root_path_new.is_empty()) { + NodePath old_abs_path = NodePath(String(p_root_node->get_path()).plus_file(r_node_path)); + old_abs_path.simplify(); + r_node_path = root_path_new.rel_path_to(old_abs_path); } - // Update the node itself if it has a valid node path and has not been deleted. - if (p_root_path == F->get().first && r_node_path != NodePath() && F->get().second != NodePath()) { - NodePath abs_path = NodePath(String(root_path_new).plus_file(r_node_path)).simplified(); - NodePath rel_path_new = F->get().second.rel_path_to(abs_path); - - r_node_path = rel_path_new; - return true; - } + return true; } return false; } -bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Variant &r_variant, List<Pair<NodePath, NodePath>> *p_renames) { +bool SceneTreeDock::_check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const { switch (r_variant.get_type()) { case Variant::NODE_PATH: { NodePath node_path = r_variant; - if (_update_node_path(p_root_path, node_path, p_renames)) { + if (!node_path.is_empty() && _update_node_path(p_root_node, node_path, p_renames)) { r_variant = node_path; return true; } @@ -1466,7 +1467,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari bool updated = false; for (int i = 0; i < a.size(); i++) { Variant value = a[i]; - if (_check_node_path_recursive(p_root_path, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames)) { if (!updated) { a = a.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1485,7 +1486,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari bool updated = false; for (int i = 0; i < d.size(); i++) { Variant value = d.get_value_at_index(i); - if (_check_node_path_recursive(p_root_path, value, p_renames)) { + if (_check_node_path_recursive(p_root_node, value, p_renames)) { if (!updated) { d = d.duplicate(); // Need to duplicate for undo-redo to work. updated = true; @@ -1506,7 +1507,7 @@ bool SceneTreeDock::_check_node_path_recursive(const NodePath &p_root_path, Vari return false; } -void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { +void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { Map<Ref<Animation>, Set<int>> rem_anims; if (!r_rem_anims) { r_rem_anims = &rem_anims; @@ -1520,19 +1521,24 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP return; } + // No renaming if base node is deleted. + Map<Node *, NodePath>::Element *found_base_path = p_renames->find(p_base); + if (found_base_path && found_base_path->get().is_empty()) { + return; + } + // Renaming node paths used in node properties. List<PropertyInfo> properties; p_base->get_property_list(&properties); - NodePath base_root_path = p_base->get_path(); - for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (!(E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { + for (const PropertyInfo &E : properties) { + if (!(E.usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR))) { continue; } - String propertyname = E->get().name; + String propertyname = E.name; Variant old_variant = p_base->get(propertyname); Variant updated_variant = old_variant; - if (_check_node_path_recursive(base_root_path, updated_variant, p_renames)) { + if (_check_node_path_recursive(p_base, updated_variant, p_renames)) { editor_data->get_undo_redo().add_do_property(p_base, propertyname, updated_variant); editor_data->get_undo_redo().add_undo_property(p_base, propertyname, old_variant); p_base->set(propertyname, updated_variant); @@ -1548,21 +1554,11 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP Node *root = ap->get_node(ap->get_root()); if (root) { - NodePath root_path = root->get_path(); - NodePath new_root_path = root_path; - - for (List<Pair<NodePath, NodePath>>::Element *E = p_renames->front(); E; E = E->next()) { - if (E->get().first == root_path) { - new_root_path = E->get().second; - break; - } - } - - if (new_root_path != NodePath()) { - //will not be erased - - for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); + Map<Node *, NodePath>::Element *found_root_path = p_renames->find(root); + NodePath new_root_path = found_root_path ? found_root_path->get() : root->get_path(); + if (!new_root_path.is_empty()) { // No renaming if root node is deleted. + for (const StringName &E : anims) { + Ref<Animation> anim = ap->get_animation(E); if (!r_rem_anims->has(anim)) { r_rem_anims->insert(anim, Set<int>()); Set<int> &ran = r_rem_anims->find(anim)->get(); @@ -1584,47 +1580,44 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP continue; } - NodePath old_np = n->get_path(); - if (!ran.has(i)) { continue; //channel was removed } - for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - if (F->get().first == old_np) { - if (F->get().second == NodePath()) { - //will be erased - - int idx = 0; - Set<int>::Element *EI = ran.front(); - ERR_FAIL_COND(!EI); //bug - while (EI->get() != i) { - idx++; - EI = EI->next(); - ERR_FAIL_COND(!EI); //another bug - } - - editor_data->get_undo_redo().add_do_method(anim.ptr(), "remove_track", idx); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i)); - for (int j = 0; j < anim->track_get_key_count(i); j++) { - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j)); - } - - ran.erase(i); //byebye channel - - } else { - //will be renamed - NodePath rel_path = new_root_path.rel_path_to(F->get().second); - - NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); - if (new_path == track_np) { - continue; //bleh - } - editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path); - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np); + Map<Node *, NodePath>::Element *found_path = p_renames->find(n); + if (found_path) { + if (found_path->get() == NodePath()) { + //will be erased + + int idx = 0; + Set<int>::Element *EI = ran.front(); + ERR_FAIL_COND(!EI); //bug + while (EI->get() != i) { + idx++; + EI = EI->next(); + ERR_FAIL_COND(!EI); //another bug } + + editor_data->get_undo_redo().add_do_method(anim.ptr(), "remove_track", idx); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "add_track", anim->track_get_type(i), idx); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i)); + for (int j = 0; j < anim->track_get_key_count(i); j++) { + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j)); + } + + ran.erase(i); //byebye channel + + } else { + //will be renamed + NodePath rel_path = new_root_path.rel_path_to(found_path->get()); + + NodePath new_path = NodePath(rel_path.get_names(), track_np.get_subnames(), false); + if (new_path == track_np) { + continue; //bleh + } + editor_data->get_undo_redo().add_do_method(anim.ptr(), "track_set_path", i, new_path); + editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", i, track_np); } } } @@ -1639,7 +1632,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP } void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; Vector<StringName> base_path; Node *n = p_node->get_parent(); @@ -1654,10 +1647,8 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { new_base_path.push_back(p_new_name); - Pair<NodePath, NodePath> npp; - npp.first = NodePath(base_path, true); - npp.second = NodePath(new_base_path, true); - path_renames.push_back(npp); + NodePath new_path(new_base_path, true); + path_renames[p_node] = new_path; for (int i = 0; i < p_node->get_child_count(); i++) { _fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames); @@ -1669,8 +1660,8 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { bool SceneTreeDock::_validate_no_foreign() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) { + for (Node *E : selection) { + if (E != edited_scene && E->get_owner() != edited_scene) { accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); accept->popup_centered(); return false; @@ -1679,11 +1670,11 @@ bool SceneTreeDock::_validate_no_foreign() { // When edited_scene inherits from another one the root Node will be the parent Scene, // we don't want to consider that Node a foreign one otherwise we would not be able to // delete it. - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E->get()) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E) { continue; } - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) { + if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); accept->popup_centered(); return false; @@ -1696,8 +1687,8 @@ bool SceneTreeDock::_validate_no_foreign() { bool SceneTreeDock::_validate_no_instance() { List<Node *> selection = editor_selection->get_selected_node_list(); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_filename() != "") { + for (Node *E : selection) { + if (E != edited_scene && E->get_filename() != "") { accept->set_text(TTR("This operation can't be done on instantiated scenes.")); accept->popup_centered(); return false; @@ -1719,8 +1710,8 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } _do_reparent(new_parent, -1, nodes, p_keep_global_xform); @@ -1762,7 +1753,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V editor_data->get_undo_redo().create_action(TTR("Reparent Node")); - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; Vector<StringName> former_names; int inc = 0; @@ -1777,8 +1768,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } if (new_parent == node->get_parent() && node->get_index() < p_position_in_parent + ni) { @@ -1799,21 +1790,24 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V // Name was modified, fix the path renames. if (old_name.casecmp_to(new_name) != 0) { // Fix the to name to have the new name. - NodePath old_new_name = path_renames[ni].second; - NodePath new_path; - - Vector<StringName> unfixed_new_names = old_new_name.get_names(); - Vector<StringName> fixed_new_names; + Map<Node *, NodePath>::Element *found_path = path_renames.find(node); + if (found_path) { + NodePath old_new_name = found_path->get(); - // Get last name and replace with fixed new name. - for (int a = 0; a < (unfixed_new_names.size() - 1); a++) { - fixed_new_names.push_back(unfixed_new_names[a]); - } - fixed_new_names.push_back(new_name); + Vector<StringName> unfixed_new_names = old_new_name.get_names(); + Vector<StringName> fixed_new_names; - NodePath fixed_node_path = NodePath(fixed_new_names, true); + // Get last name and replace with fixed new name. + for (int a = 0; a < (unfixed_new_names.size() - 1); a++) { + fixed_new_names.push_back(unfixed_new_names[a]); + } + fixed_new_names.push_back(new_name); - path_renames[ni].second = fixed_node_path; + NodePath fixed_node_path = NodePath(fixed_new_names, true); + path_renames[node] = fixed_node_path; + } else { + ERR_PRINT("Internal error. Can't find renamed path for node '" + node->get_path() + "'"); + } } editor_data->get_undo_redo().add_do_method(ed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc); @@ -1850,8 +1844,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; - for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); + for (Node *E : owned) { + owners.push_back(E); } int child_pos = node->get_index(); @@ -1931,10 +1925,10 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { } editor_data->get_undo_redo().create_action(TTR("Attach Script")); - for (List<Node *>::Element *E = selected.front(); E; E = E->next()) { - Ref<Script> existing = E->get()->get_script(); - editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script); - editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing); + for (Node *E : selected) { + Ref<Script> existing = E->get_script(); + editor_data->get_undo_redo().add_do_method(E, "set_script", p_script); + editor_data->get_undo_redo().add_undo_method(E, "set_script", existing); editor_data->get_undo_redo().add_do_method(this, "_update_script_button"); editor_data->get_undo_redo().add_undo_method(this, "_update_script_button"); } @@ -2009,8 +2003,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { bool entire_scene = false; - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - if (E->get() == edited_scene) { + for (Node *E : remove_list) { + if (E == edited_scene) { entire_scene = true; } } @@ -2024,11 +2018,10 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { } else { remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions - List<Pair<NodePath, NodePath>> path_renames; + Map<Node *, NodePath> path_renames; //delete from animation - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2038,8 +2031,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { perform_node_renames(nullptr, &path_renames); //delete for read - for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : remove_list) { if (!n->is_inside_tree() || !n->get_parent()) { continue; } @@ -2047,8 +2039,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { List<Node *> owned; n->get_owned_by(n->get_owner(), &owned); Array owners; - for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); + for (Node *F : owned) { + owners.push_back(F); } editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n); @@ -2172,7 +2164,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { ct->set_size(ms); } - emit_signal("node_created", c); + emit_signal(SNAME("node_created"), c); } void SceneTreeDock::_create() { @@ -2201,8 +2193,7 @@ void SceneTreeDock::_create() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change type of node(s)")); - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *n = E->get(); + for (Node *n : selection) { ERR_FAIL_COND(!n); Variant c = create_dialog->instance_selected(); @@ -2259,8 +2250,8 @@ void SceneTreeDock::_create() { _do_create(parent); Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } // This works because editor_selection was cleared and populated with last created node in _do_create() @@ -2268,7 +2259,7 @@ void SceneTreeDock::_create() { _do_reparent(last_created, -1, nodes, true); } - scene_tree->get_scene_tree()->call_deferred("grab_focus"); + scene_tree->get_scene_tree()->call_deferred(SNAME("grab_focus")); } void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties, bool p_remove_old) { @@ -2280,13 +2271,13 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<PropertyInfo> pinfo; n->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - if (E->get().name == "__meta__") { - Dictionary metadata = n->get(E->get().name); + if (E.name == "__meta__") { + Dictionary metadata = n->get(E.name); if (metadata.has("_editor_description_")) { newnode->set_meta("_editor_description_", metadata["_editor_description_"]); } @@ -2303,8 +2294,8 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop continue; } - if (default_oldnode->get(E->get().name) != n->get(E->get().name)) { - newnode->set(E->get().name, n->get(E->get().name)); + if (default_oldnode->get(E.name) != n->get(E.name)) { + newnode->set(E.name, n->get(E.name)); } } @@ -2317,12 +2308,11 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<MethodInfo> sl; n->get_signal_list(&sl); - for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { + for (const MethodInfo &E : sl) { List<Object::Connection> cl; - n->get_signal_connection_list(E->get().name, &cl); + n->get_signal_connection_list(E.name, &cl); - for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { - Object::Connection &c = F->get(); + for (const Object::Connection &c : cl) { if (!(c.flags & Object::CONNECT_PERSIST)) { continue; } @@ -2515,9 +2505,51 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ Node *node = get_node(p_to); ERR_FAIL_COND(!node); - int to_pos = -1; - _normalize_drop(node, to_pos, p_type); - _perform_instantiate_scenes(p_files, node, to_pos); + if (scene_tree->get_scene_tree()->get_drop_mode_flags() & Tree::DROP_MODE_INBETWEEN) { + // Dropped PackedScene, instance it. + int to_pos = -1; + _normalize_drop(node, to_pos, p_type); + _perform_instantiate_scenes(p_files, node, to_pos); + } else { + String res_path = p_files[0]; + StringName res_type = EditorFileSystem::get_singleton()->get_file_type(res_path); + List<String> valid_properties; + + List<PropertyInfo> pinfo; + node->get_property_list(&pinfo); + + for (const PropertyInfo &p : pinfo) { + if (!(p.usage & PROPERTY_USAGE_EDITOR) || !(p.usage & PROPERTY_USAGE_STORAGE) || p.hint != PROPERTY_HINT_RESOURCE_TYPE) { + continue; + } + Vector<String> valid_types = p.hint_string.split(","); + + for (const String &prop_type : valid_types) { + if (res_type == prop_type || ClassDB::is_parent_class(res_type, prop_type) || EditorNode::get_editor_data().script_class_is_parent(res_type, prop_type)) { + valid_properties.push_back(p.name); + break; + } + } + } + + if (valid_properties.size() > 1) { + property_drop_node = node; + resource_drop_path = res_path; + + bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); + menu_properties->clear(); + for (const String &p : valid_properties) { + menu_properties->add_item(capitalize ? p.capitalize() : p); + menu_properties->set_item_metadata(menu_properties->get_item_count() - 1, p); + } + + menu_properties->set_size(Size2(1, 1)); + menu_properties->set_position(get_screen_position() + get_local_mouse_position()); + menu_properties->popup(); + } else if (!valid_properties.is_empty()) { + _perform_property_drop(node, valid_properties[0], ResourceLoader::load(res_path)); + } + } } void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { @@ -2547,8 +2579,8 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { } Vector<Node *> nodes; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - nodes.push_back(E->get()); + for (Node *E : selection) { + nodes.push_back(E); } int to_pos = -1; @@ -2564,15 +2596,15 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) { + for (const PropertyInfo &E : pinfo) { + if (!(E.usage & PROPERTY_USAGE_EDITOR)) { continue; } - if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) { + if (E.hint != PROPERTY_HINT_RESOURCE_TYPE) { continue; } - Variant value = p_obj->get(E->get().name); + Variant value = p_obj->get(E.name); if (value.get_type() != Variant::OBJECT) { continue; } @@ -2587,7 +2619,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { menu->add_submenu_item(TTR("Sub-Resources"), "Sub-Resources"); } int index = menu_subresources->get_item_count(); - menu_subresources->add_icon_item(icon, E->get().name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); + menu_subresources->add_icon_item(icon, E.name.capitalize(), EDIT_SUBRESOURCE_BASE + subresources.size()); menu_subresources->set_item_h_offset(index, p_depth * 10 * EDSCALE); subresources.push_back(obj->get_instance_id()); @@ -2599,8 +2631,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (!EditorNode::get_singleton()->get_edited_scene()) { menu->clear(); if (profile_allow_editing) { - menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); } menu->set_size(Size2(1, 1)); @@ -2632,10 +2664,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); } - menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANTIATE); } - menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Collapse"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); menu->add_separator(); existing_script = selected->get_script(); @@ -2659,18 +2691,18 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (full_selection.size() == 1) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); if (existing_script.is_valid()) { - menu->add_icon_shortcut(get_theme_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); } } if (existing_script.is_valid() && existing_script_removable) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } else if (full_selection.size() > 1) { bool script_exists = false; - for (List<Node *>::Element *E = full_selection.front(); E; E = E->next()) { - if (!E->get()->get_script().is_null()) { + for (Node *E : full_selection) { + if (!E->get_script().is_null()) { script_exists = true; break; } @@ -2678,7 +2710,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (script_exists) { add_separator = true; - menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ScriptRemove"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/detach_script"), TOOL_DETACH_SCRIPT); } } @@ -2689,41 +2721,41 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { if (full_selection.size() == 1) { - menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); + menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); } bool can_replace = true; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && (E->get()->get_owner() != edited_scene || E->get()->get_filename() != "")) { + for (Node *E : selection) { + if (E != edited_scene && (E->get_owner() != edited_scene || E->get_filename() != "")) { can_replace = false; break; } } if (can_replace) { - menu->add_icon_shortcut(get_theme_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); } if (scene_tree->get_selected() != edited_scene) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); - menu->add_icon_shortcut(get_theme_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); - menu->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); - menu->add_icon_shortcut(get_theme_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); - menu->add_icon_shortcut(get_theme_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); + menu->add_icon_shortcut(get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Reparent"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); + menu->add_icon_shortcut(get_theme_icon(SNAME("ReparentToNewNode"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); if (selection.size() == 1) { - menu->add_icon_shortcut(get_theme_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); + menu->add_icon_shortcut(get_theme_icon(SNAME("NewRoot"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); } } } if (selection.size() == 1) { if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_theme_icon(SNAME("CreateNewSceneFrom"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } if (full_selection.size() == 1) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); + menu->add_icon_shortcut(get_theme_icon(SNAME("CopyNodePath"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } bool is_external = (selection[0]->get_filename() != ""); @@ -2735,7 +2767,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE); } - menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); + menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); } else if (!is_top_level) { menu->add_separator(); bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]); @@ -2745,7 +2777,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL); } - menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); + menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Open in Editor"), TOOL_SCENE_OPEN); if (profile_allow_editing) { menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable); menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); @@ -2757,14 +2789,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing && selection.size() > 1) { //this is not a commonly used action, it makes no sense for it to be where it was nor always present. menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); + menu->add_icon_shortcut(get_theme_icon(SNAME("Rename"), SNAME("EditorIcons")), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } menu->add_separator(); - menu->add_icon_item(get_theme_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); + menu->add_icon_item(get_theme_icon(SNAME("Help"), SNAME("EditorIcons")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); + menu->add_icon_shortcut(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); } menu->set_size(Size2(1, 1)); menu->set_position(p_menu_pos); @@ -2906,7 +2938,7 @@ void SceneTreeDock::_remote_tree_selected() { edit_remote->set_pressed(true); edit_local->set_pressed(false); - emit_signal("remote_tree_selected"); + emit_signal(SNAME("remote_tree_selected")); } void SceneTreeDock::_local_tree_selected() { @@ -3007,8 +3039,8 @@ void SceneTreeDock::_feature_profile_changed() { } void SceneTreeDock::_clear_clipboard() { - for (List<Node *>::Element *E = node_clipboard.front(); E; E = E->next()) { - memdelete(E->get()); + for (Node *E : node_clipboard) { + memdelete(E); } node_clipboard.clear(); clipboard_resource_remap.clear(); @@ -3019,18 +3051,18 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) p_node->get_property_list(&props); bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_node->get(E->get().name); + Variant v = p_node->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { if (is_instantiated) { Variant orig; - if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E->get().name, orig)) { + if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E.name, orig)) { if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) { continue; } @@ -3055,12 +3087,12 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_ List<PropertyInfo> props; p_resource->get_property_list(&props); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { + for (const PropertyInfo &E : props) { + if (!(E.usage & PROPERTY_USAGE_STORAGE)) { continue; } - Variant v = p_resource->get(E->get().name); + Variant v = p_resource->get(E.name); if (v.is_ref()) { RES res = v; if (res.is_valid()) { @@ -3276,6 +3308,10 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel first_enter = true; restore_script_editor_on_drag = false; + menu_properties = memnew(PopupMenu); + add_child(menu_properties); + menu_properties->connect("id_pressed", callable_mp(this, &SceneTreeDock::_property_selected)); + clear_inherit_confirm = memnew(ConfirmationDialog); clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); clear_inherit_confirm->get_ok_button()->set_text(TTR("Clear")); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 08d992d465..4952122cb7 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -123,8 +123,13 @@ class SceneTreeDock : public VBoxContainer { HBoxContainer *tool_hbc; void _tool_selected(int p_tool, bool p_confirm_override = false); + void _property_selected(int p_idx); void _node_collapsed(Object *p_obj); + Node *property_drop_node = nullptr; + String resource_drop_path; + void _perform_property_drop(Node *p_node, String p_property, RES p_res); + EditorData *editor_data; EditorSelection *editor_selection; @@ -147,6 +152,7 @@ class SceneTreeDock : public VBoxContainer { PopupMenu *menu; PopupMenu *menu_subresources; + PopupMenu *menu_properties; ConfirmationDialog *clear_inherit_confirm; bool first_enter; @@ -211,7 +217,7 @@ class SceneTreeDock : public VBoxContainer { void _selection_changed(); void _update_script_button(); - void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames); + void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, Map<Node *, NodePath> *p_renames); void _normalize_drop(Node *&to_node, int &to_pos, int p_type); @@ -247,8 +253,8 @@ class SceneTreeDock : public VBoxContainer { static SceneTreeDock *singleton; static void _update_configuration_warning(); - static bool _update_node_path(const NodePath &p_root_path, NodePath &r_node_path, List<Pair<NodePath, NodePath>> *p_renames); - static bool _check_node_path_recursive(const NodePath &p_root_path, Variant &r_variant, List<Pair<NodePath, NodePath>> *p_renames); + bool _update_node_path(Node *p_root_node, NodePath &r_node_path, Map<Node *, NodePath> *p_renames) const; + bool _check_node_path_recursive(Node *p_root_node, Variant &r_variant, Map<Node *, NodePath> *p_renames) const; protected: void _notification(int p_what); @@ -266,8 +272,8 @@ public: void instantiate(const String &p_file); void instantiate_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); void set_selected(Node *p_node, bool p_emit_selected = false); - void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames); - void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); + void fill_path_renames(Node *p_node, Node *p_new_parent, Map<Node *, NodePath> *p_renames); + void perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index ad9ad3757c..83b0203f32 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -63,15 +63,15 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i if (p_id == BUTTON_SUBSCENE) { if (n == get_scene_node()) { if (n && n->get_scene_inherited_state().is_valid()) { - emit_signal("open", n->get_scene_inherited_state()->get_path()); + emit_signal(SNAME("open"), n->get_scene_inherited_state()->get_path()); } } else { - emit_signal("open", n->get_filename()); + emit_signal(SNAME("open"), n->get_filename()); } } else if (p_id == BUTTON_SCRIPT) { Ref<Script> script_typed = n->get_script(); if (!script_typed.is_null()) { - emit_signal("open_script", script_typed); + emit_signal(SNAME("open_script"), script_typed); } } else if (p_id == BUTTON_VISIBILITY) { @@ -79,8 +79,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() > 1 && selection.find(n) != nullptr) { - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *nv = E->get(); + for (Node *nv : selection) { ERR_FAIL_COND(!nv); if (nv == n) { continue; @@ -197,19 +196,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->set_metadata(0, p_node->get_path()); if (connect_to_script_mode) { - Color accent = get_theme_color("accent_color", "Editor"); + Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); Ref<Script> script = p_node->get_script(); if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) { //has script - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); } else { //has no script (or script is a custom type) - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); item->set_selectable(0, false); if (!script.is_null()) { // make sure to mark the script if a custom type - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT); item->set_button_disabled(0, item->get_button_count(0) - 1, true); } @@ -226,7 +225,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } } else if (part_of_subscene) { if (valid_types.size() == 0) { - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } } else if (marked.has(p_node)) { String node_name = p_node->get_name(); @@ -235,15 +234,15 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } item->set_text(0, node_name); item->set_selectable(0, marked_selectable); - item->set_custom_color(0, get_theme_color("accent_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor"))); } else if (!p_node->can_process()) { - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); } else if (!marked_selectable && !marked_children_selectable) { Node *node = p_node; while (node) { if (marked.has(node)) { item->set_selectable(0, false); - item->set_custom_color(0, get_theme_color("error_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("error_color"), SNAME("Editor"))); break; } node = node->get_parent(); @@ -254,7 +253,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll String warning = p_node->get_configuration_warnings_as_string(); if (!warning.is_empty()) { - item->add_button(0, get_theme_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + warning); + item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + warning); } int num_connections = p_node->get_persistent_signal_connection_count(); @@ -279,11 +278,11 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Ref<Texture2D> icon_temp; SceneTreeEditorButton signal_temp = BUTTON_SIGNALS; if (num_connections >= 1 && num_groups >= 1) { - icon_temp = get_theme_icon("SignalsAndGroups", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("SignalsAndGroups"), SNAME("EditorIcons")); } else if (num_connections >= 1) { - icon_temp = get_theme_icon("Signals", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("Signals"), SNAME("EditorIcons")); } else if (num_groups >= 1) { - icon_temp = get_theme_icon("Groups", "EditorIcons"); + icon_temp = get_theme_icon(SNAME("Groups"), SNAME("EditorIcons")); signal_temp = BUTTON_GROUPS; } @@ -293,7 +292,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { - item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -302,7 +301,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll item->set_tooltip(0, tooltip); } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) { - item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon(SNAME("InstanceOptions"), SNAME("EditorIcons")), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -332,7 +331,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Ref<Script> script = p_node->get_script(); if (!script.is_null()) { - item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); + item->add_button(0, get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) { item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5)); } @@ -341,19 +340,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll if (p_node->is_class("CanvasItem")) { bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_ if (is_locked) { - item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) { - item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -364,19 +363,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } else if (p_node->is_class("Node3D")) { bool is_locked = p_node->has_meta("_edit_lock_"); if (is_locked) { - item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon(SNAME("Lock"), SNAME("EditorIcons")), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); } bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) { - item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon(SNAME("Group"), SNAME("EditorIcons")), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); } bool v = p_node->call("is_visible"); if (v) { - item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } else { - item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); } if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { @@ -388,7 +387,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned(); if (is_pinned) { - item->add_button(0, get_theme_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); + item->add_button(0, get_theme_icon(SNAME("Pin"), SNAME("EditorIcons")), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); } } } @@ -429,7 +428,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll if (!valid) { //item->set_selectable(0,marked_selectable); - item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); item->set_selectable(0, false); } } @@ -475,9 +474,9 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { } if (visible) { - item->set_button(0, idx, get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); } else { - item->set_button(0, idx, get_theme_icon("GuiVisibilityHidden", "EditorIcons")); + item->set_button(0, idx, get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); } _update_visibility_color(p_node, item); @@ -521,7 +520,7 @@ void SceneTreeEditor::_node_removed(Node *p_node) { if (p_node == selected) { selected = nullptr; - _emit_node_selected(); + emit_signal("node_selected"); } } @@ -530,7 +529,7 @@ void SceneTreeEditor::_node_renamed(Node *p_node) { return; } - emit_signal("node_renamed"); + emit_signal(SNAME("node_renamed")); if (!tree_dirty) { MessageQueue::get_singleton()->push_call(this, "_update_tree"); @@ -615,20 +614,32 @@ void SceneTreeEditor::_tree_changed() { pending_test_update = true; } -void SceneTreeEditor::_deselect_items() { - // Clear currently selected items in scene tree dock. - if (editor_selection) { - editor_selection->clear(); - emit_signal("node_changed"); +void SceneTreeEditor::_selected_changed() { + TreeItem *s = tree->get_selected(); + ERR_FAIL_COND(!s); + NodePath np = s->get_metadata(0); + + Node *n = get_node(np); + + if (n == selected) { + return; } -} -void SceneTreeEditor::_emit_node_selected() { + selected = get_node(np); + blocked++; emit_signal("node_selected"); blocked--; } +void SceneTreeEditor::_deselect_items() { + // Clear currently selected items in scene tree dock. + if (editor_selection) { + editor_selection->clear(); + emit_signal(SNAME("node_changed")); + } +} + void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) { TreeItem *item = Object::cast_to<TreeItem>(p_object); ERR_FAIL_COND(!item); @@ -652,12 +663,9 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_ editor_selection->remove_node(n); } - // Selection changed to be single node, so emit "selected" (for single node) rather than "changed" (for multiple nodes) - if (editor_selection->get_selected_nodes().size() == 1) { - selected = editor_selection->get_selected_node_list()[0]; - _emit_node_selected(); - } else { - emit_signal("node_changed"); + // Emitted "selected" in _selected_changed() when select single node, so select multiple node emit "changed" + if (editor_selection->get_selected_nodes().size() > 1) { + emit_signal(SNAME("node_changed")); } } @@ -747,7 +755,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { } if (p_emit_selected) { - _emit_node_selected(); + emit_signal("node_selected"); } } @@ -804,10 +812,10 @@ void SceneTreeEditor::_renamed() { if (!undo_redo) { n->set_name(new_name); which->set_metadata(0, n->get_path()); - emit_signal("node_renamed"); + emit_signal(SNAME("node_renamed")); } else { undo_redo->create_action(TTR("Rename Node")); - emit_signal("node_prerename", n, new_name); + emit_signal(SNAME("node_prerename"), n, new_name); undo_redo->add_do_method(this, "_rename_node", n->get_instance_id(), new_name); undo_redo->add_undo_method(this, "_rename_node", n->get_instance_id(), n->get_name()); undo_redo->commit_action(); @@ -984,7 +992,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from drag_data["nodes"] = objs; tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); - emit_signal("nodes_dragged"); + emit_signal(SNAME("nodes_dragged")); return drag_data; } @@ -1025,15 +1033,24 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return true; } + bool scene_drop = true; for (int i = 0; i < files.size(); i++) { String file = files[i]; String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "PackedScene") { - return false; + scene_drop = false; + break; } } - tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); //so it works.. + if (scene_drop) { + tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); + } else { + if (files.size() > 1) { + return false; + } + tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM); + } return true; } @@ -1076,7 +1093,7 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (String(d["type"]) == "nodes") { Array nodes = d["nodes"]; - emit_signal("nodes_rearranged", nodes, np, section); + emit_signal(SNAME("nodes_rearranged"), nodes, np, section); } if (String(d["type"]) == "files") { @@ -1084,9 +1101,9 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]); if (_is_script_type(ftype)) { - emit_signal("script_dropped", files[0], np); + emit_signal(SNAME("script_dropped"), files[0], np); } else { - emit_signal("files_dropped", files, np, section); + emit_signal(SNAME("files_dropped"), files, np, section); } } @@ -1095,14 +1112,14 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (se) { String sp = se->get_edited_resource()->get_path(); if (_is_script_type(EditorFileSystem::get_singleton()->get_file_type(sp))) { - emit_signal("script_dropped", sp, np); + emit_signal(SNAME("script_dropped"), sp, np); } } } } void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) { - emit_signal("rmb_pressed", tree->get_screen_transform().xform(p_pos)); + emit_signal(SNAME("rmb_pressed"), tree->get_screen_transform().xform(p_pos)); } void SceneTreeEditor::update_warning() { @@ -1188,6 +1205,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope tree->connect("empty_tree_rmb_selected", callable_mp(this, &SceneTreeEditor::_rmb_select)); } + tree->connect("cell_selected", callable_mp(this, &SceneTreeEditor::_selected_changed)); tree->connect("item_edited", callable_mp(this, &SceneTreeEditor::_renamed), varray(), CONNECT_DEFERRED); tree->connect("multi_selected", callable_mp(this, &SceneTreeEditor::_cell_multi_selected)); tree->connect("button_pressed", callable_mp(this, &SceneTreeEditor::_cell_button_pressed)); @@ -1237,7 +1255,7 @@ void SceneTreeDialog::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); - filter->set_right_icon(tree->get_theme_icon("Search", "EditorIcons")); + filter->set_right_icon(tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_EXIT_TREE: { @@ -1252,7 +1270,7 @@ void SceneTreeDialog::_cancel() { void SceneTreeDialog::_select() { if (tree->get_selected()) { - emit_signal("selected", tree->get_selected()->get_path()); + emit_signal(SNAME("selected"), tree->get_selected()->get_path()); hide(); } } diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index e833bf93e0..acd49e8d92 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -81,6 +81,7 @@ class SceneTreeEditor : public Control { TreeItem *_find(TreeItem *p_node, const NodePath &p_path); void _notification(int p_what); + void _selected_changed(); void _deselect_items(); void _rename_node(ObjectID p_node, const String &p_name); @@ -132,8 +133,6 @@ class SceneTreeEditor : public Control { Vector<StringName> valid_types; - void _emit_node_selected(); - public: void set_filter(const String &p_filter); String get_filter() const; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index b5028096e0..9a4b38db74 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -46,7 +46,7 @@ void ScriptCreateDialog::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < ScriptServer::get_language_count(); i++) { String lang = ScriptServer::get_language(i)->get_type(); - Ref<Texture2D> lang_icon = get_theme_icon(lang, "EditorIcons"); + Ref<Texture2D> lang_icon = get_theme_icon(lang, SNAME("EditorIcons")); if (lang_icon.is_valid()) { language_menu->set_item_icon(i, lang_icon); } @@ -65,10 +65,10 @@ void ScriptCreateDialog::_notification(int p_what) { language_menu->select(default_language); } - path_button->set_icon(get_theme_icon("Folder", "EditorIcons")); - parent_browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); - parent_search_button->set_icon(get_theme_icon("ClassList", "EditorIcons")); - status_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + path_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + parent_browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); + parent_search_button->set_icon(get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); + status_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; } } @@ -205,12 +205,12 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must bool found = false; bool match = false; int index = 0; - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { //FIXME (?) - changing language this way doesn't update controls, needs rework //language_menu->select(index); // change Language option by extension found = true; - if (E->get() == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { + if (E == ScriptServer::get_language(language_menu->get_selected())->get_extension()) { match = true; } break; @@ -326,7 +326,7 @@ void ScriptCreateDialog::_create_new() { } } - emit_signal("script_created", scr); + emit_signal(SNAME("script_created"), scr); hide(); } @@ -339,7 +339,7 @@ void ScriptCreateDialog::_load_exist() { return; } - emit_signal("script_created", p_script); + emit_signal(SNAME("script_created"), p_script); hide(); } @@ -373,8 +373,8 @@ void ScriptCreateDialog::_lang_changed(int l) { ScriptServer::get_language(m)->get_recognized_extensions(&extensions); } - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - if (E->get().nocasecmp_to(extension) == 0) { + for (const String &E : extensions) { + if (E.nocasecmp_to(extension) == 0) { path = path.get_basename() + selected_ext; _path_changed(path); break; @@ -448,7 +448,7 @@ void ScriptCreateDialog::_lang_changed(int l) { override_info += ", "; } } - template_menu->set_item_icon(extended.id, get_theme_icon("Override", "EditorIcons")); + template_menu->set_item_icon(extended.id, get_theme_icon(SNAME("Override"), SNAME("EditorIcons"))); template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string()); } // Reselect last selected template @@ -534,8 +534,8 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { int lang = language_menu->get_selected(); ScriptServer::get_language(lang)->get_recognized_extensions(&extensions); - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_browse->add_filter("*." + E->get()); + for (const String &E : extensions) { + file_browse->add_filter("*." + E); } file_browse->set_current_path(file_path->get_text()); @@ -606,18 +606,18 @@ void ScriptCreateDialog::_path_submitted(const String &p_path) { void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { error_label->set_text("- " + p_msg); if (valid) { - error_label->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else { - error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } } void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) { path_error_label->set_text("- " + p_msg); if (valid) { - path_error_label->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); + path_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor"))); } else { - path_error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + path_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); } } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c2c99ed17f..b3ec0c96c4 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -176,15 +176,15 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); search_box->set_clear_button_enabled(true); - shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); + shortcut_search_box->set_right_icon(shortcuts->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); shortcut_search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(shortcuts->get_theme_icon("Close", "EditorIcons")); - restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox("bg", "Tree")); - restart_icon->set_texture(shortcuts->get_theme_icon("StatusWarning", "EditorIcons")); - restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color("warning_color", "Editor")); + restart_close_button->set_icon(shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(shortcuts->get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color(SNAME("warning_color"), SNAME("Editor"))); } void EditorSettingsDialog::_event_config_confirmed() { @@ -253,8 +253,8 @@ void EditorSettingsDialog::_update_shortcuts() { if (collapsed.has("Common")) { common_section->set_collapsed(collapsed["Common"]); } - common_section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); - common_section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); + common_section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + common_section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); // Get the action map for the editor, and add each item to the "Common" section. OrderedHashMap<StringName, InputMap::Action> action_map = InputMap::get_singleton()->get_action_map(); @@ -303,16 +303,16 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, events_display_string); if (!same_as_defaults) { - item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), 2); } if (events_display_string == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.5)); } - item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); - item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), 1); item->set_tooltip(0, action_name); item->set_tooltip(1, events_display_string); item->set_metadata(0, "Common"); @@ -324,15 +324,15 @@ void EditorSettingsDialog::_update_shortcuts() { List<String> slist; EditorSettings::get_singleton()->get_shortcut_list(&slist); - for (List<String>::Element *E = slist.front(); E; E = E->next()) { - Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E->get()); + for (const String &E : slist) { + Ref<Shortcut> sc = EditorSettings::get_singleton()->get_shortcut(E); if (!sc->has_meta("original")) { continue; } Ref<InputEvent> original = sc->get_meta("original"); - String section_name = E->get().get_slice("/", 0); + String section_name = E.get_slice("/", 0); TreeItem *section; @@ -349,8 +349,8 @@ void EditorSettingsDialog::_update_shortcuts() { } sections[section_name] = section; - section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); - section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); + section->set_custom_bg_color(0, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); + section->set_custom_bg_color(1, shortcuts->get_theme_color(SNAME("prop_subsection"), SNAME("Editor"))); } // Don't match unassigned shortcuts when searching for assigned keys in search results. @@ -362,18 +362,18 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, sc->get_as_text()); if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) { - item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Reload"), SNAME("EditorIcons")), 2); } if (sc->get_as_text() == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color(SNAME("font_color"), SNAME("Label")) * Color(1, 1, 1, 0.5)); } - item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); - item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); - item->set_tooltip(0, E->get()); - item->set_metadata(0, E->get()); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0); + item->add_button(1, shortcuts->get_theme_icon(SNAME("Close"), SNAME("EditorIcons")), 1); + item->set_tooltip(0, E); + item->set_metadata(0, E); } } @@ -403,10 +403,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column List<Ref<InputEvent>> defaults = InputMap::get_singleton()->get_builtins()[current_action]; // Convert the list to an array, and only keep key events as this is for the editor. - for (List<Ref<InputEvent>>::Element *E = defaults.front(); E; E = E->next()) { - Ref<InputEventKey> k = E->get(); + for (const Ref<InputEvent> &k : defaults) { if (k.is_valid()) { - events.append(E->get()); + events.append(k); } } @@ -426,7 +425,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column if (button_idx == SHORTCUT_EDIT) { // If editing, add a button which can be used to add an additional event. - action_popup->add_icon_item(get_theme_icon("Add", "EditorIcons"), TTR("Add")); + action_popup->add_icon_item(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), TTR("Add")); } action_popup->set_position(get_position() + get_mouse_position()); diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 1893c6b6bb..d504d3b137 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -66,7 +66,7 @@ class ShaderGlobalsEditorInterface : public Object { GDCLASS(ShaderGlobalsEditorInterface, Object) void _var_changed() { - emit_signal("var_changed"); + emit_signal(SNAME("var_changed")); } protected: @@ -84,7 +84,7 @@ protected: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Set Shader Global Variable"); + undo_redo->create_action(TTR("Set Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_set", p_name, p_value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_set", p_name, existing); RS::GlobalVariableType type = RS::get_singleton()->global_variable_get_type(p_name); @@ -110,7 +110,6 @@ protected: undo_redo->commit_action(); block_update = false; - print_line("all good?"); return true; } @@ -395,7 +394,7 @@ void ShaderGlobalsEditor::_variable_added() { Variant value = create_var(RS::GlobalVariableType(variable_type->get_selected())); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_add", var, RS::GlobalVariableType(variable_type->get_selected()), value); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_remove", var); Dictionary gv; @@ -410,10 +409,9 @@ void ShaderGlobalsEditor::_variable_added() { } void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { - print_line("deleted " + p_variable); UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Add Shader Global Variable"); + undo_redo->create_action(TTR("Add Shader Global Variable")); undo_redo->add_do_method(RS::get_singleton(), "global_variable_remove", p_variable); undo_redo->add_undo_method(RS::get_singleton(), "global_variable_add", p_variable, RS::get_singleton()->global_variable_get_type(p_variable), RS::get_singleton()->global_variable_get(p_variable)); @@ -425,7 +423,7 @@ void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { } void ShaderGlobalsEditor::_changed() { - emit_signal("globals_changed"); + emit_signal(SNAME("globals_changed")); if (!interface->block_update) { interface->notify_property_list_changed(); } @@ -439,7 +437,6 @@ void ShaderGlobalsEditor::_bind_methods() { void ShaderGlobalsEditor::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { if (is_visible_in_tree()) { - print_line("OK load settings in globalseditor"); inspector->edit(interface); } } diff --git a/editor/translations/af.po b/editor/translations/af.po index bb7e7ca553..6a74789da2 100644 --- a/editor/translations/af.po +++ b/editor/translations/af.po @@ -5251,8 +5251,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ar.po b/editor/translations/ar.po index 6d8db6f47b..b851db361f 100644 --- a/editor/translations/ar.po +++ b/editor/translations/ar.po @@ -52,12 +52,13 @@ # ILG - Game <moegypt277@gmail.com>, 2021. # Hatim Jamal <hatimjamal8@gmail.com>, 2021. # HASSAN GAMER - حسن جيمر <gamerhassan55@gmail.com>, 2021. +# abubakrAlsaab <madeinsudan19@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-09 14:32+0000\n" -"Last-Translator: HASSAN GAMER - حسن جيمر <gamerhassan55@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: abubakrAlsaab <madeinsudan19@gmail.com>\n" "Language-Team: Arabic <https://hosted.weblate.org/projects/godot-engine/" "godot/ar/>\n" "Language: ar\n" @@ -66,7 +67,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " "&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -3021,7 +3022,7 @@ msgstr "حول" #: editor/editor_node.cpp msgid "Support Godot Development" -msgstr "" +msgstr "إدعم تطوير محرك غو-دوت" #: editor/editor_node.cpp msgid "Play the project." @@ -5215,9 +5216,10 @@ msgstr "" "الضوء المعدة مسبقا." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "لايوجد ميش لكي يتم تجهيزة. تاكد من انه يحتوي على منفذ UV2 و ان زر الضوء " "'المعد' مفعل." @@ -5342,7 +5344,7 @@ msgstr "تعديل حجم العقدة \"Node2D \"%s إلى (s, %s%)" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Resize Control \"%s\" to (%d, %d)" -msgstr "" +msgstr "تغيير حجم عنصر التحكم \"٪ s\" إلى (٪ d،٪ d)" #: editor/plugins/canvas_item_editor_plugin.cpp #, fuzzy @@ -7566,6 +7568,7 @@ msgstr "تدوير الرؤية مقفول" msgid "" "To zoom further, change the camera's clipping planes (View -> Settings...)" msgstr "" +"للتكبير بشكل أكبر ، قم بتغيير مستويات اقتصاص الكاميرا (عرض -> الإعدادات ...)" #: editor/plugins/spatial_editor_plugin.cpp msgid "" @@ -9536,7 +9539,7 @@ msgstr "" #: editor/plugins/visual_shader_editor_plugin.cpp msgid "A reference to an existing uniform." -msgstr "" +msgstr "إشارة إلى زي موحد موجود." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "(Fragment/Light mode only) Scalar derivative function." @@ -9903,7 +9906,7 @@ msgstr "OpenGL ES 3.0" #: editor/project_manager.cpp msgid "Not supported by your GPU drivers." -msgstr "" +msgstr "غير مدعوم من قبل برامج تشغيل GPU(اجهزة اارسوم) الخاصة بك." #: editor/project_manager.cpp msgid "" @@ -10959,6 +10962,9 @@ msgid "" "every time it updates.\n" "Switch back to the Local scene tree dock to improve performance." msgstr "" +"إذا تم تحديده ، فسيؤدي شجرة المشهد إلى توقف المشروع في كل مرة يتم فيها " +"تحديثه.\n" +"قم بالتبديل مرة أخرى إلى رصيف شجرة المشهد المحلي لتحسين الأداء." #: editor/scene_tree_dock.cpp msgid "Local" @@ -11657,11 +11663,11 @@ msgstr "" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Begin Bake" -msgstr "" +msgstr "ابدأ الخبز (دمج تاثير الضوء في الصورة )" #: modules/lightmapper_cpu/lightmapper_cpu.cpp msgid "Preparing data structures" -msgstr "" +msgstr "تحضير هياكل البيانات" #: modules/lightmapper_cpu/lightmapper_cpu.cpp #, fuzzy @@ -12192,7 +12198,7 @@ msgstr "اختر جهازاً من القائمة" #: platform/android/export/export.cpp msgid "Unable to find the 'apksigner' tool." -msgstr "" +msgstr "تعذر العثور على أداة توقيع تطبيق اندرويد\"apksigner\"." #: platform/android/export/export.cpp msgid "" diff --git a/editor/translations/az.po b/editor/translations/az.po index 054bc9263d..be05c12c5c 100644 --- a/editor/translations/az.po +++ b/editor/translations/az.po @@ -5056,8 +5056,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/bg.po b/editor/translations/bg.po index 7bf3d40805..9759e3d1e5 100644 --- a/editor/translations/bg.po +++ b/editor/translations/bg.po @@ -5042,9 +5042,10 @@ msgstr "" "Запазете сцената и опитайте отново." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Няма полигонни мрежи за изпичане. Уверете се, че те съдържат канал UV2 и че " "флагът „Изпичане на светлината“ е включен." diff --git a/editor/translations/bn.po b/editor/translations/bn.po index 70a66820fb..f4a10f7dea 100644 --- a/editor/translations/bn.po +++ b/editor/translations/bn.po @@ -5526,8 +5526,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/br.po b/editor/translations/br.po index 9d1e52e009..0fe39331f9 100644 --- a/editor/translations/br.po +++ b/editor/translations/br.po @@ -5000,8 +5000,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ca.po b/editor/translations/ca.po index 1032b7cdeb..40429cc0e0 100644 --- a/editor/translations/ca.po +++ b/editor/translations/ca.po @@ -5277,9 +5277,10 @@ msgstr "" "camí des de les propietats de BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Cap Malla per precalcular. Comproveu que disposin d'un canal d'UV2 i que " "l'indicador 'Bake Light' és activat." diff --git a/editor/translations/cs.po b/editor/translations/cs.po index 3aaf91d758..281bc500f2 100644 --- a/editor/translations/cs.po +++ b/editor/translations/cs.po @@ -30,8 +30,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-25 02:57+0000\n" -"Last-Translator: Vojtěch Šamla <auzkok@seznam.cz>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Zbyněk <zbynek.fiala@gmail.com>\n" "Language-Team: Czech <https://hosted.weblate.org/projects/godot-engine/godot/" "cs/>\n" "Language: cs\n" @@ -39,7 +39,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.7.1-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5139,7 +5139,7 @@ msgstr "Poslední" #: editor/plugins/asset_library_editor_plugin.cpp msgid "All" -msgstr "Všechny" +msgstr "všichni" #: editor/plugins/asset_library_editor_plugin.cpp msgid "No results for \"%s\"." @@ -5194,9 +5194,10 @@ msgstr "" "Uložte scénu a zkuste to znovu." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Žádné sítě k zapečení. Ujistěte se, že obsahují kanál UV2 a že je nastaven " "příznak \"Zapéct světlo\"." @@ -10546,7 +10547,7 @@ msgstr "Hodnota, o kterou se počítadlo zvýší za každý uzel" #: editor/rename_dialog.cpp msgid "Padding" -msgstr "Odsazení" +msgstr "Zarovnávání" #: editor/rename_dialog.cpp msgid "" diff --git a/editor/translations/da.po b/editor/translations/da.po index 9e09250fbc..c86ec25b4b 100644 --- a/editor/translations/da.po +++ b/editor/translations/da.po @@ -5390,8 +5390,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/de.po b/editor/translations/de.po index bbf72f815b..954f8426f8 100644 --- a/editor/translations/de.po +++ b/editor/translations/de.po @@ -5289,9 +5289,10 @@ msgstr "" "Ein Speichern der Szene sollte dieses Problem beheben." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Keine Meshes zum vorrendern vorhanden. Meshes, die vorgerendert werden " "sollen, müssen einen UV2-Kanal beinhalten und die ‚Bake Light‘-Option " diff --git a/editor/translations/editor.pot b/editor/translations/editor.pot index a0f4654639..ae7b6b37dc 100644 --- a/editor/translations/editor.pot +++ b/editor/translations/editor.pot @@ -4980,8 +4980,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -6979,7 +6979,7 @@ msgstr "" #: editor/plugins/shader_editor_plugin.cpp msgid "" -"This shader has been modified on on disk.\n" +"This shader has been modified on disk.\n" "What action should be taken?" msgstr "" diff --git a/editor/translations/el.po b/editor/translations/el.po index 035a82f99f..40d8ab46cc 100644 --- a/editor/translations/el.po +++ b/editor/translations/el.po @@ -5239,9 +5239,10 @@ msgstr "" "Αποθηκεύστε τη σκηνή σας και δοκιμάστε ξανα." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Δεν υπάρχουν πλέγματα για προετοιμασία. Σιγουρευτείτε ότι εμπεριέχουν κανάλι " "UV2 και πως η σημαία 'Bake Light' είναι ενεργοποιημένη." diff --git a/editor/translations/eo.po b/editor/translations/eo.po index 0523742303..38c72380da 100644 --- a/editor/translations/eo.po +++ b/editor/translations/eo.po @@ -5204,8 +5204,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/es.po b/editor/translations/es.po index 5953536c60..e09d1df8c7 100644 --- a/editor/translations/es.po +++ b/editor/translations/es.po @@ -72,7 +72,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-05 21:41+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Erick Figueroa <querecuto@hotmail.com>\n" "Language-Team: Spanish <https://hosted.weblate.org/projects/godot-engine/" "godot/es/>\n" @@ -81,7 +81,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1205,7 +1205,7 @@ msgstr "Desarrollador Principal" #. you do not have to keep it in your translation. #: editor/editor_about.cpp msgid "Project Manager " -msgstr "Gestor del Proyecto " +msgstr "Administrador de Proyectos " #: editor/editor_about.cpp msgid "Developers" @@ -3078,7 +3078,7 @@ msgstr "Apoyar el desarrollo de Godot" #: editor/editor_node.cpp msgid "Play the project." -msgstr "Reproducir el proyecto." +msgstr "Ejecutar el proyecto." #: editor/editor_node.cpp msgid "Play" @@ -5293,9 +5293,10 @@ msgstr "" "Guarda tu escena e inténtalo de nuevo." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "No hay mallas para hacer bake. Asegúrate que contengan un canal UV2 y que la " "opción de 'Bake Light' está activada." @@ -10154,8 +10155,8 @@ msgid "" "The interface will update after restarting the editor or project manager." msgstr "" "Idioma cambiado.\n" -"La interfaz se actualizará después de reiniciar el editor o el gestor de " -"proyectos." +"La interfaz se actualizará después de reiniciar el editor o el administrador " +"de proyectos." #: editor/project_manager.cpp msgid "" @@ -11737,7 +11738,7 @@ msgstr "Eliminar Rotación del Cursor" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Paste Selects" -msgstr "Pegar Selecciona" +msgstr "Pegar Seleccionados" #: modules/gridmap/grid_map_editor_plugin.cpp msgid "Clear Selection" diff --git a/editor/translations/es_AR.po b/editor/translations/es_AR.po index d1fe06a565..33c29d9c6e 100644 --- a/editor/translations/es_AR.po +++ b/editor/translations/es_AR.po @@ -5237,9 +5237,10 @@ msgstr "" "Guardá tu escena e inténtalo de nuevo." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "No hay meshes para hacer bake. Asegúrate que contienen un canal UV2 y que el " "flag 'Bake Light' esta activado." diff --git a/editor/translations/et.po b/editor/translations/et.po index 05a414f5a9..fd534943b1 100644 --- a/editor/translations/et.po +++ b/editor/translations/et.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" -"PO-Revision-Date: 2021-05-10 15:32+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Kritzmensch <streef.gtx@gmail.com>\n" "Language-Team: Estonian <https://hosted.weblate.org/projects/godot-engine/" "godot/et/>\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1090,7 +1090,7 @@ msgstr "Suur tänu Godot kogukonnalt!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klõpsa, et kopeerida." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -5039,8 +5039,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -7244,7 +7244,7 @@ msgstr "Kuva tavaliselt" #: editor/plugins/spatial_editor_plugin.cpp msgid "Display Wireframe" -msgstr "Kuva traadiraamina" +msgstr "Kuva traatraamina" #: editor/plugins/spatial_editor_plugin.cpp msgid "Display Overdraw" diff --git a/editor/translations/eu.po b/editor/translations/eu.po index 87c91de10e..f9f2d97348 100644 --- a/editor/translations/eu.po +++ b/editor/translations/eu.po @@ -5012,8 +5012,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fa.po b/editor/translations/fa.po index ddccfeaebe..ab4157565e 100644 --- a/editor/translations/fa.po +++ b/editor/translations/fa.po @@ -5191,8 +5191,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fi.po b/editor/translations/fi.po index 834d1894e3..1007ee660b 100644 --- a/editor/translations/fi.po +++ b/editor/translations/fi.po @@ -5195,9 +5195,10 @@ msgstr "" "Tallenna skenesi ja yritä uudelleen." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Ei meshejä kehitettävänä. Varmista, että ne sisältävät UV2-kanavan, ja että " "'Bake Light' asetus on päällä." diff --git a/editor/translations/fil.po b/editor/translations/fil.po index 892968821b..b23a43088c 100644 --- a/editor/translations/fil.po +++ b/editor/translations/fil.po @@ -4998,8 +4998,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/fr.po b/editor/translations/fr.po index 6fad70a7c2..d4ded02294 100644 --- a/editor/translations/fr.po +++ b/editor/translations/fr.po @@ -85,8 +85,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-01 14:33+0000\n" -"Last-Translator: Clément Topy <topy72.mine@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: Pierre Caye <pierrecaye@laposte.net>\n" "Language-Team: French <https://hosted.weblate.org/projects/godot-engine/" "godot/fr/>\n" "Language: fr\n" @@ -94,7 +94,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5258,7 +5258,7 @@ msgstr "Dernier" #: editor/plugins/asset_library_editor_plugin.cpp msgid "All" -msgstr "Tout" +msgstr "All" #: editor/plugins/asset_library_editor_plugin.cpp msgid "No results for \"%s\"." @@ -5314,11 +5314,12 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" -"Aucun maillage à transférer. Assurez-vous qu'ils contiennent un canal UV2 et " -"que l'indicateur « Bake Light » est activé." +"Aucun maillage à précalculer. Assurez-vous qu'ils contiennent un canal UV2 " +"et que les propriétés « Use In Bake Light » et « Generate Lightmap » soient " +"activées." #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "Failed creating lightmap images, make sure path is writable." diff --git a/editor/translations/ga.po b/editor/translations/ga.po index 8168c1a440..9db93e38f8 100644 --- a/editor/translations/ga.po +++ b/editor/translations/ga.po @@ -4995,8 +4995,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/gl.po b/editor/translations/gl.po index 016a3ab589..68e7b47599 100644 --- a/editor/translations/gl.po +++ b/editor/translations/gl.po @@ -5162,8 +5162,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/he.po b/editor/translations/he.po index 5dc30a6cc2..a989a8aad0 100644 --- a/editor/translations/he.po +++ b/editor/translations/he.po @@ -5214,9 +5214,10 @@ msgstr "" "ממאפייני BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "אין רשתות לאפייה. ודא/י שהם מכילים ערוץ UV2 והדגל 'Bake Light' מאופשר." #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hi.po b/editor/translations/hi.po index db1dcd67e6..70187feed0 100644 --- a/editor/translations/hi.po +++ b/editor/translations/hi.po @@ -5137,8 +5137,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hr.po b/editor/translations/hr.po index d737bb04b7..c62d3f3eb5 100644 --- a/editor/translations/hr.po +++ b/editor/translations/hr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" -"PO-Revision-Date: 2021-04-11 22:02+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: LeoClose <leoclose575@gmail.com>\n" "Language-Team: Croatian <https://hosted.weblate.org/projects/godot-engine/" "godot/hr/>\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8-bit\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.6-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -41,7 +41,7 @@ msgstr "Neispravan unos %i (nije uspio) u izrazu" #: core/math/expression.cpp msgid "self can't be used because instance is null (not passed)" -msgstr "self nije moguće koristiti jer je jedinka null (nije uspio)" +msgstr "self se ne može koristiti jer instanca je null (nije prosljeđena)" #: core/math/expression.cpp msgid "Invalid operands to operator %s, %s and %s." @@ -1716,7 +1716,7 @@ msgstr "Novo" #: editor/editor_feature_profile.cpp editor/editor_node.cpp #: editor/project_manager.cpp msgid "Import" -msgstr "Uvoz" +msgstr "Uvezi" #: editor/editor_feature_profile.cpp editor/project_export.cpp msgid "Export" @@ -2861,7 +2861,7 @@ msgstr "Zajednica" #: editor/editor_node.cpp msgid "About" -msgstr "" +msgstr "U vezi s" #: editor/editor_node.cpp msgid "Support Godot Development" @@ -5009,8 +5009,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/hu.po b/editor/translations/hu.po index 85933dc05d..7a2e35e37b 100644 --- a/editor/translations/hu.po +++ b/editor/translations/hu.po @@ -5180,9 +5180,10 @@ msgstr "" "tulajdonságaiból." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nincs mesh, amibe adatokat süthetne. Bizonyosodjon meg arról, hogy " "tartalmaznak egy UV2 csatornát, és hogy a 'Fény Besütése' opció be van " diff --git a/editor/translations/id.po b/editor/translations/id.po index e1029fc231..4dce64fd92 100644 --- a/editor/translations/id.po +++ b/editor/translations/id.po @@ -5210,9 +5210,10 @@ msgstr "" "Simpan skena Anda dan coba lagi." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Tidak ada mesh-mesh untuk di bake. Pastikan mereka punya kanal UV2 dan 'Bake " "Cahaya' menyala." diff --git a/editor/translations/is.po b/editor/translations/is.po index fc1423d841..c7d7023690 100644 --- a/editor/translations/is.po +++ b/editor/translations/is.po @@ -5051,8 +5051,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/it.po b/editor/translations/it.po index 60c362c63a..f1de95dac6 100644 --- a/editor/translations/it.po +++ b/editor/translations/it.po @@ -59,12 +59,13 @@ # Alessandro Mandelli <mandelli.alessandro@ngi.it>, 2021. # Jusef Azzolina <rosarioazzolina33@gmail.com>, 2021. # Daniele Basso <tiziodcaio@gmail.com>, 2021. +# Riteo Siuga <riteo@posteo.net>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-15 19:34+0000\n" -"Last-Translator: Riteo Siuga <lorenzocerqua@tutanota.com>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Riteo Siuga <riteo@posteo.net>\n" "Language-Team: Italian <https://hosted.weblate.org/projects/godot-engine/" "godot/it/>\n" "Language: it\n" @@ -72,7 +73,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -876,6 +877,7 @@ msgid "Deferred" msgstr "Differita" #: editor/connections_dialog.cpp +#, fuzzy msgid "" "Defers the signal, storing it in a queue and only firing it at idle time." msgstr "" @@ -1172,7 +1174,7 @@ msgstr "Grazie dalla comunità di Godot!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Clicca per copiare." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -2348,7 +2350,7 @@ msgid "" msgstr "" "Questa scena non può essere salvata perché contiene un'istanziazione " "ciclica.\n" -"Riprovare ad eseguire il salvataggio dopo aver risolto il problema." +"Riprovare a eseguire il salvataggio dopo aver risolto il problema." #: editor/editor_node.cpp msgid "" @@ -2962,7 +2964,7 @@ msgstr "" #: editor/editor_node.cpp msgid "Synchronize Scene Changes" -msgstr "Sincronizza i cambi della scena" +msgstr "Sincronizza i cambiamenti delle scene" #: editor/editor_node.cpp msgid "" @@ -2978,9 +2980,10 @@ msgstr "" #: editor/editor_node.cpp msgid "Synchronize Script Changes" -msgstr "Sincronizza Modifiche Script" +msgstr "Sincronizza le modifiche degli script" #: editor/editor_node.cpp +#, fuzzy msgid "" "When this option is enabled, any script that is saved will be reloaded in " "the running project.\n" @@ -2989,7 +2992,7 @@ msgid "" msgstr "" "Quando questa opzione è abilitata, qualsiasi script salvato verrà ricaricato " "nel progetto in esecuzione.\n" -"Quando usato in remoto su un dispositivo, essa risulta più efficate " +"Quando usato in remoto su un dispositivo, essa risulta più efficace " "abilitando l'opzione \"network filesystem\"." #: editor/editor_node.cpp editor/script_create_dialog.cpp @@ -3062,6 +3065,7 @@ msgid "Report a Bug" msgstr "Segnala un problema" #: editor/editor_node.cpp +#, fuzzy msgid "Send Docs Feedback" msgstr "Valuta la documentazione" @@ -3078,6 +3082,7 @@ msgid "Support Godot Development" msgstr "Supporta lo sviluppo di Godot" #: editor/editor_node.cpp +#, fuzzy msgid "Play the project." msgstr "Esegui il progetto." @@ -3091,7 +3096,7 @@ msgstr "Metti in pausa l'esecuzione della scena per eseguire il debug." #: editor/editor_node.cpp msgid "Pause Scene" -msgstr "Pausa scena" +msgstr "Pausa la scena" #: editor/editor_node.cpp msgid "Stop the scene." @@ -3115,7 +3120,7 @@ msgstr "Avvia una scena personalizzata" #: editor/editor_node.cpp msgid "Changing the video driver requires restarting the editor." -msgstr "Il cambiamento dei driver video necessita il riavvio dell'editor." +msgstr "Il cambiamento dei driver video necessita di un riavvio dell'editor." #: editor/editor_node.cpp editor/project_settings_editor.cpp #: editor/settings_config_dialog.cpp @@ -3131,6 +3136,7 @@ msgid "Update Continuously" msgstr "Aggiorna continuamente" #: editor/editor_node.cpp +#, fuzzy msgid "Update When Changed" msgstr "Aggiorna quando modificata" @@ -3209,16 +3215,17 @@ msgid "Template Package" msgstr "Pacchetto di modelli" #: editor/editor_node.cpp +#, fuzzy msgid "Export Library" msgstr "Esporta Libreria" #: editor/editor_node.cpp msgid "Merge With Existing" -msgstr "Unisci Con Esistente" +msgstr "Unisci con una esistente" #: editor/editor_node.cpp msgid "Open & Run a Script" -msgstr "Apri ed Esegui uno Script" +msgstr "Apri ed esegui uno script" #: editor/editor_node.cpp msgid "" @@ -3244,7 +3251,7 @@ msgstr "Nuova ereditata" #: editor/editor_node.cpp msgid "Load Errors" -msgstr "Carica errori" +msgstr "Errori di caricamento" #: editor/editor_node.cpp editor/plugins/tile_map_editor_plugin.cpp msgid "Select" @@ -3252,27 +3259,28 @@ msgstr "Seleziona" #: editor/editor_node.cpp msgid "Open 2D Editor" -msgstr "Apri Editor 2D" +msgstr "Apri l'editor 2D" #: editor/editor_node.cpp msgid "Open 3D Editor" -msgstr "Apri Editor 3D" +msgstr "Apri l'editor 3D" #: editor/editor_node.cpp msgid "Open Script Editor" -msgstr "Apri Editor degli script" +msgstr "Apri l'editor degli script" #: editor/editor_node.cpp editor/project_manager.cpp +#, fuzzy msgid "Open Asset Library" -msgstr "Apri Libreria degli Asset" +msgstr "Apri la libreria degli Asset" #: editor/editor_node.cpp msgid "Open the next Editor" -msgstr "Apri l'Editor successivo" +msgstr "Apri l'editor successivo" #: editor/editor_node.cpp msgid "Open the previous Editor" -msgstr "Apri l'Editor precedente" +msgstr "Apri l'editor precedente" #: editor/editor_node.h msgid "Warning!" @@ -3284,7 +3292,7 @@ msgstr "Nessuna sottorisorsa trovata." #: editor/editor_plugin.cpp msgid "Creating Mesh Previews" -msgstr "Creazione Anteprime Mesh" +msgstr "Creando le anteprime delle mesh" #: editor/editor_plugin.cpp msgid "Thumbnail..." @@ -3292,11 +3300,11 @@ msgstr "Miniatura..." #: editor/editor_plugin_settings.cpp msgid "Main Script:" -msgstr "Script Principale:" +msgstr "Script principale:" #: editor/editor_plugin_settings.cpp msgid "Edit Plugin" -msgstr "Modifica estensione" +msgstr "Modifica l'estensione" #: editor/editor_plugin_settings.cpp msgid "Installed Plugins:" @@ -3328,32 +3336,37 @@ msgid "Measure:" msgstr "Misura:" #: editor/editor_profiler.cpp +#, fuzzy msgid "Frame Time (sec)" -msgstr "Tempo Frame (sec)" +msgstr "Tempo fotogramma (sec)" #: editor/editor_profiler.cpp +#, fuzzy msgid "Average Time (sec)" -msgstr "Tempo Medio (sec)" +msgstr "Tempo medio (sec)" #: editor/editor_profiler.cpp +#, fuzzy msgid "Frame %" -msgstr "Frame %" +msgstr "% fotogramma" #: editor/editor_profiler.cpp +#, fuzzy msgid "Physics Frame %" -msgstr "Fotogramma della Fisica %" +msgstr "% fotogramma fisico" #: editor/editor_profiler.cpp msgid "Inclusive" msgstr "Inclusivo" #: editor/editor_profiler.cpp +#, fuzzy msgid "Self" msgstr "Se stesso" #: editor/editor_profiler.cpp msgid "Frame #:" -msgstr "Frame #:" +msgstr "Fotogramma #:" #: editor/editor_profiler.cpp msgid "Time" @@ -3365,7 +3378,7 @@ msgstr "Chiamate" #: editor/editor_properties.cpp msgid "Edit Text:" -msgstr "Modifica Testo:" +msgstr "Modifica il testo:" #: editor/editor_properties.cpp editor/script_create_dialog.cpp msgid "On" @@ -3389,55 +3402,57 @@ msgstr "Assegna..." #: editor/editor_properties.cpp msgid "Invalid RID" -msgstr "RID Invalido" +msgstr "RID non valido" #: editor/editor_properties.cpp msgid "" "The selected resource (%s) does not match any type expected for this " "property (%s)." msgstr "" -"La risorsa selezionata (%s) non corrisponde ad alcun tipo atteso per questa " -"proprietà (%s)." +"La risorsa selezionata (%s) non corrisponde ad alcun tipo previsto per " +"questa proprietà (%s)." #: editor/editor_properties.cpp msgid "" "Can't create a ViewportTexture on resources saved as a file.\n" "Resource needs to belong to a scene." msgstr "" -"Impossibile creare ViewportTexture da risorse salvate come file.\n" -"La risorsa deve appartenere ad una scena." +"Impossibile creare un ViewportTexture su delle risorse salvate come file.\n" +"Esse devono appartenere a una scena." #: editor/editor_properties.cpp +#, fuzzy msgid "" "Can't create a ViewportTexture on this resource because it's not set as " "local to scene.\n" "Please switch on the 'local to scene' property on it (and all resources " "containing it up to a node)." msgstr "" -"Impossibile creare ViewportTexture da questa risorsa perché non è definita " -"localmente in una scena.\n" -"Per favore attivare la proprietà \"local to scene\" sulla risorsa (e su " -"tutte le risorse che la contengono, fino al nodo che le utilizza)." +"Impossibile creare un VieportTexture su questa risorsa perché non è stata " +"impostata come locale alla scena.\n" +"Per favore attivare la properietà \"local to scene\" su di essa (e su tutte " +"quelle che la contengono fino ad arrivare a un nodo)." #: editor/editor_properties.cpp editor/property_editor.cpp msgid "Pick a Viewport" -msgstr "Scegli una Vista" +msgstr "Selezionare una vista" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "New Script" -msgstr "Nuovo Script" +msgstr "Nuovo script" #: editor/editor_properties.cpp editor/scene_tree_dock.cpp msgid "Extend Script" -msgstr "Estendi Script" +msgstr "Estendi script" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "New %s" msgstr "Nuovo %s" #: editor/editor_properties.cpp editor/property_editor.cpp +#, fuzzy msgid "Make Unique" -msgstr "Rendi Unico" +msgstr "Rendi unico" #: editor/editor_properties.cpp #: editor/plugins/animation_blend_space_1d_editor.cpp @@ -3455,11 +3470,12 @@ msgstr "Incolla" #: editor/editor_properties.cpp editor/property_editor.cpp msgid "Convert To %s" -msgstr "Converti In %s" +msgstr "Converti in %s" #: editor/editor_properties.cpp editor/property_editor.cpp +#, fuzzy msgid "Selected node is not a Viewport!" -msgstr "Il nodo selezionato non è una Viewport!" +msgstr "Il nodo selezionato non è un Viewport!" #: editor/editor_properties_array_dict.cpp msgid "Size: " @@ -3472,19 +3488,19 @@ msgstr "Pagina: " #: editor/editor_properties_array_dict.cpp #: editor/plugins/theme_editor_plugin.cpp msgid "Remove Item" -msgstr "Rimuovi Elemento" +msgstr "Rimuovi l'elemento" #: editor/editor_properties_array_dict.cpp msgid "New Key:" -msgstr "Nuova Chiave:" +msgstr "Nuova chiave:" #: editor/editor_properties_array_dict.cpp msgid "New Value:" -msgstr "Nuovo Valore:" +msgstr "Nuovo valore:" #: editor/editor_properties_array_dict.cpp msgid "Add Key/Value Pair" -msgstr "Aggiungi Coppia Chiave/Valore" +msgstr "Aggiungi una coppia chiave/valore" #: editor/editor_run_native.cpp msgid "" @@ -3492,13 +3508,15 @@ msgid "" "Please add a runnable preset in the Export menu or define an existing preset " "as runnable." msgstr "" -"Nessuna esportazione eseguibile trovata per questa piattaforma.\n" -"Per favore, aggiungi un preset eseguibile nel menù Export oppure definisci " -"un preset già esistente come \"eseguibile\"." +"Nessuna preimpostazione di esportazione eseguibile trovata per questa " +"piattaforma.\n" +"Per favore, aggiungerne una nel menù di esportazione o impostarne una già " +"esistente come eseguibile." #: editor/editor_run_script.cpp +#, fuzzy msgid "Write your logic in the _run() method." -msgstr "Scrivi la logica nel metodo _run()." +msgstr "Inserire la logica dello script nel metodo _run()." #: editor/editor_run_script.cpp msgid "There is an edited scene already." @@ -4499,7 +4517,7 @@ msgstr "Rimuovi Triangolo BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "BlendSpace2D does not belong to an AnimationTree node." -msgstr "BlendSpace2D non appartiene ad un nodo AnimationTree." +msgstr "BlendSpace2D non appartiene a un nodo AnimationTree." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "No triangles exist, so no blending can take place." @@ -5292,9 +5310,10 @@ msgstr "" "Salva la scena e riprova." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nessuna mesh da preprocessare. Assicurarsi che contengano un canale UV2 e " "che la spunta \"Bake Light\" sia abilitata." @@ -6658,7 +6677,7 @@ msgstr "Spostare il giunto" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "" "The skeleton property of the Polygon2D does not point to a Skeleton2D node" -msgstr "La proprietà scheletro del Polygon2D non punta ad un nodo Skeleton2D" +msgstr "La proprietà scheletro del Polygon2D non punta a un nodo Skeleton2D" #: editor/plugins/polygon_2d_editor_plugin.cpp msgid "Sync Bones" @@ -6914,7 +6933,7 @@ msgstr "Preloader Risorsa" #: editor/plugins/root_motion_editor_plugin.cpp msgid "AnimationTree has no path set to an AnimationPlayer" -msgstr "AnimationTree non ha nessun percorso impostato ad un AnimationPlayer" +msgstr "AnimationTree non ha nessun percorso impostato a un AnimationPlayer" #: editor/plugins/root_motion_editor_plugin.cpp msgid "Path to AnimationPlayer is invalid" @@ -6982,10 +7001,11 @@ msgid "Script is not in tool mode, will not be able to run." msgstr "Lo script non è in modalità tool, non sarà possibile eseguirlo." #: editor/plugins/script_editor_plugin.cpp +#, fuzzy msgid "" "To run this script, it must inherit EditorScript and be set to tool mode." msgstr "" -"Per eseguire questo script, esso deve ereditare EditorScript ed essere " +"Per eseguire questo script, esso deve ereditare da EditorScript ed essere " "impostato in modalità tool." #: editor/plugins/script_editor_plugin.cpp @@ -9322,8 +9342,9 @@ msgid "Finds the nearest even integer to the parameter." msgstr "Trova il numero intero pari più vicino al parametro." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "Clamps the value between 0.0 and 1.0." -msgstr "Blocca il valore tra 0.0 ed 1.0." +msgstr "Blocca il valore tra 0.0 e 1.0." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "Extracts the sign of the parameter." @@ -9342,6 +9363,7 @@ msgid "Returns the square root of the parameter." msgstr "Restituisce la radice quadrata del parametro." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n" "\n" @@ -9353,7 +9375,7 @@ msgstr "" "\n" "Restituisce 0.0 se \"x\" è più piccolo di \"edge0\", o 1.0 se \"x\" è più " "grande di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 " -"ed 1.0 usando i polinomi di Hermite." +"e 1.0 usando i polinomi di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "" @@ -9430,6 +9452,7 @@ msgid "Transform function." msgstr "Funzione di trasformazione." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Calculate the outer product of a pair of vectors.\n" "\n" @@ -9513,6 +9536,7 @@ msgid "Calculates the dot product of two vectors." msgstr "Calcola il prodotto scalare di due vettori." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Returns the vector that points in the same direction as a reference vector. " "The function has three vector parameters : N, the vector to orient, I, the " @@ -9562,6 +9586,7 @@ msgid "Returns the vector that points in the direction of refraction." msgstr "Restituisce un vettore che punta nella direzione della refrazione." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n" "\n" @@ -9571,11 +9596,12 @@ msgid "" msgstr "" "SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n" "\n" -"Restituisce 0.0 se \"x\" è minore di \"edge0\", ed 1.0 se \"x\" è più grande " -"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 ed 1.0 " +"Restituisce 0.0 se \"x\" è minore di \"edge0\", e 1.0 se \"x\" è più grande " +"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 e 1.0 " "usando i polinomiali di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n" "\n" @@ -9585,8 +9611,8 @@ msgid "" msgstr "" "SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n" "\n" -"Restituisce 0.0 se \"x\" è minore di \"edge0\", ed 1.0 se \"x\" è più grande " -"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 ed 1.0 " +"Restituisce 0.0 se \"x\" è minore di \"edge0\", e 1.0 se \"x\" è più grande " +"di \"edge1\". Altrimenti, il valore di ritorno è interpolato tra 0.0 e 1.0 " "usando i polinomiali di Hermite." #: editor/plugins/visual_shader_editor_plugin.cpp @@ -9638,13 +9664,14 @@ msgid "Vector uniform." msgstr "Uniforme vettore." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "Custom Godot Shader Language expression, with custom amount of input and " "output ports. This is a direct injection of code into the vertex/fragment/" "light function, do not use it to write the function declarations inside." msgstr "" "Una espressione del Custom Godot Shader Language, con quantità " -"personalizzabile di porte input ed output. Questa è una iniezione diretta di " +"personalizzabile di porte input e output. Questa è una iniezione diretta di " "codice nella funzione vertex/fragment/light. Non usarla per scrivere le " "dichiarazione della funzione all'interno." @@ -9654,7 +9681,7 @@ msgid "" "direction of camera (pass associated inputs to it)." msgstr "" "Restituisce il decadimento in base al prodotto scalare della normale della " -"superfice e direzione della telecamera (passa gli input associati ad essa)." +"superfice e direzione della telecamera (passa gli input associati a essa)." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "" @@ -9669,8 +9696,9 @@ msgstr "" "dichiarare varianti, uniformi e costanti." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "A reference to an existing uniform." -msgstr "Un riferimento ad una uniform esistente." +msgstr "Un riferimento a una uniform esistente." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "(Fragment/Light mode only) Scalar derivative function." @@ -9713,20 +9741,22 @@ msgstr "" "differenziazione locale." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "(Fragment/Light mode only) (Vector) Sum of absolute derivative in 'x' and " "'y'." msgstr "" "(Soltanto modalità Fragment/Light) (Vettore) Somma delle derivate assolute " -"in \"x\" ed \"y\"." +"in \"x\" e \"y\"." #: editor/plugins/visual_shader_editor_plugin.cpp +#, fuzzy msgid "" "(Fragment/Light mode only) (Scalar) Sum of absolute derivative in 'x' and " "'y'." msgstr "" "(Soltanto modalità Fragment/Light) (Scalare) Somma delle derivate assolute " -"in \"x\" ed \"y\"." +"in \"x\" e \"y\"." #: editor/plugins/visual_shader_editor_plugin.cpp msgid "VisualShader" @@ -9757,13 +9787,14 @@ msgstr "" "I template di esportazione sembrano essere mancanti o non validi." #: editor/project_export.cpp +#, fuzzy msgid "" "Failed to export the project for platform '%s'.\n" "This might be due to a configuration issue in the export preset or your " "export settings." msgstr "" "Impossibile esportare il progetto per la piattaforma \"%s\".\n" -"Questo potrebbe essere dovuto ad un problema di configurazione nel preset di " +"Questo potrebbe essere dovuto a un problema di configurazione nel preset di " "esportazione o nelle impostazioni di esportazione." #: editor/project_export.cpp @@ -12264,7 +12295,7 @@ msgstr "L'oggetto base non è un Nodo!" #: modules/visual_script/visual_script_func_nodes.cpp msgid "Path does not lead Node!" -msgstr "Il percorso non conduce ad un Nodo!" +msgstr "Il percorso non conduce a un Nodo!" #: modules/visual_script/visual_script_func_nodes.cpp msgid "Invalid index property name '%s' in node %s." @@ -12676,7 +12707,7 @@ msgid "" "CollisionObject2D derived node. Please only use it as a child of Area2D, " "StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape." msgstr "" -"CollisionPolygon2D serve a fornire una forma di collisione ad un nodo " +"CollisionPolygon2D serve a fornire una forma di collisione a un nodo " "derivato di CollisionObject2D. Si prega di utilizzarlo solamente come figlio " "di Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. in modo da " "dargli una forma." @@ -12698,13 +12729,14 @@ msgstr "" "costruzione \"Segmenti\"." #: scene/2d/collision_shape_2d.cpp +#, fuzzy msgid "" "CollisionShape2D only serves to provide a collision shape to a " "CollisionObject2D derived node. Please only use it as a child of Area2D, " "StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape." msgstr "" -"CollisionShape2D serve a fornire una forma di collisione ad un nodo derivato " -"di CollisionObject2D. Si prega di utilizzarlo solamente come figlio di " +"CollisionShape2D serve a fornire una forma di collisione a un nodo derivato " +"da CollisionObject2D. Si prega di utilizzarlo solamente come figlio di " "Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. in modo da dargli " "una forma." @@ -12840,9 +12872,9 @@ msgstr "" "Modifica invece la dimensione nelle forme di collisione figlie." #: scene/2d/remote_transform_2d.cpp +#, fuzzy msgid "Path property must point to a valid Node2D node to work." -msgstr "" -"La proprietà path deve puntare ad un nodo Node2D valido per funzionare." +msgstr "La proprietà path deve puntare a un nodo Node2D valido per funzionare." #: scene/2d/skeleton_2d.cpp msgid "This Bone2D chain should end at a Skeleton2D node." @@ -12888,11 +12920,12 @@ msgid "ARVRController must have an ARVROrigin node as its parent." msgstr "ARVRController deve avere un nodo ARVROrigin come genitore." #: scene/3d/arvr_nodes.cpp +#, fuzzy msgid "" "The controller ID must not be 0 or this controller won't be bound to an " "actual controller." msgstr "" -"L'id del controller non deve essere 0 o non verrà associato ad un controller " +"L'id del controller non deve essere 0 o non verrà associato a un controller " "attuale." #: scene/3d/arvr_nodes.cpp @@ -12900,11 +12933,12 @@ msgid "ARVRAnchor must have an ARVROrigin node as its parent." msgstr "ARVRAnchor deve avere un nodo ARVROrigin come genitore." #: scene/3d/arvr_nodes.cpp +#, fuzzy msgid "" "The anchor ID must not be 0 or this anchor won't be bound to an actual " "anchor." msgstr "" -"L'ID dell'ancora non deve essere 0 oppure non verrà associato ad un'ancora " +"L'ID dell'ancora non deve essere 0 oppure non verrà associato a un'ancora " "attuale." #: scene/3d/arvr_nodes.cpp @@ -12947,28 +12981,29 @@ msgstr "" "definire la sua forma." #: scene/3d/collision_polygon.cpp +#, fuzzy msgid "" "CollisionPolygon only serves to provide a collision shape to a " "CollisionObject derived node. Please only use it as a child of Area, " "StaticBody, RigidBody, KinematicBody, etc. to give them a shape." msgstr "" -"CollisionPolygon serve solamente a fornire una forma di collisione ad un " -"nodo derivato di CollisionObject. Si prega di usarlo solamente come figlio " -"di Area, StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una " -"forma." +"CollisionPolygon serve solamente a fornire una forma di collisione a un nodo " +"derivato da CollisionObject. Si prega di usarlo solamente come figlio di " +"Area, StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una forma." #: scene/3d/collision_polygon.cpp msgid "An empty CollisionPolygon has no effect on collision." msgstr "Un CollisionPolygon vuoto non ha effetti in collisione." #: scene/3d/collision_shape.cpp +#, fuzzy msgid "" "CollisionShape only serves to provide a collision shape to a CollisionObject " "derived node. Please only use it as a child of Area, StaticBody, RigidBody, " "KinematicBody, etc. to give them a shape." msgstr "" -"CollisionShape serve a fornire una forma di collisione ad un nodo derivato " -"di CollisionObject. Si prega di utilizzarlo solamente come figlio di Area, " +"CollisionShape serve a fornire una forma di collisione a un nodo derivato da " +"CollisionObject. Si prega di utilizzarlo solamente come figlio di Area, " "StaticBody, RigidBody, KinematicBody, etc. in modo da dargli una forma." #: scene/3d/collision_shape.cpp @@ -13288,13 +13323,14 @@ msgid "If \"Exp Edit\" is enabled, \"Min Value\" must be greater than 0." msgstr "Se \"Exp Edit\" è abilitato, \"Min Value\" deve essere maggiore di 0." #: scene/gui/scroll_container.cpp +#, fuzzy msgid "" "ScrollContainer is intended to work with a single child control.\n" "Use a container as child (VBox, HBox, etc.), or a Control and set the custom " "minimum size manually." msgstr "" "ScrollContainer è inteso per funzionare con un singolo figlio di controllo.\n" -"Usa un container come figlio (VBox, HBox, ect.), oppure un nodo Control ed " +"Usa un container come figlio (VBox, HBox, ect.), oppure un nodo Control e " "imposta la dimensione minima personalizzata manualmente." #: scene/gui/tree.cpp diff --git a/editor/translations/ja.po b/editor/translations/ja.po index 1fd770fe13..45977a890f 100644 --- a/editor/translations/ja.po +++ b/editor/translations/ja.po @@ -5214,9 +5214,10 @@ msgstr "" "シーンを保存してから再度行ってください。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "ベイクするメッシュがありません。メッシュに UV2チャンネルが含まれてお" "り、'Bake Light' フラグがオンになっていることを確認してください。" diff --git a/editor/translations/ka.po b/editor/translations/ka.po index 587624651a..7a108d6f95 100644 --- a/editor/translations/ka.po +++ b/editor/translations/ka.po @@ -5176,8 +5176,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/km.po b/editor/translations/km.po index fe396cf590..33e9b00daf 100644 --- a/editor/translations/km.po +++ b/editor/translations/km.po @@ -4986,8 +4986,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ko.po b/editor/translations/ko.po index ec9fed24ca..877f572f48 100644 --- a/editor/translations/ko.po +++ b/editor/translations/ko.po @@ -27,7 +27,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-20 13:35+0000\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" "Last-Translator: Myeongjin Lee <aranet100@gmail.com>\n" "Language-Team: Korean <https://hosted.weblate.org/projects/godot-engine/" "godot/ko/>\n" @@ -36,7 +36,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.7\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5182,9 +5182,10 @@ msgstr "" "당신의 씬을 저장하고 다시 시도하세요." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "라이트맵을 구울 메시가 없습니다. 메시가 UV2 채널을 갖고 있고 'Bake Light' 플" "래그가 켜져 있는지 확인해주세요." diff --git a/editor/translations/lt.po b/editor/translations/lt.po index 6df1f44cfb..f4043f1de2 100644 --- a/editor/translations/lt.po +++ b/editor/translations/lt.po @@ -5145,8 +5145,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/lv.po b/editor/translations/lv.po index 8c8a0011c7..a4c8d10715 100644 --- a/editor/translations/lv.po +++ b/editor/translations/lv.po @@ -5038,8 +5038,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mi.po b/editor/translations/mi.po index 36a93be0ee..5a847e6594 100644 --- a/editor/translations/mi.po +++ b/editor/translations/mi.po @@ -4978,8 +4978,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mk.po b/editor/translations/mk.po index 7e5aa06f3c..001542b888 100644 --- a/editor/translations/mk.po +++ b/editor/translations/mk.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ml.po b/editor/translations/ml.po index 3919011ade..f7bc8349bc 100644 --- a/editor/translations/ml.po +++ b/editor/translations/ml.po @@ -4993,8 +4993,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/mr.po b/editor/translations/mr.po index 4d81595cb1..66157f77d1 100644 --- a/editor/translations/mr.po +++ b/editor/translations/mr.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ms.po b/editor/translations/ms.po index 6226d644a3..d8714d6196 100644 --- a/editor/translations/ms.po +++ b/editor/translations/ms.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-05-29 13:49+0000\n" +"PO-Revision-Date: 2021-07-23 12:59+0000\n" "Last-Translator: Keviindran Ramachandran <keviinx@yahoo.com>\n" "Language-Team: Malay <https://hosted.weblate.org/projects/godot-engine/godot/" "ms/>\n" @@ -23,7 +23,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -459,7 +459,7 @@ msgstr "Kunci Gerak Anim" #: editor/animation_track_editor.cpp #: modules/visual_script/visual_script_editor.cpp msgid "Clipboard is empty!" -msgstr "" +msgstr "Papan klip kosong!" #: editor/animation_track_editor.cpp msgid "Paste Tracks" @@ -1122,7 +1122,7 @@ msgstr "Terima kasih dari komuniti Godot!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klik untuk salin." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -1624,16 +1624,15 @@ msgstr "" "GLES3. Aktifkan 'Import Etc 2' atau 'Import Pvrtc' dalam Tetapan Projek." #: editor/editor_export.cpp -#, fuzzy msgid "" "Target platform requires 'PVRTC' texture compression for the driver fallback " "to GLES2.\n" "Enable 'Import Pvrtc' in Project Settings, or disable 'Driver Fallback " "Enabled'." msgstr "" -"Platform sasaran memerlukan pemampatan tekstur 'ETC' untuk sandaran pemandu " +"Platform sasaran memerlukan pemampatan tekstur 'PVRTC' untuk sandaran driver " "ke GLES2.\n" -"Aktifkan 'Import Etc' dalam Tetapan Projek, atau nyahaktifkan 'Driver " +"Aktifkan 'Import Pvrtc' dalam Tetapan Projek, atau nyahaktifkan 'Driver " "Fallback Enabled'." #: editor/editor_export.cpp platform/android/export/export.cpp @@ -2335,9 +2334,8 @@ msgid "Layout name not found!" msgstr "Nama susun atur tidak dijumpai!" #: editor/editor_node.cpp -#, fuzzy msgid "Restored the Default layout to its base settings." -msgstr "Tata letak lalai telah dipulihkan ke tetapan asas." +msgstr "Susun atur lalai telah dipulihkan ke tetapan asas." #: editor/editor_node.cpp msgid "" @@ -4501,34 +4499,34 @@ msgstr "Tetapkan kedudukan pengadunan dalam ruang" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Select and move points, create points with RMB." -msgstr "" +msgstr "Pilih dan pindahkan titik-titik, cipta titik-titik dengan RMB." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp scene/gui/graph_edit.cpp msgid "Enable snap and show grid." -msgstr "" +msgstr "Aktifkan snap dan tunjukkan grid." #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Point" -msgstr "" +msgstr "Titik" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp #: editor/plugins/animation_blend_tree_editor_plugin.cpp msgid "Open Editor" -msgstr "" +msgstr "Buka Editor" #: editor/plugins/animation_blend_space_1d_editor.cpp #: editor/plugins/animation_blend_space_2d_editor.cpp #: editor/plugins/animation_blend_tree_editor_plugin.cpp #: editor/plugins/animation_state_machine_editor.cpp msgid "Open Animation Node" -msgstr "" +msgstr "Buka Nod Animasi" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Triangle already exists." -msgstr "" +msgstr "Segi tiga sudah wujud." #: editor/plugins/animation_blend_space_2d_editor.cpp #, fuzzy @@ -4537,39 +4535,40 @@ msgstr "Anim Tambah Trek" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Change BlendSpace2D Limits" -msgstr "" +msgstr "Tukar Had-had BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Change BlendSpace2D Labels" -msgstr "" +msgstr "Tukar Label-label BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Remove BlendSpace2D Point" -msgstr "" +msgstr "Keluarkan Titik BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Remove BlendSpace2D Triangle" -msgstr "" +msgstr "Keluarkan Segi tiga BlendSpace2D" #: editor/plugins/animation_blend_space_2d_editor.cpp +#, fuzzy msgid "BlendSpace2D does not belong to an AnimationTree node." -msgstr "" +msgstr "BlendSpace2D bukan milik nod AnimationTree." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "No triangles exist, so no blending can take place." -msgstr "" +msgstr "Tiada segi tiga-segi tiga wujud, jadi tiada pengadunan boleh berlaku." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Toggle Auto Triangles" -msgstr "" +msgstr "Togol Segi Tiga Auto" #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Create triangles by connecting points." -msgstr "" +msgstr "Cipta segi tiga dengan menhubungkan titik-titik." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Erase points and triangles." -msgstr "" +msgstr "Padamkan titik-titik dan segi tiga-segi tiga." #: editor/plugins/animation_blend_space_2d_editor.cpp msgid "Generate blend triangles automatically (instead of manually)" @@ -5334,8 +5333,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/nb.po b/editor/translations/nb.po index 042ee8d26f..c36274abba 100644 --- a/editor/translations/nb.po +++ b/editor/translations/nb.po @@ -5427,8 +5427,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/nl.po b/editor/translations/nl.po index 2410cd5ad0..296291e435 100644 --- a/editor/translations/nl.po +++ b/editor/translations/nl.po @@ -46,12 +46,13 @@ # T-rex08 <ipadtriceratops@gmail.com>, 2021. # Dwarffish <hoogvlietjohan@gmail.com>, 2021. # Arthur de Roos <arthur.de.roos@gmail.com>, 2021. +# Vancha March <tjipkevdh@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-06-05 08:32+0000\n" -"Last-Translator: Stijn Hinlopen <f.a.hinlopen@gmail.com>\n" +"PO-Revision-Date: 2021-07-26 14:18+0000\n" +"Last-Translator: Vancha March <tjipkevdh@gmail.com>\n" "Language-Team: Dutch <https://hosted.weblate.org/projects/godot-engine/godot/" "nl/>\n" "Language: nl\n" @@ -59,7 +60,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -1162,7 +1163,7 @@ msgstr "Bedankt van de Godot gemeenschap!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." -msgstr "" +msgstr "Klik om te kopiëren." #: editor/editor_about.cpp msgid "Godot Engine contributors" @@ -5243,9 +5244,10 @@ msgstr "" "Sla uw scène op en probeer opnieuw." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Geen meshes om te bakken. Zorg ervoor dat ze een UV2 kanaal bevatten en dat " "'Bake Light' vlag aan staat." diff --git a/editor/translations/or.po b/editor/translations/or.po index 87528cdac5..c1d191a4a5 100644 --- a/editor/translations/or.po +++ b/editor/translations/or.po @@ -4984,8 +4984,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/pl.po b/editor/translations/pl.po index 3c51593e02..d933e8f92b 100644 --- a/editor/translations/pl.po +++ b/editor/translations/pl.po @@ -52,8 +52,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-05 14:32+0000\n" -"Last-Translator: Rafal Brozio <rafal.brozio@gmail.com>\n" +"PO-Revision-Date: 2021-07-16 05:47+0000\n" +"Last-Translator: Tomek <kobewi4e@gmail.com>\n" "Language-Team: Polish <https://hosted.weblate.org/projects/godot-engine/" "godot/pl/>\n" "Language: pl\n" @@ -62,7 +62,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.8-dev\n" +"X-Generator: Weblate 4.7.2-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5229,9 +5229,10 @@ msgstr "" "Zapisz scenę i spróbuj ponownie." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Brak siatek do cieniowania. Upewnij się, że zawierają kanał UV2 i że flaga " "\"Bake Light\" jest ustawiona." @@ -5760,7 +5761,7 @@ msgstr "Powiększ do zaznaczenia" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Preview Canvas Scale" -msgstr "Skala płótna podglądu" +msgstr "Podejrzyj skalę płótna" #: editor/plugins/canvas_item_editor_plugin.cpp msgid "Translation mask for inserting keys." diff --git a/editor/translations/pr.po b/editor/translations/pr.po index 675c9cf506..9b586ad756 100644 --- a/editor/translations/pr.po +++ b/editor/translations/pr.po @@ -5153,8 +5153,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/pt.po b/editor/translations/pt.po index 17b1861821..6eb24001a5 100644 --- a/editor/translations/pt.po +++ b/editor/translations/pt.po @@ -5209,9 +5209,10 @@ msgstr "" "Guarde a sua cena e tente novamente." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Não há malhas para consolidar. Assegure-se que contêm um canal UV2 e que a " "referência 'Bake Light' flag está on." diff --git a/editor/translations/pt_BR.po b/editor/translations/pt_BR.po index e79dd0fa19..01f6220bbd 100644 --- a/editor/translations/pt_BR.po +++ b/editor/translations/pt_BR.po @@ -5320,9 +5320,10 @@ msgstr "" "Salve sua cena e tente novamente." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Não há malhas para preparar. Certifique-se de que elas possuem um canal UV2 " "e que a propriedade \"Preparar Luz\" está habilitada." diff --git a/editor/translations/ro.po b/editor/translations/ro.po index 7ac06fc1b1..3b5af5fe1a 100644 --- a/editor/translations/ro.po +++ b/editor/translations/ro.po @@ -5218,9 +5218,10 @@ msgstr "" "cale de salvare din proprietățile BakedLightmap." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Nicio structură pentru procesare. Asigură-te că acestea conțin un canal UV2 " "și că opțiunea 'Procesează Lumina' este pornită." diff --git a/editor/translations/ru.po b/editor/translations/ru.po index 4b56d21383..e02b70b16d 100644 --- a/editor/translations/ru.po +++ b/editor/translations/ru.po @@ -97,12 +97,13 @@ # Bualma Show <appleaidar6@gmail.com>, 2021. # enderlorde <madel.laboratories@gmail.com>, 2021. # Олег Довгер <oleg.a.dovger@gmail.com>, 2021. +# Anna Malinovskaia <tacitcoast@gmail.com>, 2021. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2021-07-13 06:13+0000\n" -"Last-Translator: Danil Alexeev <danil@alexeev.xyz>\n" +"PO-Revision-Date: 2021-07-19 09:34+0000\n" +"Last-Translator: Anna Malinovskaia <tacitcoast@gmail.com>\n" "Language-Team: Russian <https://hosted.weblate.org/projects/godot-engine/" "godot/ru/>\n" "Language: ru\n" @@ -5286,9 +5287,10 @@ msgstr "" "Сохраните сцену и попробуйте ещё раз." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Нет полисеток для запекания. Убедитесь, что они содержат канал UV2 и что " "флаг «Запекание света» включён." diff --git a/editor/translations/si.po b/editor/translations/si.po index a5586af274..36abdd4774 100644 --- a/editor/translations/si.po +++ b/editor/translations/si.po @@ -5024,8 +5024,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sk.po b/editor/translations/sk.po index d97e1321ef..cb56bb037e 100644 --- a/editor/translations/sk.po +++ b/editor/translations/sk.po @@ -5183,9 +5183,10 @@ msgstr "" "na uloženie so BakedLightmap vlastností." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Žiadne mesh-e na bake. Uistite sa že obsahujú UV2 channel a je na ňom 'Bake " "Light' vlajka." diff --git a/editor/translations/sl.po b/editor/translations/sl.po index 07bd33c389..42f0bfc2cb 100644 --- a/editor/translations/sl.po +++ b/editor/translations/sl.po @@ -5419,9 +5419,10 @@ msgstr "" "shranitev iz lastnosti Zapečene Svetlobne karte." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Brez modelov za peko. Poskrbi, da vsebujejo kanal UV2 in da je vključena " "oznaka 'Zapeči Svetlobo'." diff --git a/editor/translations/sq.po b/editor/translations/sq.po index 49a42b5553..f054de99bd 100644 --- a/editor/translations/sq.po +++ b/editor/translations/sq.po @@ -5273,8 +5273,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sr_Cyrl.po b/editor/translations/sr_Cyrl.po index 53fb04b3e4..5d4f6cab1b 100644 --- a/editor/translations/sr_Cyrl.po +++ b/editor/translations/sr_Cyrl.po @@ -5682,8 +5682,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp #, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Нема мрежа за печење. Провери да ли садрже UV2 канал и да је опција 'Изпеци " "Светла' укључена." diff --git a/editor/translations/sr_Latn.po b/editor/translations/sr_Latn.po index 0a90379b41..49f7cd7f3e 100644 --- a/editor/translations/sr_Latn.po +++ b/editor/translations/sr_Latn.po @@ -5048,8 +5048,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/sv.po b/editor/translations/sv.po index 0c5db25a9a..79c1c4a1b9 100644 --- a/editor/translations/sv.po +++ b/editor/translations/sv.po @@ -5277,8 +5277,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/ta.po b/editor/translations/ta.po index 0c9022b097..45eef9a8f6 100644 --- a/editor/translations/ta.po +++ b/editor/translations/ta.po @@ -5033,8 +5033,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/te.po b/editor/translations/te.po index 8274d5520f..47338f3f28 100644 --- a/editor/translations/te.po +++ b/editor/translations/te.po @@ -4987,8 +4987,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/th.po b/editor/translations/th.po index e9c2a80a49..fc38c35df9 100644 --- a/editor/translations/th.po +++ b/editor/translations/th.po @@ -5125,9 +5125,10 @@ msgstr "" "ลองบันทึกฉากของคุณแล้วลองอีกครั้ง" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "ไม่มีพื้นผิวให้สร้าง lightmap กรุณาตรวจสอบว่าพื้นผิวมี UV2 และได้เปิดใช้งาน 'Bake Light'" diff --git a/editor/translations/tr.po b/editor/translations/tr.po index 578d7b48d0..4f3eb3ff60 100644 --- a/editor/translations/tr.po +++ b/editor/translations/tr.po @@ -5250,9 +5250,10 @@ msgstr "" "Sahneyi kaydedip tekrar deneyin." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Pişirilecek örüntüler yok. Örüntülerin UV2 kanalı içerdiğinden ve 'Bake " "Light' bayrağınının açık olduğundan emin olun." diff --git a/editor/translations/tt.po b/editor/translations/tt.po index 3e63f2369d..d5d41b7879 100644 --- a/editor/translations/tt.po +++ b/editor/translations/tt.po @@ -4987,8 +4987,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/tzm.po b/editor/translations/tzm.po index 0b0ce7d01e..fdb092c6a4 100644 --- a/editor/translations/tzm.po +++ b/editor/translations/tzm.po @@ -4985,8 +4985,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/uk.po b/editor/translations/uk.po index 50508c5df3..66c69938f6 100644 --- a/editor/translations/uk.po +++ b/editor/translations/uk.po @@ -5222,9 +5222,10 @@ msgstr "" "Збережіть вашу сцену і повторіть спробу." #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "Немає полісеток для запікання. Переконайтеся, що вони містять канал UV2 і що " "прапор 'Запікання світла' включений." diff --git a/editor/translations/ur_PK.po b/editor/translations/ur_PK.po index 0a213a2bdf..5476915ea5 100644 --- a/editor/translations/ur_PK.po +++ b/editor/translations/ur_PK.po @@ -5091,8 +5091,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/vi.po b/editor/translations/vi.po index 0104d05502..4267f19def 100644 --- a/editor/translations/vi.po +++ b/editor/translations/vi.po @@ -5156,8 +5156,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/zh_CN.po b/editor/translations/zh_CN.po index 4393cb4e08..c5b0c34c74 100644 --- a/editor/translations/zh_CN.po +++ b/editor/translations/zh_CN.po @@ -83,7 +83,7 @@ msgid "" msgstr "" "Project-Id-Version: Chinese (Simplified) (Godot Engine)\n" "POT-Creation-Date: 2018-01-20 12:15+0200\n" -"PO-Revision-Date: 2021-07-13 06:13+0000\n" +"PO-Revision-Date: 2021-07-23 12:59+0000\n" "Last-Translator: Haoyu Qiu <timothyqiu32@gmail.com>\n" "Language-Team: Chinese (Simplified) <https://hosted.weblate.org/projects/" "godot-engine/godot/zh_Hans/>\n" @@ -1172,7 +1172,7 @@ msgstr "改变字典值" #: editor/editor_about.cpp msgid "Thanks from the Godot community!" -msgstr "Godot 社区感谢你!" +msgstr "Godot 社区感谢大家!" #: editor/editor_about.cpp editor/editor_node.cpp editor/project_manager.cpp msgid "Click to copy." @@ -5171,9 +5171,10 @@ msgstr "" "BakedLightmap 属性。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "没有可烘焙的网格。请确保网格包含 UV2 通道并且勾选 “Bake Light” 选项。" #: editor/plugins/baked_lightmap_editor_plugin.cpp @@ -7338,7 +7339,7 @@ msgstr "顶视图。" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom View." -msgstr "仰视图。" +msgstr "底视图。" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom" @@ -7547,11 +7548,11 @@ msgstr "使用吸附" #: editor/plugins/spatial_editor_plugin.cpp msgid "Bottom View" -msgstr "仰视图" +msgstr "底视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Top View" -msgstr "俯视图" +msgstr "顶视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Rear View" @@ -7559,7 +7560,7 @@ msgstr "后视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Front View" -msgstr "正视图" +msgstr "前视图" #: editor/plugins/spatial_editor_plugin.cpp msgid "Left View" @@ -8240,7 +8241,7 @@ msgstr "新建自动图块" #: editor/plugins/tile_set_editor_plugin.cpp msgid "New Atlas" -msgstr "新建合集" +msgstr "新建图集" #: editor/plugins/tile_set_editor_plugin.cpp msgid "Next Coordinate" diff --git a/editor/translations/zh_HK.po b/editor/translations/zh_HK.po index 28a69ee289..69a8998437 100644 --- a/editor/translations/zh_HK.po +++ b/editor/translations/zh_HK.po @@ -5380,8 +5380,8 @@ msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" #: editor/plugins/baked_lightmap_editor_plugin.cpp diff --git a/editor/translations/zh_TW.po b/editor/translations/zh_TW.po index f65d628d63..2d04a07157 100644 --- a/editor/translations/zh_TW.po +++ b/editor/translations/zh_TW.po @@ -5118,9 +5118,10 @@ msgstr "" "請保存場景並重試。" #: editor/plugins/baked_lightmap_editor_plugin.cpp +#, fuzzy msgid "" -"No meshes to bake. Make sure they contain an UV2 channel and that the 'Bake " -"Light' flag is on." +"No meshes to bake. Make sure they contain an UV2 channel and that the 'Use " +"In Baked Light' and 'Generate Lightmap' flags are on." msgstr "" "無可烘焙之網格。請確保這些網格包含 UV2 通道並已開啟「Bake Light」旗標。" |