diff options
Diffstat (limited to 'editor/plugins')
90 files changed, 3394 insertions, 2708 deletions
diff --git a/editor/plugins/SCsub b/editor/plugins/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/plugins/SCsub +++ b/editor/plugins/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 8d5444db73..c26daa3857 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -204,9 +204,9 @@ void AbstractPolygon2DEditor::_notification(int p_what) { disable_polygon_editing(false, String()); - button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); - button_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); - button_delete->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons")); + 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_edit->set_pressed(true); get_tree()->connect("node_removed", callable_mp(this, &AbstractPolygon2DEditor::_node_removed)); @@ -218,7 +218,7 @@ void AbstractPolygon2DEditor::_notification(int p_what) { void AbstractPolygon2DEditor::_node_removed(Node *p_node) { if (p_node == _get_node()) { - edit(NULL); + edit(nullptr); hide(); canvas_item_editor->update_viewport(); @@ -310,7 +310,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { create_resource->set_text(String("No polygon resource on this node.\nCreate and assign one?")); - create_resource->popup_centered_minsize(); + create_resource->popup_centered(); } return (mb.is_valid() && mb->get_button_index() == 1); } @@ -573,7 +573,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_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); const Vertex active_point = get_active_point(); const int n_polygons = _get_polygon_count(); @@ -651,7 +651,7 @@ 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_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); String num = String::num(vertex.vertex); Size2 num_size = font->get_string_size(num); p_overlay->draw_string(font, point - num_size * 0.5, num, Color(1.0, 1.0, 1.0, 0.5)); @@ -661,7 +661,7 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl if (edge_point.valid()) { - Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } @@ -690,7 +690,7 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { canvas_item_editor->update_viewport(); } else { - _set_node(NULL); + _set_node(nullptr); } } @@ -801,7 +801,7 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive) { - canvas_item_editor = NULL; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -854,7 +854,7 @@ void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) { } else { polygon_editor->hide(); - polygon_editor->edit(NULL); + polygon_editor->edit(nullptr); } } diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 7916ac71ea..eb50df2166 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -73,7 +73,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven ap->get_animation_list(&names); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - animations_menu->add_icon_item(get_icon("Animation", "EditorIcons"), E->get()); + animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); animations_to_add.push_back(E->get()); } } @@ -97,7 +97,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven menu->add_separator(); menu->add_item(TTR("Load..."), MENU_LOAD_FILE); - menu->set_global_position(blend_space_draw->get_global_transform().xform(mb->get_position())); + menu->set_position(blend_space_draw->get_screen_transform().xform(mb->get_position())); menu->popup(); add_point_pos = (mb->get_position() / blend_space_draw->get_size()).x; @@ -197,18 +197,18 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { - Color linecolor = get_color("font_color", "Label"); + Color linecolor = get_theme_color("font_color", "Label"); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_font("font", "Label"); - Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font("font", "Label"); + Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); blend_space_draw->draw_rect(Rect2(Point2(), s), color, false); } @@ -280,7 +280,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_color("accent_color", "Editor"); + color = get_theme_color("accent_color", "Editor"); } else { color = linecolor; color.a *= 0.5; @@ -532,15 +532,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_style_override("panel", get_stylebox("bg", "Tree")); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); - panel->add_style_override("panel", get_stylebox("bg", "Tree")); - tool_blend->set_icon(get_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_icon("EditKey", "EditorIcons")); - tool_erase->set_icon(get_icon("Remove", "EditorIcons")); - snap->set_icon(get_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_icon("Edit", "EditorIcons")); + 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")); } if (p_what == NOTIFICATION_PROCESS) { @@ -589,7 +589,7 @@ void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) { } } -AnimationNodeBlendSpace1DEditor *AnimationNodeBlendSpace1DEditor::singleton = NULL; +AnimationNodeBlendSpace1DEditor *AnimationNodeBlendSpace1DEditor::singleton = nullptr; AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() { singleton = this; @@ -735,7 +735,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() { open_file = memnew(EditorFileDialog); add_child(open_file); open_file->set_title(TTR("Open Animation Node")); - open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_file_opened)); undo_redo = EditorNode::get_undo_redo(); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 663f2dde05..4343535eb6 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -30,9 +30,9 @@ #include "animation_blend_space_2d_editor.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/math/delaunay.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_scale.h" @@ -40,7 +40,7 @@ #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) { @@ -100,7 +100,7 @@ void AnimationNodeBlendSpace2DEditor::_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_icon("Animation", "EditorIcons"), E->get()); + animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); animations_to_add.push_back(E->get()); } } @@ -124,7 +124,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven menu->add_separator(); menu->add_item(TTR("Load..."), MENU_LOAD_FILE); - menu->set_global_position(blend_space_draw->get_global_transform().xform(mb->get_position())); + menu->set_position(blend_space_draw->get_screen_transform().xform(mb->get_position())); menu->popup(); add_point_pos = (mb->get_position() / blend_space_draw->get_size()); add_point_pos.y = 1.0 - add_point_pos.y; @@ -406,17 +406,17 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { - Color linecolor = get_color("font_color", "Label"); + Color linecolor = get_theme_color("font_color", "Label"); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; - Ref<Font> font = get_font("font", "Label"); - Ref<Texture2D> icon = get_icon("KeyValue", "EditorIcons"); - Ref<Texture2D> icon_selected = get_icon("KeySelected", "EditorIcons"); + Ref<Font> font = get_theme_font("font", "Label"); + Ref<Texture2D> icon = get_theme_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> icon_selected = get_theme_icon("KeySelected", "EditorIcons"); Size2 s = blend_space_draw->get_size(); if (blend_space_draw->has_focus()) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "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); @@ -502,7 +502,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { Color color; if (i == selected_triangle) { - color = get_color("accent_color", "Editor"); + color = get_theme_color("accent_color", "Editor"); color.a *= 0.5; } else { color = linecolor; @@ -563,7 +563,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { { Color color; if (tool_blend->is_pressed()) { - color = get_color("accent_color", "Editor"); + color = get_theme_color("accent_color", "Editor"); } else { color = linecolor; color.a *= 0.5; @@ -754,21 +754,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_style_override("panel", get_stylebox("bg", "Tree")); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); - panel->add_style_override("panel", get_stylebox("bg", "Tree")); - tool_blend->set_icon(get_icon("EditPivot", "EditorIcons")); - tool_select->set_icon(get_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_icon("EditKey", "EditorIcons")); - tool_triangle->set_icon(get_icon("ToolTriangle", "EditorIcons")); - tool_erase->set_icon(get_icon("Remove", "EditorIcons")); - snap->set_icon(get_icon("SnapGrid", "EditorIcons")); - open_editor->set_icon(get_icon("Edit", "EditorIcons")); - auto_triangles->set_icon(get_icon("AutoTriangle", "EditorIcons")); + 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")); interpolation->clear(); - interpolation->add_icon_item(get_icon("TrackContinuous", "EditorIcons"), "", 0); - interpolation->add_icon_item(get_icon("TrackDiscrete", "EditorIcons"), "", 1); - interpolation->add_icon_item(get_icon("TrackCapture", "EditorIcons"), "", 2); + 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); } if (p_what == NOTIFICATION_PROCESS) { @@ -810,7 +810,7 @@ void AnimationNodeBlendSpace2DEditor::_open_editor() { } void AnimationNodeBlendSpace2DEditor::_removed_from_graph() { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() { @@ -833,7 +833,7 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() { ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpace2DEditor::_removed_from_graph); } -AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = NULL; +AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = nullptr; AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { @@ -1042,7 +1042,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { open_file = memnew(EditorFileDialog); add_child(open_file); open_file->set_title(TTR("Open Animation Node")); - open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_file_opened)); undo_redo = EditorNode::get_undo_redo(); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index e79909fae1..54c60aba71 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -30,8 +30,8 @@ #include "animation_blend_tree_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_inspector.h" @@ -40,7 +40,7 @@ #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" #include "scene/gui/progress_bar.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) { @@ -145,7 +145,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { name->set_text(E->get()); name->set_expand_to_text_length(true); node->add_child(name); - node->set_slot(0, false, 0, Color(), true, 0, get_color("font_color", "Label")); + node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label")); name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode)); name->connect("focus_exited", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed_focus_out), varray(name, agnode), CONNECT_DEFERRED); base = 1; @@ -157,7 +157,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { 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_color("font_color", "Label"), false, 0, Color()); + node->set_slot(base + i, true, 0, get_theme_color("font_color", "Label"), false, 0, Color()); } List<PropertyInfo> pinfo; @@ -185,7 +185,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { 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_icon("Edit", "EditorIcons")); + open_in_editor->set_icon(get_theme_icon("Edit", "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->set_h_size_flags(SIZE_SHRINK_CENTER); @@ -196,7 +196,7 @@ 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_icon("AnimationFilter", "EditorIcons")); + edit_filters->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); node->add_child(edit_filters); edit_filters->connect("pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_edit_filters), varray(E->get()), CONNECT_DEFERRED); edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER); @@ -207,7 +207,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() { MenuButton *mb = memnew(MenuButton); mb->set_text(anim->get_animation()); - mb->set_icon(get_icon("Animation", "EditorIcons")); + mb->set_icon(get_theme_icon("Animation", "EditorIcons")); Array options; node->add_child(memnew(HSeparator)); @@ -242,16 +242,16 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode"); + Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "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; c = mono_color; - node->add_color_override("title_color", c); + node->add_theme_color_override("title_color", c); c.a = 0.7; - node->add_color_override("close_color", c); - node->add_color_override("resizer_color", c); + node->add_theme_color_override("close_color", c); + node->add_theme_color_override("resizer_color", c); } } @@ -579,7 +579,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano for (Set<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); @@ -608,7 +608,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano } } - Node *node = NULL; + Node *node = nullptr; if (base->has_node(accum)) { node = base->get_node(accum); } @@ -619,7 +619,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano String concat = path.get_concatenated_subnames(); - Skeleton *skeleton = Object::cast_to<Skeleton>(node); + Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); if (skeleton && skeleton->find_bone(concat) != -1) { //path in skeleton const String &bone = concat; @@ -643,7 +643,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_icon("BoneAttachment", "EditorIcons")); + ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); } else { ti = parenthood[accum]; } @@ -654,7 +654,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_icon("BoneAttachment", "EditorIcons")); + ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); ti->set_metadata(0, path); } else { @@ -705,12 +705,12 @@ void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) { if (!_update_filters(anode)) return; - filter_dialog->popup_centered_minsize(Size2(500, 500) * EDSCALE); + filter_dialog->popup_centered(Size2(500, 500) * EDSCALE); } void AnimationNodeBlendTreeEditor::_removed_from_graph() { if (is_visible()) { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } } @@ -718,8 +718,8 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_style_override("panel", get_stylebox("bg", "Tree")); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); + 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")); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) _update_graph(); @@ -756,7 +756,7 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { } AnimationTree *graph_player = AnimationTreeEditor::get_singleton()->get_tree(); - AnimationPlayer *player = NULL; + AnimationPlayer *player = nullptr; if (graph_player->has_node(graph_player->get_animation_player())) { player = Object::cast_to<AnimationPlayer>(graph_player->get_node(graph_player->get_animation_player())); } @@ -802,7 +802,7 @@ void AnimationNodeBlendTreeEditor::_bind_methods() { ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters); } -AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = NULL; +AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr; void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) { @@ -931,7 +931,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { add_node->set_text(TTR("Add Node...")); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->get_popup()->connect("id_pressed", callable_mp(this, &AnimationNodeBlendTreeEditor::_add_node)); - add_node->connect("about_to_show", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu)); + add_node->connect("about_to_popup", callable_mp(this, &AnimationNodeBlendTreeEditor::_update_options_menu)); add_options.push_back(AddOption("Animation", "AnimationNodeAnimation")); add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot")); @@ -975,7 +975,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { open_file = memnew(EditorFileDialog); add_child(open_file); open_file->set_title(TTR("Open Animation Node")); - open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_file_opened)); undo_redo = EditorNode::get_undo_redo(); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index af12335a27..d96a3b0bab 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -30,28 +30,28 @@ #include "animation_player_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/animation_track_editor.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning. -#include "editor/plugins/spatial_editor_plugin.h" // For onion skinning. -#include "scene/main/viewport.h" -#include "servers/visual_server.h" +#include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning. +#include "scene/main/window.h" +#include "servers/rendering_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { if (player && player == p_node) { - player = NULL; + player = nullptr; set_process(false); track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); track_editor->show_select_node_warning(true); _update_player(); } @@ -105,33 +105,33 @@ void AnimationPlayerEditor::_notification(int p_what) { get_tree()->connect("node_removed", callable_mp(this, &AnimationPlayerEditor::_node_removed)); - add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel")); + add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); } break; case NOTIFICATION_THEME_CHANGED: { - autoplay->set_icon(get_icon("AutoPlay", "EditorIcons")); + autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); - play->set_icon(get_icon("PlayStart", "EditorIcons")); - play_from->set_icon(get_icon("Play", "EditorIcons")); - play_bw->set_icon(get_icon("PlayStartBackwards", "EditorIcons")); - play_bw_from->set_icon(get_icon("PlayBackwards", "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")); - autoplay_icon = get_icon("AutoPlay", "EditorIcons"); - stop->set_icon(get_icon("Stop", "EditorIcons")); + autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons"); + stop->set_icon(get_theme_icon("Stop", "EditorIcons")); - onion_toggle->set_icon(get_icon("Onion", "EditorIcons")); - onion_skinning->set_icon(get_icon("GuiTabMenu", "EditorIcons")); + onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons")); + onion_skinning->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); - pin->set_icon(get_icon("Pin", "EditorIcons")); + pin->set_icon(get_theme_icon("Pin", "EditorIcons")); - tool_anim->add_style_override("normal", get_stylebox("normal", "Button")); - track_editor->get_edit_menu()->add_style_override("normal", get_stylebox("normal", "Button")); + 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")); -#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_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(m_icon, "EditorIcons")) ITEM_ICON(TOOL_NEW_ANIM, "New"); ITEM_ICON(TOOL_LOAD_ANIM, "Load"); @@ -299,7 +299,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { } else { track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); } autoplay->set_pressed(current == player->get_autoplay()); @@ -349,7 +349,7 @@ void AnimationPlayerEditor::_animation_rename() { } void AnimationPlayerEditor::_animation_load() { ERR_FAIL_COND(!player); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file->clear_filters(); List<String> extensions; @@ -392,7 +392,7 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) { void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) { - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); List<String> extensions; ResourceSaver::get_recognized_extensions(p_resource, &extensions); @@ -407,7 +407,7 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) file->set_current_path(p_resource->get_path()); if (extensions.size()) { String ext = p_resource->get_path().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { + if (extensions.find(ext) == nullptr) { file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get())); } } @@ -434,7 +434,7 @@ void AnimationPlayerEditor::_animation_remove() { return; delete_dialog->set_text(TTR("Delete Animation?")); - delete_dialog->popup_centered_minsize(); + delete_dialog->popup_centered(); } void AnimationPlayerEditor::_animation_remove_confirmed() { @@ -488,7 +488,7 @@ double AnimationPlayerEditor::_get_editor_step() const { ERR_FAIL_COND_V(!anim.is_valid(), 0.0); // Use more precise snapping when holding Shift - return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step(); + return InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step(); } return 0.0; @@ -501,7 +501,7 @@ void AnimationPlayerEditor::_animation_name_edited() { String new_name = name->get_text(); if (new_name == "" || new_name.find(":") != -1 || new_name.find("/") != -1) { error_dialog->set_text(TTR("Invalid animation name!")); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); return; } @@ -512,7 +512,7 @@ void AnimationPlayerEditor::_animation_name_edited() { if (player->has_animation(new_name)) { error_dialog->set_text(TTR("Animation name already exists!")); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); return; } @@ -729,7 +729,7 @@ void AnimationPlayerEditor::_animation_edit() { } } else { track_editor->set_animation(Ref<Animation>()); - track_editor->set_root(NULL); + track_editor->set_root(nullptr); } } @@ -845,10 +845,10 @@ void AnimationPlayerEditor::_update_player() { frame->set_editable(animlist.size() != 0); animation->set_disabled(animlist.size() == 0); autoplay->set_disabled(animlist.size() == 0); - tool_anim->set_disabled(player == NULL); + tool_anim->set_disabled(player == nullptr); onion_toggle->set_disabled(animlist.size() == 0); onion_skinning->set_disabled(animlist.size() == 0); - pin->set_disabled(player == NULL); + pin->set_disabled(player == nullptr); if (!player) { AnimationPlayerEditor::singleton->get_track_editor()->update_keying(); @@ -947,8 +947,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o alpha += alpha_step; if (onion.captures_valid[cidx]) { - VS::get_singleton()->canvas_item_add_texture_rect_region( - ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); + RS::get_singleton()->canvas_item_add_texture_rect_region( + ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); } cidx++; @@ -961,8 +961,8 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o alpha -= alpha_step; if (onion.captures_valid[cidx]) { - VS::get_singleton()->canvas_item_add_texture_rect_region( - ci, dst_rect, VS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); + RS::get_singleton()->canvas_item_add_texture_rect_region( + ci, dst_rect, RS::get_singleton()->viewport_get_texture(onion.captures[cidx]), src_rect, Color(1, 1, 1, alpha)); } cidx++; @@ -1058,7 +1058,7 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) { if (player == p_pl && is_visible_in_tree()) { _update_player(); - if (blend_editor.dialog->is_visible_in_tree()) + if (blend_editor.dialog->is_visible()) _animation_blend(); // Update. } } @@ -1152,7 +1152,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { if (!animation->get_item_count()) { error_dialog->set_text(TTR("No animation to copy!")); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); return; } @@ -1165,7 +1165,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard(); if (!anim2.is_valid()) { error_dialog->set_text(TTR("No animation resource on clipboard!")); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); return; } @@ -1195,7 +1195,7 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { if (!animation->get_item_count()) { error_dialog->set_text(TTR("No animation to edit!")); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); return; } @@ -1318,17 +1318,17 @@ void AnimationPlayerEditor::_allocate_onion_layers() { bool is_present = onion.differences_only && i == captures - 1; // Each capture is a viewport with a canvas item attached that renders a full-size rect with the contents of the main viewport. - onion.captures.write[i] = VS::get_singleton()->viewport_create(); + onion.captures.write[i] = RS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height); - VS::get_singleton()->viewport_set_update_mode(onion.captures[i], VS::VIEWPORT_UPDATE_ALWAYS); - VS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present); - VS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas); + RS::get_singleton()->viewport_set_size(onion.captures[i], capture_size.width, capture_size.height); + RS::get_singleton()->viewport_set_update_mode(onion.captures[i], RS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_set_transparent_background(onion.captures[i], !is_present); + RS::get_singleton()->viewport_attach_canvas(onion.captures[i], onion.capture.canvas); } // Reset the capture canvas item to the current root viewport texture (defensive). - VS::get_singleton()->canvas_item_clear(onion.capture.canvas_item); - VS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid()); + RS::get_singleton()->canvas_item_clear(onion.capture.canvas_item); + RS::get_singleton()->canvas_item_add_texture_rect(onion.capture.canvas_item, Rect2(Point2(), capture_size), get_tree()->get_root()->get_texture()->get_rid()); onion.capture_size = capture_size; } @@ -1337,7 +1337,7 @@ void AnimationPlayerEditor::_free_onion_layers() { for (int i = 0; i < onion.captures.size(); i++) { if (onion.captures[i].is_valid()) { - VS::get_singleton()->free(onion.captures[i]); + RS::get_singleton()->free(onion.captures[i]); } } onion.captures.clear(); @@ -1385,9 +1385,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Hide superfluous elements that would make the overlay unnecessary cluttered. Dictionary canvas_edit_state; Dictionary spatial_edit_state; - if (SpatialEditor::get_singleton()->is_visible()) { + if (Node3DEditor::get_singleton()->is_visible()) { // 3D - spatial_edit_state = SpatialEditor::get_singleton()->get_state(); + spatial_edit_state = Node3DEditor::get_singleton()->get_state(); Dictionary new_state = spatial_edit_state.duplicate(); new_state["show_grid"] = false; new_state["show_origin"] = false; @@ -1404,7 +1404,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { } new_state["viewports"] = vp; // TODO: Save/restore only affected entries. - SpatialEditor::get_singleton()->set_state(new_state); + Node3DEditor::get_singleton()->set_state(new_state); } else { // CanvasItemEditor // 2D canvas_edit_state = CanvasItemEditor::get_singleton()->get_state(); @@ -1420,19 +1420,19 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Tweak the root viewport to ensure it's rendered before our target. RID root_vp = get_tree()->get_root()->get_viewport_rid(); - Rect2 root_vp_screen_rect = get_tree()->get_root()->get_attach_to_screen_rect(); - VS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2()); - VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_ALWAYS); + Rect2 root_vp_screen_rect = Rect2(Vector2(), get_tree()->get_root()->get_size()); + RS::get_singleton()->viewport_attach_to_screen(root_vp, Rect2()); + RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_ALWAYS); RID present_rid; if (onion.differences_only) { // Capture present scene as it is. - VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID()); + RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, RID()); present_rid = onion.captures[onion.captures.size() - 1]; - VS::get_singleton()->viewport_set_active(present_rid, true); - VS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid); - VS::get_singleton()->draw(false); - VS::get_singleton()->viewport_set_active(present_rid, false); + RS::get_singleton()->viewport_set_active(present_rid, true); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, present_rid); + RS::get_singleton()->draw(false); + RS::get_singleton()->viewport_set_active(present_rid, false); } // Backup current animation state. @@ -1441,10 +1441,10 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Render every past/future step with the capture shader. - VS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); + RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); onion.capture.material->set_shader_param("bkg_color", GLOBAL_GET("rendering/environment/default_clear_color")); onion.capture.material->set_shader_param("differences_only", onion.differences_only); - onion.capture.material->set_shader_param("present", onion.differences_only ? VS::get_singleton()->viewport_get_texture(present_rid) : RID()); + onion.capture.material->set_shader_param("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID()); int step_off_a = onion.past ? -onion.steps : 0; int step_off_b = onion.future ? onion.steps : 0; @@ -1465,22 +1465,22 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { onion.captures_valid.write[cidx] = valid; if (valid) { player->seek(pos, true); - get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials. + get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds. values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D). - VS::get_singleton()->viewport_set_active(onion.captures[cidx], true); - VS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]); - VS::get_singleton()->draw(false); - VS::get_singleton()->viewport_set_active(onion.captures[cidx], false); + RS::get_singleton()->viewport_set_active(onion.captures[cidx], true); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]); + RS::get_singleton()->draw(false); + RS::get_singleton()->viewport_set_active(onion.captures[cidx], false); } cidx++; } // Restore root viewport. - VS::get_singleton()->viewport_set_parent_viewport(root_vp, RID()); - VS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect); - VS::get_singleton()->viewport_set_update_mode(root_vp, VS::VIEWPORT_UPDATE_WHEN_VISIBLE); + RS::get_singleton()->viewport_set_parent_viewport(root_vp, RID()); + RS::get_singleton()->viewport_attach_to_screen(root_vp, root_vp_screen_rect); + RS::get_singleton()->viewport_set_update_mode(root_vp, RS::VIEWPORT_UPDATE_WHEN_VISIBLE); // Restore animation state // (Seeking with update=true wouldn't do the trick because the current value of the properties @@ -1489,9 +1489,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { player->restore_animated_values(values_backup); // Restore state of main editors. - if (SpatialEditor::get_singleton()->is_visible()) { + if (Node3DEditor::get_singleton()->is_visible()) { // 3D - SpatialEditor::get_singleton()->set_state(spatial_edit_state); + Node3DEditor::get_singleton()->set_state(spatial_edit_state); } else { // CanvasItemEditor // 2D CanvasItemEditor::get_singleton()->set_state(canvas_edit_state); @@ -1549,7 +1549,7 @@ void AnimationPlayerEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_stop_onion_skinning"), &AnimationPlayerEditor::_stop_onion_skinning); } -AnimationPlayerEditor *AnimationPlayerEditor::singleton = NULL; +AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr; AnimationPlayer *AnimationPlayerEditor::get_player() const { @@ -1565,7 +1565,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay set_focus_mode(FOCUS_ALL); - player = NULL; + player = nullptr; HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); @@ -1764,9 +1764,9 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay onion.last_frame = 0; onion.can_overlay = false; onion.capture_size = Size2(); - onion.capture.canvas = VS::get_singleton()->canvas_create(); - onion.capture.canvas_item = VS::get_singleton()->canvas_item_create(); - VS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas); + onion.capture.canvas = RS::get_singleton()->canvas_create(); + onion.capture.canvas_item = RS::get_singleton()->canvas_item_create(); + RS::get_singleton()->canvas_item_set_parent(onion.capture.canvas_item, onion.capture.canvas); onion.capture.material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); @@ -1792,14 +1792,14 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay COLOR = vec4(capture_samp.rgb * dir_color.rgb, bkg_mask * diff_mask); \ } \ "); - VS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); + RS::get_singleton()->material_set_shader(onion.capture.material->get_rid(), onion.capture.shader->get_rid()); } AnimationPlayerEditor::~AnimationPlayerEditor() { _free_onion_layers(); - VS::get_singleton()->free(onion.capture.canvas); - VS::get_singleton()->free(onion.capture.canvas_item); + RS::get_singleton()->free(onion.capture.canvas); + RS::get_singleton()->free(onion.capture.canvas_item); } void AnimationPlayerEditorPlugin::_notification(int p_what) { diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index cae959e1f4..c06f62a8c1 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -30,9 +30,9 @@ #include "animation_state_machine_editor.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/math/delaunay.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_scale.h" @@ -40,7 +40,7 @@ #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" bool AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) { @@ -97,7 +97,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv 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_icon("Animation", "EditorIcons"), E->get()); + animations_menu->add_icon_item(get_theme_icon("Animation", "EditorIcons"), E->get()); animations_to_add.push_back(E->get()); } } @@ -121,7 +121,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv menu->add_separator(); menu->add_item(TTR("Load..."), MENU_LOAD_FILE); - menu->set_global_position(state_machine_draw->get_global_transform().xform(mb->get_position())); + menu->set_position(state_machine_draw->get_screen_transform().xform(mb->get_position())); menu->popup(); add_node_pos = mb->get_position() / EDSCALE + state_machine->get_graph_offset(); } @@ -149,16 +149,16 @@ 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_stylebox("normal", "LineEdit"); + Ref<StyleBox> line_sb = get_theme_stylebox("normal", "LineEdit"); Rect2 edit_rect = node_rects[i].name; edit_rect.position -= line_sb->get_offset(); edit_rect.size += line_sb->get_minimum_size(); - name_edit->set_global_position(state_machine_draw->get_global_transform().xform(edit_rect.position)); - name_edit->set_size(edit_rect.size); + name_edit_popup->set_position(state_machine_draw->get_screen_transform().xform(edit_rect.position)); + name_edit_popup->set_size(edit_rect.size); name_edit->set_text(node_rects[i].node_name); - name_edit->show_modal(); + name_edit_popup->popup(); name_edit->grab_focus(); name_edit->select_all(); @@ -504,9 +504,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_color("font_color", "Label"); + Color linecolor = get_theme_color("font_color", "Label"); Color icon_color(1, 1, 1); - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); if (!p_enabled) { linecolor.a *= 0.2; @@ -515,12 +515,12 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } Ref<Texture2D> icons[6] = { - get_icon("TransitionImmediateBig", "EditorIcons"), - get_icon("TransitionSyncBig", "EditorIcons"), - get_icon("TransitionEndBig", "EditorIcons"), - get_icon("TransitionImmediateAutoBig", "EditorIcons"), - get_icon("TransitionSyncAutoBig", "EditorIcons"), - get_icon("TransitionEndAutoBig", "EditorIcons") + 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") }; if (p_selected) { @@ -573,18 +573,18 @@ 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_stylebox("state_machine_frame", "GraphNode"); - Ref<StyleBox> style_selected = get_stylebox("state_machine_selectedframe", "GraphNode"); + 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_font("title_font", "GraphNode"); - Color font_color = get_color("title_color", "GraphNode"); - Ref<Texture2D> play = get_icon("Play", "EditorIcons"); - Ref<Texture2D> auto_play = get_icon("AutoPlay", "EditorIcons"); - Ref<Texture2D> edit = get_icon("Edit", "EditorIcons"); - Color accent = get_color("accent_color", "Editor"); - Color linecolor = get_color("font_color", "Label"); + Ref<Font> font = get_theme_font("title_font", "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"); linecolor.a *= 0.3; - Ref<StyleBox> playing_overlay = get_stylebox("position", "GraphNode"); + Ref<StyleBox> playing_overlay = get_theme_stylebox("position", "GraphNode"); bool playing = false; StringName current; @@ -686,7 +686,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_icon("TransitionImmediateBig", "EditorIcons"); + Ref<Texture2D> tr_reference_icon = get_theme_icon("TransitionImmediateBig", "EditorIcons"); float tr_bidi_offset = int(tr_reference_icon->get_height() * 0.8); //draw transition lines @@ -879,7 +879,7 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { float pos = CLAMP(play_pos, 0, len); float c = pos / len; - Color fg = get_color("font_color", "Label"); + Color fg = get_theme_color("font_color", "Label"); Color bg = fg; bg.a *= 0.3; @@ -905,26 +905,26 @@ void AnimationNodeStateMachineEditor::_update_graph() { void AnimationNodeStateMachineEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_style_override("panel", get_stylebox("bg", "Tree")); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); - panel->add_style_override("panel", get_stylebox("bg", "Tree")); + 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_select->set_icon(get_icon("ToolSelect", "EditorIcons")); - tool_create->set_icon(get_icon("ToolAddNode", "EditorIcons")); - tool_connect->set_icon(get_icon("ToolConnect", "EditorIcons")); + 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")); transition_mode->clear(); - transition_mode->add_icon_item(get_icon("TransitionImmediate", "EditorIcons"), TTR("Immediate")); - transition_mode->add_icon_item(get_icon("TransitionSync", "EditorIcons"), TTR("Sync")); - transition_mode->add_icon_item(get_icon("TransitionEnd", "EditorIcons"), TTR("At End")); + 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")); - tool_erase->set_icon(get_icon("Remove", "EditorIcons")); - tool_autoplay->set_icon(get_icon("AutoPlay", "EditorIcons")); - tool_end->set_icon(get_icon("AutoEnd", "EditorIcons")); + 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")); play_mode->clear(); - play_mode->add_icon_item(get_icon("PlayTravel", "EditorIcons"), TTR("Travel")); - play_mode->add_icon_item(get_icon("Play", "EditorIcons"), TTR("Immediate")); + play_mode->add_icon_item(get_theme_icon("PlayTravel", "EditorIcons"), TTR("Travel")); + play_mode->add_icon_item(get_theme_icon("Play", "EditorIcons"), TTR("Immediate")); } if (p_what == NOTIFICATION_PROCESS) { @@ -1082,7 +1082,7 @@ void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) { void AnimationNodeStateMachineEditor::_removed_from_graph() { - EditorNode::get_singleton()->edit_item(NULL); + EditorNode::get_singleton()->edit_item(nullptr); } void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { @@ -1110,7 +1110,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_undo_method(this, "_update_graph"); undo_redo->commit_action(); - name_edit->hide(); + name_edit_popup->hide(); updating = false; state_machine_draw->update(); @@ -1241,7 +1241,7 @@ void AnimationNodeStateMachineEditor::_bind_methods() { ClassDB::bind_method("_open_editor", &AnimationNodeStateMachineEditor::_open_editor); } -AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = NULL; +AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = nullptr; AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { @@ -1357,17 +1357,18 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { animations_menu->set_name("animations"); animations_menu->connect("index_pressed", callable_mp(this, &AnimationNodeStateMachineEditor::_add_animation_type)); + name_edit_popup = memnew(Popup); + add_child(name_edit_popup); name_edit = memnew(LineEdit); - state_machine_draw->add_child(name_edit); - name_edit->hide(); + name_edit_popup->add_child(name_edit); + name_edit->set_anchors_and_margins_preset(PRESET_WIDE); name_edit->connect("text_entered", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited)); name_edit->connect("focus_exited", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited_focus_out)); - name_edit->set_as_toplevel(true); open_file = memnew(EditorFileDialog); add_child(open_file); open_file->set_title(TTR("Open Animation Node")); - open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); open_file->connect("file_selected", callable_mp(this, &AnimationNodeStateMachineEditor::_file_opened)); undo_redo = EditorNode::get_undo_redo(); diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 132e66b28d..5c4fc87df5 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -50,6 +50,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { ToolButton *tool_select; ToolButton *tool_create; ToolButton *tool_connect; + Popup *name_edit_popup; LineEdit *name_edit; HBoxContainer *tool_erase_hb; diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index c9706a7f68..e771c5610f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -34,9 +34,9 @@ #include "animation_blend_space_2d_editor.h" #include "animation_blend_tree_editor_plugin.h" #include "animation_state_machine_editor.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/math/delaunay.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/editor_scale.h" @@ -44,7 +44,7 @@ #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/scene_string_names.h" void AnimationTreeEditor::edit(AnimationTree *p_tree) { @@ -169,7 +169,7 @@ void AnimationTreeEditor::_notification(int p_what) { void AnimationTreeEditor::_bind_methods() { } -AnimationTreeEditor *AnimationTreeEditor::singleton = NULL; +AnimationTreeEditor *AnimationTreeEditor::singleton = nullptr; void AnimationTreeEditor::add_plugin(AnimationTreeNodeEditorPlugin *p_editor) { ERR_FAIL_COND(p_editor->get_parent()); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 80b7e6ffc8..14c44b7973 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -30,8 +30,8 @@ #include "asset_library_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/io/json.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_node.h" @@ -62,10 +62,10 @@ void EditorAssetLibraryItem::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_icon("ProjectIconLoading", "EditorIcons")); - category->add_color_override("font_color", Color(0.5, 0.5, 0.5)); - author->add_color_override("font_color", Color(0.5, 0.5, 0.5)); - price->add_color_override("font_color", Color(0.5, 0.5, 0.5)); + icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "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)); } } @@ -99,11 +99,11 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE); border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE); border->set_default_margin(MARGIN_TOP, 5 * EDSCALE); - add_style_override("panel", border); + add_theme_style_override("panel", border); HBoxContainer *hb = memnew(HBoxContainer); // Add some spacing to visually separate the icon from the asset details. - hb->add_constant_override("separation", 15 * EDSCALE); + hb->add_theme_constant_override("separation", 15 * EDSCALE); add_child(hb); icon = memnew(TextureButton); @@ -116,7 +116,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { VBoxContainer *vb = memnew(VBoxContainer); hb->add_child(vb); - vb->set_h_size_flags(SIZE_EXPAND_FILL); + vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); title = memnew(LinkButton); title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER); @@ -137,7 +137,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { vb->add_child(price); set_custom_minimum_size(Size2(250, 100) * EDSCALE); - set_h_size_flags(SIZE_EXPAND_FILL); + set_h_size_flags(Control::SIZE_EXPAND_FILL); } ////////////////////////////////////////////////////////////////////////////// @@ -156,7 +156,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 = get_icon("PlayOverlay", "EditorIcons")->get_data(); + Ref<Image> overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_data(); Ref<Image> thumbnail = p_image->get_data(); thumbnail = thumbnail->duplicate(); Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); @@ -172,7 +172,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const preview_images[i].button->set_icon(tex); // Make it clearer that clicking it will open an external link - preview_images[i].button->set_default_cursor_shape(CURSOR_POINTING_HAND); + preview_images[i].button->set_default_cursor_shape(Control::CURSOR_POINTING_HAND); } else { preview_images[i].button->set_icon(p_image); } @@ -198,7 +198,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_style_override("panel", get_stylebox("normal", "TextEdit")); + previews_bg->add_theme_style_override("panel", previews->get_theme_stylebox("normal", "TextEdit")); } break; } } @@ -219,7 +219,7 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) { if (!preview_images[i].is_video) { if (preview_images[i].image.is_valid()) { preview->set_texture(preview_images[i].image); - minimum_size_changed(); + child_controls_changed(); } } else { _link_click(preview_images[i].video_link); @@ -256,12 +256,12 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons preview.is_video = p_video; preview.button = memnew(Button); preview.button->set_flat(true); - preview.button->set_icon(get_icon("ThumbnailWait", "EditorIcons")); + preview.button->set_icon(previews->get_theme_icon("ThumbnailWait", "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 = get_icon("ThumbnailWait", "EditorIcons"); + preview.image = previews->get_theme_icon("ThumbnailWait", "EditorIcons"); } preview_images.push_back(preview); if (preview_images.size() == 1 && !p_video) { @@ -275,7 +275,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { add_child(hbox); VBoxContainer *desc_vbox = memnew(VBoxContainer); hbox->add_child(desc_vbox); - hbox->add_constant_override("separation", 15 * EDSCALE); + hbox->add_theme_constant_override("separation", 15 * EDSCALE); item = memnew(EditorAssetLibraryItem); @@ -284,14 +284,14 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { description = memnew(RichTextLabel); desc_vbox->add_child(description); - description->set_v_size_flags(SIZE_EXPAND_FILL); + description->set_v_size_flags(Control::SIZE_EXPAND_FILL); description->connect("meta_clicked", callable_mp(this, &EditorAssetLibraryItemDescription::_link_click)); - description->add_constant_override("line_separation", Math::round(5 * EDSCALE)); + description->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); VBoxContainer *previews_vbox = memnew(VBoxContainer); hbox->add_child(previews_vbox); - previews_vbox->add_constant_override("separation", 15 * EDSCALE); - previews_vbox->set_v_size_flags(SIZE_EXPAND_FILL); + previews_vbox->add_theme_constant_override("separation", 15 * EDSCALE); + previews_vbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); preview = memnew(TextureRect); previews_vbox->add_child(preview); @@ -308,7 +308,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { previews->set_enable_v_scroll(false); previews->set_enable_h_scroll(true); preview_hb = memnew(HBoxContainer); - preview_hb->set_v_size_flags(SIZE_EXPAND_FILL); + preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); previews->add_child(preview_hb); get_ok()->set_text(TTR("Download")); @@ -375,7 +375,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int if (error_text != String()) { download_error->set_text(TTR("Asset Download Error:") + "\n" + error_text); - download_error->popup_centered_minsize(); + download_error->popup_centered(); return; } @@ -393,7 +393,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_icon("FileBrokenBigThumb", "EditorIcons")); + icon->set_texture(get_theme_icon("FileBrokenBigThumb", "EditorIcons")); host = p_download_url; sha256 = p_sha256_hash; _make_request(); @@ -406,8 +406,8 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used. case NOTIFICATION_ENTER_TREE: { - add_style_override("panel", get_stylebox("panel", "TabContainer")); - dismiss->set_normal_texture(get_icon("Close", "EditorIcons")); + add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer")); + dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons")); } break; case NOTIFICATION_PROCESS: { @@ -507,13 +507,13 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { VBoxContainer *vb = memnew(VBoxContainer); hb->add_child(vb); - vb->set_h_size_flags(SIZE_EXPAND_FILL); + vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); HBoxContainer *title_hb = memnew(HBoxContainer); vb->add_child(title_hb); title = memnew(Label); title_hb->add_child(title); - title->set_h_size_flags(SIZE_EXPAND_FILL); + title->set_h_size_flags(Control::SIZE_EXPAND_FILL); dismiss = memnew(TextureButton); dismiss->connect("pressed", callable_mp(this, &EditorAssetLibraryItemDownload::_close)); @@ -525,7 +525,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { status = memnew(Label(TTR("Idle"))); vb->add_child(status); - status->add_color_override("font_color", Color(0.5, 0.5, 0.5)); + status->add_theme_color_override("font_color", Color(0.5, 0.5, 0.5)); progress = memnew(ProgressBar); vb->add_child(progress); @@ -571,8 +571,8 @@ void EditorAssetLibrary::_notification(int p_what) { case NOTIFICATION_READY: { - error_tr->set_texture(get_icon("Error", "EditorIcons")); - filter->set_right_icon(get_icon("Search", "EditorIcons")); + error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); + filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); error_label->raise(); @@ -602,10 +602,10 @@ void EditorAssetLibrary::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree")); - downloads_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); - error_tr->set_texture(get_icon("Error", "EditorIcons")); - filter->set_right_icon(get_icon("Search", "EditorIcons")); + 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")); filter->set_clear_button_enabled(true); } break; } @@ -635,7 +635,7 @@ void EditorAssetLibrary::_install_asset() { EditorAssetLibraryItemDownload *d = Object::cast_to<EditorAssetLibraryItemDownload>(downloads_hb->get_child(i)); if (d && d->get_asset_id() == description->get_asset_id()) { - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(TTR("Download for this asset is already in progress!")); return; } @@ -774,7 +774,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_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); } } } @@ -819,7 +819,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_icon("FileBrokenBigThumb", "EditorIcons")); + obj->call("set_image", image_queue[p_queue_id].image_type, image_queue[p_queue_id].image_index, get_theme_icon("FileBrokenBigThumb", "EditorIcons")); } } @@ -976,7 +976,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int to = p_page_count; hbc->add_spacer(); - hbc->add_constant_override("separation", 5 * EDSCALE); + hbc->add_theme_constant_override("separation", 5 * EDSCALE); Button *first = memnew(Button); first->set_text(TTR("First")); @@ -1191,8 +1191,8 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const asset_items = memnew(GridContainer); asset_items->set_columns(2); - asset_items->add_constant_override("hseparation", 10 * EDSCALE); - asset_items->add_constant_override("vseparation", 10 * EDSCALE); + asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE); + asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE); library_vb->add_child(asset_items); @@ -1260,7 +1260,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const description = memnew(EditorAssetLibraryItemDescription); add_child(description); - description->popup_centered_minsize(); + description->popup_centered(); description->connect("confirmed", callable_mp(this, &EditorAssetLibrary::_install_asset)); description->configure(r["title"], r["asset_id"], category_map[r["category_id"]], r["category_id"], r["author"], r["author_id"], r["cost"], r["version"], r["version_string"], r["description"], r["download_url"], r["browse_url"], r["download_hash"]); @@ -1305,7 +1305,7 @@ void EditorAssetLibrary::_asset_file_selected(const String &p_file) { if (asset_installer) { memdelete(asset_installer); - asset_installer = NULL; + asset_installer = nullptr; } asset_installer = memnew(EditorAssetInstaller); @@ -1353,11 +1353,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { HBoxContainer *search_hb = memnew(HBoxContainer); library_main->add_child(search_hb); - library_main->add_constant_override("separation", 10 * EDSCALE); + library_main->add_theme_constant_override("separation", 10 * EDSCALE); filter = memnew(LineEdit); search_hb->add_child(filter); - filter->set_h_size_flags(SIZE_EXPAND_FILL); + filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->connect("text_entered", callable_mp(this, &EditorAssetLibrary::_search_text_entered)); search = memnew(Button(TTR("Search"))); search->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), make_binds(0)); @@ -1392,7 +1392,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(sort); - sort->set_h_size_flags(SIZE_EXPAND_FILL); + sort->set_h_size_flags(Control::SIZE_EXPAND_FILL); sort->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search)); search_hb2->add_child(memnew(VSeparator)); @@ -1401,7 +1401,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { categories = memnew(OptionButton); categories->add_item(TTR("All")); search_hb2->add_child(categories); - categories->set_h_size_flags(SIZE_EXPAND_FILL); + categories->set_h_size_flags(Control::SIZE_EXPAND_FILL); categories->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_rerun_search)); search_hb2->add_child(memnew(VSeparator)); @@ -1417,7 +1417,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { repository->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_repository_changed)); search_hb2->add_child(repository); - repository->set_h_size_flags(SIZE_EXPAND_FILL); + repository->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_hb2->add_child(memnew(VSeparator)); @@ -1435,7 +1435,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_scroll_bg = memnew(PanelContainer); library_main->add_child(library_scroll_bg); - library_scroll_bg->set_v_size_flags(SIZE_EXPAND_FILL); + library_scroll_bg->set_v_size_flags(Control::SIZE_EXPAND_FILL); library_scroll = memnew(ScrollContainer); library_scroll->set_enable_v_scroll(true); @@ -1452,11 +1452,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { PanelContainer *library_vb_border = memnew(PanelContainer); library_scroll->add_child(library_vb_border); - library_vb_border->add_style_override("panel", border2); - library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL); + library_vb_border->add_theme_style_override("panel", border2); + library_vb_border->set_h_size_flags(Control::SIZE_EXPAND_FILL); library_vb = memnew(VBoxContainer); - library_vb->set_h_size_flags(SIZE_EXPAND_FILL); + library_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); library_vb_border->add_child(library_vb); @@ -1474,8 +1474,8 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { asset_items = memnew(GridContainer); asset_items->set_columns(2); - asset_items->add_constant_override("hseparation", 10 * EDSCALE); - asset_items->add_constant_override("vseparation", 10 * EDSCALE); + asset_items->add_theme_constant_override("hseparation", 10 * EDSCALE); + asset_items->add_theme_constant_override("vseparation", 10 * EDSCALE); library_vb->add_child(asset_items); @@ -1489,18 +1489,18 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { last_queue_id = 0; - library_vb->add_constant_override("separation", 20 * EDSCALE); + library_vb->add_theme_constant_override("separation", 20 * EDSCALE); error_hb = memnew(HBoxContainer); library_main->add_child(error_hb); error_label = memnew(Label); - error_label->add_color_override("color", get_color("error_color", "Editor")); + error_label->add_theme_color_override("color", get_theme_color("error_color", "Editor")); error_hb->add_child(error_label); error_tr = memnew(TextureRect); error_tr->set_v_size_flags(Control::SIZE_SHRINK_CENTER); error_hb->add_child(error_tr); - description = NULL; + description = nullptr; set_process(true); set_process_unhandled_input(true); @@ -1516,11 +1516,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { asset_open->set_access(EditorFileDialog::ACCESS_FILESYSTEM); asset_open->add_filter("*.zip ; " + TTR("Assets ZIP File")); - asset_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); + asset_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); add_child(asset_open); asset_open->connect("file_selected", callable_mp(this, &EditorAssetLibrary::_asset_file_selected)); - asset_installer = NULL; + asset_installer = nullptr; } /////// diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 7a1722c73b..0459ac7618 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_icon("MainPlay", "EditorIcons")); - _stop_button->set_icon(get_icon("Stop", "EditorIcons")); - _preview->set_frame_color(get_color("dark_color_2", "Editor")); - set_frame_color(get_color("dark_color_1", "Editor")); + _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); + _stop_button->set_icon(get_theme_icon("Stop", "EditorIcons")); + _preview->set_frame_color(get_theme_color("dark_color_2", "Editor")); + set_frame_color(get_theme_color("dark_color_1", "Editor")); _indicator->update(); _preview->update(); @@ -87,9 +87,9 @@ void AudioStreamEditor::_draw_preview() { } Vector<Color> color; - color.push_back(get_color("contrast_color_2", "Editor")); + color.push_back(get_theme_color("contrast_color_2", "Editor")); - VS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); } void AudioStreamEditor::_preview_changed(ObjectID p_which) { @@ -110,11 +110,11 @@ void AudioStreamEditor::_play() { if (_player->is_playing()) { _player->stop(); - _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); set_process(false); } else { _player->play(_current); - _play_button->set_icon(get_icon("Pause", "EditorIcons")); + _play_button->set_icon(get_theme_icon("Pause", "EditorIcons")); set_process(true); } } @@ -122,7 +122,7 @@ void AudioStreamEditor::_play() { void AudioStreamEditor::_stop() { _player->stop(); - _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); _current = 0; _indicator->update(); set_process(false); @@ -130,7 +130,7 @@ void AudioStreamEditor::_stop() { void AudioStreamEditor::_on_finished() { - _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); if (_current == _player->get_stream()->get_length()) { _current = 0; _indicator->update(); @@ -146,7 +146,7 @@ void AudioStreamEditor::_draw_indicator() { Rect2 rect = _preview->get_rect(); float len = stream->get_length(); float ofs_x = _current / len * rect.size.width; - _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), get_color("accent_color", "Editor"), 1); + _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), get_theme_color("accent_color", "Editor"), 1); _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /"); } @@ -225,7 +225,7 @@ AudioStreamEditor::AudioStreamEditor() { _preview->add_child(_indicator); HBoxContainer *hbox = memnew(HBoxContainer); - hbox->add_constant_override("separation", 0); + hbox->add_theme_constant_override("separation", 0); vbox->add_child(hbox); _play_button = memnew(ToolButton); @@ -241,12 +241,12 @@ 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_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + _current_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); _current_label->set_modulate(Color(1, 1, 1, 0.5)); hbox->add_child(_current_label); _duration_label = memnew(Label); - _duration_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + _duration_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); hbox->add_child(_duration_label); } diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp index 6bc9562c5a..ba161244d6 100644 --- a/editor/plugins/baked_lightmap_editor_plugin.cpp +++ b/editor/plugins/baked_lightmap_editor_plugin.cpp @@ -81,25 +81,25 @@ void BakedLightmapEditorPlugin::make_visible(bool p_visible) { } } -EditorProgress *BakedLightmapEditorPlugin::tmp_progress = NULL; +EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr; void BakedLightmapEditorPlugin::bake_func_begin(int p_steps) { - ERR_FAIL_COND(tmp_progress != NULL); + ERR_FAIL_COND(tmp_progress != nullptr); tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), p_steps, true)); } bool BakedLightmapEditorPlugin::bake_func_step(int p_step, const String &p_description) { - ERR_FAIL_COND_V(tmp_progress == NULL, false); + ERR_FAIL_COND_V(tmp_progress == nullptr, false); return tmp_progress->step(p_description, p_step, false); } void BakedLightmapEditorPlugin::bake_func_end() { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); memdelete(tmp_progress); - tmp_progress = NULL; + tmp_progress = nullptr; } void BakedLightmapEditorPlugin::_bind_methods() { @@ -116,7 +116,7 @@ BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) { bake->hide(); bake->connect("pressed", this, "_bake"); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake); - lightmap = NULL; + lightmap = nullptr; BakedLightmap::bake_begin_function = bake_func_begin; BakedLightmap::bake_step_function = bake_func_step; diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp index 8726c8c552..8bc1374269 100644 --- a/editor/plugins/camera_editor_plugin.cpp +++ b/editor/plugins/camera_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* camera_editor_plugin.cpp */ +/* camera_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,45 +28,45 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "camera_editor_plugin.h" +#include "camera_3d_editor_plugin.h" -#include "spatial_editor_plugin.h" +#include "node_3d_editor_plugin.h" -void CameraEditor::_node_removed(Node *p_node) { +void Camera3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; - SpatialEditor::get_singleton()->set_custom_camera(NULL); + node = nullptr; + Node3DEditor::get_singleton()->set_custom_camera(nullptr); hide(); } } -void CameraEditor::_pressed() { +void Camera3DEditor::_pressed() { - Node *sn = (node && preview->is_pressed()) ? node : NULL; - SpatialEditor::get_singleton()->set_custom_camera(sn); + Node *sn = (node && preview->is_pressed()) ? node : nullptr; + Node3DEditor::get_singleton()->set_custom_camera(sn); } -void CameraEditor::_bind_methods() { +void Camera3DEditor::_bind_methods() { } -void CameraEditor::edit(Node *p_camera) { +void Camera3DEditor::edit(Node *p_camera) { node = p_camera; if (!node) { preview->set_pressed(false); - SpatialEditor::get_singleton()->set_custom_camera(NULL); + Node3DEditor::get_singleton()->set_custom_camera(nullptr); } else { if (preview->is_pressed()) - SpatialEditor::get_singleton()->set_custom_camera(p_camera); + Node3DEditor::get_singleton()->set_custom_camera(p_camera); else - SpatialEditor::get_singleton()->set_custom_camera(NULL); + Node3DEditor::get_singleton()->set_custom_camera(nullptr); } } -CameraEditor::CameraEditor() { +Camera3DEditor::Camera3DEditor() { preview = memnew(Button); add_child(preview); @@ -79,30 +79,30 @@ CameraEditor::CameraEditor() { preview->set_margin(MARGIN_RIGHT, 0); preview->set_margin(MARGIN_TOP, 0); preview->set_margin(MARGIN_BOTTOM, 10); - preview->connect("pressed", callable_mp(this, &CameraEditor::_pressed)); + preview->connect("pressed", callable_mp(this, &Camera3DEditor::_pressed)); } -void CameraEditorPlugin::edit(Object *p_object) { +void Camera3DEditorPlugin::edit(Object *p_object) { - SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object)); + Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object)); //camera_editor->edit(Object::cast_to<Node>(p_object)); } -bool CameraEditorPlugin::handles(Object *p_object) const { +bool Camera3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Camera"); + return p_object->is_class("Camera3D"); } -void CameraEditorPlugin::make_visible(bool p_visible) { +void Camera3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - //SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object)); + //Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object)); } else { - SpatialEditor::get_singleton()->set_can_preview(NULL); + Node3DEditor::get_singleton()->set_can_preview(nullptr); } } -CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) { +Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) { editor = p_node; /* camera_editor = memnew( CameraEditor ); @@ -120,5 +120,5 @@ CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) { */ } -CameraEditorPlugin::~CameraEditorPlugin() { +Camera3DEditorPlugin::~Camera3DEditorPlugin() { } diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h index 9758a1ffbd..1e57ac7cd2 100644 --- a/editor/plugins/camera_editor_plugin.h +++ b/editor/plugins/camera_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* camera_editor_plugin.h */ +/* camera_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,11 +33,11 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/camera.h" +#include "scene/3d/camera_3d.h" -class CameraEditor : public Control { +class Camera3DEditor : public Control { - GDCLASS(CameraEditor, Control); + GDCLASS(Camera3DEditor, Control); Panel *panel; Button *preview; @@ -51,25 +51,25 @@ protected: public: void edit(Node *p_camera); - CameraEditor(); + Camera3DEditor(); }; -class CameraEditorPlugin : public EditorPlugin { +class Camera3DEditorPlugin : public EditorPlugin { - GDCLASS(CameraEditorPlugin, EditorPlugin); + GDCLASS(Camera3DEditorPlugin, EditorPlugin); //CameraEditor *camera_editor; EditorNode *editor; public: - virtual String get_name() const { return "Camera"; } + virtual String get_name() const { return "Camera3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - CameraEditorPlugin(EditorNode *p_node); - ~CameraEditorPlugin(); + Camera3DEditorPlugin(EditorNode *p_node); + ~Camera3DEditorPlugin(); }; #endif // CAMERA_EDITOR_PLUGIN_H diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 9f66672f4a..cd3df08276 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "canvas_item_editor_plugin.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "core/print_string.h" #include "core/project_settings.h" @@ -40,17 +40,17 @@ #include "editor/editor_settings.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" +#include "scene/2d/gpu_particles_2d.h" #include "scene/2d/light_2d.h" -#include "scene/2d/particles_2d.h" #include "scene/2d/polygon_2d.h" #include "scene/2d/skeleton_2d.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" #include "scene/2d/touch_screen_button.h" #include "scene/gui/grid_container.h" #include "scene/gui/nine_patch_rect.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/main/canvas_layer.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #define MIN_ZOOM 0.01 @@ -99,7 +99,7 @@ public: label = memnew(Label); label->set_text(TTR("Grid Offset:")); child_container->add_child(label); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); grid_offset_x = memnew(SpinBox); grid_offset_x->set_min(-SPIN_BOX_GRID_RANGE); @@ -107,7 +107,7 @@ public: grid_offset_x->set_allow_lesser(true); grid_offset_x->set_allow_greater(true); grid_offset_x->set_suffix("px"); - grid_offset_x->set_h_size_flags(SIZE_EXPAND_FILL); + grid_offset_x->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(grid_offset_x); grid_offset_y = memnew(SpinBox); @@ -116,20 +116,20 @@ public: grid_offset_y->set_allow_lesser(true); grid_offset_y->set_allow_greater(true); grid_offset_y->set_suffix("px"); - grid_offset_y->set_h_size_flags(SIZE_EXPAND_FILL); + grid_offset_y->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(grid_offset_y); label = memnew(Label); label->set_text(TTR("Grid Step:")); child_container->add_child(label); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); grid_step_x = memnew(SpinBox); grid_step_x->set_min(0.01); grid_step_x->set_max(SPIN_BOX_GRID_RANGE); grid_step_x->set_allow_greater(true); grid_step_x->set_suffix("px"); - grid_step_x->set_h_size_flags(SIZE_EXPAND_FILL); + grid_step_x->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(grid_step_x); grid_step_y = memnew(SpinBox); @@ -137,7 +137,7 @@ public: grid_step_y->set_max(SPIN_BOX_GRID_RANGE); grid_step_y->set_allow_greater(true); grid_step_y->set_suffix("px"); - grid_step_y->set_h_size_flags(SIZE_EXPAND_FILL); + grid_step_y->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(grid_step_y); child_container = memnew(GridContainer); @@ -146,7 +146,7 @@ public: label = memnew(Label); label->set_text(TTR("Primary Line Every:")); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(label); primary_grid_steps = memnew(SpinBox); @@ -155,7 +155,7 @@ public: primary_grid_steps->set_max(100); primary_grid_steps->set_allow_greater(true); primary_grid_steps->set_suffix(TTR("steps")); - primary_grid_steps->set_h_size_flags(SIZE_EXPAND_FILL); + primary_grid_steps->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(primary_grid_steps); container->add_child(memnew(HSeparator)); @@ -169,25 +169,25 @@ public: label = memnew(Label); label->set_text(TTR("Rotation Offset:")); child_container->add_child(label); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); rotation_offset = memnew(SpinBox); rotation_offset->set_min(-SPIN_BOX_ROTATION_RANGE); rotation_offset->set_max(SPIN_BOX_ROTATION_RANGE); rotation_offset->set_suffix("deg"); - rotation_offset->set_h_size_flags(SIZE_EXPAND_FILL); + rotation_offset->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(rotation_offset); label = memnew(Label); label->set_text(TTR("Rotation Step:")); child_container->add_child(label); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); rotation_step = memnew(SpinBox); rotation_step->set_min(-SPIN_BOX_ROTATION_RANGE); rotation_step->set_max(SPIN_BOX_ROTATION_RANGE); rotation_step->set_suffix("deg"); - rotation_step->set_h_size_flags(SIZE_EXPAND_FILL); + rotation_step->set_h_size_flags(Control::SIZE_EXPAND_FILL); child_container->add_child(rotation_step); container->add_child(memnew(HSeparator)); @@ -198,13 +198,13 @@ public: label = memnew(Label); label->set_text(TTR("Scale Step:")); child_container->add_child(label); - label->set_h_size_flags(SIZE_EXPAND_FILL); + label->set_h_size_flags(Control::SIZE_EXPAND_FILL); scale_step = memnew(SpinBox); scale_step->set_min(SPIN_BOX_SCALE_MIN); scale_step->set_max(SPIN_BOX_SCALE_MAX); scale_step->set_allow_greater(true); - scale_step->set_h_size_flags(SIZE_EXPAND_FILL); + scale_step->set_h_size_flags(Control::SIZE_EXPAND_FILL); scale_step->set_step(0.01f); child_container->add_child(scale_step); } @@ -334,7 +334,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; - bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL); + bool is_snap_active = smart_snap_active ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); // Smart snap using the canvas position Vector2 output = p_target; @@ -462,7 +462,7 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig } float CanvasItemEditor::snap_angle(float p_target, float p_start) const { - if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) { + if (((smart_snap_active || snap_rotation) ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) { if (snap_relative) { return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step); } else { @@ -477,7 +477,7 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { Ref<InputEventKey> k = p_ev; - if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) + if (!is_visible_in_tree()) return; if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) { @@ -503,7 +503,7 @@ Object *CanvasItemEditor::_get_editor_data(Object *p_what) { CanvasItem *ci = Object::cast_to<CanvasItem>(p_what); if (!ci) - return NULL; + return nullptr; return memnew(CanvasItemEditorSelectedItem); } @@ -667,7 +667,7 @@ void CanvasItemEditor::_get_bones_at_pos(const Point2 &p_pos, Vector<_SelectResu Node2D *from_node = Object::cast_to<Node2D>(ObjectDB::get_instance(E->key().from)); Vector<Vector2> bone_shape; - if (!_get_bone_shape(&bone_shape, NULL, E)) + if (!_get_bone_shape(&bone_shape, nullptr, E)) continue; // Check if the point is inside the Polygon2D @@ -1284,7 +1284,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo // Pan the viewport Point2i relative; if (bool(EditorSettings::get_singleton()->get("editors/2d/warped_mouse_panning"))) { - relative = Input::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect()); + relative = InputFilter::get_singleton()->warp_mouse_motion(m, viewport->get_global_rect()); } else { relative = m->get_relative(); } @@ -1343,7 +1343,7 @@ bool CanvasItemEditor::_gui_input_pivot(const Ref<InputEvent> &p_event) { if (drag_selection.size() == 1) { new_pos = snap_point(drag_from, SNAP_NODE_SIDES | SNAP_NODE_CENTER | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, drag_selection[0]); } else { - new_pos = snap_point(drag_from, SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, NULL, drag_selection); + 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(); @@ -1912,13 +1912,14 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { Transform2D simple_xform = (viewport->get_transform() * unscaled_transform).affine_inverse() * transform; bool uniform = m->get_shift(); - bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL); + bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); Point2 drag_from_local = simple_xform.xform(drag_from); Point2 drag_to_local = simple_xform.xform(drag_to); Point2 offset = drag_to_local - drag_from_local; Size2 scale = canvas_item->call("get_scale"); + Size2 original_scale = scale; float ratio = scale.y / scale.x; if (drag_type == DRAG_SCALE_BOTH) { Size2 scale_factor = drag_to_local / drag_from_local; @@ -1931,6 +1932,7 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { Size2 scale_factor = Vector2(offset.x, -offset.y) / SCALE_HANDLE_DISTANCE; Size2 parent_scale = parent_xform.get_scale(); scale_factor *= Vector2(1.0 / parent_scale.x, 1.0 / parent_scale.y); + if (drag_type == DRAG_SCALE_X) { scale.x += scale_factor.x; if (uniform) { @@ -1945,8 +1947,13 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { } if (snap_scale && !is_ctrl) { - scale.x = roundf(scale.x / snap_scale_step) * snap_scale_step; - scale.y = roundf(scale.y / snap_scale_step) * snap_scale_step; + if (snap_relative) { + scale.x = original_scale.x * (roundf((scale.x / original_scale.x) / snap_scale_step) * snap_scale_step); + scale.y = original_scale.y * (roundf((scale.y / original_scale.y) / snap_scale_step) * snap_scale_step); + } else { + scale.x = roundf(scale.x / snap_scale_step) * snap_scale_step; + scale.y = roundf(scale.y / snap_scale_step) * snap_scale_step; + } } canvas_item->call("set_scale", scale); @@ -2031,7 +2038,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { Vector<List<Dictionary>> all_bones_ik_states; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { List<Dictionary> bones_ik_states; - _save_canvas_item_ik_chain(E->get(), NULL, &bones_ik_states); + _save_canvas_item_ik_chain(E->get(), nullptr, &bones_ik_states); all_bones_ik_states.push_back(bones_ik_states); } @@ -2046,7 +2053,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { previous_pos = _get_encompassing_rect_from_list(drag_selection).position; } - Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, NULL, drag_selection); + Point2 new_pos = snap_point(previous_pos + (drag_to - drag_from), SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL | SNAP_NODE_PARENT | SNAP_NODE_ANCHORS | SNAP_OTHER_NODES, 0, nullptr, drag_selection); if (drag_type == DRAG_MOVE_X) { new_pos.y = previous_pos.y; @@ -2133,7 +2140,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { Vector<List<Dictionary>> all_bones_ik_states; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { List<Dictionary> bones_ik_states; - _save_canvas_item_ik_chain(E->get(), NULL, &bones_ik_states); + _save_canvas_item_ik_chain(E->get(), nullptr, &bones_ik_states); all_bones_ik_states.push_back(bones_ik_states); } @@ -2207,10 +2214,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (k.is_valid() && !k->is_pressed() && drag_type == DRAG_KEY_MOVE && tool == TOOL_SELECT && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_LEFT || k->get_keycode() == KEY_RIGHT)) { // Confirm canvas items move by arrow keys - if ((!Input::get_singleton()->is_key_pressed(KEY_UP)) && - (!Input::get_singleton()->is_key_pressed(KEY_DOWN)) && - (!Input::get_singleton()->is_key_pressed(KEY_LEFT)) && - (!Input::get_singleton()->is_key_pressed(KEY_RIGHT))) { + if ((!InputFilter::get_singleton()->is_key_pressed(KEY_UP)) && + (!InputFilter::get_singleton()->is_key_pressed(KEY_DOWN)) && + (!InputFilter::get_singleton()->is_key_pressed(KEY_LEFT)) && + (!InputFilter::get_singleton()->is_key_pressed(KEY_RIGHT))) { _commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true); drag_type = DRAG_NONE; } @@ -2284,7 +2291,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } selection_menu_additive_selection = b->get_shift(); - selection_menu->set_global_position(b->get_global_position()); + selection_menu->set_position(get_screen_transform().xform(b->get_position())); selection_menu->popup(); return true; } @@ -2299,7 +2306,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { return true; // Find the item to select - CanvasItem *canvas_item = NULL; + CanvasItem *canvas_item = nullptr; // Retrieve the bones Vector<_SelectResult> selection = Vector<_SelectResult>(); @@ -2588,9 +2595,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { } void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) { - Color color = get_color("font_color", "Editor"); + Color color = get_theme_color("font_color", "Editor"); color.a = 0.8; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); Size2 text_size = font->get_string_size(p_string); switch (p_side) { case MARGIN_LEFT: @@ -2626,7 +2633,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_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); + get_theme_stylebox("Focus", "EditorStyles")->draw(viewport->get_canvas_item(), Rect2(Point2(), viewport->get_size())); } } @@ -2657,18 +2664,18 @@ void CanvasItemEditor::_draw_guides() { } // Dragged guide - Color text_color = get_color("font_color", "Editor"); + Color text_color = get_theme_color("font_color", "Editor"); text_color.a = 0.5; if (drag_type == DRAG_DOUBLE_GUIDE || drag_type == DRAG_V_GUIDE) { String str = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).x)); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); Size2 text_size = font->get_string_size(str); viewport->draw_string(font, Point2(dragged_guide_pos.x + 10, RULER_WIDTH + text_size.y / 2 + 10), str, text_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 = vformat("%d px", Math::round(xform.affine_inverse().xform(dragged_guide_pos).y)); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); Size2 text_size = font->get_string_size(str); viewport->draw_string(font, Point2(RULER_WIDTH + 10, dragged_guide_pos.y + text_size.y / 2 + 10), str, text_color); viewport->draw_line(Point2(0, dragged_guide_pos.y), Point2(viewport->get_size().x, dragged_guide_pos.y), guide_color, Math::round(EDSCALE)); @@ -2690,11 +2697,11 @@ void CanvasItemEditor::_draw_smart_snapping() { } void CanvasItemEditor::_draw_rulers() { - Color bg_color = get_color("dark_color_2", "Editor"); - Color graduation_color = get_color("font_color", "Editor").linear_interpolate(bg_color, 0.5); - Color font_color = get_color("font_color", "Editor"); + Color bg_color = get_theme_color("dark_color_2", "Editor"); + Color graduation_color = get_theme_color("font_color", "Editor").linear_interpolate(bg_color, 0.5); + Color font_color = get_theme_color("font_color", "Editor"); font_color.a = 0.8; - Ref<Font> font = get_font("rulers", "EditorFonts"); + Ref<Font> font = get_theme_font("rulers", "EditorFonts"); // The rule transform Transform2D ruler_transform = Transform2D(); @@ -2856,7 +2863,7 @@ void CanvasItemEditor::_draw_ruler_tool() { return; if (ruler_tool_active) { - Color ruler_primary_color = get_color("accent_color", "Editor"); + Color ruler_primary_color = get_theme_color("accent_color", "Editor"); Color ruler_secondary_color = ruler_primary_color; ruler_secondary_color.a = 0.5; @@ -2873,8 +2880,8 @@ void CanvasItemEditor::_draw_ruler_tool() { viewport->draw_line(corner, end, ruler_secondary_color, Math::round(EDSCALE)); } - Ref<Font> font = get_font("bold", "EditorFonts"); - Color font_color = get_color("font_color", "Editor"); + Ref<Font> font = get_theme_font("bold", "EditorFonts"); + Color font_color = get_theme_color("font_color", "Editor"); Color font_secondary_color = font_color; font_secondary_color.a = 0.5; float text_height = font->get_height(); @@ -2974,8 +2981,8 @@ void CanvasItemEditor::_draw_ruler_tool() { } else { if (grid_snap_active) { - Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); - viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + 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); } } } @@ -3187,19 +3194,21 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { } void CanvasItemEditor::_draw_selection() { - Ref<Texture2D> pivot_icon = get_icon("EditorPivot", "EditorIcons"); - Ref<Texture2D> position_icon = get_icon("EditorPosition", "EditorIcons"); - Ref<Texture2D> previous_position_icon = get_icon("EditorPositionPrevious", "EditorIcons"); + 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"); RID ci = viewport->get_canvas_item(); - List<CanvasItem *> selection = _get_edited_canvas_items(false, false); + 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()); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); + bool item_locked = canvas_item->has_meta("_edit_lock_"); + // Draw the previous position if we are dragging the node if (show_helpers && (drag_type == DRAG_MOVE || drag_type == DRAG_ROTATE || @@ -3239,6 +3248,10 @@ void CanvasItemEditor::_draw_selection() { Color c = Color(1, 0.6, 0.4, 0.7); + if (item_locked) { + c = Color(0.7, 0.7, 0.7, 0.7); + } + for (int i = 0; i < 4; i++) { viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE)); } @@ -3251,7 +3264,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_set_transform_matrix(viewport->get_transform()); } - if (single && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks + if (single && !item_locked && (tool == TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_SCALE || tool == TOOL_ROTATE || tool == TOOL_EDIT_PIVOT)) { //kind of sucks // Draw the pivot if (canvas_item->_edit_use_pivot()) { @@ -3297,8 +3310,8 @@ void CanvasItemEditor::_draw_selection() { } // Draw the move handles - bool is_ctrl = Input::get_singleton()->is_key_pressed(KEY_CONTROL); - bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); + bool is_ctrl = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); + bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT); if (tool == TOOL_MOVE && show_transformation_gizmos) { if (_is_node_movable(canvas_item)) { Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); @@ -3312,16 +3325,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_color("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(move_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(EDSCALE)); + 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)); 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_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, move_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(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_set_transform_matrix(viewport->get_transform()); } @@ -3334,7 +3347,7 @@ void CanvasItemEditor::_draw_selection() { Transform2D simple_xform = viewport->get_transform() * unscaled_transform; Size2 scale_factor = Size2(SCALE_HANDLE_DISTANCE, SCALE_HANDLE_DISTANCE); - bool uniform = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + bool uniform = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); Point2 offset = (simple_xform.affine_inverse().xform(drag_to) - simple_xform.affine_inverse().xform(drag_from)) * zoom; if (drag_type == DRAG_SCALE_X) { @@ -3351,12 +3364,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_color("axis_x_color", "Editor")); - viewport->draw_line(Point2(), Point2(scale_factor.x * EDSCALE, 0), get_color("axis_x_color", "Editor"), Math::round(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)); Rect2 y_handle_rect = Rect2(-5 * EDSCALE, scale_factor.y * EDSCALE, 10 * EDSCALE, 10 * EDSCALE); - viewport->draw_rect(y_handle_rect, get_color("axis_y_color", "Editor")); - viewport->draw_line(Point2(), Point2(0, scale_factor.y * EDSCALE), get_color("axis_y_color", "Editor"), Math::round(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_set_transform_matrix(viewport->get_transform()); } @@ -3371,11 +3384,11 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_color("box_selection_fill_color", "Editor")); + get_theme_color("box_selection_fill_color", "Editor")); viewport->draw_rect( Rect2(bsfrom, bsto - bsfrom), - get_color("box_selection_stroke_color", "Editor"), + get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); } @@ -3385,7 +3398,7 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line( transform.xform(drag_rotation_center), transform.xform(drag_to), - get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), + get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), Math::round(2 * EDSCALE)); } } @@ -3427,7 +3440,7 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c } } if (points.size() >= 2) { - VisualServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, points[0], points[1], p_color); } } @@ -3435,8 +3448,8 @@ void CanvasItemEditor::_draw_axis() { if (show_origin) { - _draw_straight_line(Point2(), Point2(1, 0), get_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75)); - _draw_straight_line(Point2(), Point2(0, 1), get_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75)); + _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)); } if (show_viewport) { @@ -3455,7 +3468,7 @@ void CanvasItemEditor::_draw_axis() { }; for (int i = 0; i < 4; i++) { - VisualServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, screen_endpoints[i], screen_endpoints[(i + 1) % 4], area_axis_color); } } } @@ -3512,8 +3525,8 @@ void CanvasItemEditor::_draw_bones() { outline_colors.push_back(bone_outline_color); } - VisualServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors); - VisualServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID()); + RenderingServer::get_singleton()->canvas_item_add_polygon(ci, bone_shape_outline, outline_colors); + RenderingServer::get_singleton()->canvas_item_add_primitive(ci, bone_shape, colors, Vector<Vector2>(), RID()); } } } @@ -3547,7 +3560,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_icon("EditorPositionUnselected", "EditorIcons"); + Ref<Texture2D> position_icon = get_theme_icon("EditorPositionUnselected", "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); @@ -3564,7 +3577,7 @@ void CanvasItemEditor::_draw_hover() { Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "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)); @@ -3615,13 +3628,13 @@ void CanvasItemEditor::_draw_locks_and_groups(Node *p_node, const Transform2D &p if (canvas_item) { float offset = 0; - Ref<Texture2D> lock = get_icon("LockViewport", "EditorIcons"); + Ref<Texture2D> lock = get_theme_icon("LockViewport", "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_icon("GroupViewport", "EditorIcons"); + Ref<Texture2D> group = get_theme_icon("GroupViewport", "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; @@ -3744,7 +3757,7 @@ void CanvasItemEditor::_draw_viewport() { } RID ci = viewport->get_canvas_item(); - VisualServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D()); + RenderingServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D()); EditorPluginList *over_plugin_list = editor->get_editor_plugins_over(); if (!over_plugin_list->empty()) { @@ -3893,7 +3906,7 @@ void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); for (int i = 0; i < 4; i++) { select_sb->set_margin_size(Margin(i), 4); select_sb->set_default_margin(Margin(i), 4); @@ -3906,7 +3919,7 @@ void CanvasItemEditor::_notification(int p_what) { } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_sb->set_texture(get_icon("EditorRect2D", "EditorIcons")); + select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); } if (p_what == NOTIFICATION_EXIT_TREE) { @@ -3915,85 +3928,85 @@ void CanvasItemEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE || p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_button->set_icon(get_icon("ToolSelect", "EditorIcons")); - list_select_button->set_icon(get_icon("ListSelect", "EditorIcons")); - move_button->set_icon(get_icon("ToolMove", "EditorIcons")); - scale_button->set_icon(get_icon("ToolScale", "EditorIcons")); - rotate_button->set_icon(get_icon("ToolRotate", "EditorIcons")); - smart_snap_button->set_icon(get_icon("Snap", "EditorIcons")); - grid_snap_button->set_icon(get_icon("SnapGrid", "EditorIcons")); - snap_config_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons")); - skeleton_menu->set_icon(get_icon("Bone", "EditorIcons")); - override_camera_button->set_icon(get_icon("Camera2D", "EditorIcons")); - pan_button->set_icon(get_icon("ToolPan", "EditorIcons")); - ruler_button->set_icon(get_icon("Ruler", "EditorIcons")); - pivot_button->set_icon(get_icon("EditPivot", "EditorIcons")); - select_handle = get_icon("EditorHandle", "EditorIcons"); - anchor_handle = get_icon("EditorControlAnchor", "EditorIcons"); - lock_button->set_icon(get_icon("Lock", "EditorIcons")); - unlock_button->set_icon(get_icon("Unlock", "EditorIcons")); - group_button->set_icon(get_icon("Group", "EditorIcons")); - ungroup_button->set_icon(get_icon("Ungroup", "EditorIcons")); - key_loc_button->set_icon(get_icon("KeyPosition", "EditorIcons")); - key_rot_button->set_icon(get_icon("KeyRotation", "EditorIcons")); - key_scale_button->set_icon(get_icon("KeyScale", "EditorIcons")); - key_insert_button->set_icon(get_icon("Key", "EditorIcons")); - key_auto_insert_button->set_icon(get_icon("AutoKey", "EditorIcons")); - animation_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons")); - - zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons")); - zoom_plus->set_icon(get_icon("ZoomMore", "EditorIcons")); - - presets_menu->set_icon(get_icon("ControlLayout", "EditorIcons")); + 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("GuiTabMenu", "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")); + animation_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + + zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); + zoom_plus->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + + presets_menu->set_icon(get_theme_icon("ControlLayout", "EditorIcons")); PopupMenu *p = presets_menu->get_popup(); p->clear(); - p->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT); - p->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT); - p->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP); - p->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT); - p->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM); - p->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER); + p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT); + p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP); + p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT); + p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM); + p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE); - p->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE); - p->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE); - p->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE); - p->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE); - p->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE); + p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE); + p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE); + p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE); p->add_separator(); - p->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE); - p->add_icon_item(get_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO); + p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE); + p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO); p->add_separator(); p->add_submenu_item(TTR("Anchors only"), "Anchors"); - p->set_item_icon(21, get_icon("Anchor", "EditorIcons")); + p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons")); anchors_popup->clear(); - anchors_popup->add_icon_item(get_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_PRESET_TOP_LEFT); - anchors_popup->add_icon_item(get_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_PRESET_TOP_RIGHT); - anchors_popup->add_icon_item(get_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_PRESET_BOTTOM_RIGHT); - anchors_popup->add_icon_item(get_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_PRESET_BOTTOM_LEFT); + 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_separator(); - anchors_popup->add_icon_item(get_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_PRESET_CENTER_LEFT); - anchors_popup->add_icon_item(get_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_PRESET_CENTER_TOP); - anchors_popup->add_icon_item(get_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_PRESET_CENTER_RIGHT); - anchors_popup->add_icon_item(get_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_PRESET_CENTER_BOTTOM); - anchors_popup->add_icon_item(get_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_PRESET_CENTER); + 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_separator(); - anchors_popup->add_icon_item(get_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_PRESET_LEFT_WIDE); - anchors_popup->add_icon_item(get_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_PRESET_TOP_WIDE); - anchors_popup->add_icon_item(get_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_PRESET_RIGHT_WIDE); - anchors_popup->add_icon_item(get_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_PRESET_BOTTOM_WIDE); - anchors_popup->add_icon_item(get_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_PRESET_VCENTER_WIDE); - anchors_popup->add_icon_item(get_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_PRESET_HCENTER_WIDE); + 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_separator(); - anchors_popup->add_icon_item(get_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE); + anchors_popup->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_PRESET_WIDE); - anchor_mode_button->set_icon(get_icon("Anchor", "EditorIcons")); + anchor_mode_button->set_icon(get_theme_icon("Anchor", "EditorIcons")); } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -4911,7 +4924,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { bool preview = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE)); preview = !preview; - VS::get_singleton()->canvas_set_disable_scale(!preview); + RS::get_singleton()->canvas_set_disable_scale(!preview); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE), preview); } break; @@ -5420,21 +5433,21 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { bottom_split = memnew(VSplitContainer); add_child(bottom_split); - bottom_split->set_v_size_flags(SIZE_EXPAND_FILL); + bottom_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); palette_split = memnew(HSplitContainer); bottom_split->add_child(palette_split); - palette_split->set_v_size_flags(SIZE_EXPAND_FILL); + palette_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); viewport_scrollable = memnew(Control); palette_split->add_child(viewport_scrollable); viewport_scrollable->set_mouse_filter(MOUSE_FILTER_PASS); viewport_scrollable->set_clip_contents(true); - viewport_scrollable->set_v_size_flags(SIZE_EXPAND_FILL); - viewport_scrollable->set_h_size_flags(SIZE_EXPAND_FILL); + viewport_scrollable->set_v_size_flags(Control::SIZE_EXPAND_FILL); + viewport_scrollable->set_h_size_flags(Control::SIZE_EXPAND_FILL); viewport_scrollable->connect("draw", callable_mp(this, &CanvasItemEditor::_update_scrollbars)); - ViewportContainer *scene_tree = memnew(ViewportContainer); + SubViewportContainer *scene_tree = memnew(SubViewportContainer); viewport_scrollable->add_child(scene_tree); scene_tree->set_stretch(true); scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE); @@ -5445,7 +5458,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { zoom_hb = memnew(HBoxContainer); // Bring the zoom percentage closer to the zoom buttons - zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE)); + zoom_hb->add_theme_constant_override("separation", Math::round(-8 * EDSCALE)); controls_vb->add_child(zoom_hb); viewport = memnew(CanvasItemEditorViewport(p_editor, this)); @@ -5462,7 +5475,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { info_overlay->set_margin(MARGIN_LEFT, 10); info_overlay->set_margin(MARGIN_BOTTOM, -15); info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN); - info_overlay->add_constant_override("separation", 10); + info_overlay->add_theme_constant_override("separation", 10); viewport_scrollable->add_child(info_overlay); Theme *info_overlay_theme = memnew(Theme); @@ -5477,8 +5490,8 @@ 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_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor")); - warning_child_of_container->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts")); + 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")); add_control_to_info_overlay(warning_child_of_container); h_scroll = memnew(HScrollBar); @@ -5783,7 +5796,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { selection_menu = memnew(PopupMenu); add_child(selection_menu); - selection_menu->set_custom_minimum_size(Vector2(100, 0)); + selection_menu->set_min_size(Vector2(100, 0)); selection_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_selection_result_pressed)); selection_menu->connect("popup_hide", callable_mp(this, &CanvasItemEditor::_selection_menu_hide)); @@ -5800,7 +5813,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { call_deferred("set_state", get_state()); } -CanvasItemEditor *CanvasItemEditor::singleton = NULL; +CanvasItemEditor *CanvasItemEditor::singleton = nullptr; void CanvasItemEditorPlugin::edit(Object *p_object) { @@ -5818,13 +5831,13 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) { if (p_visible) { canvas_item_editor->show(); canvas_item_editor->set_physics_process(true); - VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false); + RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), false); } else { canvas_item_editor->hide(); canvas_item_editor->set_physics_process(false); - VisualServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true); } } @@ -5886,9 +5899,9 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons ERR_FAIL_COND(res.is_null()); Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (texture != NULL || scene != NULL) { - if (texture != NULL) { - Sprite *sprite = memnew(Sprite); + if (texture != nullptr || scene != nullptr) { + if (texture != nullptr) { + Sprite2D *sprite = memnew(Sprite2D); sprite->set_texture(texture); sprite->set_modulate(Color(1, 1, 1, 0.7f)); preview_node->add_child(sprite); @@ -5953,7 +5966,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child); editor_data->get_undo_redo().add_do_method(child, "set_owner", editor->get_edited_scene()); editor_data->get_undo_redo().add_do_reference(child); - editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)nullptr); } if (parent) { @@ -6049,7 +6062,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { // Without root dropping multiple files is not allowed if (!target_node && selected_files.size() > 1) { accept->set_text(TTR("Cannot instantiate multiple nodes without root.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } @@ -6064,7 +6077,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { continue; } Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - if (scene != NULL && scene.is_valid()) { + if (scene != nullptr && scene.is_valid()) { if (!target_node) { // Without root node act the same as "Load Inherited Scene" Error err = EditorNode::get_singleton()->load_scene(path, false, true); @@ -6079,12 +6092,12 @@ void CanvasItemEditorViewport::_perform_drop_data() { } } else { Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); - if (texture != NULL && texture.is_valid()) { + if (texture != nullptr && texture.is_valid()) { Node *child; if (default_type == "Light2D") child = memnew(Light2D); - else if (default_type == "Particles2D") - child = memnew(Particles2D); + else if (default_type == "GPUParticles2D") + child = memnew(GPUParticles2D); else if (default_type == "Polygon2D") child = memnew(Polygon2D); else if (default_type == "TouchScreenButton") @@ -6094,7 +6107,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { else if (default_type == "NinePatchRect") child = memnew(NinePatchRect); else - child = memnew(Sprite); // default + child = memnew(Sprite2D); // default _create_nodes(target_node, child, path, drop_pos); } @@ -6110,7 +6123,7 @@ void CanvasItemEditorViewport::_perform_drop_data() { } files_str = files_str.substr(0, files_str.length() - 1); accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str())); - accept->popup_centered_minsize(); + accept->popup_centered(); } } @@ -6176,7 +6189,7 @@ void CanvasItemEditorViewport::_show_resource_type_selector() { check->set_pressed(check->get_text() == default_type); } selector->set_title(vformat(TTR("Add %s"), default_type)); - selector->popup_centered_minsize(); + selector->popup_centered(); } bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { @@ -6191,8 +6204,8 @@ bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { } void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p_data) { - bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); - bool is_alt = Input::get_singleton()->is_key_pressed(KEY_ALT); + bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); + bool is_alt = InputFilter::get_singleton()->is_key_pressed(KEY_ALT); selected_files.clear(); Dictionary d = p_data; @@ -6209,7 +6222,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p list.push_back(root_node); } else { drop_pos = p_point; - target_node = NULL; + target_node = nullptr; } } @@ -6233,7 +6246,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_color_override("font_color", get_color("warning_color", "Editor")); + label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); } break; case NOTIFICATION_EXIT_TREE: { disconnect("mouse_exited", callable_mp(this, &CanvasItemEditorViewport::_on_mouse_exit)); @@ -6247,18 +6260,18 @@ void CanvasItemEditorViewport::_bind_methods() { } CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas_item_editor) { - default_type = "Sprite"; + default_type = "Sprite2D"; // Node2D - types.push_back("Sprite"); + types.push_back("Sprite2D"); types.push_back("Light2D"); - types.push_back("Particles2D"); + types.push_back("GPUParticles2D"); types.push_back("Polygon2D"); types.push_back("TouchScreenButton"); // Control types.push_back("TextureRect"); types.push_back("NinePatchRect"); - target_node = NULL; + target_node = nullptr; editor = p_node; editor_data = editor->get_scene_tree_dock()->get_editor_data(); canvas_item_editor = p_canvas_item_editor; @@ -6271,12 +6284,12 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte editor->get_gui_base()->add_child(selector); selector->set_title(TTR("Change Default Type")); selector->connect("confirmed", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_confirmed)); - selector->connect("popup_hide", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed)); + selector->connect("cancelled", callable_mp(this, &CanvasItemEditorViewport::_on_change_type_closed)); VBoxContainer *vbc = memnew(VBoxContainer); selector->add_child(vbc); - vbc->set_h_size_flags(SIZE_EXPAND_FILL); - vbc->set_v_size_flags(SIZE_EXPAND_FILL); + vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); + vbc->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE); btn_group = memnew(VBoxContainer); @@ -6293,21 +6306,21 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte } label = memnew(Label); - label->add_color_override("font_color_shadow", Color(0, 0, 0, 1)); - label->add_constant_override("shadow_as_outline", 1 * EDSCALE); + label->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 1)); + label->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE); label->hide(); canvas_item_editor->get_controls_container()->add_child(label); label_desc = memnew(Label); label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type")); - label_desc->add_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1)); - label_desc->add_color_override("font_color_shadow", Color(0.2f, 0.2f, 0.2f, 1)); - label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE); - label_desc->add_constant_override("line_spacing", 0); + label_desc->add_theme_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1)); + label_desc->add_theme_color_override("font_color_shadow", Color(0.2f, 0.2f, 0.2f, 1)); + label_desc->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE); + label_desc->add_theme_constant_override("line_spacing", 0); label_desc->hide(); canvas_item_editor->get_controls_container()->add_child(label_desc); - VS::get_singleton()->canvas_set_disable_scale(true); + RS::get_singleton()->canvas_set_disable_scale(true); } CanvasItemEditorViewport::~CanvasItemEditorViewport() { diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 3c4cacf5c8..9f1a92f563 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -33,12 +33,12 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/2d/canvas_item.h" #include "scene/gui/box_container.h" #include "scene/gui/check_box.h" #include "scene/gui/label.h" #include "scene/gui/panel_container.h" #include "scene/gui/spin_box.h" +#include "scene/main/canvas_item.h" class CanvasItemEditorViewport; @@ -613,7 +613,7 @@ public: SNAP_DEFAULT = SNAP_GRID | SNAP_GUIDES | SNAP_PIXEL, }; - Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = NULL, List<CanvasItem *> p_other_nodes_exceptions = List<CanvasItem *>()); + Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = nullptr, List<CanvasItem *> p_other_nodes_exceptions = List<CanvasItem *>()); float snap_angle(float p_target, float p_start = 0) const; Transform2D get_canvas_transform() const { return transform; } @@ -687,7 +687,7 @@ class CanvasItemEditorViewport : public Control { CanvasItemEditor *canvas_item_editor; Node2D *preview_node; AcceptDialog *accept; - WindowDialog *selector; + AcceptDialog *selector; Label *selector_label; Label *label; Label *label_desc; diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 3d32c0b698..87e9987aa1 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -42,7 +42,7 @@ void CollisionPolygon2DEditor::_set_node(Node *p_polygon) { CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 1562286073..26adc5156b 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_polygon_editor_plugin.cpp */ +/* collision_polygon_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,26 +28,26 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "collision_polygon_editor_plugin.h" +#include "collision_polygon_3d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/os/file_access.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor/editor_settings.h" -#include "scene/3d/camera.h" -#include "spatial_editor_plugin.h" +#include "node_3d_editor_plugin.h" +#include "scene/3d/camera_3d.h" -void Polygon3DEditor::_notification(int p_what) { +void CollisionPolygon3DEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon(get_icon("Edit", "EditorIcons")); - button_edit->set_icon(get_icon("MovePoint", "EditorIcons")); + button_create->set_icon(get_theme_icon("Edit", "EditorIcons")); + button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons")); button_edit->set_pressed(true); - get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed)); + get_tree()->connect("node_removed", callable_mp(this, &CollisionPolygon3DEditor::_node_removed)); } break; case NOTIFICATION_PROCESS: { @@ -63,10 +63,10 @@ void Polygon3DEditor::_notification(int p_what) { } break; } } -void Polygon3DEditor::_node_removed(Node *p_node) { +void CollisionPolygon3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; if (imgeom->get_parent() == p_node) p_node->remove_child(imgeom); hide(); @@ -74,7 +74,7 @@ void Polygon3DEditor::_node_removed(Node *p_node) { } } -void Polygon3DEditor::_menu_option(int p_option) { +void CollisionPolygon3DEditor::_menu_option(int p_option) { switch (p_option) { @@ -93,7 +93,7 @@ void Polygon3DEditor::_menu_option(int p_option) { } } -void Polygon3DEditor::_wip_close() { +void CollisionPolygon3DEditor::_wip_close() { undo_redo->create_action(TTR("Create Polygon3D")); undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon")); @@ -109,7 +109,7 @@ void Polygon3DEditor::_wip_close() { undo_redo->commit_action(); } -bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { +bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { if (!node) return false; @@ -342,14 +342,14 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu Vector2 cpoint(spoint.x, spoint.y); - if (snap_ignore && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + if (snap_ignore && !InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) { snap_ignore = false; } - if (!snap_ignore && SpatialEditor::get_singleton()->is_snap_enabled()) { + if (!snap_ignore && Node3DEditor::get_singleton()->is_snap_enabled()) { cpoint = cpoint.snapped(Vector2( - SpatialEditor::get_singleton()->get_translate_snap(), - SpatialEditor::get_singleton()->get_translate_snap())); + Node3DEditor::get_singleton()->get_translate_snap(), + Node3DEditor::get_singleton()->get_translate_snap())); } edited_point_pos = cpoint; @@ -360,7 +360,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu return false; } -float Polygon3DEditor::_get_depth() { +float CollisionPolygon3DEditor::_get_depth() { if (bool(node->call("_has_editable_3d_polygon_no_depth"))) return 0; @@ -368,7 +368,7 @@ float Polygon3DEditor::_get_depth() { return float(node->call("get_depth")); } -void Polygon3DEditor::_polygon_draw() { +void CollisionPolygon3DEditor::_polygon_draw() { if (!node) return; @@ -489,11 +489,11 @@ void Polygon3DEditor::_polygon_draw() { m->surface_set_material(0, handle_material); } -void Polygon3DEditor::edit(Node *p_collision_polygon) { +void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) { if (p_collision_polygon) { - node = Object::cast_to<Spatial>(p_collision_polygon); + node = Object::cast_to<Node3D>(p_collision_polygon); //Enable the pencil tool if the polygon is empty if (Vector<Vector2>(node->call("get_polygon")).size() == 0) { _menu_option(MODE_CREATE); @@ -507,7 +507,7 @@ void Polygon3DEditor::edit(Node *p_collision_polygon) { prev_depth = -1; } else { - node = NULL; + node = nullptr; if (imgeom->get_parent()) imgeom->get_parent()->remove_child(imgeom); @@ -516,31 +516,31 @@ void Polygon3DEditor::edit(Node *p_collision_polygon) { } } -void Polygon3DEditor::_bind_methods() { +void CollisionPolygon3DEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw); + ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw); } -Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { +CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { - node = NULL; + node = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); add_child(memnew(VSeparator)); button_create = memnew(ToolButton); add_child(button_create); - button_create->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_CREATE)); + button_create->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_CREATE)); button_create->set_toggle_mode(true); button_edit = memnew(ToolButton); add_child(button_edit); - button_edit->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_EDIT)); + button_edit->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_EDIT)); button_edit->set_toggle_mode(true); mode = MODE_EDIT; wip_active = false; - imgeom = memnew(ImmediateGeometry); + imgeom = memnew(ImmediateGeometry3D); imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); @@ -556,11 +556,11 @@ Polygon3DEditor::Polygon3DEditor(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_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle = editor->get_gui_base()->get_theme_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); - pointsm = memnew(MeshInstance); + pointsm = memnew(MeshInstance3D); imgeom->add_child(pointsm); m.instance(); pointsm->set_mesh(m); @@ -569,7 +569,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { snap_ignore = false; } -Polygon3DEditor::~Polygon3DEditor() { +CollisionPolygon3DEditor::~CollisionPolygon3DEditor() { memdelete(imgeom); } @@ -581,7 +581,7 @@ void Polygon3DEditorPlugin::edit(Object *p_object) { bool Polygon3DEditorPlugin::handles(Object *p_object) const { - return Object::cast_to<Spatial>(p_object) && bool(p_object->call("_is_editable_3d_polygon")); + return Object::cast_to<Node3D>(p_object) && bool(p_object->call("_is_editable_3d_polygon")); } void Polygon3DEditorPlugin::make_visible(bool p_visible) { @@ -591,15 +591,15 @@ void Polygon3DEditorPlugin::make_visible(bool p_visible) { } else { collision_polygon_editor->hide(); - collision_polygon_editor->edit(NULL); + collision_polygon_editor->edit(nullptr); } } Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) { editor = p_node; - collision_polygon_editor = memnew(Polygon3DEditor(p_node)); - SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); + collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node)); + Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); collision_polygon_editor->hide(); } diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_3d_editor_plugin.h index 3b6c25ac17..9751b1f79e 100644 --- a/editor/plugins/collision_polygon_editor_plugin.h +++ b/editor/plugins/collision_polygon_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* collision_polygon_editor_plugin.h */ +/* collision_polygon_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,16 +33,16 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/collision_polygon.h" -#include "scene/3d/immediate_geometry.h" -#include "scene/3d/mesh_instance.h" +#include "scene/3d/collision_polygon_3d.h" +#include "scene/3d/immediate_geometry_3d.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/gui/tool_button.h" class CanvasItemEditor; -class Polygon3DEditor : public HBoxContainer { +class CollisionPolygon3DEditor : public HBoxContainer { - GDCLASS(Polygon3DEditor, HBoxContainer); + GDCLASS(CollisionPolygon3DEditor, HBoxContainer); UndoRedo *undo_redo; enum Mode { @@ -62,9 +62,9 @@ class Polygon3DEditor : public HBoxContainer { EditorNode *editor; Panel *panel; - Spatial *node; - ImmediateGeometry *imgeom; - MeshInstance *pointsm; + Node3D *node; + ImmediateGeometry3D *imgeom; + MeshInstance3D *pointsm; Ref<ArrayMesh> m; MenuButton *options; @@ -90,21 +90,21 @@ protected: static void _bind_methods(); public: - virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); + virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event); void edit(Node *p_collision_polygon); - Polygon3DEditor(EditorNode *p_editor); - ~Polygon3DEditor(); + CollisionPolygon3DEditor(EditorNode *p_editor); + ~CollisionPolygon3DEditor(); }; class Polygon3DEditorPlugin : public EditorPlugin { GDCLASS(Polygon3DEditorPlugin, EditorPlugin); - Polygon3DEditor *collision_polygon_editor; + CollisionPolygon3DEditor *collision_polygon_editor; EditorNode *editor; public: - virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } + virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } virtual String get_name() const { return "Polygon3DEditor"; } bool has_main_screen() const { return false; } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 01b4a61a85..594dd0d0cb 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -39,6 +39,13 @@ #include "scene/resources/rectangle_shape_2d.h" #include "scene/resources/segment_shape_2d.h" +void CollisionShape2DEditor::_node_removed(Node *p_node) { + + if (p_node == node) { + node = nullptr; + } +} + Variant CollisionShape2DEditor::get_handle_value(int idx) const { switch (shape_type) { @@ -435,7 +442,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_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> h = get_theme_icon("EditorHandle", "EditorIcons"); Vector2 size = h->get_size() * 0.5; handles.clear(); @@ -525,6 +532,20 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } } +void CollisionShape2DEditor::_notification(int p_what) { + + switch (p_what) { + + case NOTIFICATION_ENTER_TREE: { + get_tree()->connect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &CollisionShape2DEditor::_node_removed)); + } break; + } +} + void CollisionShape2DEditor::edit(Node *p_node) { if (!canvas_item_editor) { @@ -540,7 +561,7 @@ void CollisionShape2DEditor::edit(Node *p_node) { edit_handle = -1; shape_type = -1; - node = NULL; + node = nullptr; } canvas_item_editor->update_viewport(); @@ -553,8 +574,8 @@ void CollisionShape2DEditor::_bind_methods() { CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) { - node = NULL; - canvas_item_editor = NULL; + node = nullptr; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = p_editor->get_undo_redo(); @@ -576,7 +597,7 @@ bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const { void CollisionShape2DEditorPlugin::make_visible(bool visible) { if (!visible) { - edit(NULL); + edit(nullptr); } } diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 025420a886..6bb621c476 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -71,6 +71,8 @@ class CollisionShape2DEditor : public Control { void _get_current_shape_type(); protected: + void _notification(int p_what); + void _node_removed(Node *p_node); static void _bind_methods(); public: diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 119528dfc8..ef4d7d7646 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -60,7 +60,7 @@ void CPUParticles2DEditorPlugin::make_visible(bool p_visible) { void CPUParticles2DEditorPlugin::_file_selected(const String &p_file) { source_emission_file = p_file; - emission_mask->popup_centered_minsize(); + emission_mask->popup_centered(); } void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) { @@ -73,7 +73,7 @@ void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) { } break; case MENU_CLEAR_EMISSION_MASK: { - emission_mask->popup_centered_minsize(); + emission_mask->popup_centered(); } break; case MENU_RESTART: { @@ -241,7 +241,7 @@ 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(menu->get_popup()->get_icon("Particles2D", "EditorIcons")); + menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons")); file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); } } @@ -251,7 +251,7 @@ void CPUParticles2DEditorPlugin::_bind_methods() { CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = NULL; + particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); @@ -262,11 +262,9 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { toolbar->add_child(memnew(VSeparator)); menu = memnew(MenuButton); - menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK); - menu->get_popup()->add_separator(); menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); - // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK); - menu->set_text(TTR("Particles")); + menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK); + menu->set_text(TTR("CPUParticles2D")); menu->set_switch_on_hover(true); toolbar->add_child(menu); @@ -276,7 +274,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { for (List<String>::Element *E = ext.front(); E; E = E->next()) { file->add_filter("*." + E->get() + "; " + E->get().to_upper()); } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); epoints = memnew(SpinBox); diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 2161041ee6..59a353a581 100644 --- a/editor/plugins/cpu_particles_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* cpu_particles_editor_plugin.cpp */ +/* cpu_particles_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,26 +28,26 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "cpu_particles_editor_plugin.h" +#include "cpu_particles_3d_editor_plugin.h" -#include "editor/plugins/spatial_editor_plugin.h" +#include "editor/plugins/node_3d_editor_plugin.h" -void CPUParticlesEditor::_node_removed(Node *p_node) { +void CPUParticles3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } -void CPUParticlesEditor::_notification(int p_notification) { +void CPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_icon("CPUParticles", "EditorIcons")); + options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons")); } } -void CPUParticlesEditor::_menu_option(int p_option) { +void CPUParticles3DEditor::_menu_option(int p_option) { switch (p_option) { @@ -65,13 +65,13 @@ void CPUParticlesEditor::_menu_option(int p_option) { } } -void CPUParticlesEditor::edit(CPUParticles *p_particles) { +void CPUParticles3DEditor::edit(CPUParticles3D *p_particles) { base_node = p_particles; node = p_particles; } -void CPUParticlesEditor::_generate_emission_points() { +void CPUParticles3DEditor::_generate_emission_points() { /// hacer codigo aca Vector<Vector3> points; @@ -82,45 +82,44 @@ void CPUParticlesEditor::_generate_emission_points() { } if (normals.size() == 0) { - node->set_emission_shape(CPUParticles::EMISSION_SHAPE_POINTS); + node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_POINTS); node->set_emission_points(points); } else { - node->set_emission_shape(CPUParticles::EMISSION_SHAPE_DIRECTED_POINTS); + node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_DIRECTED_POINTS); node->set_emission_points(points); node->set_emission_normals(normals); } } -void CPUParticlesEditor::_bind_methods() { +void CPUParticles3DEditor::_bind_methods() { } -CPUParticlesEditor::CPUParticlesEditor() { +CPUParticles3DEditor::CPUParticles3DEditor() { particles_editor_hb = memnew(HBoxContainer); - SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); + Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); options = memnew(MenuButton); options->set_switch_on_hover(true); particles_editor_hb->add_child(options); particles_editor_hb->hide(); - options->set_text(TTR("CPUParticles")); - options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); - options->get_popup()->add_separator(); + options->set_text(TTR("CPUParticles3D")); options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); - options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticlesEditor::_menu_option)); + options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); + options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles3DEditor::_menu_option)); } -void CPUParticlesEditorPlugin::edit(Object *p_object) { +void CPUParticles3DEditorPlugin::edit(Object *p_object) { - particles_editor->edit(Object::cast_to<CPUParticles>(p_object)); + particles_editor->edit(Object::cast_to<CPUParticles3D>(p_object)); } -bool CPUParticlesEditorPlugin::handles(Object *p_object) const { +bool CPUParticles3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("CPUParticles"); + return p_object->is_class("CPUParticles3D"); } -void CPUParticlesEditorPlugin::make_visible(bool p_visible) { +void CPUParticles3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { particles_editor->show(); @@ -128,18 +127,18 @@ void CPUParticlesEditorPlugin::make_visible(bool p_visible) { } else { particles_editor->particles_editor_hb->hide(); particles_editor->hide(); - particles_editor->edit(NULL); + particles_editor->edit(nullptr); } } -CPUParticlesEditorPlugin::CPUParticlesEditorPlugin(EditorNode *p_node) { +CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) { editor = p_node; - particles_editor = memnew(CPUParticlesEditor); + particles_editor = memnew(CPUParticles3DEditor); editor->get_viewport()->add_child(particles_editor); particles_editor->hide(); } -CPUParticlesEditorPlugin::~CPUParticlesEditorPlugin() { +CPUParticles3DEditorPlugin::~CPUParticles3DEditorPlugin() { } diff --git a/editor/plugins/cpu_particles_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index 4cf143fc0c..796c842e07 100644 --- a/editor/plugins/cpu_particles_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* cpu_particles_editor_plugin.h */ +/* cpu_particles_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,12 +31,12 @@ #ifndef CPU_PARTICLES_EDITOR_PLUGIN_H #define CPU_PARTICLES_EDITOR_PLUGIN_H -#include "editor/plugins/particles_editor_plugin.h" -#include "scene/3d/cpu_particles.h" +#include "editor/plugins/gpu_particles_3d_editor_plugin.h" +#include "scene/3d/cpu_particles_3d.h" -class CPUParticlesEditor : public ParticlesEditorBase { +class CPUParticles3DEditor : public GPUParticles3DEditorBase { - GDCLASS(CPUParticlesEditor, ParticlesEditorBase); + GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase); enum Menu { @@ -46,11 +46,11 @@ class CPUParticlesEditor : public ParticlesEditorBase { }; - CPUParticles *node; + CPUParticles3D *node; void _menu_option(int); - friend class CPUParticlesEditorPlugin; + friend class CPUParticles3DEditorPlugin; virtual void _generate_emission_points(); @@ -60,26 +60,26 @@ protected: static void _bind_methods(); public: - void edit(CPUParticles *p_particles); - CPUParticlesEditor(); + void edit(CPUParticles3D *p_particles); + CPUParticles3DEditor(); }; -class CPUParticlesEditorPlugin : public EditorPlugin { +class CPUParticles3DEditorPlugin : public EditorPlugin { - GDCLASS(CPUParticlesEditorPlugin, EditorPlugin); + GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin); - CPUParticlesEditor *particles_editor; + CPUParticles3DEditor *particles_editor; EditorNode *editor; public: - virtual String get_name() const { return "CPUParticles"; } + virtual String get_name() const { return "CPUParticles3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - CPUParticlesEditorPlugin(EditorNode *p_node); - ~CPUParticlesEditorPlugin(); + CPUParticles3DEditorPlugin(EditorNode *p_node); + ~CPUParticles3DEditorPlugin(); }; #endif // CPU_PARTICLES_EDITOR_PLUGIN_H diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 878787231d..71c5a78e0b 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "canvas_item_editor_plugin.h" #include "core/core_string_names.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" @@ -210,7 +210,7 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { else tangent = 9999 * (dir.y >= 0 ? 1 : -1); - bool link = !Input::get_singleton()->is_key_pressed(KEY_SHIFT); + bool link = !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); if (_selected_tangent == TANGENT_LEFT) { curve.set_point_left_tangent(_selected_point, tangent); @@ -511,7 +511,7 @@ void CurveEditor::set_hover_point_index(int index) { } void CurveEditor::update_view_transform() { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); const real_t margin = font->get_height() + 2 * EDSCALE; float min_y = 0; @@ -626,7 +626,7 @@ void CurveEditor::_draw() { // Background Vector2 view_size = get_rect().size; - draw_style_box(get_stylebox("bg", "Tree"), Rect2(Point2(), view_size)); + draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), view_size)); // Grid @@ -635,8 +635,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_color("mono_color", "Editor") * Color(1, 1, 1, 0.15); - const Color grid_color1 = get_color("mono_color", "Editor") * Color(1, 1, 1, 0.07); + 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); 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); @@ -656,9 +656,9 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); float font_height = font->get_height(); - Color text_color = get_color("font_color", "Editor"); + Color text_color = get_theme_color("font_color", "Editor"); { // X axis @@ -686,7 +686,7 @@ void CurveEditor::_draw() { if (_selected_point >= 0) { - const Color tangent_color = get_color("accent_color", "Editor"); + const Color tangent_color = get_theme_color("accent_color", "Editor"); int i = _selected_point; Vector2 pos = curve.get_point_position(i); @@ -708,8 +708,8 @@ void CurveEditor::_draw() { draw_set_transform_matrix(_world_to_view); - const Color line_color = get_color("font_color", "Editor"); - const Color edge_line_color = get_color("highlight_color", "Editor"); + const Color line_color = get_theme_color("font_color", "Editor"); + const Color edge_line_color = get_theme_color("highlight_color", "Editor"); CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color); plot_curve_accurate(curve, 4.f / view_size.x, plot_func); @@ -718,8 +718,8 @@ void CurveEditor::_draw() { draw_set_transform_matrix(Transform2D()); - const Color point_color = get_color("font_color", "Editor"); - const Color selected_point_color = get_color("accent_color", "Editor"); + const Color point_color = get_theme_color("font_color", "Editor"); + const Color selected_point_color = get_theme_color("accent_color", "Editor"); for (int i = 0; i < curve.get_point_count(); ++i) { Vector2 pos = curve.get_point_position(i); @@ -755,7 +755,7 @@ void CurveEditor::_bind_methods() { bool EditorInspectorPluginCurve::can_handle(Object *p_object) { - return Object::cast_to<Curve>(p_object) != NULL; + return Object::cast_to<Curve>(p_object) != nullptr; } void EditorInspectorPluginCurve::parse_begin(Object *p_object) { diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index c4069ac2ab..566ff378c3 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -54,7 +54,6 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d // Main editor debug menu. debug_menu = p_debug_menu; PopupMenu *p = debug_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); p->set_hide_on_checkable_item_selection(false); p->add_check_shortcut(ED_SHORTCUT("editor/deploy_with_remote_debug", TTR("Deploy with Remote Debug")), RUN_DEPLOY_REMOTE_DEBUG); p->set_item_tooltip(p->get_item_count() - 1, TTR("When exporting or deploying, the resulting executable will attempt to connect to the IP of this computer in order to be debugged.")); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 3c173ab783..a8c4bddccf 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -328,19 +328,19 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si if (material->get_shader_mode() == Shader::MODE_SPATIAL) { - VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); + RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done = false; - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); - VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); + RS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); @@ -358,35 +358,35 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { - scenario = VS::get_singleton()->scenario_create(); + scenario = RS::get_singleton()->scenario_create(); - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); - VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); - VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); + camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); + RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); - light = VS::get_singleton()->directional_light_create(); - light_instance = VS::get_singleton()->instance_create2(light, scenario); - VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light = RS::get_singleton()->directional_light_create(); + light_instance = RS::get_singleton()->instance_create2(light, scenario); + RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + //RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); - sphere = VS::get_singleton()->mesh_create(); - sphere_instance = VS::get_singleton()->instance_create2(sphere, scenario); + sphere = RS::get_singleton()->mesh_create(); + sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario); int lats = 32; int lons = 32; @@ -453,25 +453,25 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { } Array arr; - arr.resize(VS::ARRAY_MAX); - arr[VS::ARRAY_VERTEX] = vertices; - arr[VS::ARRAY_NORMAL] = normals; - arr[VS::ARRAY_TANGENT] = tangents; - arr[VS::ARRAY_TEX_UV] = uvs; - VS::get_singleton()->mesh_add_surface_from_arrays(sphere, VS::PRIMITIVE_TRIANGLES, arr); + arr.resize(RS::ARRAY_MAX); + arr[RS::ARRAY_VERTEX] = vertices; + arr[RS::ARRAY_NORMAL] = normals; + arr[RS::ARRAY_TANGENT] = tangents; + arr[RS::ARRAY_TEX_UV] = uvs; + RS::get_singleton()->mesh_add_surface_from_arrays(sphere, RS::PRIMITIVE_TRIANGLES, arr); } EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() { - VS::get_singleton()->free(sphere); - VS::get_singleton()->free(sphere_instance); - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + RS::get_singleton()->free(sphere); + RS::get_singleton()->free(sphere_instance); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); } /////////////////////////////////////////////////////////////////////////// @@ -706,7 +706,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 Ref<Mesh> mesh = p_from; ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>()); - VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); + RS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; @@ -723,21 +723,21 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 xform.basis.scale(Vector3(m, m, m)); xform.origin = -xform.basis.xform(ofs); //-ofs*m; xform.origin.z -= rot_aabb.size.z * 2; - VS::get_singleton()->instance_set_transform(mesh_instance, xform); + RS::get_singleton()->instance_set_transform(mesh_instance, xform); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done = false; - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); - VS::get_singleton()->instance_set_base(mesh_instance, RID()); + RS::get_singleton()->instance_set_base(mesh_instance, RID()); img->convert(Image::FORMAT_RGBA8); @@ -759,49 +759,49 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { - scenario = VS::get_singleton()->scenario_create(); + scenario = RS::get_singleton()->scenario_create(); - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); - VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); - //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); - VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); + camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); + RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + //RS::get_singleton()->camera_set_perspective(camera,45,0.1,10); + RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - light = VS::get_singleton()->directional_light_create(); - light_instance = VS::get_singleton()->instance_create2(light, scenario); - VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light = RS::get_singleton()->directional_light_create(); + light_instance = RS::get_singleton()->instance_create2(light, scenario); + RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); - light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + //RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); + light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - VS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); - //sphere = VS::get_singleton()->mesh_create(); - mesh_instance = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_scenario(mesh_instance, scenario); + //sphere = RS::get_singleton()->mesh_create(); + mesh_instance = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_scenario(mesh_instance, scenario); } EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { - //VS::get_singleton()->free(sphere); - VS::get_singleton()->free(mesh_instance); - VS::get_singleton()->free(viewport); - VS::get_singleton()->free(light); - VS::get_singleton()->free(light_instance); - VS::get_singleton()->free(light2); - VS::get_singleton()->free(light_instance2); - VS::get_singleton()->free(camera); - VS::get_singleton()->free(scenario); + //RS::get_singleton()->free(sphere); + RS::get_singleton()->free(mesh_instance); + RS::get_singleton()->free(viewport); + RS::get_singleton()->free(light); + RS::get_singleton()->free(light_instance); + RS::get_singleton()->free(light2); + RS::get_singleton()->free(light_instance2); + RS::get_singleton()->free(camera); + RS::get_singleton()->free(scenario); } /////////////////////////////////////////////////////////////////////////// @@ -849,16 +849,16 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, font->draw(canvas_item, pos, sampled_text); preview_done = false; - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture + RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); while (!preview_done) { OS::get_singleton()->delay_usec(10); } - VS::get_singleton()->canvas_item_clear(canvas_item); + RS::get_singleton()->canvas_item_clear(canvas_item); - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); img->convert(Image::FORMAT_RGBA8); @@ -891,22 +891,22 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 EditorFontPreviewPlugin::EditorFontPreviewPlugin() { - viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_DISABLED); - VS::get_singleton()->viewport_set_size(viewport, 128, 128); - VS::get_singleton()->viewport_set_active(viewport, true); - viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_DISABLED); + RS::get_singleton()->viewport_set_size(viewport, 128, 128); + RS::get_singleton()->viewport_set_active(viewport, true); + viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - canvas = VS::get_singleton()->canvas_create(); - canvas_item = VS::get_singleton()->canvas_item_create(); + canvas = RS::get_singleton()->canvas_create(); + canvas_item = RS::get_singleton()->canvas_item_create(); - VS::get_singleton()->viewport_attach_canvas(viewport, canvas); - VS::get_singleton()->canvas_item_set_parent(canvas_item, canvas); + RS::get_singleton()->viewport_attach_canvas(viewport, canvas); + RS::get_singleton()->canvas_item_set_parent(canvas_item, canvas); } EditorFontPreviewPlugin::~EditorFontPreviewPlugin() { - VS::get_singleton()->free(canvas_item); - VS::get_singleton()->free(canvas); - VS::get_singleton()->free(viewport); + RS::get_singleton()->free(canvas_item); + RS::get_singleton()->free(canvas); + RS::get_singleton()->free(viewport); } diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp index c077c23e8a..6a171c4703 100644 --- a/editor/plugins/gi_probe_editor_plugin.cpp +++ b/editor/plugins/gi_probe_editor_plugin.cpp @@ -87,16 +87,16 @@ void GIProbeEditorPlugin::_notification(int p_what) { Color color; if (size_mb <= 16.0 + CMP_EPSILON) { // Fast. - color = bake_info->get_color("success_color", "Editor"); + color = bake_info->get_theme_color("success_color", "Editor"); } else if (size_mb <= 64.0 + CMP_EPSILON) { // Medium. - color = bake_info->get_color("warning_color", "Editor"); + color = bake_info->get_theme_color("warning_color", "Editor"); } else { // Slow. - color = bake_info->get_color("error_color", "Editor"); + color = bake_info->get_theme_color("error_color", "Editor"); } + bake_info->add_theme_color_override("font_color", color); - bake_info->add_color_override("font_color", color); bake_info->set_text(text); } } @@ -113,25 +113,25 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) { } } -EditorProgress *GIProbeEditorPlugin::tmp_progress = NULL; +EditorProgress *GIProbeEditorPlugin::tmp_progress = nullptr; void GIProbeEditorPlugin::bake_func_begin(int p_steps) { - ERR_FAIL_COND(tmp_progress != NULL); + ERR_FAIL_COND(tmp_progress != nullptr); tmp_progress = memnew(EditorProgress("bake_gi", TTR("Bake GI Probe"), p_steps)); } void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); tmp_progress->step(p_description, p_step, false); } void GIProbeEditorPlugin::bake_func_end() { - ERR_FAIL_COND(tmp_progress == NULL); + ERR_FAIL_COND(tmp_progress == nullptr); memdelete(tmp_progress); - tmp_progress = NULL; + tmp_progress = nullptr; } void GIProbeEditorPlugin::_giprobe_save_path_and_bake(const String &p_path) { @@ -153,7 +153,7 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); bake_hb->hide(); bake = memnew(ToolButton); - bake->set_icon(editor->get_gui_base()->get_icon("Bake", "EditorIcons")); + bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); bake->set_text(TTR("Bake GI Probe")); bake->connect("pressed", callable_mp(this, &GIProbeEditorPlugin::_bake)); bake_hb->add_child(bake); @@ -163,9 +163,9 @@ GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { bake_hb->add_child(bake_info); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, bake_hb); - gi_probe = NULL; + gi_probe = nullptr; probe_file = memnew(EditorFileDialog); - probe_file->set_mode(EditorFileDialog::MODE_SAVE_FILE); + probe_file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); probe_file->add_filter("*.res"); probe_file->connect("file_selected", callable_mp(this, &GIProbeEditorPlugin::_giprobe_save_path_and_bake)); get_editor_interface()->get_base_control()->add_child(probe_file); diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 812144742f..5c35285c22 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* particles_2d_editor_plugin.cpp */ +/* gpu_particles_2d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "particles_2d_editor_plugin.h" +#include "gpu_particles_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" #include "core/io/image_loader.h" @@ -36,17 +36,17 @@ #include "scene/gui/separator.h" #include "scene/resources/particles_material.h" -void Particles2DEditorPlugin::edit(Object *p_object) { +void GPUParticles2DEditorPlugin::edit(Object *p_object) { - particles = Object::cast_to<Particles2D>(p_object); + particles = Object::cast_to<GPUParticles2D>(p_object); } -bool Particles2DEditorPlugin::handles(Object *p_object) const { +bool GPUParticles2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Particles2D"); + return p_object->is_class("GPUParticles2D"); } -void Particles2DEditorPlugin::make_visible(bool p_visible) { +void GPUParticles2DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { @@ -57,13 +57,13 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) { } } -void Particles2DEditorPlugin::_file_selected(const String &p_file) { +void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) { source_emission_file = p_file; - emission_mask->popup_centered_minsize(); + emission_mask->popup_centered(); } -void Particles2DEditorPlugin::_menu_callback(int p_idx) { +void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { switch (p_idx) { case MENU_GENERATE_VISIBILITY_RECT: { @@ -72,7 +72,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { generate_seconds->set_value(1.0); else generate_seconds->set_value(trunc(gen_time) + 1.0); - generate_visibility_rect->popup_centered_minsize(); + generate_visibility_rect->popup_centered(); } break; case MENU_LOAD_EMISSION_MASK: { @@ -81,7 +81,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { } break; case MENU_CLEAR_EMISSION_MASK: { - emission_mask->popup_centered_minsize(); + emission_mask->popup_centered(); } break; case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { @@ -94,7 +94,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { cpu_particles->set_z_index(particles->get_z_index()); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Convert to CPUParticles")); + ur->create_action(TTR("Convert to CPUParticles2D")); ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", particles, cpu_particles, true, false); ur->add_do_reference(cpu_particles); ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, particles, false, false); @@ -109,7 +109,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { } } -void Particles2DEditorPlugin::_generate_visibility_rect() { +void GPUParticles2DEditorPlugin::_generate_visibility_rect() { float time = generate_seconds->get_value(); @@ -149,7 +149,7 @@ void Particles2DEditorPlugin::_generate_visibility_rect() { undo_redo->commit_action(); } -void Particles2DEditorPlugin::_generate_emission_mask() { +void GPUParticles2DEditorPlugin::_generate_emission_mask() { Ref<ParticlesMaterial> pm = particles->get_process_material(); if (!pm.is_valid()) { @@ -345,22 +345,22 @@ void Particles2DEditorPlugin::_generate_emission_mask() { } } -void Particles2DEditorPlugin::_notification(int p_what) { +void GPUParticles2DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - menu->get_popup()->connect("id_pressed", callable_mp(this, &Particles2DEditorPlugin::_menu_callback)); - menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons")); - file->connect("file_selected", callable_mp(this, &Particles2DEditorPlugin::_file_selected)); + menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); + menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons")); + file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); } } -void Particles2DEditorPlugin::_bind_methods() { +void GPUParticles2DEditorPlugin::_bind_methods() { } -Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { +GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = NULL; + particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); @@ -371,15 +371,12 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { toolbar->add_child(memnew(VSeparator)); menu = memnew(MenuButton); + menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); menu->get_popup()->add_item(TTR("Generate Visibility Rect"), MENU_GENERATE_VISIBILITY_RECT); - menu->get_popup()->add_separator(); menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK); // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK); - menu->get_popup()->add_separator(); - menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); - menu->get_popup()->add_separator(); - menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); - menu->set_text(TTR("Particles")); + menu->get_popup()->add_item(TTR("Convert to CPUParticles2D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); + menu->set_text(TTR("GPUParticles2D")); menu->set_switch_on_hover(true); toolbar->add_child(menu); @@ -389,7 +386,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { for (List<String>::Element *E = ext.front(); E; E = E->next()) { file->add_filter("*." + E->get() + "; " + E->get().to_upper()); } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); toolbar->add_child(file); epoints = memnew(SpinBox); @@ -411,7 +408,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { toolbar->add_child(generate_visibility_rect); - generate_visibility_rect->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_visibility_rect)); + generate_visibility_rect->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_visibility_rect)); emission_mask = memnew(ConfirmationDialog); emission_mask->set_title(TTR("Load Emission Mask")); @@ -428,8 +425,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { toolbar->add_child(emission_mask); - emission_mask->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_emission_mask)); + emission_mask->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_emission_mask)); } -Particles2DEditorPlugin::~Particles2DEditorPlugin() { +GPUParticles2DEditorPlugin::~GPUParticles2DEditorPlugin() { } diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 29652a1826..008d04a211 100644 --- a/editor/plugins/particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* particles_2d_editor_plugin.h */ +/* gpu_particles_2d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -34,13 +34,13 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "scene/2d/collision_polygon_2d.h" -#include "scene/2d/particles_2d.h" +#include "scene/2d/gpu_particles_2d.h" #include "scene/gui/box_container.h" #include "scene/gui/file_dialog.h" -class Particles2DEditorPlugin : public EditorPlugin { +class GPUParticles2DEditorPlugin : public EditorPlugin { - GDCLASS(Particles2DEditorPlugin, EditorPlugin); + GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin); enum { @@ -57,7 +57,7 @@ class Particles2DEditorPlugin : public EditorPlugin { EMISSION_MODE_BORDER_DIRECTED }; - Particles2D *particles; + GPUParticles2D *particles; EditorFileDialog *file; EditorNode *editor; @@ -87,14 +87,14 @@ protected: static void _bind_methods(); public: - virtual String get_name() const { return "Particles2D"; } + virtual String get_name() const { return "GPUParticles2D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - Particles2DEditorPlugin(EditorNode *p_node); - ~Particles2DEditorPlugin(); + GPUParticles2DEditorPlugin(EditorNode *p_node); + ~GPUParticles2DEditorPlugin(); }; #endif // PARTICLES_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index a4d704c6e1..7f80acc176 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* particles_editor_plugin.cpp */ +/* gpu_particles_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,14 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "particles_editor_plugin.h" +#include "gpu_particles_3d_editor_plugin.h" #include "core/io/resource_loader.h" -#include "editor/plugins/spatial_editor_plugin.h" -#include "scene/3d/cpu_particles.h" +#include "editor/plugins/node_3d_editor_plugin.h" +#include "scene/3d/cpu_particles_3d.h" #include "scene/resources/particles_material.h" -bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) { +bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) { bool use_normals = emission_fill->get_selected() == 1; @@ -161,26 +161,26 @@ bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &no return true; } -void ParticlesEditorBase::_node_selected(const NodePath &p_path) { +void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) { Node *sel = get_node(p_path); if (!sel) return; - if (!sel->is_class("Spatial")) { + if (!sel->is_class("Node3D")) { - EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Spatial."), sel->get_name())); + EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Node3D."), sel->get_name())); return; } - VisualInstance *vi = Object::cast_to<VisualInstance>(sel); + VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sel); if (!vi) { EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name())); return; } - geometry = vi->get_faces(VisualInstance::FACES_SOLID); + geometry = vi->get_faces(VisualInstance3D::FACES_SOLID); if (geometry.size() == 0) { @@ -202,10 +202,10 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) { emission_dialog->popup_centered(Size2(300, 130)); } -void ParticlesEditorBase::_bind_methods() { +void GPUParticles3DEditorBase::_bind_methods() { } -ParticlesEditorBase::ParticlesEditorBase() { +GPUParticles3DEditorBase::GPUParticles3DEditorBase() { emission_dialog = memnew(ConfirmationDialog); emission_dialog->set_title(TTR("Create Emitter")); @@ -226,30 +226,30 @@ ParticlesEditorBase::ParticlesEditorBase() { emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill); emission_dialog->get_ok()->set_text(TTR("Create")); - emission_dialog->connect("confirmed", callable_mp(this, &ParticlesEditorBase::_generate_emission_points)); + emission_dialog->connect("confirmed", callable_mp(this, &GPUParticles3DEditorBase::_generate_emission_points)); emission_tree_dialog = memnew(SceneTreeDialog); add_child(emission_tree_dialog); - emission_tree_dialog->connect("selected", callable_mp(this, &ParticlesEditorBase::_node_selected)); + emission_tree_dialog->connect("selected", callable_mp(this, &GPUParticles3DEditorBase::_node_selected)); } -void ParticlesEditor::_node_removed(Node *p_node) { +void GPUParticles3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } -void ParticlesEditor::_notification(int p_notification) { +void GPUParticles3DEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE) { - options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons")); - get_tree()->connect("node_removed", callable_mp(this, &ParticlesEditor::_node_removed)); + options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons")); + get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); } } -void ParticlesEditor::_menu_option(int p_option) { +void GPUParticles3DEditor::_menu_option(int p_option) { switch (p_option) { @@ -260,7 +260,7 @@ void ParticlesEditor::_menu_option(int p_option) { generate_seconds->set_value(1.0); else generate_seconds->set_value(trunc(gen_time) + 1.0); - generate_aabb->popup_centered_minsize(); + generate_aabb->popup_centered(); } break; case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { Ref<ParticlesMaterial> material = node->get_process_material(); @@ -274,7 +274,7 @@ void ParticlesEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { - CPUParticles *cpu_particles = memnew(CPUParticles); + CPUParticles3D *cpu_particles = memnew(CPUParticles3D); cpu_particles->convert_from_particles(node); cpu_particles->set_name(node->get_name()); cpu_particles->set_transform(node->get_transform()); @@ -282,7 +282,7 @@ void ParticlesEditor::_menu_option(int p_option) { cpu_particles->set_pause_mode(node->get_pause_mode()); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action(TTR("Convert to CPUParticles")); + ur->create_action(TTR("Convert to CPUParticles3D")); ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false); ur->add_do_reference(cpu_particles); ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false); @@ -298,7 +298,7 @@ void ParticlesEditor::_menu_option(int p_option) { } } -void ParticlesEditor::_generate_aabb() { +void GPUParticles3DEditor::_generate_aabb() { float time = generate_seconds->get_value(); @@ -340,13 +340,13 @@ void ParticlesEditor::_generate_aabb() { ur->commit_action(); } -void ParticlesEditor::edit(Particles *p_particles) { +void GPUParticles3DEditor::edit(GPUParticles3D *p_particles) { base_node = p_particles; node = p_particles; } -void ParticlesEditor::_generate_emission_points() { +void GPUParticles3DEditor::_generate_emission_points() { /// hacer codigo aca Vector<Vector3> points; @@ -419,29 +419,26 @@ void ParticlesEditor::_generate_emission_points() { } } -void ParticlesEditor::_bind_methods() { +void GPUParticles3DEditor::_bind_methods() { } -ParticlesEditor::ParticlesEditor() { +GPUParticles3DEditor::GPUParticles3DEditor() { - node = NULL; + node = nullptr; particles_editor_hb = memnew(HBoxContainer); - SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); + Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); options = memnew(MenuButton); options->set_switch_on_hover(true); particles_editor_hb->add_child(options); particles_editor_hb->hide(); - options->set_text(TTR("Particles")); + options->set_text(TTR("GPUParticles3D")); + options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB); - options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); - options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); - options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); + options->get_popup()->add_item(TTR("Convert to CPUParticles3D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); - options->get_popup()->connect("id_pressed", callable_mp(this, &ParticlesEditor::_menu_option)); + options->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles3DEditor::_menu_option)); generate_aabb = memnew(ConfirmationDialog); generate_aabb->set_title(TTR("Generate Visibility AABB")); @@ -455,20 +452,20 @@ ParticlesEditor::ParticlesEditor() { add_child(generate_aabb); - generate_aabb->connect("confirmed", callable_mp(this, &ParticlesEditor::_generate_aabb)); + generate_aabb->connect("confirmed", callable_mp(this, &GPUParticles3DEditor::_generate_aabb)); } -void ParticlesEditorPlugin::edit(Object *p_object) { +void GPUParticles3DEditorPlugin::edit(Object *p_object) { - particles_editor->edit(Object::cast_to<Particles>(p_object)); + particles_editor->edit(Object::cast_to<GPUParticles3D>(p_object)); } -bool ParticlesEditorPlugin::handles(Object *p_object) const { +bool GPUParticles3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Particles"); + return p_object->is_class("GPUParticles3D"); } -void ParticlesEditorPlugin::make_visible(bool p_visible) { +void GPUParticles3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { particles_editor->show(); @@ -476,18 +473,18 @@ void ParticlesEditorPlugin::make_visible(bool p_visible) { } else { particles_editor->particles_editor_hb->hide(); particles_editor->hide(); - particles_editor->edit(NULL); + particles_editor->edit(nullptr); } } -ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) { +GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) { editor = p_node; - particles_editor = memnew(ParticlesEditor); + particles_editor = memnew(GPUParticles3DEditor); editor->get_viewport()->add_child(particles_editor); particles_editor->hide(); } -ParticlesEditorPlugin::~ParticlesEditorPlugin() { +GPUParticles3DEditorPlugin::~GPUParticles3DEditorPlugin() { } diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index fb5ce17560..cf1cff32c0 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* particles_editor_plugin.h */ +/* gpu_particles_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,15 +33,15 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/particles.h" +#include "scene/3d/gpu_particles_3d.h" #include "scene/gui/spin_box.h" -class ParticlesEditorBase : public Control { +class GPUParticles3DEditorBase : public Control { - GDCLASS(ParticlesEditorBase, Control); + GDCLASS(GPUParticles3DEditorBase, Control); protected: - Spatial *base_node; + Node3D *base_node; Panel *panel; MenuButton *options; HBoxContainer *particles_editor_hb; @@ -61,16 +61,16 @@ protected: static void _bind_methods(); public: - ParticlesEditorBase(); + GPUParticles3DEditorBase(); }; -class ParticlesEditor : public ParticlesEditorBase { +class GPUParticles3DEditor : public GPUParticles3DEditorBase { - GDCLASS(ParticlesEditor, ParticlesEditorBase); + GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase); ConfirmationDialog *generate_aabb; SpinBox *generate_seconds; - Particles *node; + GPUParticles3D *node; enum Menu { @@ -86,7 +86,7 @@ class ParticlesEditor : public ParticlesEditorBase { void _menu_option(int); - friend class ParticlesEditorPlugin; + friend class GPUParticles3DEditorPlugin; virtual void _generate_emission_points(); @@ -96,26 +96,26 @@ protected: static void _bind_methods(); public: - void edit(Particles *p_particles); - ParticlesEditor(); + void edit(GPUParticles3D *p_particles); + GPUParticles3DEditor(); }; -class ParticlesEditorPlugin : public EditorPlugin { +class GPUParticles3DEditorPlugin : public EditorPlugin { - GDCLASS(ParticlesEditorPlugin, EditorPlugin); + GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin); - ParticlesEditor *particles_editor; + GPUParticles3DEditor *particles_editor; EditorNode *editor; public: - virtual String get_name() const { return "Particles"; } + virtual String get_name() const { return "GPUParticles3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - ParticlesEditorPlugin(EditorNode *p_node); - ~ParticlesEditorPlugin(); + GPUParticles3DEditorPlugin(EditorNode *p_node); + ~GPUParticles3DEditorPlugin(); }; #endif // PARTICLES_EDITOR_PLUGIN_H diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index ff03fcf159..67de610ae7 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "canvas_item_editor_plugin.h" #include "editor/editor_scale.h" -#include "spatial_editor_plugin.h" +#include "node_3d_editor_plugin.h" Size2 GradientEditor::get_minimum_size() const { return Size2(0, 60) * EDSCALE; @@ -79,7 +79,7 @@ GradientEditor::GradientEditor() { bool EditorInspectorPluginGradient::can_handle(Object *p_object) { - return Object::cast_to<Gradient>(p_object) != NULL; + return Object::cast_to<Gradient>(p_object) != nullptr; } void EditorInspectorPluginGradient::parse_begin(Object *p_object) { diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index ba640883c7..1dbc78804b 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -163,7 +163,7 @@ void ItemListOptionButtonPlugin::erase(int p_idx) { ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() { - ob = NULL; + ob = nullptr; } /////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ void ItemListPopupMenuPlugin::erase(int p_idx) { ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() { - pp = NULL; + pp = nullptr; } /////////////////////////////////////////////////////////////// @@ -244,7 +244,7 @@ void ItemListItemListPlugin::erase(int p_idx) { ItemListItemListPlugin::ItemListItemListPlugin() { - pp = NULL; + pp = nullptr; } /////////////////////////////////////////////////////////////// @@ -254,7 +254,7 @@ ItemListItemListPlugin::ItemListItemListPlugin() { void ItemListEditor::_node_removed(Node *p_node) { if (p_node == item_list) { - item_list = NULL; + item_list = nullptr; hide(); dialog->hide(); } @@ -264,8 +264,8 @@ void ItemListEditor::_notification(int p_notification) { if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) { - add_button->set_icon(get_icon("Add", "EditorIcons")); - del_button->set_icon(get_icon("Remove", "EditorIcons")); + add_button->set_icon(get_theme_icon("Add", "EditorIcons")); + del_button->set_icon(get_theme_icon("Remove", "EditorIcons")); } else if (p_notification == NOTIFICATION_READY) { get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed)); @@ -311,7 +311,7 @@ void ItemListEditor::edit(Node *p_item_list) { if (!item_list) { selected_idx = -1; - property_editor->edit(NULL); + property_editor->edit(nullptr); return; } @@ -329,7 +329,7 @@ void ItemListEditor::edit(Node *p_item_list) { } selected_idx = -1; - property_editor->edit(NULL); + property_editor->edit(nullptr); } bool ItemListEditor::handles(Object *p_object) const { @@ -349,7 +349,7 @@ void ItemListEditor::_bind_methods() { ItemListEditor::ItemListEditor() { selected_idx = -1; - item_list = NULL; + item_list = nullptr; toolbar_button = memnew(ToolButton); toolbar_button->set_text(TTR("Items")); @@ -408,7 +408,7 @@ void ItemListEditorPlugin::make_visible(bool p_visible) { } else { item_list_editor->hide(); - item_list_editor->edit(NULL); + item_list_editor->edit(nullptr); } } diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 22df287f97..f8550a884b 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -112,7 +112,7 @@ void LightOccluder2DEditor::_create_resource() { LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } LightOccluder2DEditorPlugin::LightOccluder2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 4ac9d0af3b..5b887390a6 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -64,7 +64,7 @@ void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, con Line2DEditor::Line2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index b39465f618..eb14495b9c 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -31,8 +31,9 @@ #include "material_editor_plugin.h" #include "editor/editor_scale.h" -#include "scene/gui/viewport_container.h" +#include "scene/gui/subviewport_container.h" #include "scene/resources/particles_material.h" +#include "scene/resources/sky_material.h" void MaterialEditor::_notification(int p_what) { @@ -43,15 +44,15 @@ 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_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons")); + 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")); - sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff", "EditorIcons")); - sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere", "EditorIcons")); - box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff", "EditorIcons")); - box_switch->set_pressed_texture(get_icon("MaterialPreviewCube", "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")); first_enter = false; } @@ -59,7 +60,7 @@ void MaterialEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -94,6 +95,7 @@ void MaterialEditor::_button_pressed(Node *p_button) { sphere_instance->hide(); box_switch->set_pressed(true); sphere_switch->set_pressed(false); + EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", false); } if (p_button == sphere_switch) { @@ -101,6 +103,7 @@ void MaterialEditor::_button_pressed(Node *p_button) { sphere_instance->show(); box_switch->set_pressed(false); sphere_switch->set_pressed(true); + EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", true); } } @@ -109,12 +112,12 @@ void MaterialEditor::_bind_methods() { MaterialEditor::MaterialEditor() { - vc = memnew(ViewportContainer); + vc = memnew(SubViewportContainer); vc->set_stretch(true); add_child(vc); vc->set_anchors_and_margins_preset(PRESET_WIDE); - viewport = memnew(Viewport); - Ref<World> world; + viewport = memnew(SubViewport); + Ref<World3D> world; world.instance(); viewport->set_world(world); //use own world vc->add_child(viewport); @@ -122,25 +125,25 @@ MaterialEditor::MaterialEditor() { viewport->set_transparent_background(true); viewport->set_msaa(Viewport::MSAA_4X); - camera = memnew(Camera); + camera = memnew(Camera3D); camera->set_transform(Transform(Basis(), Vector3(0, 0, 3))); camera->set_perspective(45, 0.1, 10); camera->make_current(); viewport->add_child(camera); - light1 = memnew(DirectionalLight); + light1 = memnew(DirectionalLight3D); light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); viewport->add_child(light1); - light2 = memnew(DirectionalLight); + light2 = memnew(DirectionalLight3D); light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_color(Color(0.7, 0.7, 0.7)); viewport->add_child(light2); - sphere_instance = memnew(MeshInstance); + sphere_instance = memnew(MeshInstance3D); viewport->add_child(sphere_instance); - box_instance = memnew(MeshInstance); + box_instance = memnew(MeshInstance3D); viewport->add_child(box_instance); Transform box_xform; @@ -154,7 +157,6 @@ MaterialEditor::MaterialEditor() { sphere_instance->set_mesh(sphere_mesh); box_mesh.instance(); box_instance->set_mesh(box_mesh); - box_instance->hide(); set_custom_minimum_size(Size2(1, 150) * EDSCALE); @@ -193,6 +195,15 @@ MaterialEditor::MaterialEditor() { light_2_switch->connect("pressed", callable_mp(this, &MaterialEditor::_button_pressed), varray(light_2_switch)); first_enter = true; + + if (EditorSettings::get_singleton()->get_project_metadata("inspector_options", "material_preview_on_sphere", true)) { + box_instance->hide(); + } else { + box_instance->show(); + sphere_instance->hide(); + box_switch->set_pressed(true); + sphere_switch->set_pressed(false); + } } /////////////////////// @@ -221,8 +232,8 @@ void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() { env.instance(); - Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true)); - env->set_sky(proc_sky); + Ref<Sky> sky = memnew(Sky()); + env->set_sky(sky); env->set_background(Environment::BG_COLOR); env->set_ambient_source(Environment::AMBIENT_SOURCE_SKY); env->set_reflection_source(Environment::REFLECTION_SOURCE_SKY); @@ -255,14 +266,14 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { @@ -272,7 +283,7 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p if (texture.is_valid()) { smat->set_shader_param(E->get().name, texture); } else { - Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } } @@ -301,17 +312,17 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + 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 = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } @@ -339,17 +350,131 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p Ref<Shader> shader; shader.instance(); - String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + 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); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String ProceduralSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + 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); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PanoramaSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + 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); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PhysicalSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = RS::get_singleton()->shader_get_code(mat->get_shader_rid()); shader->set_code(code); smat->set_shader(shader); List<PropertyInfo> params; - VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + 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 = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); smat->set_shader_param(E->get().name, value); } diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 95a6c4bf8f..50036e4f72 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -36,24 +36,24 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/camera.h" -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/resources/material.h" -class ViewportContainer; +class SubViewportContainer; class MaterialEditor : public Control { GDCLASS(MaterialEditor, Control); - ViewportContainer *vc; - Viewport *viewport; - MeshInstance *sphere_instance; - MeshInstance *box_instance; - DirectionalLight *light1; - DirectionalLight *light2; - Camera *camera; + SubViewportContainer *vc; + SubViewport *viewport; + MeshInstance3D *sphere_instance; + MeshInstance3D *box_instance; + DirectionalLight3D *light1; + DirectionalLight3D *light2; + Camera3D *camera; Ref<SphereMesh> sphere_mesh; Ref<CubeMesh> box_mesh; @@ -127,4 +127,31 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; +class ProceduralSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(ProceduralSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PanoramaSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PanoramaSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PhysicalSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PhysicalSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 5a17f0d4f1..5e657c3b71 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -57,10 +57,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_icon("MaterialPreviewLight1", "EditorIcons")); - light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons")); - light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons")); - light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons")); + 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")); first_enter = false; } } @@ -115,31 +115,31 @@ void MeshEditor::_bind_methods() { MeshEditor::MeshEditor() { - viewport = memnew(Viewport); - Ref<World> world; + viewport = memnew(SubViewport); + Ref<World3D> world; world.instance(); viewport->set_world(world); //use own world add_child(viewport); viewport->set_disable_input(true); viewport->set_msaa(Viewport::MSAA_2X); set_stretch(true); - camera = memnew(Camera); + camera = memnew(Camera3D); camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1))); camera->set_perspective(45, 0.1, 10); viewport->add_child(camera); - light1 = memnew(DirectionalLight); + light1 = memnew(DirectionalLight3D); light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); viewport->add_child(light1); - light2 = memnew(DirectionalLight); + light2 = memnew(DirectionalLight3D); light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_color(Color(0.7, 0.7, 0.7)); viewport->add_child(light2); - rotation = memnew(Spatial); + rotation = memnew(Node3D); viewport->add_child(rotation); - mesh_instance = memnew(MeshInstance); + mesh_instance = memnew(MeshInstance3D); rotation->add_child(mesh_instance); set_custom_minimum_size(Size2(1, 150) * EDSCALE); @@ -173,7 +173,7 @@ MeshEditor::MeshEditor() { bool EditorInspectorPluginMesh::can_handle(Object *p_object) { - return Object::cast_to<Mesh>(p_object) != NULL; + return Object::cast_to<Mesh>(p_object) != nullptr; } void EditorInspectorPluginMesh::parse_begin(Object *p_object) { diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 87c4a1776b..072e21f260 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -33,25 +33,25 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/camera.h" -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" -#include "scene/gui/viewport_container.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/gui/subviewport_container.h" #include "scene/resources/material.h" -class MeshEditor : public ViewportContainer { +class MeshEditor : public SubViewportContainer { - GDCLASS(MeshEditor, ViewportContainer); + GDCLASS(MeshEditor, SubViewportContainer); float rot_x; float rot_y; - Viewport *viewport; - MeshInstance *mesh_instance; - Spatial *rotation; - DirectionalLight *light1; - DirectionalLight *light2; - Camera *camera; + SubViewport *viewport; + MeshInstance3D *mesh_instance; + Node3D *rotation; + DirectionalLight3D *light1; + DirectionalLight3D *light2; + Camera3D *camera; Ref<Mesh> mesh; diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 6025e7dd9d..7819f62bc7 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* mesh_instance_editor_plugin.cpp */ +/* mesh_instance_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,34 +28,34 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "mesh_instance_editor_plugin.h" +#include "mesh_instance_3d_editor_plugin.h" #include "editor/editor_scale.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/navigation_region.h" -#include "scene/3d/physics_body.h" +#include "node_3d_editor_plugin.h" +#include "scene/3d/collision_shape_3d.h" +#include "scene/3d/navigation_region_3d.h" +#include "scene/3d/physics_body_3d.h" #include "scene/gui/box_container.h" -#include "spatial_editor_plugin.h" -void MeshInstanceEditor::_node_removed(Node *p_node) { +void MeshInstance3DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } -void MeshInstanceEditor::edit(MeshInstance *p_mesh) { +void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) { node = p_mesh; } -void MeshInstanceEditor::_menu_option(int p_option) { +void MeshInstance3DEditor::_menu_option(int p_option) { Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { err_dialog->set_text(TTR("Mesh is empty!")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -68,16 +68,16 @@ void MeshInstanceEditor::_menu_option(int p_option) { List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.empty()) { - Ref<Shape> shape = mesh->create_trimesh_shape(); + Ref<Shape3D> shape = mesh->create_trimesh_shape(); if (shape.is_null()) { err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); - StaticBody *body = memnew(StaticBody); + StaticBody3D *body = memnew(StaticBody3D); body->add_child(cshape); Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); @@ -96,7 +96,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - MeshInstance *instance = Object::cast_to<MeshInstance>(E->get()); + MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get()); if (!instance) continue; @@ -104,13 +104,13 @@ void MeshInstanceEditor::_menu_option(int p_option) { if (m.is_null()) continue; - Ref<Shape> shape = m->create_trimesh_shape(); + Ref<Shape3D> shape = m->create_trimesh_shape(); if (shape.is_null()) continue; - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); - StaticBody *body = memnew(StaticBody); + StaticBody3D *body = memnew(StaticBody3D); body->add_child(cshape); Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner(); @@ -130,15 +130,15 @@ void MeshInstanceEditor::_menu_option(int p_option) { if (node == get_tree()->get_edited_scene_root()) { err_dialog->set_text(TTR("This doesn't work on scene root!")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - Ref<Shape> shape = mesh->create_trimesh_shape(); + Ref<Shape3D> shape = mesh->create_trimesh_shape(); if (shape.is_null()) return; - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); Node *owner = node->get_owner(); @@ -158,22 +158,22 @@ void MeshInstanceEditor::_menu_option(int p_option) { if (node == get_tree()->get_edited_scene_root()) { err_dialog->set_text(TTR("Can't create a single convex collision shape for the scene root.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - Ref<Shape> shape = mesh->create_convex_shape(); + Ref<Shape3D> shape = mesh->create_convex_shape(); if (shape.is_null()) { err_dialog->set_text(TTR("Couldn't create a single convex collision shape.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Create Single Convex Shape")); - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); cshape->set_transform(node->get_transform()); @@ -192,15 +192,15 @@ void MeshInstanceEditor::_menu_option(int p_option) { if (node == get_tree()->get_edited_scene_root()) { err_dialog->set_text(TTR("Can't create multiple convex collision shapes for the scene root.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - Vector<Ref<Shape>> shapes = mesh->convex_decompose(); + Vector<Ref<Shape3D>> shapes = mesh->convex_decompose(); if (!shapes.size()) { err_dialog->set_text(TTR("Couldn't create any collision shapes.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -209,7 +209,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { for (int i = 0; i < shapes.size(); i++) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shapes[i]); cshape->set_transform(node->get_transform()); @@ -233,7 +233,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { return; nmesh->create_from_mesh(mesh); - NavigationRegion *nmi = memnew(NavigationRegion); + NavigationRegion3D *nmi = memnew(NavigationRegion3D); nmi->set_navigation_mesh(nmesh); Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); @@ -258,14 +258,14 @@ void MeshInstanceEditor::_menu_option(int p_option) { Ref<ArrayMesh> mesh2 = node->get_mesh(); if (!mesh2.is_valid()) { err_dialog->set_text(TTR("Contained Mesh is not of type ArrayMesh.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } Error err = mesh2->lightmap_unwrap(node->get_global_transform()); if (err != OK) { err_dialog->set_text(TTR("UV Unwrap failed, mesh may not be manifold?")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -274,7 +274,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { Ref<Mesh> mesh2 = node->get_mesh(); if (!mesh2.is_valid()) { err_dialog->set_text(TTR("No mesh to debug.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } _create_uv_lines(0); @@ -283,7 +283,7 @@ void MeshInstanceEditor::_menu_option(int p_option) { Ref<Mesh> mesh2 = node->get_mesh(); if (!mesh2.is_valid()) { err_dialog->set_text(TTR("No mesh to debug.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } _create_uv_lines(1); @@ -291,20 +291,20 @@ void MeshInstanceEditor::_menu_option(int p_option) { } } -struct MeshInstanceEditorEdgeSort { +struct MeshInstance3DEditorEdgeSort { Vector2 a; Vector2 b; - bool operator<(const MeshInstanceEditorEdgeSort &p_b) const { + bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const { if (a == p_b.a) return b < p_b.b; else return a < p_b.a; } - MeshInstanceEditorEdgeSort() {} - MeshInstanceEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) { + MeshInstance3DEditorEdgeSort() {} + MeshInstance3DEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) { if (p_a < p_b) { a = p_a; b = p_b; @@ -315,12 +315,12 @@ struct MeshInstanceEditorEdgeSort { } }; -void MeshInstanceEditor::_create_uv_lines(int p_layer) { +void MeshInstance3DEditor::_create_uv_lines(int p_layer) { Ref<Mesh> mesh = node->get_mesh(); ERR_FAIL_COND(!mesh.is_valid()); - Set<MeshInstanceEditorEdgeSort> edges; + Set<MeshInstance3DEditorEdgeSort> edges; uv_lines.clear(); for (int i = 0; i < mesh->get_surface_count(); i++) { if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES) @@ -330,33 +330,30 @@ void MeshInstanceEditor::_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->popup_centered_minsize(); + err_dialog->popup_centered(); return; } const Vector2 *r = uv.ptr(); Vector<int> indices = a[Mesh::ARRAY_INDEX]; - const int *ri; + const int *ri = nullptr; int ic; - bool use_indices; if (indices.size()) { ic = indices.size(); ri = indices.ptr(); - use_indices = true; } else { ic = uv.size(); - use_indices = false; } for (int j = 0; j < ic; j += 3) { for (int k = 0; k < 3; k++) { - MeshInstanceEditorEdgeSort edge; - if (use_indices) { + MeshInstance3DEditorEdgeSort edge; + if (ri) { edge.a = r[ri[j + k]]; edge.b = r[ri[j + ((k + 1) % 3)]]; } else { @@ -374,10 +371,10 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) { } } - debug_uv_dialog->popup_centered_minsize(); + debug_uv_dialog->popup_centered(); } -void MeshInstanceEditor::_debug_uv_draw() { +void MeshInstance3DEditor::_debug_uv_draw() { if (uv_lines.size() == 0) return; @@ -388,34 +385,34 @@ void MeshInstanceEditor::_debug_uv_draw() { debug_uv->draw_multiline(uv_lines, Color(1.0, 0.8, 0.7)); } -void MeshInstanceEditor::_create_outline_mesh() { +void MeshInstance3DEditor::_create_outline_mesh() { Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { - err_dialog->set_text(TTR("MeshInstance lacks a Mesh!")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("MeshInstance3D lacks a Mesh.")); + err_dialog->popup_centered(); return; } if (mesh->get_surface_count() == 0) { - err_dialog->set_text(TTR("Mesh has not surface to create outlines from!")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("Mesh has not surface to create outlines from.")); + err_dialog->popup_centered(); return; } else if (mesh->get_surface_count() == 1 && mesh->surface_get_primitive_type(0) != Mesh::PRIMITIVE_TRIANGLES) { - err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES!")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("Mesh primitive type is not PRIMITIVE_TRIANGLES.")); + err_dialog->popup_centered(); return; } Ref<Mesh> mesho = mesh->create_outline(outline_size->get_value()); if (mesho.is_null()) { - err_dialog->set_text(TTR("Could not create outline!")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("Could not create outline.")); + err_dialog->popup_centered(); return; } - MeshInstance *mi = memnew(MeshInstance); + MeshInstance3D *mi = memnew(MeshInstance3D); mi->set_mesh(mesho); Node *owner = node->get_owner(); if (get_tree()->get_edited_scene_root() == node) { @@ -434,20 +431,20 @@ void MeshInstanceEditor::_create_outline_mesh() { ur->commit_action(); } -void MeshInstanceEditor::_bind_methods() { +void MeshInstance3DEditor::_bind_methods() { } -MeshInstanceEditor::MeshInstanceEditor() { +MeshInstance3DEditor::MeshInstance3DEditor() { options = memnew(MenuButton); options->set_switch_on_hover(true); - SpatialEditor::get_singleton()->add_control_to_menu_panel(options); + Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text(TTR("Mesh")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MeshInstance", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "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 StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); + 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.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); @@ -459,13 +456,13 @@ MeshInstanceEditor::MeshInstanceEditor() { options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible.")); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the StandardMaterial Grow property when using that property isn't possible.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1); options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2); options->get_popup()->add_item(TTR("Unwrap UV2 for Lightmap/AO"), MENU_OPTION_CREATE_UV2); - options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstanceEditor::_menu_option)); + options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstance3DEditor::_menu_option)); outline_dialog = memnew(ConfirmationDialog); outline_dialog->set_title(TTR("Create Outline Mesh")); @@ -483,7 +480,7 @@ MeshInstanceEditor::MeshInstanceEditor() { outline_dialog_vbc->add_margin_child(TTR("Outline Size:"), outline_size); add_child(outline_dialog); - outline_dialog->connect("confirmed", callable_mp(this, &MeshInstanceEditor::_create_outline_mesh)); + outline_dialog->connect("confirmed", callable_mp(this, &MeshInstance3DEditor::_create_outline_mesh)); err_dialog = memnew(AcceptDialog); add_child(err_dialog); @@ -493,39 +490,39 @@ MeshInstanceEditor::MeshInstanceEditor() { add_child(debug_uv_dialog); debug_uv = memnew(Control); debug_uv->set_custom_minimum_size(Size2(600, 600) * EDSCALE); - debug_uv->connect("draw", callable_mp(this, &MeshInstanceEditor::_debug_uv_draw)); + debug_uv->connect("draw", callable_mp(this, &MeshInstance3DEditor::_debug_uv_draw)); debug_uv_dialog->add_child(debug_uv); } -void MeshInstanceEditorPlugin::edit(Object *p_object) { +void MeshInstance3DEditorPlugin::edit(Object *p_object) { - mesh_editor->edit(Object::cast_to<MeshInstance>(p_object)); + mesh_editor->edit(Object::cast_to<MeshInstance3D>(p_object)); } -bool MeshInstanceEditorPlugin::handles(Object *p_object) const { +bool MeshInstance3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("MeshInstance"); + return p_object->is_class("MeshInstance3D"); } -void MeshInstanceEditorPlugin::make_visible(bool p_visible) { +void MeshInstance3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { mesh_editor->options->show(); } else { mesh_editor->options->hide(); - mesh_editor->edit(NULL); + mesh_editor->edit(nullptr); } } -MeshInstanceEditorPlugin::MeshInstanceEditorPlugin(EditorNode *p_node) { +MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) { editor = p_node; - mesh_editor = memnew(MeshInstanceEditor); + mesh_editor = memnew(MeshInstance3DEditor); editor->get_viewport()->add_child(mesh_editor); mesh_editor->options->hide(); } -MeshInstanceEditorPlugin::~MeshInstanceEditorPlugin() { +MeshInstance3DEditorPlugin::~MeshInstance3DEditorPlugin() { } diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h index 5ca9aa3fec..a5d90c42d5 100644 --- a/editor/plugins/mesh_instance_editor_plugin.h +++ b/editor/plugins/mesh_instance_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* mesh_instance_editor_plugin.h */ +/* mesh_instance_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,12 +33,12 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/mesh_instance.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/gui/spin_box.h" -class MeshInstanceEditor : public Control { +class MeshInstance3DEditor : public Control { - GDCLASS(MeshInstanceEditor, Control); + GDCLASS(MeshInstance3DEditor, Control); enum Menu { @@ -53,7 +53,7 @@ class MeshInstanceEditor : public Control { MENU_OPTION_DEBUG_UV2, }; - MeshInstance *node; + MeshInstance3D *node; MenuButton *options; @@ -70,7 +70,7 @@ class MeshInstanceEditor : public Control { void _create_outline_mesh(); void _create_uv_lines(int p_layer); - friend class MeshInstanceEditorPlugin; + friend class MeshInstance3DEditorPlugin; void _debug_uv_draw(); @@ -79,26 +79,26 @@ protected: static void _bind_methods(); public: - void edit(MeshInstance *p_mesh); - MeshInstanceEditor(); + void edit(MeshInstance3D *p_mesh); + MeshInstance3DEditor(); }; -class MeshInstanceEditorPlugin : public EditorPlugin { +class MeshInstance3DEditorPlugin : public EditorPlugin { - GDCLASS(MeshInstanceEditorPlugin, EditorPlugin); + GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin); - MeshInstanceEditor *mesh_editor; + MeshInstance3DEditor *mesh_editor; EditorNode *editor; public: - virtual String get_name() const { return "MeshInstance"; } + virtual String get_name() const { return "MeshInstance3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - MeshInstanceEditorPlugin(EditorNode *p_node); - ~MeshInstanceEditorPlugin(); + MeshInstance3DEditorPlugin(EditorNode *p_node); + ~MeshInstance3DEditorPlugin(); }; #endif // MESH_EDITOR_PLUGIN_H diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 4e63a498b8..a3e3d88ae2 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -33,12 +33,12 @@ #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "main/main.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation_region.h" -#include "scene/3d/physics_body.h" -#include "scene/main/viewport.h" +#include "node_3d_editor_plugin.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/navigation_region_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" -#include "spatial_editor_plugin.h" void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) { @@ -71,16 +71,16 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, if (!p_merge) p_library->clear(); - Map<int, MeshInstance *> mesh_instances; + Map<int, MeshInstance3D *> mesh_instances; for (int i = 0; i < p_scene->get_child_count(); i++) { Node *child = p_scene->get_child(i); - if (!Object::cast_to<MeshInstance>(child)) { + if (!Object::cast_to<MeshInstance3D>(child)) { if (child->get_child_count() > 0) { child = child->get_child(0); - if (!Object::cast_to<MeshInstance>(child)) { + if (!Object::cast_to<MeshInstance3D>(child)) { continue; } @@ -88,7 +88,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, continue; } - MeshInstance *mi = Object::cast_to<MeshInstance>(child); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(child); Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_null()) continue; @@ -118,10 +118,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, for (int j = 0; j < mi->get_child_count(); j++) { Node *child2 = mi->get_child(j); - if (!Object::cast_to<StaticBody>(child2)) + if (!Object::cast_to<StaticBody3D>(child2)) continue; - StaticBody *sb = Object::cast_to<StaticBody>(child2); + StaticBody3D *sb = Object::cast_to<StaticBody3D>(child2); List<uint32_t> shapes; sb->get_shape_owners(&shapes); @@ -135,7 +135,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape> collision = sb->shape_owner_get_shape(E->get(), k); + Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k); if (!collision.is_valid()) continue; MeshLibrary::ShapeData shape_data; @@ -152,9 +152,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, Transform navmesh_transform; for (int j = 0; j < mi->get_child_count(); j++) { Node *child2 = mi->get_child(j); - if (!Object::cast_to<NavigationRegion>(child2)) + if (!Object::cast_to<NavigationRegion3D>(child2)) continue; - NavigationRegion *sb = Object::cast_to<NavigationRegion>(child2); + NavigationRegion3D *sb = Object::cast_to<NavigationRegion3D>(child2); navmesh = sb->get_navigation_mesh(); navmesh_transform = sb->get_transform(); if (!navmesh.is_null()) @@ -253,7 +253,7 @@ void MeshLibraryEditor::_bind_methods() { MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { file = memnew(EditorFileDialog); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); //not for now? List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); @@ -267,10 +267,10 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { file->connect("file_selected", callable_mp(this, &MeshLibraryEditor::_import_scene_cbk)); menu = memnew(MenuButton); - SpatialEditor::get_singleton()->add_control_to_menu_panel(menu); + 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_icon("MeshLibrary", "EditorIcons")); + menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshLibrary", "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 27d400c035..4f482c2b43 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -30,14 +30,14 @@ #include "multimesh_editor_plugin.h" -#include "scene/3d/mesh_instance.h" +#include "node_3d_editor_plugin.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/gui/box_container.h" -#include "spatial_editor_plugin.h" void MultiMeshEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -56,13 +56,13 @@ void MultiMeshEditor::_populate() { if (multimesh.is_null()) { err_dialog->set_text(TTR("No mesh source specified (and no MultiMesh set in node).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } if (multimesh->get_mesh().is_null()) { err_dialog->set_text(TTR("No mesh source specified (and MultiMesh contains no Mesh).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -74,16 +74,16 @@ void MultiMeshEditor::_populate() { if (!ms_node) { err_dialog->set_text(TTR("Mesh source is invalid (invalid path).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - MeshInstance *ms_instance = Object::cast_to<MeshInstance>(ms_node); + MeshInstance3D *ms_instance = Object::cast_to<MeshInstance3D>(ms_node); if (!ms_instance) { - err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance).")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance3D).")); + err_dialog->popup_centered(); return; } @@ -92,7 +92,7 @@ void MultiMeshEditor::_populate() { if (mesh.is_null()) { err_dialog->set_text(TTR("Mesh source is invalid (contains no Mesh resource).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } } @@ -100,7 +100,7 @@ void MultiMeshEditor::_populate() { if (surface_source->get_text() == "") { err_dialog->set_text(TTR("No surface source specified.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -109,27 +109,27 @@ void MultiMeshEditor::_populate() { if (!ss_node) { err_dialog->set_text(TTR("Surface source is invalid (invalid path).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } - GeometryInstance *ss_instance = Object::cast_to<MeshInstance>(ss_node); + GeometryInstance3D *ss_instance = Object::cast_to<MeshInstance3D>(ss_node); if (!ss_instance) { err_dialog->set_text(TTR("Surface source is invalid (no geometry).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform(); - Vector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID); + Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID); if (geometry.size() == 0) { err_dialog->set_text(TTR("Surface source is invalid (no faces).")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -261,7 +261,7 @@ void MultiMeshEditor::_menu_option(int p_option) { } } -void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) { +void MultiMeshEditor::edit(MultiMeshInstance3D *p_multimesh) { node = p_multimesh; } @@ -284,10 +284,10 @@ MultiMeshEditor::MultiMeshEditor() { options = memnew(MenuButton); options->set_switch_on_hover(true); - SpatialEditor::get_singleton()->add_control_to_menu_panel(options); + Node3DEditor::get_singleton()->add_control_to_menu_panel(options); options->set_text("MultiMesh"); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("MultiMeshInstance", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance3D", "EditorIcons")); options->get_popup()->add_item(TTR("Populate Surface")); options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option)); @@ -371,7 +371,7 @@ MultiMeshEditor::MultiMeshEditor() { populate_dialog->add_child(std); std->connect("selected", callable_mp(this, &MultiMeshEditor::_browsed)); - _last_pp_node = NULL; + _last_pp_node = nullptr; err_dialog = memnew(AcceptDialog); add_child(err_dialog); @@ -379,12 +379,12 @@ MultiMeshEditor::MultiMeshEditor() { void MultiMeshEditorPlugin::edit(Object *p_object) { - multimesh_editor->edit(Object::cast_to<MultiMeshInstance>(p_object)); + multimesh_editor->edit(Object::cast_to<MultiMeshInstance3D>(p_object)); } bool MultiMeshEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("MultiMeshInstance"); + return p_object->is_class("MultiMeshInstance3D"); } void MultiMeshEditorPlugin::make_visible(bool p_visible) { @@ -394,7 +394,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) { } else { multimesh_editor->options->hide(); - multimesh_editor->edit(NULL); + multimesh_editor->edit(nullptr); } } diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h index 2c7b98cfbc..15c9b91fee 100644 --- a/editor/plugins/multimesh_editor_plugin.h +++ b/editor/plugins/multimesh_editor_plugin.h @@ -33,7 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/multimesh_instance.h" +#include "scene/3d/multimesh_instance_3d.h" #include "scene/gui/spin_box.h" class MultiMeshEditor : public Control { @@ -44,11 +44,11 @@ class MultiMeshEditor : public Control { AcceptDialog *err_dialog; MenuButton *options; - MultiMeshInstance *_last_pp_node; + MultiMeshInstance3D *_last_pp_node; bool browsing_source; Panel *panel; - MultiMeshInstance *node; + MultiMeshInstance3D *node; LineEdit *surface_source; LineEdit *mesh_source; @@ -78,7 +78,7 @@ protected: static void _bind_methods(); public: - void edit(MultiMeshInstance *p_multimesh); + void edit(MultiMeshInstance3D *p_multimesh); MultiMeshEditor(); }; diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 6671d0b6b4..e41b32ac86 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -123,7 +123,7 @@ void NavigationPolygonEditor::_create_resource() { NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; } NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) : diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 10f8cbc0a5..0bc35e2498 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h @@ -32,7 +32,7 @@ #define NAVIGATIONPOLYGONEDITORPLUGIN_H #include "editor/plugins/abstract_polygon_2d_editor.h" -#include "scene/2d/navigation_polygon.h" +#include "scene/2d/navigation_region_2d.h" class NavigationPolygonEditor : public AbstractPolygon2DEditor { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index c305c181cc..f51b9b20e4 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* spatial_editor_plugin.cpp */ +/* node_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "spatial_editor_plugin.h" +#include "node_3d_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/math/camera_matrix.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/print_string.h" #include "core/project_settings.h" @@ -40,17 +40,18 @@ #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/script_editor_plugin.h" -#include "editor/spatial_editor_gizmos.h" -#include "scene/3d/camera.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/physics_body.h" -#include "scene/3d/visual_instance.h" -#include "scene/gui/viewport_container.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/collision_shape_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/gui/subviewport_container.h" #include "scene/resources/packed_scene.h" #include "scene/resources/surface_tool.h" +#include "servers/display_server.h" #define DISTANCE_DEFAULT 4 @@ -80,17 +81,17 @@ void ViewportRotationControl::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { axis_menu_options.clear(); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_RIGHT); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_TOP); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_FRONT); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_LEFT); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_BOTTOM); - axis_menu_options.push_back(SpatialEditorViewport::VIEW_REAR); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_TOP); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_FRONT); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_LEFT); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_BOTTOM); + axis_menu_options.push_back(Node3DEditorViewport::VIEW_REAR); axis_colors.clear(); - axis_colors.push_back(get_color("axis_x_color", "Editor")); - axis_colors.push_back(get_color("axis_y_color", "Editor")); - axis_colors.push_back(get_color("axis_z_color", "Editor")); + 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")); update(); if (!is_connected("mouse_exited", callable_mp(this, &ViewportRotationControl::_on_mouse_exited))) { @@ -139,7 +140,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_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", Color(0.3, 0.3, 0.3)); + draw_char(get_theme_font("rotation_control", "EditorFonts"), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", 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); } @@ -238,7 +239,7 @@ void ViewportRotationControl::_on_mouse_exited() { update(); } -void ViewportRotationControl::set_viewport(SpatialEditorViewport *p_viewport) { +void ViewportRotationControl::set_viewport(Node3DEditorViewport *p_viewport) { viewport = p_viewport; } @@ -246,9 +247,9 @@ void ViewportRotationControl::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &ViewportRotationControl::_gui_input); } -void SpatialEditorViewport::_update_camera(float p_interp_delta) { +void Node3DEditorViewport::_update_camera(float p_interp_delta) { - bool is_orthogonal = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL; + bool is_orthogonal = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL; Cursor old_camera_cursor = camera_cursor; camera_cursor = cursor; @@ -297,10 +298,10 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) { float zoom_inertia = EDITOR_GET("editors/3d/navigation_feel/zoom_inertia"); //determine if being manipulated - bool manipulated = Input::get_singleton()->get_mouse_button_mask() & (2 | 4); - manipulated |= Input::get_singleton()->is_key_pressed(KEY_SHIFT); - manipulated |= Input::get_singleton()->is_key_pressed(KEY_ALT); - manipulated |= Input::get_singleton()->is_key_pressed(KEY_CONTROL); + bool manipulated = InputFilter::get_singleton()->get_mouse_button_mask() & (2 | 4); + manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); + manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_ALT); + manipulated |= InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); float orbit_inertia = MAX(0.00001, manipulated ? manip_orbit_inertia : free_orbit_inertia); float translation_inertia = MAX(0.0001, manipulated ? manip_translation_inertia : free_translation_inertia); @@ -346,7 +347,7 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) { if (orthogonal) { float half_fov = Math::deg2rad(get_fov()) / 2.0; float height = 2.0 * cursor.distance * Math::tan(half_fov); - camera->set_orthogonal(height, 0.1, 8192); + camera->set_orthogonal(height, get_znear(), get_zfar()); } else { camera->set_perspective(get_fov(), get_znear(), get_zfar()); } @@ -356,21 +357,21 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) { } } -Transform SpatialEditorViewport::to_camera_transform(const Cursor &p_cursor) const { +Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const { Transform camera_transform; camera_transform.translate(p_cursor.pos); camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot); if (orthogonal) - camera_transform.translate(0, 0, 4096); + camera_transform.translate(0, 0, (get_zfar() - get_znear()) / 2.0); else camera_transform.translate(0, 0, p_cursor.distance); return camera_transform; } -int SpatialEditorViewport::get_selected_count() const { +int Node3DEditorViewport::get_selected_count() const { Map<Node *, Object *> &selection = editor_selection->get_selection(); @@ -378,11 +379,11 @@ int SpatialEditorViewport::get_selected_count() const { for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->key()); + Node3D *sp = Object::cast_to<Node3D>(E->key()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -392,68 +393,68 @@ int SpatialEditorViewport::get_selected_count() const { return count; } -float SpatialEditorViewport::get_znear() const { +float Node3DEditorViewport::get_znear() const { return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z); } -float SpatialEditorViewport::get_zfar() const { +float Node3DEditorViewport::get_zfar() const { return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z); } -float SpatialEditorViewport::get_fov() const { +float Node3DEditorViewport::get_fov() const { return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV); } -Transform SpatialEditorViewport::_get_camera_transform() const { +Transform Node3DEditorViewport::_get_camera_transform() const { return camera->get_global_transform(); } -Vector3 SpatialEditorViewport::_get_camera_position() const { +Vector3 Node3DEditorViewport::_get_camera_position() const { return _get_camera_transform().origin; } -Point2 SpatialEditorViewport::_point_to_screen(const Vector3 &p_point) { +Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) { - return camera->unproject_position(p_point) * viewport_container->get_stretch_shrink(); + return camera->unproject_position(p_point) * subviewport_container->get_stretch_shrink(); } -Vector3 SpatialEditorViewport::_get_ray_pos(const Vector2 &p_pos) const { +Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const { - return camera->project_ray_origin(p_pos / viewport_container->get_stretch_shrink()); + return camera->project_ray_origin(p_pos / subviewport_container->get_stretch_shrink()); } -Vector3 SpatialEditorViewport::_get_camera_normal() const { +Vector3 Node3DEditorViewport::_get_camera_normal() const { return -_get_camera_transform().basis.get_axis(2); } -Vector3 SpatialEditorViewport::_get_ray(const Vector2 &p_pos) const { +Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const { - return camera->project_ray_normal(p_pos / viewport_container->get_stretch_shrink()); + return camera->project_ray_normal(p_pos / subviewport_container->get_stretch_shrink()); } -void SpatialEditorViewport::_clear_selected() { +void Node3DEditorViewport::_clear_selected() { editor_selection->clear(); } -void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) { +void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) { if (clicked.is_null()) return; Node *node = Object::cast_to<Node>(ObjectDB::get_instance(clicked)); - Spatial *selected = Object::cast_to<Spatial>(node); + Node3D *selected = Object::cast_to<Node3D>(node); if (!selected) return; if (!p_allow_locked) { // Replace the node by the group if grouped while (node && node != editor->get_edited_scene()->get_parent()) { - Spatial *selected_tmp = Object::cast_to<Spatial>(node); + Node3D *selected_tmp = Object::cast_to<Node3D>(node); if (selected_tmp && node->has_meta("_edit_group_")) { selected = selected_tmp; } @@ -466,7 +467,7 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single, bool p } } -void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { +void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { if (!p_append) { editor_selection->clear(); @@ -486,32 +487,32 @@ void SpatialEditorViewport::_select(Node *p_node, bool p_append, bool p_single) } } -ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle, bool p_alt_select) { +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; Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); - Vector2 shrinked_pos = p_pos / viewport_container->get_stretch_shrink(); + Vector2 shrinked_pos = p_pos / subviewport_container->get_stretch_shrink(); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); - Set<Ref<EditorSpatialGizmo>> found_gizmos; + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); + Set<Ref<EditorNode3DGizmo>> found_gizmos; Node *edited_scene = get_tree()->get_edited_scene_root(); ObjectID closest; - Node *item = NULL; + Node *item = nullptr; float closest_dist = 1e20; int selected_handle = -1; for (int i = 0; i < instances.size(); i++) { - Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i])); + Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!spat) continue; - Ref<EditorSpatialGizmo> seg = spat->get_gizmo(); + Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); if ((!seg.is_valid()) || found_gizmos.has(seg)) { continue; @@ -557,24 +558,24 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, return closest; } -void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) { +void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select) { Vector3 ray = _get_ray(p_pos); Vector3 pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); - Set<Ref<EditorSpatialGizmo>> found_gizmos; + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(pos, ray, get_tree()->get_root()->get_world()->get_scenario()); + Set<Ref<EditorNode3DGizmo>> found_gizmos; r_includes_current = false; for (int i = 0; i < instances.size(); i++) { - Spatial *spat = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i])); + Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!spat) continue; - Ref<EditorSpatialGizmo> seg = spat->get_gizmo(); + Ref<EditorNode3DGizmo> seg = spat->get_gizmo(); if (!seg.is_valid()) continue; @@ -587,7 +588,7 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_incl Vector3 normal; int handle = -1; - bool inters = seg->intersect_ray(camera, p_pos, point, normal, NULL, p_alt_select); + bool inters = seg->intersect_ray(camera, p_pos, point, normal, nullptr, p_alt_select); if (!inters) continue; @@ -613,7 +614,7 @@ void SpatialEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_incl results.sort(); } -Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { +Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { CameraMatrix cm; if (orthogonal) { @@ -632,7 +633,7 @@ Vector3 SpatialEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { return camera_transform.xform(Vector3(((p_vector3.x / get_size().width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (p_vector3.y / get_size().height)) * 2.0 - 1.0) * screen_he.y, -(get_znear() + p_vector3.z))); } -void SpatialEditorViewport::_select_region() { +void Node3DEditorViewport::_select_region() { if (cursor.region_begin == cursor.region_end) return; //nothing really @@ -685,14 +686,14 @@ void SpatialEditorViewport::_select_region() { frustum.push_back(far); } - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_convex(frustum, get_tree()->get_root()->get_world()->get_scenario()); Vector<Node *> selected; Node *edited_scene = get_tree()->get_edited_scene_root(); for (int i = 0; i < instances.size(); i++) { - Spatial *sp = Object::cast_to<Spatial>(ObjectDB::get_instance(instances[i])); + Node3D *sp = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!sp || _is_node_locked(sp)) continue; @@ -702,10 +703,10 @@ void SpatialEditorViewport::_select_region() { } // Replace the node by the group if grouped - if (item->is_class("Spatial")) { - Spatial *sel = Object::cast_to<Spatial>(item); + if (item->is_class("Node3D")) { + Node3D *sel = Object::cast_to<Node3D>(item); while (item && item != editor->get_edited_scene()->get_parent()) { - Spatial *selected_tmp = Object::cast_to<Spatial>(item); + Node3D *selected_tmp = Object::cast_to<Node3D>(item); if (selected_tmp && item->has_meta("_edit_group_")) { sel = selected_tmp; } @@ -718,7 +719,7 @@ void SpatialEditorViewport::_select_region() { if (_is_node_locked(item)) continue; - Ref<EditorSpatialGizmo> seg = sp->get_gizmo(); + Ref<EditorNode3DGizmo> seg = sp->get_gizmo(); if (!seg.is_valid()) continue; @@ -734,7 +735,7 @@ void SpatialEditorViewport::_select_region() { } } -void SpatialEditorViewport::_update_name() { +void Node3DEditorViewport::_update_name() { String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective"); @@ -750,7 +751,7 @@ void SpatialEditorViewport::_update_name() { view_menu->set_size(Vector2(0, 0)); // resets the button size } -void SpatialEditorViewport::_compute_edit(const Point2 &p_point) { +void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { _edit.click_ray = _get_ray(Vector2(p_point.x, p_point.y)); _edit.click_ray_pos = _get_ray_pos(Vector2(p_point.x, p_point.y)); @@ -762,11 +763,11 @@ void SpatialEditorViewport::_compute_edit(const Point2 &p_point) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -800,7 +801,7 @@ static int _get_key_modifier(Ref<InputEventWithModifiers> e) { return 0; } -bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { +bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { if (!spatial_editor->is_gizmo_visible()) return false; @@ -816,7 +817,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig Transform gt = spatial_editor->get_gizmo_transform(); float gs = gizmo_scale; - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) { int col_axis = -1; float col_d = 1e20; @@ -885,7 +886,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) { int col_axis = -1; float col_d = 1e20; @@ -924,7 +925,7 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) { int col_axis = -1; float col_d = 1e20; @@ -999,37 +1000,37 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig return false; } -void SpatialEditorViewport::_surface_mouse_enter() { +void Node3DEditorViewport::_surface_mouse_enter() { if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) surface->grab_focus(); } -void SpatialEditorViewport::_surface_mouse_exit() { +void Node3DEditorViewport::_surface_mouse_exit() { _remove_preview(); } -void SpatialEditorViewport::_surface_focus_enter() { +void Node3DEditorViewport::_surface_focus_enter() { view_menu->set_disable_shortcuts(false); } -void SpatialEditorViewport::_surface_focus_exit() { +void Node3DEditorViewport::_surface_focus_exit() { view_menu->set_disable_shortcuts(true); } -bool SpatialEditorViewport ::_is_node_locked(const Node *p_node) { +bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) { return p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_"); } -void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { +void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { _find_items_at_pos(b->get_position(), clicked_includes_current, selection_results, b->get_shift()); Node *scene = editor->get_edited_scene(); for (int i = 0; i < selection_results.size(); i++) { - Spatial *item = selection_results[i].item; + Node3D *item = selection_results[i].item; if (item != scene && item->get_owner() != scene && !scene->is_editable_instance(item->get_owner())) { //invalid result selection_results.remove(i); @@ -1045,7 +1046,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { selection_results.clear(); if (clicked.is_valid()) { - _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != SpatialEditor::TOOL_MODE_LIST_SELECT); + _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT); clicked = ObjectID(); } @@ -1056,7 +1057,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { for (int i = 0; i < selection_results.size(); i++) { - Spatial *spat = selection_results[i].item; + Node3D *spat = selection_results[i].item; Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); @@ -1070,7 +1071,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { Node *node = spat; while (node && node != ed_scene->get_parent()) { - Spatial *selected_tmp = Object::cast_to<Spatial>(node); + Node3D *selected_tmp = Object::cast_to<Node3D>(node); if (selected_tmp && node->has_meta("_edit_group_")) { locked = 2; } @@ -1090,12 +1091,12 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) { selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_class() + "\nPath: " + node_path); } - selection_menu->set_global_position(b->get_global_position()); + selection_menu->set_position(get_screen_transform().xform(b->get_position())); selection_menu->popup(); } } -void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { +void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (previewing) return; //do NONE @@ -1148,7 +1149,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (b->is_pressed() && _edit.gizmo.is_valid()) { //restore _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, true); - _edit.gizmo = Ref<EditorSpatialGizmo>(); + _edit.gizmo = Ref<EditorNode3DGizmo>(); } if (_edit.mode == TRANSFORM_NONE && b->is_pressed()) { @@ -1171,11 +1172,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -1250,7 +1251,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; } - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_LIST_SELECT) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_LIST_SELECT) { _list_select(b); break; } @@ -1270,7 +1271,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (can_select_gizmos && spatial_editor->get_selected()) { - Ref<EditorSpatialGizmo> seg = spatial_editor->get_selected()->get_gizmo(); + Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); if (seg.is_valid()) { int handle = -1; Vector3 point; @@ -1292,7 +1293,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { clicked = ObjectID(); clicked_includes_current = false; - if ((spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE) { + if ((spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT && b->get_control()) || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE) { /* HANDLE ROTATION */ if (get_selected_count() == 0) @@ -1303,7 +1304,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; } - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) { if (get_selected_count() == 0) break; //bye @@ -1313,7 +1314,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; } - if (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE) { + if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) { if (get_selected_count() == 0) break; //bye @@ -1346,10 +1347,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (clicked.is_valid() && gizmo_handle >= 0) { - Spatial *spa = Object::cast_to<Spatial>(ObjectDB::get_instance(clicked)); + Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); if (spa) { - Ref<EditorSpatialGizmo> seg = spa->get_gizmo(); + Ref<EditorNode3DGizmo> seg = spa->get_gizmo(); if (seg.is_valid()) { _edit.gizmo = seg; @@ -1366,7 +1367,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (_edit.gizmo.is_valid()) { _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false); - _edit.gizmo = Ref<EditorSpatialGizmo>(); + _edit.gizmo = Ref<EditorNode3DGizmo>(); break; } if (clicked.is_valid()) { @@ -1393,11 +1394,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -1424,7 +1425,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (spatial_editor->get_selected()) { - Ref<EditorSpatialGizmo> seg = spatial_editor->get_selected()->get_gizmo(); + Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); if (seg.is_valid()) { int selected_handle = -1; @@ -1592,12 +1593,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) { continue; } - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) { continue; } @@ -1717,12 +1718,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) { continue; } - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) { continue; } @@ -1815,11 +1816,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -2053,7 +2054,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -2082,7 +2083,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { accept_event(); } -void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { +void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); @@ -2102,7 +2103,7 @@ void SpatialEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const cursor.pos = camera_transform.origin; } -void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { +void Node3DEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { const NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); @@ -2125,7 +2126,7 @@ void SpatialEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, cons } } -void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { +void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { if (lock_rotation) { _nav_pan(p_event, p_relative); @@ -2154,7 +2155,7 @@ void SpatialEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, con _update_name(); } -void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { +void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { if (orthogonal) { _nav_pan(p_event, p_relative); @@ -2194,7 +2195,7 @@ void SpatialEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, cons _update_name(); } -void SpatialEditorViewport::set_freelook_active(bool active_now) { +void Node3DEditorViewport::set_freelook_active(bool active_now) { if (!freelook_active && active_now) { // Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential @@ -2213,20 +2214,20 @@ void SpatialEditorViewport::set_freelook_active(bool active_now) { } // Hide mouse like in an FPS (warping doesn't work) - OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_CAPTURED); + DisplayServer::get_singleton()->mouse_set_mode(DisplayServer::MOUSE_MODE_CAPTURED); } else if (freelook_active && !active_now) { // Sync camera cursor to cursor to "cut" interpolation jumps due to changing referential cursor = camera_cursor; // Restore mouse - OS::get_singleton()->set_mouse_mode(OS::MOUSE_MODE_VISIBLE); + DisplayServer::get_singleton()->mouse_set_mode(DisplayServer::MOUSE_MODE_VISIBLE); } freelook_active = active_now; } -void SpatialEditorViewport::scale_cursor_distance(real_t scale) { +void Node3DEditorViewport::scale_cursor_distance(real_t scale) { // Prevents zero distance which would short-circuit any scaling if (cursor.distance < ZOOM_MIN_DISTANCE) @@ -2241,7 +2242,7 @@ void SpatialEditorViewport::scale_cursor_distance(real_t scale) { surface->update(); } -void SpatialEditorViewport::scale_freelook_speed(real_t scale) { +void Node3DEditorViewport::scale_freelook_speed(real_t scale) { // Prevents zero distance which would short-circuit any scaling if (freelook_speed < FREELOOK_MIN_SPEED) @@ -2256,10 +2257,10 @@ void SpatialEditorViewport::scale_freelook_speed(real_t scale) { surface->update(); } -Point2i SpatialEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const { +Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const { Point2i relative; if (bool(EDITOR_DEF("editors/3d/navigation/warped_mouse_panning", false))) { - relative = Input::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect()); + relative = InputFilter::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect()); } else { relative = p_ev_mouse_motion->get_relative(); } @@ -2272,23 +2273,41 @@ static bool is_shortcut_pressed(const String &p_path) { return false; } InputEventKey *k = Object::cast_to<InputEventKey>(shortcut->get_shortcut().ptr()); - if (k == NULL) { + if (k == nullptr) { return false; } - const Input &input = *Input::get_singleton(); + const InputFilter &input = *InputFilter::get_singleton(); int keycode = k->get_keycode(); return input.is_key_pressed(keycode); } -void SpatialEditorViewport::_update_freelook(real_t delta) { +void Node3DEditorViewport::_update_freelook(real_t delta) { if (!is_freelook_active()) { return; } - const Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1)); + const FreelookNavigationScheme navigation_scheme = (FreelookNavigationScheme)EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_navigation_scheme").operator int(); + + Vector3 forward; + if (navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) { + // Forward/backward keys will always go straight forward/backward, never moving on the Y axis. + forward = Vector3(0, 0, -1).rotated(Vector3(0, 1, 0), camera->get_rotation().y); + } else { + // Forward/backward keys will be relative to the camera pitch. + forward = camera->get_transform().basis.xform(Vector3(0, 0, -1)); + } + const Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0)); - const Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0)); + + Vector3 up; + if (navigation_scheme == FREELOOK_PARTIALLY_AXIS_LOCKED || navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) { + // Up/down keys will always go up/down regardless of camera pitch. + up = Vector3(0, 1, 0); + } else { + // Up/down keys will be relative to the camera pitch. + up = camera->get_transform().basis.xform(Vector3(0, 1, 0)); + } Vector3 direction; @@ -2325,22 +2344,22 @@ void SpatialEditorViewport::_update_freelook(real_t delta) { cursor.eye_pos += motion; } -void SpatialEditorViewport::set_message(String p_message, float p_time) { +void Node3DEditorViewport::set_message(String p_message, float p_time) { message = p_message; message_time = p_time; } -void SpatialEditorPlugin::edited_scene_changed() { - for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) { - SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(i); +void Node3DEditorPlugin::edited_scene_changed() { + for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) { + Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(i); if (viewport->is_visible()) { viewport->notification(Control::NOTIFICATION_VISIBILITY_CHANGED); } } } -void SpatialEditorViewport::_notification(int p_what) { +void Node3DEditorViewport::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { @@ -2366,7 +2385,7 @@ void SpatialEditorViewport::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { // The crosshair icon doesn't depend on the editor theme. - crosshair->set_texture(get_icon("Crosshair", "EditorIcons")); + crosshair->set_texture(get_theme_icon("Crosshair", "EditorIcons")); // Set the anchors and margins after changing the icon to ensure it's centered correctly. crosshair->set_anchors_and_margins_preset(PRESET_CENTER); } @@ -2385,16 +2404,16 @@ void SpatialEditorViewport::_notification(int p_what) { _update_freelook(delta); Node *scene_root = editor->get_scene_tree_dock()->get_editor_data()->get_edited_scene_root(); - if (previewing_cinema && scene_root != NULL) { - Camera *cam = scene_root->get_viewport()->get_camera(); - if (cam != NULL && cam != previewing) { + if (previewing_cinema && scene_root != nullptr) { + Camera3D *cam = scene_root->get_viewport()->get_camera(); + if (cam != nullptr && cam != previewing) { //then switch the viewport's camera to the scene's viewport camera - if (previewing != NULL) { - previewing->disconnect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); + if (previewing != nullptr) { + previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); } previewing = cam; - previewing->connect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); + previewing->connect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), cam->get_camera()); surface->update(); } } @@ -2408,23 +2427,24 @@ void SpatialEditorViewport::_notification(int p_what) { for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->key()); + Node3D *sp = Object::cast_to<Node3D>(E->key()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; Transform t = sp->get_global_gizmo_transform(); exist = true; - if (se->last_xform == t) + if (se->last_xform == t && !se->last_xform_dirty) continue; changed = true; + se->last_xform_dirty = false; se->last_xform = t; - VisualInstance *vi = Object::cast_to<VisualInstance>(sp); + VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp); se->aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); @@ -2435,7 +2455,7 @@ void SpatialEditorViewport::_notification(int p_what) { aabb_s.scale(se->aabb.size); t.basis = t.basis * aabb_s; - VisualServer::get_singleton()->instance_set_transform(se->sbox_instance, t); + RenderingServer::get_singleton()->instance_set_transform(se->sbox_instance, t); } if (changed || (spatial_editor->is_gizmo_visible() && !exist)) { @@ -2470,19 +2490,23 @@ void SpatialEditorViewport::_notification(int p_what) { bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION)); - if (shrink != (viewport_container->get_stretch_shrink() > 1)) { - viewport_container->set_stretch_shrink(shrink ? 2 : 1); + if (shrink != (subviewport_container->get_stretch_shrink() > 1)) { + subviewport_container->set_stretch_shrink(shrink ? 2 : 1); } //update msaa if changed - int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa"); + int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/screen_filters/msaa"); viewport->set_msaa(Viewport::MSAA(msaa_mode)); + int ssaa_mode = GLOBAL_GET("rendering/quality/screen_filters/screen_space_aa"); + viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode)); bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); - info_label->set_visible(show_info); + if (show_info != info_label->is_visible()) { + info_label->set_visible(show_info); + } - Camera *current_camera; + Camera3D *current_camera; if (previewing) { current_camera = previewing; @@ -2507,17 +2531,46 @@ void SpatialEditorViewport::_notification(int p_what) { text += TTR("Surface Changes") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_SURFACE_CHANGES_IN_FRAME)) + "\n"; text += TTR("Draw Calls") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_DRAW_CALLS_IN_FRAME)) + "\n"; text += TTR("Vertices") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_VERTICES_IN_FRAME)); + info_label->set_text(text); } // FPS Counter. - bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); - fps_label->set_visible(show_fps); - + bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME)); + + if (show_fps != fps_label->is_visible()) { + fps_label->set_visible(show_fps); + RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps); + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + cpu_time_history[i] = 0; + gpu_time_history[i] = 0; + } + cpu_time_history_index = 0; + cpu_time_history_index = 0; + } if (show_fps) { + + cpu_time_history[cpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_cpu(viewport->get_viewport_rid()); + cpu_time_history_index = (cpu_time_history_index + 1) % FRAME_TIME_HISTORY; + float cpu_time = 0.0; + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + cpu_time += cpu_time_history[i]; + } + cpu_time /= FRAME_TIME_HISTORY; + + gpu_time_history[gpu_time_history_index] = RS::get_singleton()->viewport_get_measured_render_time_gpu(viewport->get_viewport_rid()); + gpu_time_history_index = (gpu_time_history_index + 1) % FRAME_TIME_HISTORY; + float gpu_time = 0.0; + for (int i = 0; i < FRAME_TIME_HISTORY; i++) { + gpu_time += gpu_time_history[i]; + } + gpu_time /= FRAME_TIME_HISTORY; + String text; - const float temp_fps = Engine::get_singleton()->get_frames_per_second(); - text += TTR(vformat("FPS: %d (%s ms)", temp_fps, String::num(1000.0f / temp_fps, 2))); + text += TTR("CPU Time") + ": " + String::num(cpu_time, 1) + " ms\n"; + text += TTR("GPU Time") + ": " + String::num(gpu_time, 1) + " ms\n"; + text += TTR("FPS") + ": " + itos(1000.0 / gpu_time); + fps_label->set_text(text); } @@ -2536,12 +2589,12 @@ void SpatialEditorViewport::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - surface->connect("draw", callable_mp(this, &SpatialEditorViewport::_draw)); - surface->connect("gui_input", callable_mp(this, &SpatialEditorViewport::_sinput)); - surface->connect("mouse_entered", callable_mp(this, &SpatialEditorViewport::_surface_mouse_enter)); - surface->connect("mouse_exited", callable_mp(this, &SpatialEditorViewport::_surface_mouse_exit)); - surface->connect("focus_entered", callable_mp(this, &SpatialEditorViewport::_surface_focus_enter)); - surface->connect("focus_exited", callable_mp(this, &SpatialEditorViewport::_surface_focus_exit)); + surface->connect("draw", callable_mp(this, &Node3DEditorViewport::_draw)); + surface->connect("gui_input", callable_mp(this, &Node3DEditorViewport::_sinput)); + surface->connect("mouse_entered", callable_mp(this, &Node3DEditorViewport::_surface_mouse_enter)); + surface->connect("mouse_exited", callable_mp(this, &Node3DEditorViewport::_surface_mouse_exit)); + surface->connect("focus_entered", callable_mp(this, &Node3DEditorViewport::_surface_focus_enter)); + surface->connect("focus_exited", callable_mp(this, &Node3DEditorViewport::_surface_focus_exit)); _init_gizmo_instance(index); } @@ -2553,25 +2606,25 @@ void SpatialEditorViewport::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED) { - view_menu->set_icon(get_icon("GuiTabMenu", "EditorIcons")); - preview_camera->set_icon(get_icon("Camera", "EditorIcons")); + view_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); + preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons")); - view_menu->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - view_menu->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + 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")); - preview_camera->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_style_override("hover", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_style_override("pressed", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_style_override("focus", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - preview_camera->add_style_override("disabled", editor->get_gui_base()->get_stylebox("Information3dViewport", "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")); - info_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - fps_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - cinema_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); - locked_label->add_style_override("normal", editor->get_gui_base()->get_stylebox("Information3dViewport", "EditorStyles")); + info_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")); } } @@ -2596,7 +2649,7 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> ico surface.draw_texture(icon, icon_pos); } -void SpatialEditorViewport::_draw() { +void Node3DEditorViewport::_draw() { EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over(); if (!over_plugin_list->empty()) { @@ -2611,7 +2664,7 @@ void SpatialEditorViewport::_draw() { if (surface->has_focus()) { Size2 size = surface->get_size(); Rect2 r = Rect2(Point2(), size); - get_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r); + get_theme_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r); } if (cursor.region_select) { @@ -2619,11 +2672,11 @@ void SpatialEditorViewport::_draw() { surface->draw_rect( selection_rect, - get_color("box_selection_fill_color", "Editor")); + get_theme_color("box_selection_fill_color", "Editor")); surface->draw_rect( selection_rect, - get_color("box_selection_stroke_color", "Editor"), + get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); } @@ -2631,7 +2684,7 @@ void SpatialEditorViewport::_draw() { RID ci = surface->get_canvas_item(); if (message_time > 0) { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); Point2 msgpos = Point2(5, get_size().y - 20); font->draw(ci, msgpos + Point2(1, 1), message, Color(0, 0, 0, 0.8)); font->draw(ci, msgpos + Point2(-1, -1), message, Color(0, 0, 0, 0.8)); @@ -2641,11 +2694,11 @@ void SpatialEditorViewport::_draw() { if (_edit.mode == TRANSFORM_ROTATE) { Point2 center = _point_to_screen(_edit.center); - VisualServer::get_singleton()->canvas_item_add_line( + RenderingServer::get_singleton()->canvas_item_add_line( ci, _edit.mouse_pos, center, - get_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), + get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), Math::round(2 * EDSCALE)); } if (previewing) { @@ -2657,14 +2710,14 @@ void SpatialEditorViewport::_draw() { Rect2 draw_rect; switch (previewing->get_keep_aspect_mode()) { - case Camera::KEEP_WIDTH: { + case Camera3D::KEEP_WIDTH: { draw_rect.size = Size2(s.width, s.width / aspect); draw_rect.position.x = 0; draw_rect.position.y = (s.height - draw_rect.size.y) * 0.5; } break; - case Camera::KEEP_HEIGHT: { + case Camera3D::KEEP_HEIGHT: { draw_rect.size = Size2(s.height * aspect, s.height); draw_rect.position.y = 0; @@ -2696,7 +2749,7 @@ void SpatialEditorViewport::_draw() { if (logscale_t < 0.25) logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0); - draw_indicator_bar(*surface, 1.0 - logscale_t, get_icon("ViewportSpeed", "EditorIcons")); + draw_indicator_bar(*surface, 1.0 - logscale_t, get_theme_icon("ViewportSpeed", "EditorIcons")); } } else { @@ -2714,14 +2767,14 @@ void SpatialEditorViewport::_draw() { if (logscale_t < 0.25) logscale_t = 0.25 * Math::exp(4.0 * logscale_t - 1.0); - draw_indicator_bar(*surface, logscale_t, get_icon("ViewportZoom", "EditorIcons")); + draw_indicator_bar(*surface, logscale_t, get_theme_icon("ViewportZoom", "EditorIcons")); } } } } } -void SpatialEditorViewport::_menu_option(int p_option) { +void Node3DEditorViewport::_menu_option(int p_option) { switch (p_option) { @@ -2808,11 +2861,11 @@ void SpatialEditorViewport::_menu_option(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -2844,11 +2897,11 @@ void SpatialEditorViewport::_menu_option(int p_option) { undo_redo->create_action(TTR("Align Rotation with View")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -2868,7 +2921,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { camera->set_environment(RES()); } else { - camera->set_environment(SpatialEditor::get_singleton()->get_viewport_environment()); + camera->set_environment(Node3DEditor::get_singleton()->get_viewport_environment()); } view_menu->get_popup()->set_item_checked(idx, current); @@ -2932,7 +2985,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; - camera->set_doppler_tracking(current ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED); + camera->set_doppler_tracking(current ? Camera3D::DOPPLER_TRACKING_IDLE_STEP : Camera3D::DOPPLER_TRACKING_DISABLED); view_menu->get_popup()->set_item_checked(idx, current); } break; @@ -2948,7 +3001,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { if (current) { preview_camera->hide(); } else { - if (previewing != NULL) + if (previewing != nullptr) preview_camera->show(); } } break; @@ -2978,9 +3031,9 @@ void SpatialEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(idx, !current); } break; - case VIEW_FPS: { + case VIEW_FRAME_TIME: { - int idx = view_menu->get_popup()->get_item_index(VIEW_FPS); + int idx = view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME); bool current = view_menu->get_popup()->is_item_checked(idx); view_menu->get_popup()->set_item_checked(idx, !current); @@ -2998,6 +3051,8 @@ void SpatialEditorViewport::_menu_option(int p_option) { case VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION: case VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE: case VIEW_DISPLAY_DEBUG_SSAO: + case VIEW_DISPLAY_DEBUG_PSSM_SPLITS: + case VIEW_DISPLAY_DEBUG_DECAL_ATLAS: case VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER: { static const int display_options[] = { @@ -3016,6 +3071,8 @@ void SpatialEditorViewport::_menu_option(int p_option) { VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE, VIEW_DISPLAY_DEBUG_SSAO, VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER, + VIEW_DISPLAY_DEBUG_PSSM_SPLITS, + VIEW_DISPLAY_DEBUG_DECAL_ATLAS, VIEW_MAX }; static const Viewport::DebugDraw debug_draw_modes[] = { @@ -3034,6 +3091,8 @@ void SpatialEditorViewport::_menu_option(int p_option) { Viewport::DEBUG_DRAW_SCENE_LUMINANCE, Viewport::DEBUG_DRAW_SSAO, Viewport::DEBUG_DRAW_ROUGHNESS_LIMITER, + Viewport::DEBUG_DRAW_PSSM_SPLITS, + Viewport::DEBUG_DRAW_DECAL_ATLAS, }; int idx = 0; @@ -3059,84 +3118,84 @@ void SpatialEditorViewport::_menu_option(int p_option) { } } -void SpatialEditorViewport::_set_auto_orthogonal() { +void Node3DEditorViewport::_set_auto_orthogonal() { if (!orthogonal && view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL))) { _menu_option(VIEW_ORTHOGONAL); auto_orthogonal = true; } } -void SpatialEditorViewport::_preview_exited_scene() { +void Node3DEditorViewport::_preview_exited_scene() { - preview_camera->disconnect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview)); + preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); preview_camera->set_pressed(false); _toggle_camera_preview(false); - preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview)); + preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); view_menu->show(); } -void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { +void Node3DEditorViewport::_init_gizmo_instance(int p_idx) { uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx); for (int i = 0; i < 3; i++) { - move_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer); - - move_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer); - - rotate_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer); - - scale_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); - - scale_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); - VS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); - VS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); - } -} - -void SpatialEditorViewport::_finish_gizmo_instances() { + move_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(move_gizmo_instance[i], spatial_editor->get_move_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(move_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(move_gizmo_instance[i], layer); + + move_plane_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(move_plane_gizmo_instance[i], spatial_editor->get_move_plane_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(move_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(move_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(move_plane_gizmo_instance[i], layer); + + rotate_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(rotate_gizmo_instance[i], spatial_editor->get_rotate_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(rotate_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(rotate_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(rotate_gizmo_instance[i], layer); + + scale_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(scale_gizmo_instance[i], spatial_editor->get_scale_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(scale_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); + + scale_plane_gizmo_instance[i] = RS::get_singleton()->instance_create(); + RS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); + RS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); + } +} + +void Node3DEditorViewport::_finish_gizmo_instances() { for (int i = 0; i < 3; i++) { - VS::get_singleton()->free(move_gizmo_instance[i]); - VS::get_singleton()->free(move_plane_gizmo_instance[i]); - VS::get_singleton()->free(rotate_gizmo_instance[i]); - VS::get_singleton()->free(scale_gizmo_instance[i]); - VS::get_singleton()->free(scale_plane_gizmo_instance[i]); + RS::get_singleton()->free(move_gizmo_instance[i]); + RS::get_singleton()->free(move_plane_gizmo_instance[i]); + RS::get_singleton()->free(rotate_gizmo_instance[i]); + RS::get_singleton()->free(scale_gizmo_instance[i]); + RS::get_singleton()->free(scale_plane_gizmo_instance[i]); } } -void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { +void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { ERR_FAIL_COND(p_activate && !preview); ERR_FAIL_COND(!p_activate && !previewing); if (!p_activate) { - previewing->disconnect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); - previewing = NULL; - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore + previewing->disconnect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + previewing = nullptr; + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore if (!preview) preview_camera->hide(); view_menu->set_disabled(false); @@ -3145,21 +3204,21 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { } else { previewing = preview; - previewing->connect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace + previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace view_menu->set_disabled(true); surface->update(); } } -void SpatialEditorViewport::_toggle_cinema_preview(bool p_activate) { +void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { previewing_cinema = p_activate; if (!previewing_cinema) { - if (previewing != NULL) - previewing->disconnect("tree_exited", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); + if (previewing != nullptr) + previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); - previewing = NULL; - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore + previewing = nullptr; + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore preview_camera->set_pressed(false); if (!preview) { preview_camera->hide(); @@ -3171,7 +3230,7 @@ void SpatialEditorViewport::_toggle_cinema_preview(bool p_activate) { } } -void SpatialEditorViewport::_selection_result_pressed(int p_result) { +void Node3DEditorViewport::_selection_result_pressed(int p_result) { if (selection_results.size() <= p_result) return; @@ -3179,19 +3238,19 @@ void SpatialEditorViewport::_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() != SpatialEditor::TOOL_MODE_LIST_SELECT); + _select_clicked(clicked_wants_append, true, spatial_editor->get_tool_mode() != Node3DEditor::TOOL_MODE_LIST_SELECT); clicked = ObjectID(); } } -void SpatialEditorViewport::_selection_menu_hide() { +void Node3DEditorViewport::_selection_menu_hide() { selection_results.clear(); selection_menu->clear(); selection_menu->set_size(Vector2(0, 0)); } -void SpatialEditorViewport::set_can_preview(Camera *p_preview) { +void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) { preview = p_preview; @@ -3199,7 +3258,7 @@ void SpatialEditorViewport::set_can_preview(Camera *p_preview) { preview_camera->set_visible(p_preview); } -void SpatialEditorViewport::update_transform_gizmo_view() { +void Node3DEditorViewport::update_transform_gizmo_view() { if (!is_visible_in_tree()) return; @@ -3210,11 +3269,11 @@ void SpatialEditorViewport::update_transform_gizmo_view() { if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); - VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false); + RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); } return; } @@ -3235,27 +3294,27 @@ void SpatialEditorViewport::update_transform_gizmo_view() { const int viewport_base_height = 400 * MAX(1, EDSCALE); gizmo_scale = (gizmo_size / Math::abs(dd)) * MAX(1, EDSCALE) * - MIN(viewport_base_height, viewport_container->get_size().height) / viewport_base_height / - viewport_container->get_stretch_shrink(); + MIN(viewport_base_height, subviewport_container->get_size().height) / viewport_base_height / + subviewport_container->get_stretch_shrink(); Vector3 scale = Vector3(1, 1, 1) * gizmo_scale; xform.basis.scale(scale); for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE)); - VisualServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_MOVE)); - VisualServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE)); - VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); - VisualServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); - VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); + RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); + RenderingServer::get_singleton()->instance_set_transform(move_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE)); + RenderingServer::get_singleton()->instance_set_transform(rotate_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_ROTATE)); + RenderingServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); + RenderingServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); + RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE)); } } -void SpatialEditorViewport::set_state(const Dictionary &p_state) { +void Node3DEditorViewport::set_state(const Dictionary &p_state) { if (p_state.has("position")) cursor.pos = p_state["position"]; @@ -3316,7 +3375,7 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) { bool doppler = p_state["doppler"]; int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER); - camera->set_doppler_tracking(doppler ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED); + camera->set_doppler_tracking(doppler ? Camera3D::DOPPLER_TRACKING_IDLE_STEP : Camera3D::DOPPLER_TRACKING_DISABLED); view_menu->get_popup()->set_item_checked(idx, doppler); } if (p_state.has("gizmos")) { @@ -3333,12 +3392,12 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) { if (view_menu->get_popup()->is_item_checked(idx) != information) _menu_option(VIEW_INFORMATION); } - if (p_state.has("fps")) { - bool fps = p_state["fps"]; + if (p_state.has("frame_time")) { + bool fps = p_state["frame_time"]; - int idx = view_menu->get_popup()->get_item_index(VIEW_FPS); + int idx = view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME); if (view_menu->get_popup()->is_item_checked(idx) != fps) - _menu_option(VIEW_FPS); + _menu_option(VIEW_FRAME_TIME); } if (p_state.has("half_res")) { bool half_res = p_state["half_res"]; @@ -3353,25 +3412,25 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) { view_menu->get_popup()->set_item_checked(idx, previewing_cinema); } - if (preview_camera->is_connected("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview))) { - preview_camera->disconnect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview)); + if (preview_camera->is_connected("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview))) { + preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); } if (p_state.has("previewing")) { Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]); - if (Object::cast_to<Camera>(pv)) { - previewing = Object::cast_to<Camera>(pv); - previewing->connect("tree_exiting", callable_mp(this, &SpatialEditorViewport::_preview_exited_scene)); - VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace + if (Object::cast_to<Camera3D>(pv)) { + previewing = Object::cast_to<Camera3D>(pv); + previewing->connect("tree_exiting", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene)); + RS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace view_menu->set_disabled(true); surface->update(); preview_camera->set_pressed(true); preview_camera->show(); } } - preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview)); + preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); } -Dictionary SpatialEditorViewport::get_state() const { +Dictionary Node3DEditorViewport::get_state() const { Dictionary d; d["position"] = cursor.pos; @@ -3379,7 +3438,7 @@ Dictionary SpatialEditorViewport::get_state() const { d["y_rotation"] = cursor.y_rot; d["distance"] = cursor.distance; d["use_environment"] = camera->get_environment().is_valid(); - d["use_orthogonal"] = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL; + d["use_orthogonal"] = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL; d["view_name"] = name; d["auto_orthogonal"] = auto_orthogonal; d["auto_orthogonal_enabled"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL)); @@ -3395,8 +3454,8 @@ Dictionary SpatialEditorViewport::get_state() const { d["doppler"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER)); d["gizmos"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS)); d["information"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); - d["fps"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); - d["half_res"] = viewport_container->get_stretch_shrink() > 1; + d["frame_time"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME)); + d["half_res"] = subviewport_container->get_stretch_shrink() > 1; d["cinematic_preview"] = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW)); if (previewing) d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing); @@ -3406,17 +3465,17 @@ Dictionary SpatialEditorViewport::get_state() const { return d; } -void SpatialEditorViewport::_bind_methods() { +void Node3DEditorViewport::_bind_methods() { - ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &SpatialEditorViewport::update_transform_gizmo_view); // Used by call_deferred. - ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpatialEditorViewport::can_drop_data_fw); - ClassDB::bind_method(D_METHOD("drop_data_fw"), &SpatialEditorViewport::drop_data_fw); + ClassDB::bind_method(D_METHOD("update_transform_gizmo_view"), &Node3DEditorViewport::update_transform_gizmo_view); // Used by call_deferred. + ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &Node3DEditorViewport::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw"), &Node3DEditorViewport::drop_data_fw); ADD_SIGNAL(MethodInfo("toggle_maximize_view", PropertyInfo(Variant::OBJECT, "viewport"))); ADD_SIGNAL(MethodInfo("clicked", PropertyInfo(Variant::OBJECT, "viewport"))); } -void SpatialEditorViewport::reset() { +void Node3DEditorViewport::reset() { orthogonal = false; auto_orthogonal = false; @@ -3434,7 +3493,7 @@ void SpatialEditorViewport::reset() { _update_name(); } -void SpatialEditorViewport::focus_selection() { +void Node3DEditorViewport::focus_selection() { if (!get_selected_count()) return; @@ -3445,11 +3504,11 @@ void SpatialEditorViewport::focus_selection() { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -3464,20 +3523,20 @@ void SpatialEditorViewport::focus_selection() { cursor.pos = center; } -void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) { +void Node3DEditorViewport::assign_pending_data_pointers(Node3D *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) { preview_node = p_preview_node; preview_bounds = p_preview_bounds; accept = p_accept; } -Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const { +Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const { const float MAX_DISTANCE = 10; Vector3 world_ray = _get_ray(p_pos); Vector3 world_pos = _get_ray_pos(p_pos); - Vector<ObjectID> instances = VisualServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario()); - Set<Ref<EditorSpatialGizmo>> found_gizmos; + Vector<ObjectID> instances = RenderingServer::get_singleton()->instances_cull_ray(world_pos, world_ray, get_tree()->get_root()->get_world()->get_scenario()); + Set<Ref<EditorNode3DGizmo>> found_gizmos; float closest_dist = MAX_DISTANCE; @@ -3486,12 +3545,12 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const for (int i = 0; i < instances.size(); i++) { - MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(ObjectDB::get_instance(instances[i])); + MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i])); if (!mesh_instance) continue; - Ref<EditorSpatialGizmo> seg = mesh_instance->get_gizmo(); + Ref<EditorNode3DGizmo> seg = mesh_instance->get_gizmo(); if ((!seg.is_valid()) || found_gizmos.has(seg)) { continue; @@ -3501,7 +3560,7 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 hit_point; Vector3 hit_normal; - bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, NULL, false); + bool inters = seg->intersect_ray(camera, p_pos, hit_point, hit_normal, nullptr, false); if (!inters) continue; @@ -3527,20 +3586,20 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const return point + offset; } -AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform) { +AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_toplevel_transform) { AABB bounds; - const MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(p_parent); + const MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(p_parent); if (mesh_instance) { bounds = mesh_instance->get_aabb(); } for (int i = 0; i < p_parent->get_child_count(); i++) { - Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i)); + Node3D *child = Object::cast_to<Node3D>(p_parent->get_child(i)); if (child) { AABB child_bounds = _calculate_spatial_bounds(child, false); - if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Spatial")) { + if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Node3D")) { bounds = child_bounds; } else { bounds.merge_with(child_bounds); @@ -3548,7 +3607,7 @@ AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, b } } - if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Spatial")) { + if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Node3D")) { bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); } @@ -3559,16 +3618,16 @@ AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, b return bounds; } -void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { +void Node3DEditorViewport::_create_preview(const Vector<String> &files) const { for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); ERR_CONTINUE(res.is_null()); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - if (mesh != NULL || scene != NULL) { - if (mesh != NULL) { - MeshInstance *mesh_instance = memnew(MeshInstance); + if (mesh != nullptr || scene != nullptr) { + if (mesh != nullptr) { + MeshInstance3D *mesh_instance = memnew(MeshInstance3D); mesh_instance->set_mesh(mesh); preview_node->add_child(mesh_instance); } else { @@ -3585,7 +3644,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { *preview_bounds = _calculate_spatial_bounds(preview_node); } -void SpatialEditorViewport::_remove_preview() { +void Node3DEditorViewport::_remove_preview() { if (preview_node->get_parent()) { for (int i = preview_node->get_child_count() - 1; i >= 0; i--) { Node *node = preview_node->get_child(i); @@ -3596,7 +3655,7 @@ void SpatialEditorViewport::_remove_preview() { } } -bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) { +bool Node3DEditorViewport::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) { if (p_desired_node->get_filename() == p_target_scene_path) { return true; } @@ -3611,18 +3670,18 @@ bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_s return false; } -bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) { +bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) { RES res = ResourceLoader::load(path); ERR_FAIL_COND_V(res.is_null(), false); Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - Node *instanced_scene = NULL; + Node *instanced_scene = nullptr; - if (mesh != NULL || scene != NULL) { - if (mesh != NULL) { - MeshInstance *mesh_instance = memnew(MeshInstance); + if (mesh != nullptr || scene != nullptr) { + if (mesh != nullptr) { + MeshInstance3D *mesh_instance = memnew(MeshInstance3D); mesh_instance->set_mesh(mesh); mesh_instance->set_name(path.get_file().get_basename()); instanced_scene = mesh_instance; @@ -3635,7 +3694,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - if (instanced_scene == NULL) { + if (instanced_scene == nullptr) { return false; } @@ -3646,7 +3705,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - if (scene != NULL) { + if (scene != nullptr) { instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); } @@ -3661,7 +3720,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name)); Transform global_transform; - Spatial *parent_spatial = Object::cast_to<Spatial>(parent); + Node3D *parent_spatial = Object::cast_to<Node3D>(parent); if (parent_spatial) global_transform = parent_spatial->get_global_gizmo_transform(); @@ -3672,7 +3731,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P return true; } -void SpatialEditorViewport::_perform_drop_data() { +void Node3DEditorViewport::_perform_drop_data() { _remove_preview(); Vector<String> error_files; @@ -3687,7 +3746,7 @@ void SpatialEditorViewport::_perform_drop_data() { } Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res)); - if (mesh != NULL || scene != NULL) { + if (mesh != nullptr || scene != nullptr) { bool success = _create_instance(target_node, path, drop_pos); if (!success) { error_files.push_back(path); @@ -3704,11 +3763,11 @@ void SpatialEditorViewport::_perform_drop_data() { } files_str = files_str.substr(0, files_str.length() - 1); accept->set_text(vformat(TTR("Error instancing scene from %s"), files_str.c_str())); - accept->popup_centered_minsize(); + accept->popup_centered(); } } -bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { +bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { bool can_instance = false; @@ -3765,11 +3824,11 @@ bool SpatialEditorViewport::can_drop_data_fw(const Point2 &p_point, const Varian return can_instance; } -void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { +void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { if (!can_drop_data_fw(p_point, p_data, p_from)) return; - bool is_shift = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + bool is_shift = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); selected_files.clear(); Dictionary d = p_data; @@ -3784,14 +3843,14 @@ void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p list.push_back(root_node); } else { accept->set_text(TTR("No parent to instance a child at.")); - accept->popup_centered_minsize(); + accept->popup_centered(); _remove_preview(); return; } } if (list.size() != 1) { accept->set_text(TTR("This operation requires a single selected node.")); - accept->popup_centered_minsize(); + accept->popup_centered(); _remove_preview(); return; } @@ -3805,7 +3864,10 @@ void SpatialEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p _perform_drop_data(); } -SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) { +Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index) { + + cpu_time_history_index = 0; + gpu_time_history_index = 0; _edit.mode = TRANSFORM_NONE; _edit.plane = TRANSFORM_VIEW; @@ -3827,12 +3889,12 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed zoom_indicator_delay = 0.0; spatial_editor = p_spatial_editor; - ViewportContainer *c = memnew(ViewportContainer); - viewport_container = c; + SubViewportContainer *c = memnew(SubViewportContainer); + subviewport_container = c; c->set_stretch(true); add_child(c); c->set_anchors_and_margins_preset(Control::PRESET_WIDE); - viewport = memnew(Viewport); + viewport = memnew(SubViewport); viewport->set_disable_input(true); c->add_child(viewport); @@ -3841,7 +3903,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed add_child(surface); surface->set_anchors_and_margins_preset(Control::PRESET_WIDE); surface->set_clip_contents(true); - camera = memnew(Camera); + camera = memnew(Camera3D); camera->set_disable_gizmo(true); camera->set_cull_mask(((1 << 20) - 1) | (1 << (GIZMO_BASE_LAYER + p_index)) | (1 << GIZMO_EDIT_LAYER) | (1 << GIZMO_GRID_LAYER)); viewport->add_child(camera); @@ -3885,11 +3947,15 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_lighting", TTR("Display Lighting")), VIEW_DISPLAY_LIGHTING); view_menu->get_popup()->add_radio_check_shortcut(ED_SHORTCUT("spatial_editor/view_display_unshaded", TTR("Display Unshaded")), VIEW_DISPLAY_SHADELESS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL), true); + display_submenu->add_radio_check_item(TTR("Directional Shadow Splits"), VIEW_DISPLAY_DEBUG_PSSM_SPLITS); + display_submenu->add_separator(); display_submenu->add_radio_check_item(TTR("Normal Buffer"), VIEW_DISPLAY_NORMAL_BUFFER); display_submenu->add_separator(); display_submenu->add_radio_check_item(TTR("Shadow Atlas"), VIEW_DISPLAY_DEBUG_SHADOW_ATLAS); display_submenu->add_radio_check_item(TTR("Directional Shadow"), VIEW_DISPLAY_DEBUG_DIRECTIONAL_SHADOW_ATLAS); display_submenu->add_separator(); + display_submenu->add_radio_check_item(TTR("Decal Atlas"), VIEW_DISPLAY_DEBUG_DECAL_ATLAS); + display_submenu->add_separator(); display_submenu->add_radio_check_item(TTR("GIProbe Lighting"), VIEW_DISPLAY_DEBUG_GIPROBE_LIGHTING); display_submenu->add_radio_check_item(TTR("GIProbe Albedo"), VIEW_DISPLAY_DEBUG_GIPROBE_ALBEDO); display_submenu->add_radio_check_item(TTR("GIProbe Emission"), VIEW_DISPLAY_DEBUG_GIPROBE_EMISSION); @@ -3905,7 +3971,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_information", TTR("View Information")), VIEW_INFORMATION); - view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View FPS")), VIEW_FPS); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View Frame Time")), VIEW_FRAME_TIME); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true); view_menu->get_popup()->add_separator(); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_half_resolution", TTR("Half Resolution")), VIEW_HALF_RESOLUTION); @@ -3922,11 +3988,14 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/focus_selection"), VIEW_CENTER_TO_SELECTION); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_transform_with_view"), VIEW_ALIGN_TRANSFORM_WITH_VIEW); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/align_rotation_with_view"), VIEW_ALIGN_ROTATION_WITH_VIEW); - view_menu->get_popup()->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_menu_option)); - display_submenu->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_menu_option)); + view_menu->get_popup()->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option)); + display_submenu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option)); view_menu->set_disable_shortcuts(true); - - if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) { +#ifndef _MSC_VER +#warning this needs to be fixed +#endif + //if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) { + if (false) { // Alternate display modes only work when using the Vulkan renderer; make this explicit. const int normal_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_NORMAL); const int wireframe_idx = view_menu->get_popup()->get_item_index(VIEW_DISPLAY_WIREFRAME); @@ -3958,11 +4027,11 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed vbox->add_child(preview_camera); preview_camera->set_h_size_flags(0); preview_camera->hide(); - preview_camera->connect("toggled", callable_mp(this, &SpatialEditorViewport::_toggle_camera_preview)); - previewing = NULL; + preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + previewing = nullptr; gizmo_scale = 1.0; - preview_node = NULL; + preview_node = nullptr; info_label = memnew(Label); info_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE); @@ -3979,7 +4048,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE); fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN); - fps_label->set_tooltip(TTR("Note: The FPS value displayed is the editor's framerate.\nIt cannot be used as a reliable indication of in-game performance.")); + fps_label->set_tooltip(TTR("Note: The FPS is estimated on a 60hz refresh rate.")); fps_label->set_mouse_filter(MOUSE_FILTER_PASS); // Otherwise tooltip doesn't show. surface->add_child(fps_label); fps_label->hide(); @@ -4025,16 +4094,16 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed surface->add_child(top_right_vbox); - accept = NULL; + accept = nullptr; freelook_active = false; freelook_speed = EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_base_speed"); selection_menu = memnew(PopupMenu); add_child(selection_menu); - selection_menu->set_custom_minimum_size(Size2(100, 0) * EDSCALE); - selection_menu->connect("id_pressed", callable_mp(this, &SpatialEditorViewport::_selection_result_pressed)); - selection_menu->connect("popup_hide", callable_mp(this, &SpatialEditorViewport::_selection_menu_hide)); + selection_menu->set_min_size(Size2(100, 0) * EDSCALE); + selection_menu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_selection_result_pressed)); + selection_menu->connect("popup_hide", callable_mp(this, &Node3DEditorViewport::_selection_menu_hide)); if (p_index == 0) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER), true); @@ -4044,12 +4113,12 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed name = ""; _update_name(); - EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &SpatialEditorViewport::update_transform_gizmo_view)); + EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Node3DEditorViewport::update_transform_gizmo_view)); } ////////////////////////////////////////////////////////////// -void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { +void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; @@ -4058,8 +4127,8 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) if (mb->is_pressed()) { Vector2 size = get_size(); - int h_sep = get_constant("separation", "HSplitContainer"); - int v_sep = get_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant("separation", "HSplitContainer"); + int v_sep = get_theme_constant("separation", "VSplitContainer"); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4109,8 +4178,8 @@ void SpatialEditorViewportContainer::_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_constant("separation", "HSplitContainer"); - int v_sep = get_constant("separation", "VSplitContainer"); + int h_sep = get_theme_constant("separation", "HSplitContainer"); + int v_sep = get_theme_constant("separation", "VSplitContainer"); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4142,7 +4211,7 @@ void SpatialEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) } } -void SpatialEditorViewportContainer::_notification(int p_what) { +void Node3DEditorViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) { @@ -4152,18 +4221,18 @@ void SpatialEditorViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture2D> h_grabber = get_icon("grabber", "HSplitContainer"); - Ref<Texture2D> v_grabber = get_icon("grabber", "VSplitContainer"); + Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer"); + Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer"); - Ref<Texture2D> hdiag_grabber = get_icon("GuiViewportHdiagsplitter", "EditorIcons"); - Ref<Texture2D> vdiag_grabber = get_icon("GuiViewportVdiagsplitter", "EditorIcons"); - Ref<Texture2D> vh_grabber = get_icon("GuiViewportVhsplitter", "EditorIcons"); + 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"); Vector2 size = get_size(); - int h_sep = get_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant("separation", "VSplitContainer"); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4238,10 +4307,10 @@ void SpatialEditorViewportContainer::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { - SpatialEditorViewport *viewports[4]; + Node3DEditorViewport *viewports[4]; int vc = 0; for (int i = 0; i < get_child_count(); i++) { - viewports[vc] = Object::cast_to<SpatialEditorViewport>(get_child(i)); + viewports[vc] = Object::cast_to<Node3DEditorViewport>(get_child(i)); if (viewports[vc]) { vc++; } @@ -4257,9 +4326,9 @@ void SpatialEditorViewportContainer::_notification(int p_what) { } return; } - int h_sep = get_constant("separation", "HSplitContainer"); + int h_sep = get_theme_constant("separation", "HSplitContainer"); - int v_sep = get_constant("separation", "VSplitContainer"); + int v_sep = get_theme_constant("separation", "VSplitContainer"); int mid_w = size.width * ratio_h; int mid_h = size.height * ratio_v; @@ -4357,23 +4426,23 @@ void SpatialEditorViewportContainer::_notification(int p_what) { } } -void SpatialEditorViewportContainer::set_view(View p_view) { +void Node3DEditorViewportContainer::set_view(View p_view) { view = p_view; queue_sort(); } -SpatialEditorViewportContainer::View SpatialEditorViewportContainer::get_view() { +Node3DEditorViewportContainer::View Node3DEditorViewportContainer::get_view() { return view; } -void SpatialEditorViewportContainer::_bind_methods() { +void Node3DEditorViewportContainer::_bind_methods() { - ClassDB::bind_method("_gui_input", &SpatialEditorViewportContainer::_gui_input); + ClassDB::bind_method("_gui_input", &Node3DEditorViewportContainer::_gui_input); } -SpatialEditorViewportContainer::SpatialEditorViewportContainer() { +Node3DEditorViewportContainer::Node3DEditorViewportContainer() { set_clip_contents(true); view = VIEW_USE_1_VIEWPORT; @@ -4388,15 +4457,15 @@ SpatialEditorViewportContainer::SpatialEditorViewportContainer() { /////////////////////////////////////////////////////////////////// -SpatialEditor *SpatialEditor::singleton = NULL; +Node3DEditor *Node3DEditor::singleton = nullptr; -SpatialEditorSelectedItem::~SpatialEditorSelectedItem() { +Node3DEditorSelectedItem::~Node3DEditorSelectedItem() { if (sbox_instance.is_valid()) - VisualServer::get_singleton()->free(sbox_instance); + RenderingServer::get_singleton()->free(sbox_instance); } -void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { +void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { for (int i = 0; i < 3; i++) { @@ -4408,7 +4477,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { } } -void SpatialEditor::update_transform_gizmo() { +void Node3DEditor::update_transform_gizmo() { List<Node *> &selection = editor_selection->get_selected_node_list(); AABB center; @@ -4419,11 +4488,11 @@ void SpatialEditor::update_transform_gizmo() { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -4454,7 +4523,7 @@ void SpatialEditor::update_transform_gizmo() { void _update_all_gizmos(Node *p_node) { for (int i = p_node->get_child_count() - 1; 0 <= i; --i) { - Spatial *spatial_node = Object::cast_to<Spatial>(p_node->get_child(i)); + Node3D *spatial_node = Object::cast_to<Node3D>(p_node->get_child(i)); if (spatial_node) { spatial_node->update_gizmo(); } @@ -4463,29 +4532,29 @@ void _update_all_gizmos(Node *p_node) { } } -void SpatialEditor::update_all_gizmos(Node *p_node) { +void Node3DEditor::update_all_gizmos(Node *p_node) { if (!p_node) { p_node = SceneTree::get_singleton()->get_root(); } _update_all_gizmos(p_node); } -Object *SpatialEditor::_get_editor_data(Object *p_what) { +Object *Node3DEditor::_get_editor_data(Object *p_what) { - Spatial *sp = Object::cast_to<Spatial>(p_what); + Node3D *sp = Object::cast_to<Node3D>(p_what); if (!sp) - return NULL; + return nullptr; - SpatialEditorSelectedItem *si = memnew(SpatialEditorSelectedItem); + Node3DEditorSelectedItem *si = memnew(Node3DEditorSelectedItem); si->sp = sp; - si->sbox_instance = VisualServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario()); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, VS::SHADOW_CASTING_SETTING_OFF); + si->sbox_instance = RenderingServer::get_singleton()->instance_create2(selection_box->get_rid(), sp->get_world()->get_scenario()); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(si->sbox_instance, RS::SHADOW_CASTING_SETTING_OFF); return si; } -void SpatialEditor::_generate_selection_box() { +void Node3DEditor::_generate_selection_box() { AABB aabb(Vector3(), Vector3(1, 1, 1)); aabb.grow_by(aabb.get_longest_axis_size() / 20.0); @@ -4519,7 +4588,7 @@ void SpatialEditor::_generate_selection_box() { selection_box = st->commit(); } -Dictionary SpatialEditor::get_state() const { +Dictionary Node3DEditor::get_state() const { Dictionary d; @@ -4570,7 +4639,7 @@ Dictionary SpatialEditor::get_state() const { return d; } -void SpatialEditor::set_state(const Dictionary &p_state) { +void Node3DEditor::set_state(const Dictionary &p_state) { Dictionary d = p_state; @@ -4644,7 +4713,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) { if (use != view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN))) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), use); - VisualServer::get_singleton()->instance_set_visible(origin_instance, use); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, use); } } @@ -4655,7 +4724,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) { for (int j = 0; j < gizmo_plugins_by_name.size(); ++j) { if (!gizmo_plugins_by_name[j]->can_be_hidden()) continue; - int state = EditorSpatialGizmoPlugin::VISIBLE; + int state = EditorNode3DGizmoPlugin::VISIBLE; for (int i = 0; i < keys.size(); i++) { if (gizmo_plugins_by_name.write[j]->get_name() == keys[i]) { state = gizmos_status[keys[i]]; @@ -4669,12 +4738,12 @@ void SpatialEditor::set_state(const Dictionary &p_state) { } } -void SpatialEditor::edit(Spatial *p_spatial) { +void Node3DEditor::edit(Node3D *p_spatial) { if (p_spatial != selected) { if (selected) { - Ref<EditorSpatialGizmo> seg = selected->get_gizmo(); + Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); if (seg.is_valid()) { seg->set_selected(false); selected->update_gizmo(); @@ -4686,7 +4755,7 @@ void SpatialEditor::edit(Spatial *p_spatial) { if (selected) { - Ref<EditorSpatialGizmo> seg = selected->get_gizmo(); + Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); if (seg.is_valid()) { seg->set_selected(true); selected->update_gizmo(); @@ -4695,21 +4764,21 @@ void SpatialEditor::edit(Spatial *p_spatial) { } } -void SpatialEditor::_snap_changed() { +void Node3DEditor::_snap_changed() { snap_translate_value = snap_translate->get_text().to_double(); snap_rotate_value = snap_rotate->get_text().to_double(); snap_scale_value = snap_scale->get_text().to_double(); } -void SpatialEditor::_snap_update() { +void Node3DEditor::_snap_update() { snap_translate->set_text(String::num(snap_translate_value)); snap_rotate->set_text(String::num(snap_rotate_value)); snap_scale->set_text(String::num(snap_scale_value)); } -void SpatialEditor::_xform_dialog_action() { +void Node3DEditor::_xform_dialog_action() { Transform t; //translation @@ -4733,11 +4802,11 @@ void SpatialEditor::_xform_dialog_action() { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; - SpatialEditorSelectedItem *se = editor_selection->get_node_editor_data<SpatialEditorSelectedItem>(sp); + Node3DEditorSelectedItem *se = editor_selection->get_node_editor_data<Node3DEditorSelectedItem>(sp); if (!se) continue; @@ -4758,7 +4827,7 @@ void SpatialEditor::_xform_dialog_action() { undo_redo->commit_action(); } -void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) { +void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) { switch (p_option) { case MENU_TOOL_LOCAL_COORDS: { @@ -4787,7 +4856,7 @@ void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) { } } -void SpatialEditor::_menu_gizmo_toggled(int p_option) { +void Node3DEditor::_menu_gizmo_toggled(int p_option) { const int idx = gizmos_menu->get_item_index(p_option); gizmos_menu->toggle_item_multistate(idx); @@ -4795,14 +4864,14 @@ void SpatialEditor::_menu_gizmo_toggled(int p_option) { // Change icon const int state = gizmos_menu->get_item_state(idx); switch (state) { - case EditorSpatialGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_visible")); + case EditorNode3DGizmoPlugin::VISIBLE: + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_visible")); break; - case EditorSpatialGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_xray")); + case EditorNode3DGizmoPlugin::ON_TOP: + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_xray")); break; - case EditorSpatialGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_icon("visibility_hidden")); + case EditorNode3DGizmoPlugin::HIDDEN: + gizmos_menu->set_item_icon(idx, view_menu->get_popup()->get_theme_icon("visibility_hidden")); break; } @@ -4811,7 +4880,7 @@ void SpatialEditor::_menu_gizmo_toggled(int p_option) { update_all_gizmos(); } -void SpatialEditor::_update_camera_override_button(bool p_game_running) { +void Node3DEditor::_update_camera_override_button(bool p_game_running) { Button *const button = tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]; if (p_game_running) { @@ -4824,8 +4893,8 @@ void SpatialEditor::_update_camera_override_button(bool p_game_running) { } } -void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) { - SpatialEditorViewport *current_viewport = Object::cast_to<SpatialEditorViewport>(p_viewport); +void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) { + Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport); if (!current_viewport) return; @@ -4840,7 +4909,7 @@ void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) { } } -void SpatialEditor::_menu_item_pressed(int p_option) { +void Node3DEditor::_menu_item_pressed(int p_option) { switch (p_option) { @@ -4874,7 +4943,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_1_VIEWPORT: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_1_VIEWPORT); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_1_VIEWPORT); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), true); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false); @@ -4886,7 +4955,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_2_VIEWPORTS: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_2_VIEWPORTS); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), true); @@ -4898,7 +4967,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_2_VIEWPORTS_ALT: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_2_VIEWPORTS_ALT); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_2_VIEWPORTS_ALT); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false); @@ -4910,7 +4979,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_3_VIEWPORTS: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_3_VIEWPORTS); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false); @@ -4922,7 +4991,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_3_VIEWPORTS_ALT: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_3_VIEWPORTS_ALT); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_3_VIEWPORTS_ALT); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false); @@ -4934,7 +5003,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_USE_4_VIEWPORTS: { - viewport_base->set_view(SpatialEditorViewportContainer::VIEW_USE_4_VIEWPORTS); + viewport_base->set_view(Node3DEditorViewportContainer::VIEW_USE_4_VIEWPORTS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), false); @@ -4949,7 +5018,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option)); origin_enabled = !is_checked; - VisualServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, origin_enabled); // Update the grid since its appearance depends on whether the origin is enabled _finish_grid(); _init_grid(); @@ -4964,7 +5033,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { for (int i = 0; i < 3; ++i) { if (grid_enable[i]) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_enabled); grid_visible[i] = grid_enabled; } } @@ -4986,7 +5055,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *spatial = Object::cast_to<Spatial>(E->get()); + Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5010,7 +5079,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *spatial = Object::cast_to<Spatial>(E->get()); + Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5034,7 +5103,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *spatial = Object::cast_to<Spatial>(E->get()); + Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5057,7 +5126,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Spatial *spatial = Object::cast_to<Spatial>(E->get()); + Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5077,7 +5146,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } } -void SpatialEditor::_init_indicators() { +void Node3DEditor::_init_indicators() { { origin_enabled = true; @@ -5097,13 +5166,13 @@ void SpatialEditor::_init_indicators() { Color origin_color; switch (i) { case 0: - origin_color = get_color("axis_x_color", "Editor"); + origin_color = get_theme_color("axis_x_color", "Editor"); break; case 1: - origin_color = get_color("axis_y_color", "Editor"); + origin_color = get_theme_color("axis_y_color", "Editor"); break; case 2: - origin_color = get_color("axis_z_color", "Editor"); + origin_color = get_theme_color("axis_z_color", "Editor"); break; default: origin_color = Color(); @@ -5124,19 +5193,19 @@ void SpatialEditor::_init_indicators() { _init_grid(); - origin = VisualServer::get_singleton()->mesh_create(); + origin = RenderingServer::get_singleton()->mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_VERTEX] = origin_points; - d[VisualServer::ARRAY_COLOR] = origin_colors; + d.resize(RS::ARRAY_MAX); + d[RenderingServer::ARRAY_VERTEX] = origin_points; + d[RenderingServer::ARRAY_COLOR] = origin_colors; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(origin, VisualServer::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid()); + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(origin, RenderingServer::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(origin, 0, indicator_mat->get_rid()); - origin_instance = VisualServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario()); - VS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << SpatialEditorViewport::GIZMO_GRID_LAYER); + origin_instance = RenderingServer::get_singleton()->instance_create2(origin, get_tree()->get_root()->get_world()->get_scenario()); + RS::get_singleton()->instance_set_layer_mask(origin_instance, 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); - VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, VS::SHADOW_CASTING_SETTING_OFF); + RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(origin_instance, RS::SHADOW_CASTING_SETTING_OFF); } { @@ -5148,13 +5217,13 @@ void SpatialEditor::_init_indicators() { Color col; switch (i) { case 0: - col = get_color("axis_x_color", "Editor"); + col = get_theme_color("axis_x_color", "Editor"); break; case 1: - col = get_color("axis_y_color", "Editor"); + col = get_theme_color("axis_y_color", "Editor"); break; case 2: - col = get_color("axis_z_color", "Editor"); + col = get_theme_color("axis_z_color", "Editor"); break; default: col = Color(); @@ -5414,7 +5483,7 @@ void SpatialEditor::_init_indicators() { _generate_selection_box(); } -void SpatialEditor::_update_gizmos_menu() { +void Node3DEditor::_update_gizmos_menu() { gizmos_menu->clear(); @@ -5425,39 +5494,39 @@ void SpatialEditor::_update_gizmos_menu() { gizmos_menu->add_multistate_item(TTR(plugin_name), 3, plugin_state, i); const int idx = gizmos_menu->get_item_index(i); switch (plugin_state) { - case EditorSpatialGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_visible")); + case EditorNode3DGizmoPlugin::VISIBLE: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); break; - case EditorSpatialGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_xray")); + case EditorNode3DGizmoPlugin::ON_TOP: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); break; - case EditorSpatialGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_hidden")); + case EditorNode3DGizmoPlugin::HIDDEN: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); break; } } } -void SpatialEditor::_update_gizmos_menu_theme() { +void Node3DEditor::_update_gizmos_menu_theme() { for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) { if (!gizmo_plugins_by_name[i]->can_be_hidden()) continue; const int plugin_state = gizmo_plugins_by_name[i]->get_state(); const int idx = gizmos_menu->get_item_index(i); switch (plugin_state) { - case EditorSpatialGizmoPlugin::VISIBLE: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_visible")); + case EditorNode3DGizmoPlugin::VISIBLE: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_visible")); break; - case EditorSpatialGizmoPlugin::ON_TOP: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_xray")); + case EditorNode3DGizmoPlugin::ON_TOP: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_xray")); break; - case EditorSpatialGizmoPlugin::HIDDEN: - gizmos_menu->set_item_icon(idx, gizmos_menu->get_icon("visibility_hidden")); + case EditorNode3DGizmoPlugin::HIDDEN: + gizmos_menu->set_item_icon(idx, gizmos_menu->get_theme_icon("visibility_hidden")); break; } } } -void SpatialEditor::_init_grid() { +void Node3DEditor::_init_grid() { Vector<Color> grid_colors[3]; Vector<Vector3> grid_points[3]; @@ -5501,37 +5570,37 @@ void SpatialEditor::_init_grid() { grid_colors[i].push_back(line_color); } - grid[i] = VisualServer::get_singleton()->mesh_create(); + grid[i] = RenderingServer::get_singleton()->mesh_create(); Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_VERTEX] = grid_points[i]; - d[VisualServer::ARRAY_COLOR] = grid_colors[i]; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], VisualServer::PRIMITIVE_LINES, d); - VisualServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); - grid_instance[i] = VisualServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); + d.resize(RS::ARRAY_MAX); + d[RenderingServer::ARRAY_VERTEX] = grid_points[i]; + d[RenderingServer::ARRAY_COLOR] = grid_colors[i]; + RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[i], RenderingServer::PRIMITIVE_LINES, d); + RenderingServer::get_singleton()->mesh_surface_set_material(grid[i], 0, indicator_mat->get_rid()); + grid_instance[i] = RenderingServer::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]); - VisualServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], VS::SHADOW_CASTING_SETTING_OFF); - VS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << SpatialEditorViewport::GIZMO_GRID_LAYER); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], grid_visible[i]); + RenderingServer::get_singleton()->instance_geometry_set_cast_shadows_setting(grid_instance[i], RS::SHADOW_CASTING_SETTING_OFF); + RS::get_singleton()->instance_set_layer_mask(grid_instance[i], 1 << Node3DEditorViewport::GIZMO_GRID_LAYER); } } -void SpatialEditor::_finish_indicators() { +void Node3DEditor::_finish_indicators() { - VisualServer::get_singleton()->free(origin_instance); - VisualServer::get_singleton()->free(origin); + RenderingServer::get_singleton()->free(origin_instance); + RenderingServer::get_singleton()->free(origin); _finish_grid(); } -void SpatialEditor::_finish_grid() { +void Node3DEditor::_finish_grid() { for (int i = 0; i < 3; i++) { - VisualServer::get_singleton()->free(grid_instance[i]); - VisualServer::get_singleton()->free(grid[i]); + RenderingServer::get_singleton()->free(grid_instance[i]); + RenderingServer::get_singleton()->free(grid[i]); } } -bool SpatialEditor::is_any_freelook_active() const { +bool Node3DEditor::is_any_freelook_active() const { for (unsigned int i = 0; i < VIEWPORTS_COUNT; ++i) { if (viewports[i]->is_freelook_active()) return true; @@ -5539,7 +5608,7 @@ bool SpatialEditor::is_any_freelook_active() const { return false; } -void SpatialEditor::_refresh_menu_icons() { +void Node3DEditor::_refresh_menu_icons() { bool all_locked = true; bool all_grouped = true; @@ -5551,13 +5620,13 @@ void SpatialEditor::_refresh_menu_icons() { all_grouped = false; } else { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Spatial>(E->get()) && !Object::cast_to<Spatial>(E->get())->has_meta("_edit_lock_")) { + if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_lock_")) { all_locked = false; break; } } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (Object::cast_to<Spatial>(E->get()) && !Object::cast_to<Spatial>(E->get())->has_meta("_edit_group_")) { + if (Object::cast_to<Node3D>(E->get()) && !Object::cast_to<Node3D>(E->get())->has_meta("_edit_group_")) { all_grouped = false; break; } @@ -5594,35 +5663,35 @@ Set<T *> _get_child_nodes(Node *parent_node) { Set<RID> _get_physics_bodies_rid(Node *node) { Set<RID> rids = Set<RID>(); - PhysicsBody *pb = Node::cast_to<PhysicsBody>(node); + PhysicsBody3D *pb = Node::cast_to<PhysicsBody3D>(node); if (pb) { rids.insert(pb->get_rid()); } - Set<PhysicsBody *> child_nodes = _get_child_nodes<PhysicsBody>(node); - for (Set<PhysicsBody *>::Element *I = child_nodes.front(); I; I = I->next()) { + Set<PhysicsBody3D *> child_nodes = _get_child_nodes<PhysicsBody3D>(node); + for (Set<PhysicsBody3D *>::Element *I = child_nodes.front(); I; I = I->next()) { rids.insert(I->get()->get_rid()); } return rids; } -void SpatialEditor::snap_selected_nodes_to_floor() { +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()) { - Spatial *sp = Object::cast_to<Spatial>(E->get()); + Node3D *sp = Object::cast_to<Node3D>(E->get()); if (sp) { Vector3 from = Vector3(); Vector3 position_offset = Vector3(); // Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin - Set<VisualInstance *> vi = _get_child_nodes<VisualInstance>(sp); - Set<CollisionShape *> cs = _get_child_nodes<CollisionShape>(sp); + Set<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp); + Set<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp); if (cs.size()) { AABB aabb = sp->get_global_transform().xform(cs.front()->get()->get_shape()->get_debug_mesh()->get_aabb()); - for (Set<CollisionShape *>::Element *I = cs.front(); I; I = I->next()) { + for (Set<CollisionShape3D *>::Element *I = cs.front(); I; I = I->next()) { aabb.merge_with(sp->get_global_transform().xform(I->get()->get_shape()->get_debug_mesh()->get_aabb())); } Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5); @@ -5630,7 +5699,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() { position_offset.y = from.y - sp->get_global_transform().origin.y; } else if (vi.size()) { AABB aabb = vi.front()->get()->get_transformed_aabb(); - for (Set<VisualInstance *>::Element *I = vi.front(); I; I = I->next()) { + for (Set<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) { aabb.merge_with(I->get()->get_transformed_aabb()); } Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5); @@ -5653,8 +5722,8 @@ void SpatialEditor::snap_selected_nodes_to_floor() { } } - PhysicsDirectSpaceState *ss = get_tree()->get_root()->get_world()->get_direct_space_state(); - PhysicsDirectSpaceState::RayResult result; + PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world()->get_direct_space_state(); + PhysicsDirectSpaceState3D::RayResult result; Array keys = snap_data.keys(); @@ -5669,7 +5738,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() { // We need to check this before snapping to register the undo/redo action only if needed. for (int i = 0; i < keys.size(); i++) { Node *node = keys[i]; - Spatial *sp = Object::cast_to<Spatial>(node); + Node3D *sp = Object::cast_to<Node3D>(node); Dictionary d = snap_data[node]; Vector3 from = d["from"]; Vector3 to = from - Vector3(0.0, max_snap_height, 0.0); @@ -5686,7 +5755,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() { // Perform snapping if at least one node can be snapped for (int i = 0; i < keys.size(); i++) { Node *node = keys[i]; - Spatial *sp = Object::cast_to<Spatial>(node); + Node3D *sp = Object::cast_to<Node3D>(node); Dictionary d = snap_data[node]; Vector3 from = d["from"]; Vector3 to = from - Vector3(0.0, max_snap_height, 0.0); @@ -5711,48 +5780,48 @@ void SpatialEditor::snap_selected_nodes_to_floor() { } } -void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) { +void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) { - if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) + if (!is_visible_in_tree()) return; - snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL); + snap_key_enabled = InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); } -void SpatialEditor::_notification(int p_what) { +void Node3DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons")); - tool_button[SpatialEditor::TOOL_LOCK_SELECTED]->set_icon(get_icon("Lock", "EditorIcons")); - tool_button[SpatialEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_icon("Unlock", "EditorIcons")); - tool_button[SpatialEditor::TOOL_GROUP_SELECTED]->set_icon(get_icon("Group", "EditorIcons")); - tool_button[SpatialEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_icon("Ungroup", "EditorIcons")); - - tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_icon("Object", "EditorIcons")); - tool_option_button[SpatialEditor::TOOL_OPT_USE_SNAP]->set_icon(get_icon("Snap", "EditorIcons")); - tool_option_button[SpatialEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_icon("Camera", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_icon("Panels4", "EditorIcons")); + 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, &SpatialEditor::_node_removed)); - EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->connect("node_changed", callable_mp(this, &SpatialEditor::_refresh_menu_icons)); - editor_selection->connect("selection_changed", callable_mp(this, &SpatialEditor::_refresh_menu_icons)); + get_tree()->connect("node_removed", callable_mp(this, &Node3DEditor::_node_removed)); + 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, &SpatialEditor::_update_camera_override_button), make_binds(false)); - editor->connect("play_pressed", callable_mp(this, &SpatialEditor::_update_camera_override_button), make_binds(true)); + 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)); } else if (p_what == NOTIFICATION_ENTER_TREE) { _register_all_gizmos(); @@ -5764,25 +5833,25 @@ void SpatialEditor::_notification(int p_what) { _finish_indicators(); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - tool_button[SpatialEditor::TOOL_MODE_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons")); - tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons")); - tool_button[SpatialEditor::TOOL_LOCK_SELECTED]->set_icon(get_icon("Lock", "EditorIcons")); - tool_button[SpatialEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_icon("Unlock", "EditorIcons")); - tool_button[SpatialEditor::TOOL_GROUP_SELECTED]->set_icon(get_icon("Group", "EditorIcons")); - tool_button[SpatialEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_icon("Ungroup", "EditorIcons")); - - tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_icon("Object", "EditorIcons")); - tool_option_button[SpatialEditor::TOOL_OPT_USE_SNAP]->set_icon(get_icon("Snap", "EditorIcons")); - - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_icon("Panels1", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_icon("Panels2", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS_ALT), get_icon("Panels2Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS), get_icon("Panels3", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_icon("Panels3Alt", "EditorIcons")); - view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_icon("Panels4", "EditorIcons")); + 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(); @@ -5797,41 +5866,41 @@ void SpatialEditor::_notification(int p_what) { } } -void SpatialEditor::add_control_to_menu_panel(Control *p_control) { +void Node3DEditor::add_control_to_menu_panel(Control *p_control) { hbc_menu->add_child(p_control); } -void SpatialEditor::remove_control_from_menu_panel(Control *p_control) { +void Node3DEditor::remove_control_from_menu_panel(Control *p_control) { hbc_menu->remove_child(p_control); } -void SpatialEditor::set_can_preview(Camera *p_preview) { +void Node3DEditor::set_can_preview(Camera3D *p_preview) { for (int i = 0; i < 4; i++) { viewports[i]->set_can_preview(p_preview); } } -VSplitContainer *SpatialEditor::get_shader_split() { +VSplitContainer *Node3DEditor::get_shader_split() { return shader_split; } -HSplitContainer *SpatialEditor::get_palette_split() { +HSplitContainer *Node3DEditor::get_palette_split() { return palette_split; } -void SpatialEditor::_request_gizmo(Object *p_obj) { +void Node3DEditor::_request_gizmo(Object *p_obj) { - Spatial *sp = Object::cast_to<Spatial>(p_obj); + Node3D *sp = Object::cast_to<Node3D>(p_obj); if (!sp) return; if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) { - Ref<EditorSpatialGizmo> seg; + Ref<EditorNode3DGizmo> seg; for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) { seg = gizmo_plugins_by_priority.write[i]->get_gizmo(sp); @@ -5850,9 +5919,9 @@ void SpatialEditor::_request_gizmo(Object *p_obj) { } } -void SpatialEditor::_toggle_maximize_view(Object *p_viewport) { +void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { if (!p_viewport) return; - SpatialEditorViewport *current_viewport = Object::cast_to<SpatialEditorViewport>(p_viewport); + Node3DEditorViewport *current_viewport = Object::cast_to<Node3DEditorViewport>(p_viewport); if (!current_viewport) return; int index = -1; @@ -5895,49 +5964,50 @@ void SpatialEditor::_toggle_maximize_view(Object *p_viewport) { } } -void SpatialEditor::_node_removed(Node *p_node) { +void Node3DEditor::_node_removed(Node *p_node) { if (p_node == selected) - selected = NULL; -} - -void SpatialEditor::_register_all_gizmos() { - add_gizmo_plugin(Ref<CameraSpatialGizmoPlugin>(memnew(CameraSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<LightSpatialGizmoPlugin>(memnew(LightSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<AudioStreamPlayer3DSpatialGizmoPlugin>(memnew(AudioStreamPlayer3DSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<MeshInstanceSpatialGizmoPlugin>(memnew(MeshInstanceSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<SoftBodySpatialGizmoPlugin>(memnew(SoftBodySpatialGizmoPlugin))); - add_gizmo_plugin(Ref<Sprite3DSpatialGizmoPlugin>(memnew(Sprite3DSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<SkeletonSpatialGizmoPlugin>(memnew(SkeletonSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<Position3DSpatialGizmoPlugin>(memnew(Position3DSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<RayCastSpatialGizmoPlugin>(memnew(RayCastSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<SpringArmSpatialGizmoPlugin>(memnew(SpringArmSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<VehicleWheelSpatialGizmoPlugin>(memnew(VehicleWheelSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<VisibilityNotifierGizmoPlugin>(memnew(VisibilityNotifierGizmoPlugin))); - add_gizmo_plugin(Ref<ParticlesGizmoPlugin>(memnew(ParticlesGizmoPlugin))); - add_gizmo_plugin(Ref<CPUParticlesGizmoPlugin>(memnew(CPUParticlesGizmoPlugin))); + selected = nullptr; +} + +void Node3DEditor::_register_all_gizmos() { + add_gizmo_plugin(Ref<Camera3DGizmoPlugin>(memnew(Camera3DGizmoPlugin))); + add_gizmo_plugin(Ref<Light3DGizmoPlugin>(memnew(Light3DGizmoPlugin))); + add_gizmo_plugin(Ref<AudioStreamPlayer3DGizmoPlugin>(memnew(AudioStreamPlayer3DGizmoPlugin))); + add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin))); + add_gizmo_plugin(Ref<SoftBody3DGizmoPlugin>(memnew(SoftBody3DGizmoPlugin))); + add_gizmo_plugin(Ref<Sprite3DGizmoPlugin>(memnew(Sprite3DGizmoPlugin))); + add_gizmo_plugin(Ref<Skeleton3DGizmoPlugin>(memnew(Skeleton3DGizmoPlugin))); + add_gizmo_plugin(Ref<Position3DGizmoPlugin>(memnew(Position3DGizmoPlugin))); + add_gizmo_plugin(Ref<RayCast3DGizmoPlugin>(memnew(RayCast3DGizmoPlugin))); + add_gizmo_plugin(Ref<SpringArm3DGizmoPlugin>(memnew(SpringArm3DGizmoPlugin))); + add_gizmo_plugin(Ref<VehicleWheel3DGizmoPlugin>(memnew(VehicleWheel3DGizmoPlugin))); + add_gizmo_plugin(Ref<VisibilityNotifier3DGizmoPlugin>(memnew(VisibilityNotifier3DGizmoPlugin))); + add_gizmo_plugin(Ref<GPUParticles3DGizmoPlugin>(memnew(GPUParticles3DGizmoPlugin))); + add_gizmo_plugin(Ref<CPUParticles3DGizmoPlugin>(memnew(CPUParticles3DGizmoPlugin))); add_gizmo_plugin(Ref<ReflectionProbeGizmoPlugin>(memnew(ReflectionProbeGizmoPlugin))); + add_gizmo_plugin(Ref<DecalGizmoPlugin>(memnew(DecalGizmoPlugin))); add_gizmo_plugin(Ref<GIProbeGizmoPlugin>(memnew(GIProbeGizmoPlugin))); // add_gizmo_plugin(Ref<BakedIndirectLightGizmoPlugin>(memnew(BakedIndirectLightGizmoPlugin))); - add_gizmo_plugin(Ref<CollisionShapeSpatialGizmoPlugin>(memnew(CollisionShapeSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<CollisionPolygonSpatialGizmoPlugin>(memnew(CollisionPolygonSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<NavigationMeshSpatialGizmoPlugin>(memnew(NavigationMeshSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<JointSpatialGizmoPlugin>(memnew(JointSpatialGizmoPlugin))); - add_gizmo_plugin(Ref<PhysicalBoneSpatialGizmoPlugin>(memnew(PhysicalBoneSpatialGizmoPlugin))); + add_gizmo_plugin(Ref<CollisionShape3DGizmoPlugin>(memnew(CollisionShape3DGizmoPlugin))); + add_gizmo_plugin(Ref<CollisionPolygon3DGizmoPlugin>(memnew(CollisionPolygon3DGizmoPlugin))); + add_gizmo_plugin(Ref<NavigationRegion3DGizmoPlugin>(memnew(NavigationRegion3DGizmoPlugin))); + add_gizmo_plugin(Ref<Joint3DGizmoPlugin>(memnew(Joint3DGizmoPlugin))); + add_gizmo_plugin(Ref<PhysicalBone3DGizmoPlugin>(memnew(PhysicalBone3DGizmoPlugin))); } -void SpatialEditor::_bind_methods() { +void Node3DEditor::_bind_methods() { - ClassDB::bind_method("_unhandled_key_input", &SpatialEditor::_unhandled_key_input); - ClassDB::bind_method("_get_editor_data", &SpatialEditor::_get_editor_data); - ClassDB::bind_method("_request_gizmo", &SpatialEditor::_request_gizmo); + 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); ADD_SIGNAL(MethodInfo("transform_key_request")); ADD_SIGNAL(MethodInfo("item_lock_status_changed")); ADD_SIGNAL(MethodInfo("item_group_status_changed")); } -void SpatialEditor::clear() { +void Node3DEditor::clear() { settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0)); settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05)); @@ -5947,25 +6017,25 @@ void SpatialEditor::clear() { viewports[i]->reset(); } - VisualServer::get_singleton()->instance_set_visible(origin_instance, true); + RenderingServer::get_singleton()->instance_set_visible(origin_instance, true); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_ORIGIN), true); for (int i = 0; i < 3; ++i) { if (grid_enable[i]) { - VisualServer::get_singleton()->instance_set_visible(grid_instance[i], true); + RenderingServer::get_singleton()->instance_set_visible(grid_instance[i], true); grid_visible[i] = true; } } for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { - viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0); + viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0); viewports[i]->viewport->set_as_audio_listener(i == 0); } view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_GRID), true); } -SpatialEditor::SpatialEditor(EditorNode *p_editor) { +Node3DEditor::Node3DEditor(EditorNode *p_editor) { gizmo.visible = true; gizmo.scale = 1.0; @@ -5974,7 +6044,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { undo_redo = p_editor->get_undo_redo(); VBoxContainer *vbc = this; - custom_camera = NULL; + custom_camera = nullptr; singleton = this; editor = p_editor; editor_selection = editor->get_editor_selection(); @@ -5999,7 +6069,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SELECT]->set_flat(true); tool_button[TOOL_MODE_SELECT]->set_pressed(true); button_binds.write[0] = MENU_TOOL_SELECT; - tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + 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_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection")); @@ -6010,7 +6080,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_MOVE]->set_toggle_mode(true); tool_button[TOOL_MODE_MOVE]->set_flat(true); button_binds.write[0] = MENU_TOOL_MOVE; - tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W)); tool_button[TOOL_MODE_ROTATE] = memnew(ToolButton); @@ -6018,7 +6088,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_ROTATE]->set_toggle_mode(true); tool_button[TOOL_MODE_ROTATE]->set_flat(true); button_binds.write[0] = MENU_TOOL_ROTATE; - tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E)); tool_button[TOOL_MODE_SCALE] = memnew(ToolButton); @@ -6026,7 +6096,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_SCALE]->set_toggle_mode(true); tool_button[TOOL_MODE_SCALE]->set_flat(true); button_binds.write[0] = MENU_TOOL_SCALE; - tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R)); hbc_menu->add_child(memnew(VSeparator)); @@ -6036,31 +6106,31 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_button[TOOL_MODE_LIST_SELECT]->set_toggle_mode(true); tool_button[TOOL_MODE_LIST_SELECT]->set_flat(true); button_binds.write[0] = MENU_TOOL_LIST_SELECT; - tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_MODE_LIST_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_LIST_SELECT]->set_tooltip(TTR("Show a list of all objects at the position clicked\n(same as Alt+RMB in select mode).")); tool_button[TOOL_LOCK_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_LOCK_SELECTED]); button_binds.write[0] = MENU_LOCK_SELECTED; - tool_button[TOOL_LOCK_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_LOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_LOCK_SELECTED]->set_tooltip(TTR("Lock the selected object in place (can't be moved).")); tool_button[TOOL_UNLOCK_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_UNLOCK_SELECTED]); button_binds.write[0] = MENU_UNLOCK_SELECTED; - tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_UNLOCK_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_UNLOCK_SELECTED]->set_tooltip(TTR("Unlock the selected object (can be moved).")); tool_button[TOOL_GROUP_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_GROUP_SELECTED]); button_binds.write[0] = MENU_GROUP_SELECTED; - tool_button[TOOL_GROUP_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_GROUP_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_GROUP_SELECTED]->set_tooltip(TTR("Makes sure the object's children are not selectable.")); tool_button[TOOL_UNGROUP_SELECTED] = memnew(ToolButton); hbc_menu->add_child(tool_button[TOOL_UNGROUP_SELECTED]); button_binds.write[0] = MENU_UNGROUP_SELECTED; - tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed), button_binds); + tool_button[TOOL_UNGROUP_SELECTED]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_UNGROUP_SELECTED]->set_tooltip(TTR("Restores the object's children's ability to be selected.")); hbc_menu->add_child(memnew(VSeparator)); @@ -6070,7 +6140,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_flat(true); button_binds.write[0] = MENU_TOOL_LOCAL_COORDS; - tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds); + tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T)); tool_option_button[TOOL_OPT_USE_SNAP] = memnew(ToolButton); @@ -6078,7 +6148,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true); tool_option_button[TOOL_OPT_USE_SNAP]->set_flat(true); button_binds.write[0] = MENU_TOOL_USE_SNAP; - tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds); + tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds); tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y)); hbc_menu->add_child(memnew(VSeparator)); @@ -6089,13 +6159,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_flat(true); tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_disabled(true); button_binds.write[0] = MENU_TOOL_OVERRIDE_CAMERA; - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", callable_mp(this, &SpatialEditor::_menu_item_toggled), button_binds); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds); _update_camera_override_button(false); hbc_menu->add_child(memnew(VSeparator)); // Drag and drop support; - preview_node = memnew(Spatial); + preview_node = memnew(Node3D); preview_bounds = AABB(); ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7); @@ -6126,7 +6196,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { p->add_separator(); p->add_shortcut(ED_SHORTCUT("spatial_editor/configure_snap", TTR("Configure Snap...")), MENU_TRANSFORM_CONFIGURE_SNAP); - p->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed)); + p->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed)); view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); @@ -6158,13 +6228,13 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { p->set_item_checked(p->get_item_index(MENU_VIEW_ORIGIN), true); p->set_item_checked(p->get_item_index(MENU_VIEW_GRID), true); - p->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_item_pressed)); + p->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed)); gizmos_menu = memnew(PopupMenu); p->add_child(gizmos_menu); gizmos_menu->set_name("GizmosMenu"); gizmos_menu->set_hide_on_checkable_item_selection(false); - gizmos_menu->connect("id_pressed", callable_mp(this, &SpatialEditor::_menu_gizmo_toggled)); + gizmos_menu->connect("id_pressed", callable_mp(this, &Node3DEditor::_menu_gizmo_toggled)); /* REST OF MENU */ @@ -6175,14 +6245,14 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { shader_split = memnew(VSplitContainer); shader_split->set_h_size_flags(SIZE_EXPAND_FILL); palette_split->add_child(shader_split); - viewport_base = memnew(SpatialEditorViewportContainer); + viewport_base = memnew(Node3DEditorViewportContainer); shader_split->add_child(viewport_base); viewport_base->set_v_size_flags(SIZE_EXPAND_FILL); for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { - viewports[i] = memnew(SpatialEditorViewport(this, editor, i)); - viewports[i]->connect("toggle_maximize_view", callable_mp(this, &SpatialEditor::_toggle_maximize_view)); - viewports[i]->connect("clicked", callable_mp(this, &SpatialEditor::_update_camera_override_viewport)); + viewports[i] = memnew(Node3DEditorViewport(this, editor, i)); + viewports[i]->connect("toggle_maximize_view", callable_mp(this, &Node3DEditor::_toggle_maximize_view)); + viewports[i]->connect("clicked", callable_mp(this, &Node3DEditor::_update_camera_override_viewport)); viewports[i]->assign_pending_data_pointers(preview_node, &preview_bounds, accept); viewport_base->add_child(viewports[i]); } @@ -6196,8 +6266,8 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { snap_dialog = memnew(ConfirmationDialog); snap_dialog->set_title(TTR("Snap Settings")); add_child(snap_dialog); - snap_dialog->connect("confirmed", callable_mp(this, &SpatialEditor::_snap_changed)); - snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &SpatialEditor::_snap_update)); + snap_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_snap_changed)); + snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update)); VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer); snap_dialog->add_child(snap_dialog_vbc); @@ -6244,7 +6314,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar); for (uint32_t i = 0; i < VIEWPORTS_COUNT; ++i) { - settings_dialog->connect("confirmed", callable_mp(viewports[i], &SpatialEditorViewport::_update_camera), varray(0.0)); + settings_dialog->connect("confirmed", callable_mp(viewports[i], &Node3DEditorViewport::_update_camera), varray(0.0)); } /* XFORM DIALOG */ @@ -6306,11 +6376,11 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { xform_type->add_item(TTR("Post")); xform_vbc->add_child(xform_type); - xform_dialog->connect("confirmed", callable_mp(this, &SpatialEditor::_xform_dialog_action)); + xform_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_xform_dialog_action)); - scenario_debug = VisualServer::SCENARIO_DEBUG_DISABLED; + scenario_debug = RenderingServer::SCENARIO_DEBUG_DISABLED; - selected = NULL; + selected = nullptr; set_process_unhandled_key_input(true); add_to_group("_spatial_editor_group"); @@ -6324,11 +6394,11 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { over_gizmo_handle = -1; } -SpatialEditor::~SpatialEditor() { +Node3DEditor::~Node3DEditor() { memdelete(preview_node); } -void SpatialEditorPlugin::make_visible(bool p_visible) { +void Node3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { @@ -6341,31 +6411,31 @@ void SpatialEditorPlugin::make_visible(bool p_visible) { spatial_editor->set_process(false); } } -void SpatialEditorPlugin::edit(Object *p_object) { +void Node3DEditorPlugin::edit(Object *p_object) { - spatial_editor->edit(Object::cast_to<Spatial>(p_object)); + spatial_editor->edit(Object::cast_to<Node3D>(p_object)); } -bool SpatialEditorPlugin::handles(Object *p_object) const { +bool Node3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Spatial"); + return p_object->is_class("Node3D"); } -Dictionary SpatialEditorPlugin::get_state() const { +Dictionary Node3DEditorPlugin::get_state() const { return spatial_editor->get_state(); } -void SpatialEditorPlugin::set_state(const Dictionary &p_state) { +void Node3DEditorPlugin::set_state(const Dictionary &p_state) { spatial_editor->set_state(p_state); } -void SpatialEditor::snap_cursor_to_plane(const Plane &p_plane) { +void Node3DEditor::snap_cursor_to_plane(const Plane &p_plane) { //cursor.pos=p_plane.project(cursor.pos); } -Vector3 SpatialEditor::snap_point(Vector3 p_target, Vector3 p_start) const { +Vector3 Node3DEditor::snap_point(Vector3 p_target, Vector3 p_start) const { if (is_snap_enabled()) { p_target.x = Math::snap_scalar(0.0, get_translate_snap(), p_target.x); p_target.y = Math::snap_scalar(0.0, get_translate_snap(), p_target.y); @@ -6374,9 +6444,9 @@ Vector3 SpatialEditor::snap_point(Vector3 p_target, Vector3 p_start) const { return p_target; } -float SpatialEditor::get_translate_snap() const { +float Node3DEditor::get_translate_snap() const { float snap_value; - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { snap_value = snap_translate->get_text().to_double() / 10.0; } else { snap_value = snap_translate->get_text().to_double(); @@ -6385,9 +6455,9 @@ float SpatialEditor::get_translate_snap() const { return snap_value; } -float SpatialEditor::get_rotate_snap() const { +float Node3DEditor::get_rotate_snap() const { float snap_value; - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { snap_value = snap_rotate->get_text().to_double() / 3.0; } else { snap_value = snap_rotate->get_text().to_double(); @@ -6396,9 +6466,9 @@ float SpatialEditor::get_rotate_snap() const { return snap_value; } -float SpatialEditor::get_scale_snap() const { +float Node3DEditor::get_scale_snap() const { float snap_value; - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { snap_value = snap_scale->get_text().to_double() / 2.0; } else { snap_value = snap_scale->get_text().to_double(); @@ -6407,19 +6477,19 @@ float SpatialEditor::get_scale_snap() const { return snap_value; } -void SpatialEditorPlugin::_bind_methods() { +void Node3DEditorPlugin::_bind_methods() { - ClassDB::bind_method("snap_cursor_to_plane", &SpatialEditorPlugin::snap_cursor_to_plane); + ClassDB::bind_method("snap_cursor_to_plane", &Node3DEditorPlugin::snap_cursor_to_plane); } -void SpatialEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { +void Node3DEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { spatial_editor->snap_cursor_to_plane(p_plane); } struct _GizmoPluginPriorityComparator { - bool operator()(const Ref<EditorSpatialGizmoPlugin> &p_a, const Ref<EditorSpatialGizmoPlugin> &p_b) const { + bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { if (p_a->get_priority() == p_b->get_priority()) { return p_a->get_name() < p_b->get_name(); } @@ -6429,12 +6499,12 @@ struct _GizmoPluginPriorityComparator { struct _GizmoPluginNameComparator { - bool operator()(const Ref<EditorSpatialGizmoPlugin> &p_a, const Ref<EditorSpatialGizmoPlugin> &p_b) const { + bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { return p_a->get_name() < p_b->get_name(); } }; -void SpatialEditor::add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) { +void Node3DEditor::add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) { ERR_FAIL_NULL(p_plugin.ptr()); gizmo_plugins_by_priority.push_back(p_plugin); @@ -6444,19 +6514,19 @@ void SpatialEditor::add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) { gizmo_plugins_by_name.sort_custom<_GizmoPluginNameComparator>(); _update_gizmos_menu(); - SpatialEditor::get_singleton()->update_all_gizmos(); + Node3DEditor::get_singleton()->update_all_gizmos(); } -void SpatialEditor::remove_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) { +void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) { gizmo_plugins_by_priority.erase(p_plugin); gizmo_plugins_by_name.erase(p_plugin); _update_gizmos_menu(); } -SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) { +Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) { editor = p_node; - spatial_editor = memnew(SpatialEditor(p_node)); + spatial_editor = memnew(Node3DEditor(p_node)); spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); editor->get_viewport()->add_child(spatial_editor); @@ -6464,10 +6534,10 @@ SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) { spatial_editor->connect_compat("transform_key_request", editor->get_inspector_dock(), "_transform_keyed"); } -SpatialEditorPlugin::~SpatialEditorPlugin() { +Node3DEditorPlugin::~Node3DEditorPlugin() { } -void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { +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 instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); @@ -6509,7 +6579,7 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color materials[p_name] = mats; } -void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { +void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); @@ -6550,12 +6620,12 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const materials[p_name] = icons; } -void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) { +void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) { 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 = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); + Ref<Texture2D> handle_t = 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)); @@ -6572,12 +6642,12 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool materials[p_name].push_back(handle_material); } -void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_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> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) { +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>()); @@ -6596,27 +6666,27 @@ Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_n return mat; } -String EditorSpatialGizmoPlugin::get_name() const { +String EditorNode3DGizmoPlugin::get_name() const { if (get_script_instance() && get_script_instance()->has_method("get_name")) { return get_script_instance()->call("get_name"); } return TTR("Nameless gizmo"); } -int EditorSpatialGizmoPlugin::get_priority() const { +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<EditorSpatialGizmo> EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) { +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<EditorSpatialGizmo> ref = create_gizmo(p_spatial); + Ref<EditorNode3DGizmo> ref = create_gizmo(p_spatial); if (ref.is_null()) return ref; @@ -6628,18 +6698,18 @@ Ref<EditorSpatialGizmo> EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) return ref; } -void EditorSpatialGizmoPlugin::_bind_methods() { -#define GIZMO_REF PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "EditorSpatialGizmo") +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, "Spatial"))); - BIND_VMETHOD(MethodInfo(GIZMO_REF, "create_gizmo", PropertyInfo(Variant::OBJECT, "spatial", PROPERTY_HINT_RESOURCE_TYPE, "Spatial"))); + 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"), &EditorSpatialGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorSpatialGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); - ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard"), &EditorSpatialGizmoPlugin::create_handle_material, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorSpatialGizmoPlugin::add_material); + 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"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); - ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorSpatialGizmoPlugin::get_material); //, DEFVAL(Ref<EditorSpatialGizmo>())); + ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material); //, DEFVAL(Ref<EditorNode3DGizmo>())); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_name")); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_priority")); @@ -6653,7 +6723,7 @@ void EditorSpatialGizmoPlugin::_bind_methods() { 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, "Camera"), PropertyInfo(Variant::VECTOR2, "point"))); + 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); @@ -6663,103 +6733,103 @@ void EditorSpatialGizmoPlugin::_bind_methods() { #undef GIZMO_REF } -bool EditorSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { +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<EditorSpatialGizmo> EditorSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) { +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<EditorSpatialGizmo> ref; + Ref<EditorNode3DGizmo> ref; if (has_gizmo(p_spatial)) ref.instance(); return ref; } -bool EditorSpatialGizmoPlugin::can_be_hidden() const { +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 EditorSpatialGizmoPlugin::is_selectable_when_hidden() const { +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 EditorSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { if (get_script_instance() && get_script_instance()->has_method("redraw")) { - Ref<EditorSpatialGizmo> ref(p_gizmo); + Ref<EditorNode3DGizmo> ref(p_gizmo); get_script_instance()->call("redraw", ref); } } -String EditorSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +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 EditorSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +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 EditorSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +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 EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +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 EditorSpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +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 EditorSpatialGizmoPlugin::set_state(int p_state) { +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 EditorSpatialGizmoPlugin::get_state() const { +int EditorNode3DGizmoPlugin::get_state() const { return current_state; } -void EditorSpatialGizmoPlugin::unregister_gizmo(EditorSpatialGizmo *p_gizmo) { +void EditorNode3DGizmoPlugin::unregister_gizmo(EditorNode3DGizmo *p_gizmo) { current_gizmos.erase(p_gizmo); } -EditorSpatialGizmoPlugin::EditorSpatialGizmoPlugin() { +EditorNode3DGizmoPlugin::EditorNode3DGizmoPlugin() { current_state = VISIBLE; } -EditorSpatialGizmoPlugin::~EditorSpatialGizmoPlugin() { +EditorNode3DGizmoPlugin::~EditorNode3DGizmoPlugin() { for (int i = 0; i < current_gizmos.size(); ++i) { - current_gizmos[i]->set_plugin(NULL); - current_gizmos[i]->get_spatial_node()->set_gizmo(NULL); + current_gizmos[i]->set_plugin(nullptr); + current_gizmos[i]->get_spatial_node()->set_gizmo(nullptr); } - if (SpatialEditor::get_singleton()) { - SpatialEditor::get_singleton()->update_all_gizmos(); + if (Node3DEditor::get_singleton()) { + Node3DEditor::get_singleton()->update_all_gizmos(); } } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 9f78efacaf..71da14ae1a 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* spatial_editor_plugin.h */ +/* node_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -34,20 +34,20 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "editor/editor_scale.h" -#include "scene/3d/immediate_geometry.h" -#include "scene/3d/light.h" -#include "scene/3d/visual_instance.h" +#include "scene/3d/immediate_geometry_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/visual_instance_3d.h" #include "scene/gui/panel_container.h" -class Camera; -class SpatialEditor; -class EditorSpatialGizmoPlugin; -class SpatialEditorViewport; -class ViewportContainer; +class Camera3D; +class Node3DEditor; +class EditorNode3DGizmoPlugin; +class Node3DEditorViewport; +class SubViewportContainer; -class EditorSpatialGizmo : public SpatialGizmo { +class EditorNode3DGizmo : public Node3DGizmo { - GDCLASS(EditorSpatialGizmo, SpatialGizmo); + GDCLASS(EditorNode3DGizmo, Node3DGizmo); bool selected; bool instanced; @@ -75,7 +75,7 @@ public: extra_margin = false; } - void create_instance(Spatial *p_base, bool p_hidden = false); + void create_instance(Node3D *p_base, bool p_hidden = false); }; Vector<Vector3> collision_segments; @@ -93,12 +93,12 @@ public: bool valid; bool hidden; - Spatial *base; + Node3D *base; Vector<Instance> instances; - Spatial *spatial_node; - EditorSpatialGizmoPlugin *gizmo_plugin; + Node3D *spatial_node; + EditorNode3DGizmoPlugin *gizmo_plugin; - void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Spatial>(p_node)); } + void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } protected: static void _bind_methods(); @@ -115,15 +115,15 @@ public: 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, Camera *p_camera, const Point2 &p_point); + 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(Spatial *p_node); - Spatial *get_spatial_node() const { return spatial_node; } - Ref<EditorSpatialGizmoPlugin> get_plugin() const { return gizmo_plugin; } + 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 Camera *p_camera, const Vector<Plane> &p_frustum); - bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false); + 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(); virtual void create(); @@ -134,10 +134,10 @@ public: virtual bool is_editable() const; void set_hidden(bool p_hidden); - void set_plugin(EditorSpatialGizmoPlugin *p_plugin); + void set_plugin(EditorNode3DGizmoPlugin *p_plugin); - EditorSpatialGizmo(); - ~EditorSpatialGizmo(); + EditorNode3DGizmo(); + ~EditorNode3DGizmo(); }; class ViewportRotationControl : public Control { @@ -155,7 +155,7 @@ class ViewportRotationControl : public Control { } }; - SpatialEditorViewport *viewport = nullptr; + Node3DEditorViewport *viewport = nullptr; Vector<Color> axis_colors; Vector<int> axis_menu_options; bool orbiting = false; @@ -174,13 +174,13 @@ protected: void _on_mouse_exited(); public: - void set_viewport(SpatialEditorViewport *p_viewport); + void set_viewport(Node3DEditorViewport *p_viewport); }; -class SpatialEditorViewport : public Control { +class Node3DEditorViewport : public Control { - GDCLASS(SpatialEditorViewport, Control); - friend class SpatialEditor; + GDCLASS(Node3DEditorViewport, Control); + friend class Node3DEditor; friend class ViewportRotationControl; enum { @@ -202,7 +202,7 @@ class SpatialEditorViewport : public Control { VIEW_AUDIO_DOPPLER, VIEW_GIZMOS, VIEW_INFORMATION, - VIEW_FPS, + VIEW_FRAME_TIME, VIEW_DISPLAY_NORMAL, VIEW_DISPLAY_WIREFRAME, VIEW_DISPLAY_OVERDRAW, @@ -218,6 +218,8 @@ class SpatialEditorViewport : public Control { VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE, VIEW_DISPLAY_DEBUG_SSAO, VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER, + VIEW_DISPLAY_DEBUG_PSSM_SPLITS, + VIEW_DISPLAY_DEBUG_DECAL_ATLAS, VIEW_LOCK_ROTATION, VIEW_CINEMATIC_PREVIEW, VIEW_AUTO_ORTHOGONAL, @@ -228,7 +230,9 @@ public: enum { GIZMO_BASE_LAYER = 27, GIZMO_EDIT_LAYER = 26, - GIZMO_GRID_LAYER = 25 + GIZMO_GRID_LAYER = 25, + + FRAME_TIME_HISTORY = 20, }; enum NavigationScheme { @@ -237,12 +241,23 @@ public: NAVIGATION_MODO, }; + enum FreelookNavigationScheme { + FREELOOK_DEFAULT, + FREELOOK_PARTIALLY_AXIS_LOCKED, + FREELOOK_FULLY_AXIS_LOCKED, + }; + private: + float cpu_time_history[FRAME_TIME_HISTORY]; + int cpu_time_history_index; + float gpu_time_history[FRAME_TIME_HISTORY]; + int gpu_time_history_index; + int index; String name; void _menu_option(int p_option); void _set_auto_orthogonal(); - Spatial *preview_node; + Node3D *preview_node; AABB *preview_bounds; Vector<String> selected_files; AcceptDialog *accept; @@ -256,14 +271,14 @@ private: UndoRedo *undo_redo; CheckBox *preview_camera; - ViewportContainer *viewport_container; + SubViewportContainer *subviewport_container; MenuButton *view_menu; PopupMenu *display_submenu; Control *surface; - Viewport *viewport; - Camera *camera; + SubViewport *viewport; + Camera3D *camera; bool transforming; bool orthogonal; bool auto_orthogonal; @@ -284,7 +299,7 @@ private: struct _RayResult { - Spatial *item; + Node3D *item; float depth; int handle; _FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; } @@ -295,7 +310,7 @@ private: 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 = NULL, bool p_alt_select = false); + 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); Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const; @@ -366,7 +381,7 @@ private: int edited_gizmo; Point2 mouse_pos; bool snap; - Ref<EditorSpatialGizmo> gizmo; + Ref<EditorNode3DGizmo> gizmo; int gizmo_handle; Variant gizmo_initial_value; Vector3 gizmo_initial_pos; @@ -418,10 +433,10 @@ private: void _sinput(const Ref<InputEvent> &p_event); void _update_freelook(real_t delta); - SpatialEditor *spatial_editor; + Node3DEditor *spatial_editor; - Camera *previewing; - Camera *preview; + Camera3D *previewing; + Camera3D *preview; bool previewing_cinema; bool _is_node_locked(const Node *p_node); @@ -436,7 +451,7 @@ private: Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const; Vector3 _get_instance_position(const Point2 &p_pos) const; - static AABB _calculate_spatial_bounds(const Spatial *p_parent, bool p_exclude_toplevel_transform = true); + static AABB _calculate_spatial_bounds(const Node3D *p_parent, bool p_exclude_toplevel_transform = true); void _create_preview(const Vector<String> &files) const; void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); @@ -454,7 +469,7 @@ public: void update_surface() { surface->update(); } void update_transform_gizmo_view(); - void set_can_preview(Camera *p_preview); + void set_can_preview(Camera3D *p_preview); void set_state(const Dictionary &p_state); Dictionary get_state() const; void reset(); @@ -463,35 +478,39 @@ public: void focus_selection(); void assign_pending_data_pointers( - Spatial *p_preview_node, + Node3D *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept); - Viewport *get_viewport_node() { return viewport; } - Camera *get_camera() { return camera; } // return the default camera object. + SubViewport *get_viewport_node() { return viewport; } + Camera3D *get_camera() { return camera; } // return the default camera object. - SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index); + Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index); }; -class SpatialEditorSelectedItem : public Object { +class Node3DEditorSelectedItem : public Object { - GDCLASS(SpatialEditorSelectedItem, Object); + GDCLASS(Node3DEditorSelectedItem, Object); public: AABB aabb; Transform original; // original location when moving Transform original_local; Transform last_xform; // last transform - Spatial *sp; + bool last_xform_dirty; + Node3D *sp; RID sbox_instance; - SpatialEditorSelectedItem() { sp = NULL; } - ~SpatialEditorSelectedItem(); + Node3DEditorSelectedItem() { + sp = nullptr; + last_xform_dirty = true; + } + ~Node3DEditorSelectedItem(); }; -class SpatialEditorViewportContainer : public Container { +class Node3DEditorViewportContainer : public Container { - GDCLASS(SpatialEditorViewportContainer, Container); + GDCLASS(Node3DEditorViewportContainer, Container); public: enum View { @@ -527,12 +546,12 @@ public: void set_view(View p_view); View get_view(); - SpatialEditorViewportContainer(); + Node3DEditorViewportContainer(); }; -class SpatialEditor : public VBoxContainer { +class Node3DEditor : public VBoxContainer { - GDCLASS(SpatialEditor, VBoxContainer); + GDCLASS(Node3DEditor, VBoxContainer); public: static const unsigned int VIEWPORTS_COUNT = 4; @@ -564,8 +583,8 @@ private: EditorNode *editor; EditorSelection *editor_selection; - SpatialEditorViewportContainer *viewport_base; - SpatialEditorViewport *viewports[VIEWPORTS_COUNT]; + Node3DEditorViewportContainer *viewport_base; + Node3DEditorViewport *viewports[VIEWPORTS_COUNT]; VSplitContainer *shader_split; HSplitContainer *palette_split; @@ -574,7 +593,7 @@ private: ToolMode tool_mode; bool orthogonal; - VisualServer::ScenarioDebugMode scenario_debug; + RenderingServer::ScenarioDebugMode scenario_debug; RID origin; RID origin_instance; @@ -605,7 +624,7 @@ private: Ref<StandardMaterial3D> cursor_material; // Scene drag and drop support - Spatial *preview_node; + Node3D *preview_node; AABB preview_bounds; struct Gizmo { @@ -705,19 +724,19 @@ private: Ref<Environment> viewport_environment; - Spatial *selected; + Node3D *selected; void _request_gizmo(Object *p_obj); - static SpatialEditor *singleton; + static Node3DEditor *singleton; void _node_removed(Node *p_node); - Vector<Ref<EditorSpatialGizmoPlugin>> gizmo_plugins_by_priority; - Vector<Ref<EditorSpatialGizmoPlugin>> gizmo_plugins_by_name; + Vector<Ref<EditorNode3DGizmoPlugin>> gizmo_plugins_by_priority; + Vector<Ref<EditorNode3DGizmoPlugin>> gizmo_plugins_by_name; void _register_all_gizmos(); - SpatialEditor(); + Node3DEditor(); bool is_any_freelook_active() const; @@ -731,7 +750,7 @@ protected: static void _bind_methods(); public: - static SpatialEditor *get_singleton() { return singleton; } + static Node3DEditor *get_singleton() { return singleton; } void snap_cursor_to_plane(const Plane &p_plane); Vector3 snap_point(Vector3 p_target, Vector3 p_start = Vector3(0, 0, 0)) const; @@ -744,7 +763,7 @@ public: bool is_gizmo_visible() const { return gizmo.visible; } ToolMode get_tool_mode() const { return tool_mode; } - bool are_local_coords_enabled() const { return tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); } + bool are_local_coords_enabled() const { return tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); } bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; } float get_translate_snap() const; float get_rotate_snap() const; @@ -757,7 +776,7 @@ public: Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; } void update_transform_gizmo(); - void update_all_gizmos(Node *p_node = NULL); + void update_all_gizmos(Node *p_node = nullptr); void snap_selected_nodes_to_floor(); void select_gizmo_highlight_axis(int p_axis); void set_custom_camera(Node *p_camera) { custom_camera = p_camera; } @@ -776,33 +795,33 @@ public: VSplitContainer *get_shader_split(); HSplitContainer *get_palette_split(); - Spatial *get_selected() { return selected; } + Node3D *get_selected() { return selected; } int get_over_gizmo_handle() const { return over_gizmo_handle; } void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; } - void set_can_preview(Camera *p_preview); + void set_can_preview(Camera3D *p_preview); - SpatialEditorViewport *get_editor_viewport(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), NULL); + Node3DEditorViewport *get_editor_viewport(int p_idx) { + ERR_FAIL_INDEX_V(p_idx, static_cast<int>(VIEWPORTS_COUNT), nullptr); return viewports[p_idx]; } - void add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin); - void remove_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin); + void add_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin); + void remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin); - void edit(Spatial *p_spatial); + void edit(Node3D *p_spatial); void clear(); - SpatialEditor(EditorNode *p_editor); - ~SpatialEditor(); + Node3DEditor(EditorNode *p_editor); + ~Node3DEditor(); }; -class SpatialEditorPlugin : public EditorPlugin { +class Node3DEditorPlugin : public EditorPlugin { - GDCLASS(SpatialEditorPlugin, EditorPlugin); + GDCLASS(Node3DEditorPlugin, EditorPlugin); - SpatialEditor *spatial_editor; + Node3DEditor *spatial_editor; EditorNode *editor; protected: @@ -811,7 +830,7 @@ protected: public: void snap_cursor_to_plane(const Plane &p_plane); - SpatialEditor *get_spatial_editor() { return spatial_editor; } + Node3DEditor *get_spatial_editor() { return spatial_editor; } virtual String get_name() const { return "3D"; } bool has_main_screen() const { return true; } virtual void make_visible(bool p_visible); @@ -824,28 +843,27 @@ public: virtual void edited_scene_changed(); - SpatialEditorPlugin(EditorNode *p_node); - ~SpatialEditorPlugin(); + Node3DEditorPlugin(EditorNode *p_node); + ~Node3DEditorPlugin(); }; -class EditorSpatialGizmoPlugin : public Resource { +class EditorNode3DGizmoPlugin : public Resource { - GDCLASS(EditorSpatialGizmoPlugin, Resource); + GDCLASS(EditorNode3DGizmoPlugin, Resource); public: static const int VISIBLE = 0; static const int HIDDEN = 1; static const int ON_TOP = 2; -private: +protected: int current_state; - List<EditorSpatialGizmo *> current_gizmos; + List<EditorNode3DGizmo *> current_gizmos; HashMap<String, Vector<Ref<StandardMaterial3D>>> materials; -protected: static void _bind_methods(); - virtual bool has_gizmo(Spatial *p_spatial); - virtual Ref<EditorSpatialGizmo> create_gizmo(Spatial *p_spatial); + 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); @@ -853,27 +871,27 @@ public: void create_handle_material(const String &p_name, bool p_billboard = false); void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); - Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>()); + Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorNode3DGizmo> &p_gizmo = Ref<EditorNode3DGizmo>()); virtual String get_name() const; virtual int get_priority() const; virtual bool can_be_hidden() const; virtual bool is_selectable_when_hidden() const; - virtual void redraw(EditorSpatialGizmo *p_gizmo); - virtual String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) 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<EditorSpatialGizmo> get_gizmo(Spatial *p_spatial); + Ref<EditorNode3DGizmo> get_gizmo(Node3D *p_spatial); void set_state(int p_state); int get_state() const; - void unregister_gizmo(EditorSpatialGizmo *p_gizmo); + void unregister_gizmo(EditorNode3DGizmo *p_gizmo); - EditorSpatialGizmoPlugin(); - virtual ~EditorSpatialGizmoPlugin(); + EditorNode3DGizmoPlugin(); + virtual ~EditorNode3DGizmoPlugin(); }; #endif diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 165df6b500..4516b7035b 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -56,7 +56,7 @@ void Path2DEditor::_notification(int p_what) { void Path2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; hide(); } } @@ -288,7 +288,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 gpoint = mm->get_position(); Ref<Curve2D> curve = node->get_curve(); - if (curve == NULL) return true; + if (curve == nullptr) return true; if (curve->get_point_count() < 2) return true; // Find edge @@ -373,12 +373,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_icon("EditorPathSharpHandle", "EditorIcons"); - const Ref<Texture2D> path_smooth_handle = get_icon("EditorPathSmoothHandle", "EditorIcons"); + const Ref<Texture2D> path_sharp_handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); + const Ref<Texture2D> path_smooth_handle = get_theme_icon("EditorPathSmoothHandle", "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_icon("EditorCurveHandle", "EditorIcons"); + const Ref<Texture2D> curve_handle = get_theme_icon("EditorCurveHandle", "EditorIcons"); const Size2 curve_handle_size = curve_handle->get_size(); Ref<Curve2D> curve = node->get_curve(); @@ -420,7 +420,7 @@ void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (on_edge) { - Ref<Texture2D> add_handle = get_icon("EditorHandleAdd", "EditorIcons"); + Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point - add_handle->get_size() * 0.5); } } @@ -449,7 +449,7 @@ void Path2DEditor::edit(Node *p_path2d) { // node may have been deleted at this point if (node && node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed))) node->disconnect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)); - node = NULL; + node = nullptr; } } @@ -532,7 +532,7 @@ void Path2DEditor::_handle_option_pressed(int p_option) { Path2DEditor::Path2DEditor(EditorNode *p_editor) { - canvas_item_editor = NULL; + canvas_item_editor = nullptr; editor = p_editor; undo_redo = editor->get_undo_redo(); mirror_handle_angle = true; @@ -548,35 +548,35 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { sep = memnew(VSeparator); base_hb->add_child(sep); curve_edit = memnew(ToolButton); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "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")); curve_edit->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_EDIT)); base_hb->add_child(curve_edit); curve_edit_curve = memnew(ToolButton); - curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve", "EditorIcons")); + curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCurve", "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)")); curve_edit_curve->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_EDIT_CURVE)); base_hb->add_child(curve_edit_curve); curve_create = memnew(ToolButton); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "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)")); curve_create->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_CREATE)); base_hb->add_child(curve_create); curve_del = memnew(ToolButton); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); curve_del->set_toggle_mode(true); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); curve_del->connect("pressed", callable_mp(this, &Path2DEditor::_mode_selected), varray(MODE_DELETE)); base_hb->add_child(curve_del); curve_close = memnew(ToolButton); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "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)); @@ -620,7 +620,7 @@ void Path2DEditorPlugin::make_visible(bool p_visible) { path2d_editor->hide(); path2d_editor->base_hb->hide(); - path2d_editor->edit(NULL); + path2d_editor->edit(nullptr); } } diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 42b1045666..d3ece9556d 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* path_editor_plugin.cpp */ +/* path_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "path_editor_plugin.h" +#include "path_3d_editor_plugin.h" #include "core/os/keyboard.h" +#include "node_3d_editor_plugin.h" #include "scene/resources/curve.h" -#include "spatial_editor_plugin.h" -String PathSpatialGizmo::get_handle_name(int p_idx) const { +String Path3DGizmo::get_handle_name(int p_idx) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) @@ -57,7 +57,7 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const { return n; } -Variant PathSpatialGizmo::get_handle_value(int p_idx) { +Variant Path3DGizmo::get_handle_value(int p_idx) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) @@ -84,7 +84,7 @@ Variant PathSpatialGizmo::get_handle_value(int p_idx) { return ofs; } -void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { +void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) @@ -104,8 +104,8 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p if (p.intersects_ray(ray_from, ray_dir, &inters)) { - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - float snap = SpatialEditor::get_singleton()->get_translate_snap(); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + float snap = Node3DEditor::get_singleton()->get_translate_snap(); inters.snap(Vector3(snap, snap, snap)); } @@ -130,37 +130,37 @@ void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_p // Setting curve in/out positions if (p.intersects_ray(ray_from, ray_dir, &inters)) { - if (!PathEditorPlugin::singleton->is_handle_clicked()) { + if (!Path3DEditorPlugin::singleton->is_handle_clicked()) { orig_in_length = c->get_point_in(idx).length(); orig_out_length = c->get_point_out(idx).length(); - PathEditorPlugin::singleton->set_handle_clicked(true); + Path3DEditorPlugin::singleton->set_handle_clicked(true); } Vector3 local = gi.xform(inters) - base; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - float snap = SpatialEditor::get_singleton()->get_translate_snap(); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + float snap = Node3DEditor::get_singleton()->get_translate_snap(); local.snap(Vector3(snap, snap, snap)); } if (t == 0) { c->set_point_in(idx, local); - if (PathEditorPlugin::singleton->mirror_angle_enabled()) - c->set_point_out(idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length)); + if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) + c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length)); } else { c->set_point_out(idx, local); - if (PathEditorPlugin::singleton->mirror_angle_enabled()) - c->set_point_in(idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length)); + if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) + c->set_point_in(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_in_length)); } } } -void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return; - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); if (p_idx < c->get_point_count()) { @@ -192,9 +192,9 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p ur->add_do_method(c.ptr(), "set_point_in", idx, c->get_point_in(idx)); ur->add_undo_method(c.ptr(), "set_point_in", idx, p_restore); - if (PathEditorPlugin::singleton->mirror_angle_enabled()) { - ur->add_do_method(c.ptr(), "set_point_out", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_in(idx) : (-c->get_point_in(idx).normalized() * orig_out_length)); - ur->add_undo_method(c.ptr(), "set_point_out", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_out_length)); + if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) { + ur->add_do_method(c.ptr(), "set_point_out", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_in(idx) : (-c->get_point_in(idx).normalized() * orig_out_length)); + ur->add_undo_method(c.ptr(), "set_point_out", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_out_length)); } ur->commit_action(); @@ -209,15 +209,15 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p ur->add_do_method(c.ptr(), "set_point_out", idx, c->get_point_out(idx)); ur->add_undo_method(c.ptr(), "set_point_out", idx, p_restore); - if (PathEditorPlugin::singleton->mirror_angle_enabled()) { - ur->add_do_method(c.ptr(), "set_point_in", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_out(idx) : (-c->get_point_out(idx).normalized() * orig_in_length)); - ur->add_undo_method(c.ptr(), "set_point_in", idx, PathEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_in_length)); + if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) { + ur->add_do_method(c.ptr(), "set_point_in", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -c->get_point_out(idx) : (-c->get_point_out(idx).normalized() * orig_in_length)); + ur->add_undo_method(c.ptr(), "set_point_in", idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -static_cast<Vector3>(p_restore) : (-static_cast<Vector3>(p_restore).normalized() * orig_in_length)); } ur->commit_action(); } } -void PathSpatialGizmo::redraw() { +void Path3DGizmo::redraw() { clear(); @@ -252,7 +252,7 @@ void PathSpatialGizmo::redraw() { add_collision_segments(v3p); } - if (PathEditorPlugin::singleton->get_edited_path() == path) { + if (Path3DEditorPlugin::singleton->get_edited_path() == path) { v3p.clear(); Vector<Vector3> handles; Vector<Vector3> sec_handles; @@ -286,13 +286,13 @@ void PathSpatialGizmo::redraw() { } } -PathSpatialGizmo::PathSpatialGizmo(Path *p_path) { +Path3DGizmo::Path3DGizmo(Path3D *p_path) { path = p_path; set_spatial_node(p_path); } -bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { +bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { if (!path) return false; @@ -448,10 +448,10 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp return false; } -void PathEditorPlugin::edit(Object *p_object) { +void Path3DEditorPlugin::edit(Object *p_object) { if (p_object) { - path = Object::cast_to<Path>(p_object); + path = Object::cast_to<Path3D>(p_object); if (path) { if (path->get_curve().is_valid()) { @@ -459,8 +459,8 @@ void PathEditorPlugin::edit(Object *p_object) { } } } else { - Path *pre = path; - path = NULL; + Path3D *pre = path; + path = nullptr; if (pre) { pre->get_curve()->emit_signal("changed"); } @@ -468,12 +468,12 @@ void PathEditorPlugin::edit(Object *p_object) { //collision_polygon_editor->edit(Object::cast_to<Node>(p_object)); } -bool PathEditorPlugin::handles(Object *p_object) const { +bool Path3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Path"); + return p_object->is_class("Path3D"); } -void PathEditorPlugin::make_visible(bool p_visible) { +void Path3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { @@ -493,8 +493,8 @@ void PathEditorPlugin::make_visible(bool p_visible) { sep->hide(); { - Path *pre = path; - path = NULL; + Path3D *pre = path; + path = nullptr; if (pre && pre->get_curve().is_valid()) { pre->get_curve()->emit_signal("changed"); } @@ -502,14 +502,14 @@ void PathEditorPlugin::make_visible(bool p_visible) { } } -void PathEditorPlugin::_mode_changed(int p_idx) { +void Path3DEditorPlugin::_mode_changed(int p_idx) { curve_create->set_pressed(p_idx == 0); curve_edit->set_pressed(p_idx == 1); curve_del->set_pressed(p_idx == 2); } -void PathEditorPlugin::_close_curve() { +void Path3DEditorPlugin::_close_curve() { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) @@ -519,7 +519,7 @@ void PathEditorPlugin::_close_curve() { c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0)); } -void PathEditorPlugin::_handle_option_pressed(int p_option) { +void Path3DEditorPlugin::_handle_option_pressed(int p_option) { PopupMenu *pm; pm = handle_menu->get_popup(); @@ -539,78 +539,78 @@ void PathEditorPlugin::_handle_option_pressed(int p_option) { } } -void PathEditorPlugin::_notification(int p_what) { +void Path3DEditorPlugin::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - curve_create->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(0)); - curve_edit->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(1)); - curve_del->connect("pressed", callable_mp(this, &PathEditorPlugin::_mode_changed), make_binds(2)); - curve_close->connect("pressed", callable_mp(this, &PathEditorPlugin::_close_curve)); + curve_create->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(0)); + curve_edit->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(1)); + curve_del->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_mode_changed), make_binds(2)); + curve_close->connect("pressed", callable_mp(this, &Path3DEditorPlugin::_close_curve)); } } -void PathEditorPlugin::_bind_methods() { +void Path3DEditorPlugin::_bind_methods() { } -PathEditorPlugin *PathEditorPlugin::singleton = NULL; +Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr; -PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { +Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { - path = NULL; + path = nullptr; editor = p_node; singleton = this; mirror_handle_angle = true; mirror_handle_length = true; - Ref<PathSpatialGizmoPlugin> gizmo_plugin; + Ref<Path3DGizmoPlugin> gizmo_plugin; gizmo_plugin.instance(); - SpatialEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); + Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin); sep = memnew(VSeparator); sep->hide(); - SpatialEditor::get_singleton()->add_control_to_menu_panel(sep); + Node3DEditor::get_singleton()->add_control_to_menu_panel(sep); curve_edit = memnew(ToolButton); - curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); + curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveEdit", "EditorIcons")); curve_edit->set_toggle_mode(true); curve_edit->hide(); 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("Right Click: Delete Point")); - SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_edit); + Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_edit); curve_create = memnew(ToolButton); - curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); + curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); curve_create->set_toggle_mode(true); curve_create->hide(); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)")); - SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_create); + Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_create); curve_del = memnew(ToolButton); - curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons")); + curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveDelete", "EditorIcons")); curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); - SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_del); + Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew(ToolButton); - curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons")); + curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveClose", "EditorIcons")); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); - SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close); + Node3DEditor::get_singleton()->add_control_to_menu_panel(curve_close); PopupMenu *menu; handle_menu = memnew(MenuButton); handle_menu->set_text(TTR("Options")); handle_menu->hide(); - SpatialEditor::get_singleton()->add_control_to_menu_panel(handle_menu); + Node3DEditor::get_singleton()->add_control_to_menu_panel(handle_menu); menu = handle_menu->get_popup(); menu->add_check_item(TTR("Mirror Handle Angles")); menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle); menu->add_check_item(TTR("Mirror Handle Lengths")); menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length); - menu->connect("id_pressed", callable_mp(this, &PathEditorPlugin::_handle_option_pressed)); + menu->connect("id_pressed", callable_mp(this, &Path3DEditorPlugin::_handle_option_pressed)); curve_edit->set_pressed(true); /* @@ -624,27 +624,27 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { */ } -PathEditorPlugin::~PathEditorPlugin() { +Path3DEditorPlugin::~Path3DEditorPlugin() { } -Ref<EditorSpatialGizmo> PathSpatialGizmoPlugin::create_gizmo(Spatial *p_spatial) { - Ref<PathSpatialGizmo> ref; +Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) { + Ref<Path3DGizmo> ref; - Path *path = Object::cast_to<Path>(p_spatial); - if (path) ref = Ref<PathSpatialGizmo>(memnew(PathSpatialGizmo(path))); + Path3D *path = Object::cast_to<Path3D>(p_spatial); + if (path) ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path))); return ref; } -String PathSpatialGizmoPlugin::get_name() const { - return "Path"; +String Path3DGizmoPlugin::get_name() const { + return "Path3D"; } -int PathSpatialGizmoPlugin::get_priority() const { +int Path3DGizmoPlugin::get_priority() const { return -1; } -PathSpatialGizmoPlugin::PathSpatialGizmoPlugin() { +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); diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 8ff83911f8..3f18cadacd 100644 --- a/editor/plugins/path_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* path_editor_plugin.h */ +/* path_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -31,14 +31,14 @@ #ifndef PATH_EDITOR_PLUGIN_H #define PATH_EDITOR_PLUGIN_H -#include "editor/spatial_editor_gizmos.h" -#include "scene/3d/path.h" +#include "editor/node_3d_editor_gizmos.h" +#include "scene/3d/path_3d.h" -class PathSpatialGizmo : public EditorSpatialGizmo { +class Path3DGizmo : public EditorNode3DGizmo { - GDCLASS(PathSpatialGizmo, EditorSpatialGizmo); + GDCLASS(Path3DGizmo, EditorNode3DGizmo); - Path *path; + Path3D *path; mutable Vector3 original; mutable float orig_in_length; mutable float orig_out_length; @@ -46,29 +46,29 @@ class PathSpatialGizmo : public EditorSpatialGizmo { public: virtual String get_handle_name(int p_idx) const; virtual Variant get_handle_value(int p_idx); - virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point); + 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); virtual void redraw(); - PathSpatialGizmo(Path *p_path = NULL); + Path3DGizmo(Path3D *p_path = nullptr); }; -class PathSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { +class Path3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(PathSpatialGizmoPlugin, EditorSpatialGizmoPlugin); + GDCLASS(Path3DGizmoPlugin, EditorNode3DGizmoPlugin); protected: - Ref<EditorSpatialGizmo> create_gizmo(Spatial *p_spatial); + Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial); public: String get_name() const; int get_priority() const; - PathSpatialGizmoPlugin(); + Path3DGizmoPlugin(); }; -class PathEditorPlugin : public EditorPlugin { +class Path3DEditorPlugin : public EditorPlugin { - GDCLASS(PathEditorPlugin, EditorPlugin); + GDCLASS(Path3DEditorPlugin, EditorPlugin); Separator *sep; ToolButton *curve_create; @@ -79,7 +79,7 @@ class PathEditorPlugin : public EditorPlugin { EditorNode *editor; - Path *path; + Path3D *path; void _mode_changed(int p_idx); void _close_curve(); @@ -98,14 +98,12 @@ protected: static void _bind_methods(); public: - Path *get_edited_path() { return path; } + Path3D *get_edited_path() { return path; } - static PathEditorPlugin *singleton; - virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); + static Path3DEditorPlugin *singleton; + virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event); - //virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); } - //virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); - virtual String get_name() const { return "Path"; } + virtual String get_name() const { return "Path3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; @@ -116,8 +114,8 @@ public: bool is_handle_clicked() { return handle_clicked; } void set_handle_clicked(bool clicked) { handle_clicked = clicked; } - PathEditorPlugin(EditorNode *p_node); - ~PathEditorPlugin(); + Path3DEditorPlugin(EditorNode *p_node); + ~Path3DEditorPlugin(); }; #endif // PATH_EDITOR_PLUGIN_H diff --git a/editor/plugins/physical_bone_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index e0d48afeef..6d38f7f318 100644 --- a/editor/plugins/physical_bone_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physical_bone_plugin.cpp */ +/* physical_bone_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,32 +28,33 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "physical_bone_plugin.h" -#include "editor/plugins/spatial_editor_plugin.h" -#include "scene/3d/physics_body.h" +#include "physical_bone_3d_editor_plugin.h" -void PhysicalBoneEditor::_bind_methods() { +#include "editor/plugins/node_3d_editor_plugin.h" +#include "scene/3d/physics_body_3d.h" + +void PhysicalBone3DEditor::_bind_methods() { } -void PhysicalBoneEditor::_on_toggle_button_transform_joint(bool p_is_pressed) { +void PhysicalBone3DEditor::_on_toggle_button_transform_joint(bool p_is_pressed) { _set_move_joint(); } -void PhysicalBoneEditor::_set_move_joint() { +void PhysicalBone3DEditor::_set_move_joint() { if (selected) { selected->_set_gizmo_move_joint(button_transform_joint->is_pressed()); } } -PhysicalBoneEditor::PhysicalBoneEditor(EditorNode *p_editor) : +PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : editor(p_editor), - selected(NULL) { + selected(nullptr) { spatial_editor_hb = memnew(HBoxContainer); spatial_editor_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN); - SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); + Node3DEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); spatial_editor_hb->add_child(memnew(VSeparator)); @@ -61,16 +62,16 @@ PhysicalBoneEditor::PhysicalBoneEditor(EditorNode *p_editor) : spatial_editor_hb->add_child(button_transform_joint); button_transform_joint->set_text(TTR("Move Joint")); - button_transform_joint->set_icon(SpatialEditor::get_singleton()->get_icon("PhysicalBone", "EditorIcons")); + button_transform_joint->set_icon(Node3DEditor::get_singleton()->get_theme_icon("PhysicalBone3D", "EditorIcons")); button_transform_joint->set_toggle_mode(true); - button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBoneEditor::_on_toggle_button_transform_joint)); + button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); hide(); } -PhysicalBoneEditor::~PhysicalBoneEditor() {} +PhysicalBone3DEditor::~PhysicalBone3DEditor() {} -void PhysicalBoneEditor::set_selected(PhysicalBone *p_pb) { +void PhysicalBone3DEditor::set_selected(PhysicalBone3D *p_pb) { button_transform_joint->set_pressed(false); @@ -79,33 +80,33 @@ void PhysicalBoneEditor::set_selected(PhysicalBone *p_pb) { _set_move_joint(); } -void PhysicalBoneEditor::hide() { +void PhysicalBone3DEditor::hide() { spatial_editor_hb->hide(); } -void PhysicalBoneEditor::show() { +void PhysicalBone3DEditor::show() { spatial_editor_hb->show(); } -PhysicalBonePlugin::PhysicalBonePlugin(EditorNode *p_editor) : +PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin(EditorNode *p_editor) : editor(p_editor), - selected(NULL), + selected(nullptr), physical_bone_editor(editor) {} -void PhysicalBonePlugin::make_visible(bool p_visible) { +void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { physical_bone_editor.show(); } else { physical_bone_editor.hide(); - physical_bone_editor.set_selected(NULL); - selected = NULL; + physical_bone_editor.set_selected(nullptr); + selected = nullptr; } } -void PhysicalBonePlugin::edit(Object *p_node) { - selected = static_cast<PhysicalBone *>(p_node); // Trust it +void PhysicalBone3DEditorPlugin::edit(Object *p_node) { + selected = static_cast<PhysicalBone3D *>(p_node); // Trust it ERR_FAIL_COND(!selected); physical_bone_editor.set_selected(selected); diff --git a/editor/plugins/physical_bone_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h index 459a67db05..74932710d6 100644 --- a/editor/plugins/physical_bone_plugin.h +++ b/editor/plugins/physical_bone_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* physical_bone_plugin.h */ +/* physical_bone_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,14 +33,14 @@ #include "editor/editor_node.h" -class PhysicalBoneEditor : public Object { - GDCLASS(PhysicalBoneEditor, Object); +class PhysicalBone3DEditor : public Object { + GDCLASS(PhysicalBone3DEditor, Object); EditorNode *editor; HBoxContainer *spatial_editor_hb; ToolButton *button_transform_joint; - PhysicalBone *selected; + PhysicalBone3D *selected; protected: static void _bind_methods(); @@ -50,29 +50,29 @@ private: void _set_move_joint(); public: - PhysicalBoneEditor(EditorNode *p_editor); - ~PhysicalBoneEditor(); + PhysicalBone3DEditor(EditorNode *p_editor); + ~PhysicalBone3DEditor(); - void set_selected(PhysicalBone *p_pb); + void set_selected(PhysicalBone3D *p_pb); void hide(); void show(); }; -class PhysicalBonePlugin : public EditorPlugin { - GDCLASS(PhysicalBonePlugin, EditorPlugin); +class PhysicalBone3DEditorPlugin : public EditorPlugin { + GDCLASS(PhysicalBone3DEditorPlugin, EditorPlugin); EditorNode *editor; - PhysicalBone *selected; - PhysicalBoneEditor physical_bone_editor; + PhysicalBone3D *selected; + PhysicalBone3DEditor physical_bone_editor; public: - virtual String get_name() const { return "PhysicalBone"; } - virtual bool handles(Object *p_object) const { return p_object->is_class("PhysicalBone"); } + virtual String get_name() const { return "PhysicalBone3D"; } + virtual bool handles(Object *p_object) const { return p_object->is_class("PhysicalBone3D"); } virtual void make_visible(bool p_visible); virtual void edit(Object *p_node); - PhysicalBonePlugin(EditorNode *p_editor); + PhysicalBone3DEditorPlugin(EditorNode *p_editor); }; #endif diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 8c115586a4..1f7a5b9968 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -31,8 +31,8 @@ #include "polygon_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/os/file_access.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" @@ -70,28 +70,28 @@ void Polygon2DEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - uv_edit_draw->add_style_override("panel", get_stylebox("bg", "Tree")); - bone_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); + 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")); } break; case NOTIFICATION_READY: { - button_uv->set_icon(get_icon("Uv", "EditorIcons")); + button_uv->set_icon(get_theme_icon("Uv", "EditorIcons")); - uv_button[UV_MODE_CREATE]->set_icon(get_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_CREATE_INTERNAL]->set_icon(get_icon("EditInternal", "EditorIcons")); - uv_button[UV_MODE_REMOVE_INTERNAL]->set_icon(get_icon("RemoveInternal", "EditorIcons")); - uv_button[UV_MODE_EDIT_POINT]->set_icon(get_icon("ToolSelect", "EditorIcons")); - uv_button[UV_MODE_MOVE]->set_icon(get_icon("ToolMove", "EditorIcons")); - uv_button[UV_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons")); - uv_button[UV_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons")); - uv_button[UV_MODE_ADD_POLYGON]->set_icon(get_icon("Edit", "EditorIcons")); - uv_button[UV_MODE_REMOVE_POLYGON]->set_icon(get_icon("Close", "EditorIcons")); - uv_button[UV_MODE_PAINT_WEIGHT]->set_icon(get_icon("PaintVertex", "EditorIcons")); - uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_icon("UnpaintVertex", "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("PaintVertex", "EditorIcons")); + uv_button[UV_MODE_CLEAR_WEIGHT]->set_icon(get_theme_icon("UnpaintVertex", "EditorIcons")); - b_snap_grid->set_icon(get_icon("Grid", "EditorIcons")); - b_snap_enable->set_icon(get_icon("SnapGrid", "EditorIcons")); - uv_icon_zoom->set_texture(get_icon("Zoom", "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")); uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); @@ -107,10 +107,10 @@ void Polygon2DEditor::_notification(int p_what) { void Polygon2DEditor::_sync_bones() { - Skeleton2D *skeleton = NULL; + Skeleton2D *skeleton = nullptr; if (!node->has_node(node->get_skeleton())) { error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node")); - error->popup_centered_minsize(); + error->popup_centered(); } else { Node *sn = node->get_node(node->get_skeleton()); skeleton = Object::cast_to<Skeleton2D>(sn); @@ -121,7 +121,7 @@ void Polygon2DEditor::_sync_bones() { if (!skeleton) { error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node")); - error->popup_centered_minsize(); + error->popup_centered(); } else { for (int i = 0; i < skeleton->get_bone_count(); i++) { NodePath path = skeleton->get_path_to(skeleton->get_bone(i)); @@ -275,7 +275,7 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { void Polygon2DEditor::_uv_edit_popup_hide() { - EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", uv_edit->get_rect()); + EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", Rect2(uv_edit->get_position(), uv_edit->get_size())); _cancel_editing(); } @@ -289,7 +289,7 @@ void Polygon2DEditor::_menu_option(int p_option) { if (node->get_texture().is_null()) { error->set_text(TTR("No texture in this polygon.\nSet a texture to be able to edit UV.")); - error->popup_centered_minsize(); + error->popup_centered(); return; } @@ -351,7 +351,7 @@ void Polygon2DEditor::_menu_option(int p_option) { } break; case UVEDIT_GRID_SETTINGS: { - grid_settings->popup_centered_minsize(); + grid_settings->popup_centered(); } break; default: { @@ -683,7 +683,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { //close if (polygon_create.size() < 3) { error->set_text(TTR("Invalid Polygon (need 3 different vertices)")); - error->popup_centered_minsize(); + error->popup_centered(); } else { Array polygons = node->get_polygons(); polygons = polygons.duplicate(); //copy because its a reference @@ -810,7 +810,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { if (mm.is_valid()) { - if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::get_singleton()->is_key_pressed(KEY_SPACE)) { + if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) { Vector2 drag(mm->get_relative().x, mm->get_relative().y); uv_hscroll->set_value(uv_hscroll->get_value() - drag.x); @@ -990,9 +990,9 @@ void Polygon2DEditor::_uv_draw() { mtx.elements[2] = -uv_draw_ofs; mtx.scale_basis(Vector2(uv_draw_zoom, uv_draw_zoom)); - VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx); + RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), mtx); uv_edit_draw->draw_texture(base_tex, Point2()); - VS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D()); + RS::get_singleton()->canvas_item_add_set_transform(uv_edit_draw->get_canvas_item(), Transform2D()); if (snap_show_grid) { Color grid_color = Color(1.0, 1.0, 1.0, 0.15); @@ -1031,7 +1031,7 @@ void Polygon2DEditor::_uv_draw() { uvs = node->get_polygon(); } - const float *weight_r; + const float *weight_r = nullptr; if (uv_edit_mode[3]->is_pressed()) { int bone_selected = -1; @@ -1044,13 +1044,12 @@ void Polygon2DEditor::_uv_draw() { } if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == uvs.size()) { - weight_r = node->get_bone_weights(bone_selected).ptr(); } } // All UV points are sharp, so use the sharp handle icon - Ref<Texture2D> handle = get_icon("EditorPathSharpHandle", "EditorIcons"); + Ref<Texture2D> handle = get_theme_icon("EditorPathSharpHandle", "EditorIcons"); Color poly_line_color = Color(0.9, 0.5, 0.5); if (polygons.size() || polygon_create.size()) { @@ -1250,7 +1249,7 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = NULL; + node = nullptr; snap_offset = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_offset", Vector2()); snap_step = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_step", Vector2(10, 10)); use_snap = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_enabled", false); @@ -1265,8 +1264,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : uv_edit = memnew(AcceptDialog); add_child(uv_edit); uv_edit->set_title(TTR("Polygon 2D UV Editor")); - uv_edit->set_resizable(true); - uv_edit->connect("popup_hide", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide)); + uv_edit->connect("cancelled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide)); VBoxContainer *uv_main_vb = memnew(VBoxContainer); uv_edit->add_child(uv_main_vb); diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index feef505acc..852feeb675 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -41,7 +41,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_icon("Folder", "EditorIcons")); + load->set_icon(get_theme_icon("Folder", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { @@ -67,7 +67,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) dialog->set_title(TTR("Error!")); //dialog->get_cancel()->set_text("Close"); dialog->get_ok()->set_text(TTR("Close")); - dialog->popup_centered_minsize(); + dialog->popup_centered(); return; ///beh should show an error i guess } @@ -98,7 +98,7 @@ void ResourcePreloaderEditor::_load_pressed() { for (int i = 0; i < extensions.size(); i++) file->add_filter("*." + extensions[i]); - file->set_mode(EditorFileDialog::MODE_OPEN_FILES); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES); file->popup_centered_ratio(); } @@ -152,7 +152,7 @@ void ResourcePreloaderEditor::_paste_pressed() { dialog->set_text(TTR("Resource clipboard is empty!")); dialog->set_title(TTR("Error!")); dialog->get_ok()->set_text(TTR("Close")); - dialog->popup_centered_minsize(); + dialog->popup_centered(); return; ///beh should show an error i guess } @@ -181,7 +181,7 @@ void ResourcePreloaderEditor::_update_library() { tree->clear(); tree->set_hide_root(true); - TreeItem *root = tree->create_item(NULL); + TreeItem *root = tree->create_item(nullptr); List<StringName> rnames; preloader->get_resource_list(&rnames); @@ -215,11 +215,11 @@ void ResourcePreloaderEditor::_update_library() { ti->set_selectable(1, false); if (type == "PackedScene") { - ti->add_button(1, get_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_OPEN_SCENE, false, TTR("Open in Editor")); } else { - ti->add_button(1, get_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); + ti->add_button(1, get_theme_icon("Load", "EditorIcons"), BUTTON_EDIT_RESOURCE, false, TTR("Open in Editor")); } - ti->add_button(1, get_icon("Remove", "EditorIcons"), BUTTON_REMOVE, false, TTR("Remove")); + ti->add_button(1, get_theme_icon("Remove", "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 d932305c63..a7120c5d68 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "root_motion_editor_plugin.h" #include "editor/editor_node.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" void EditorPropertyRootMotion::_confirmed() { @@ -88,7 +88,7 @@ void EditorPropertyRootMotion::_node_assign() { for (Set<String>::Element *E = paths.front(); E; E = E->next()) { NodePath path = E->get(); - TreeItem *ti = NULL; + TreeItem *ti = nullptr; String accum; for (int i = 0; i < path.get_name_count(); i++) { String name = path.get_name(i); @@ -117,7 +117,7 @@ void EditorPropertyRootMotion::_node_assign() { } } - Node *node = NULL; + Node *node = nullptr; if (base->has_node(accum)) { node = base->get_node(accum); } @@ -128,7 +128,7 @@ void EditorPropertyRootMotion::_node_assign() { String concat = path.get_concatenated_subnames(); - Skeleton *skeleton = Object::cast_to<Skeleton>(node); + Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); if (skeleton && skeleton->find_bone(concat) != -1) { //path in skeleton const String &bone = concat; @@ -152,7 +152,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_icon("BoneAttachment", "EditorIcons")); + ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); ti->set_metadata(0, accum); } else { ti = parenthood[accum]; @@ -161,7 +161,7 @@ void EditorPropertyRootMotion::_node_assign() { ti->set_selectable(0, true); ti->set_text(0, concat); - ti->set_icon(0, get_icon("BoneAttachment", "EditorIcons")); + ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons")); ti->set_metadata(0, path); if (path == current) { ti->select(0); @@ -212,7 +212,7 @@ void EditorPropertyRootMotion::update_property() { } assign->set_flat(true); - Node *base_node = NULL; + Node *base_node = nullptr; if (base_hint != NodePath()) { if (get_tree()->get_root()->has_node(base_hint)) { base_node = get_tree()->get_root()->get_node(base_hint); @@ -242,7 +242,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_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); clear->set_icon(t); } } @@ -288,7 +288,7 @@ void EditorInspectorRootMotionPlugin::parse_begin(Object *p_object) { //do none } -bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) { +bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { if (p_path == "root_motion_track" && p_object->is_class("AnimationTree") && p_type == Variant::NODE_PATH) { EditorPropertyRootMotion *editor = memnew(EditorPropertyRootMotion); diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h index 8a7691de5d..f72ad1ec05 100644 --- a/editor/plugins/root_motion_editor_plugin.h +++ b/editor/plugins/root_motion_editor_plugin.h @@ -65,7 +65,7 @@ class EditorInspectorRootMotionPlugin : public EditorInspectorPlugin { public: virtual bool can_handle(Object *p_object); virtual void parse_begin(Object *p_object); - virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage); + virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false); virtual void parse_end(); }; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index b3f78b5406..2c831979de 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "script_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/os/file_access.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/project_settings.h" @@ -45,9 +45,10 @@ #include "editor/find_in_files.h" #include "editor/node_dock.h" #include "editor/plugins/shader_editor_plugin.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/scene_string_names.h" #include "script_text_editor.h" +#include "servers/display_server.h" #include "text_editor.h" /*** SCRIPT EDITOR ****/ @@ -192,7 +193,7 @@ void ScriptEditorQuickOpen::_update_search() { } } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void ScriptEditorQuickOpen::_confirmed() { @@ -215,8 +216,8 @@ void ScriptEditorQuickOpen::_notification(int p_what) { search_box->set_clear_button_enabled(true); [[fallthrough]]; } - case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + case NOTIFICATION_VISIBILITY_CHANGED: { + search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); @@ -246,12 +247,12 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); search_options->set_hide_root(true); search_options->set_hide_folding(true); - search_options->add_constant_override("draw_guides", 1); + search_options->add_theme_constant_override("draw_guides", 1); } ///////////////////////////////// -ScriptEditor *ScriptEditor::script_editor = NULL; +ScriptEditor *ScriptEditor::script_editor = nullptr; /*** SCRIPT EDITOR ******/ @@ -320,7 +321,7 @@ void ScriptEditor::_set_execution(REF p_script, int p_line) { if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { se->set_executing_line(p_line); } } @@ -336,7 +337,7 @@ void ScriptEditor::_clear_execution(REF p_script) { if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_script) || se->get_edited_resource()->get_path() == script->get_path()) { se->clear_executing_line(); } } @@ -347,7 +348,7 @@ ScriptEditorBase *ScriptEditor::_get_current_editor() const { int selected = tab_container->get_current_tab(); if (selected < 0 || selected >= tab_container->get_child_count()) - return NULL; + return nullptr; return Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); } @@ -428,12 +429,12 @@ void ScriptEditor::_go_to_tab(int p_idx) { if (Object::cast_to<ScriptEditorBase>(c)) { script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name()); - script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_icon()); + script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_theme_icon()); if (is_visible_in_tree()) Object::cast_to<ScriptEditorBase>(c)->ensure_focus(); Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { notify_script_changed(script); } @@ -442,7 +443,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_icon("Help", "EditorIcons")); + script_icon->set_texture(get_theme_icon("Help", "EditorIcons")); if (is_visible_in_tree()) Object::cast_to<EditorHelp>(c)->set_focused(); } @@ -556,7 +557,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { void ScriptEditor::_show_error_dialog(String p_path) { error_dialog->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_path)); - error_dialog->popup_centered_minsize(); + error_dialog->popup_centered(); } void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { @@ -574,7 +575,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { } Ref<Script> script = current->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { previous_scripts.push_back(script->get_path()); notify_script_close(script); } @@ -651,7 +652,7 @@ void ScriptEditor::_close_docs_tab() { void ScriptEditor::_copy_script_path() { ScriptEditorBase *se = _get_current_editor(); RES script = se->get_edited_resource(); - OS::get_singleton()->set_clipboard(script->get_path()); + DisplayServer::get_singleton()->clipboard_set(script->get_path()); } void ScriptEditor::_close_other_tabs() { @@ -703,7 +704,7 @@ void ScriptEditor::_close_all_tabs() { void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) { erase_tab_confirm->set_text(TTR("Close and save changes?") + "\n\"" + current->get_name() + "\""); - erase_tab_confirm->popup_centered_minsize(); + erase_tab_confirm->popup_centered(); } void ScriptEditor::_resave_scripts(const String &p_str) { @@ -736,7 +737,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) { } Ref<TextFile> text_file = script; - if (text_file != NULL) { + if (text_file != nullptr) { se->apply_code(); _save_text_file(text_file, text_file->get_path()); break; @@ -774,7 +775,7 @@ void ScriptEditor::_reload_scripts() { } Ref<Script> script = edited_res; - if (script != NULL) { + if (script != nullptr) { Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true); ERR_CONTINUE(!rel_script.is_valid()); script->set_source_code(rel_script->get_source_code()); @@ -783,7 +784,7 @@ void ScriptEditor::_reload_scripts() { } Ref<TextFile> text_file = edited_res; - if (text_file != NULL) { + if (text_file != nullptr) { Error err; Ref<TextFile> rel_text_file = _load_text_file(text_file->get_path(), &err); ERR_CONTINUE(!rel_text_file.is_valid()); @@ -960,9 +961,9 @@ Ref<Script> ScriptEditor::_get_current_script() { if (current) { Ref<Script> script = current->get_edited_resource(); - return script != NULL ? script : NULL; + return script != nullptr ? script : nullptr; } else { - return NULL; + return nullptr; } } @@ -995,7 +996,7 @@ void ScriptEditor::_menu_option(int p_option) { script_create_dialog->popup_centered(); } break; case FILE_NEW_TEXTFILE: { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = FILE_NEW_TEXTFILE; @@ -1004,7 +1005,7 @@ void ScriptEditor::_menu_option(int p_option) { file_dialog->set_title(TTR("New Text File...")); } break; case FILE_OPEN: { - file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = FILE_OPEN; @@ -1092,11 +1093,6 @@ void ScriptEditor::_menu_option(int p_option) { OS::get_singleton()->shell_open("https://docs.godotengine.org/"); } break; - case REQUEST_DOCS: { - - OS::get_singleton()->shell_open("https://github.com/godotengine/godot-docs/issues/new"); - } break; - case WINDOW_NEXT: { _history_forward(); @@ -1144,7 +1140,7 @@ void ScriptEditor::_menu_option(int p_option) { } Ref<TextFile> text_file = current->get_edited_resource(); - if (text_file != NULL) { + if (text_file != nullptr) { current->apply_code(); _save_text_file(text_file, text_file->get_path()); break; @@ -1168,8 +1164,8 @@ void ScriptEditor::_menu_option(int p_option) { } Ref<TextFile> text_file = current->get_edited_resource(); - if (text_file != NULL) { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + if (text_file != nullptr) { + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = FILE_SAVE_AS; @@ -1197,7 +1193,7 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_RUN: { Ref<Script> scr = current->get_edited_resource(); - if (scr == NULL || scr.is_null()) { + if (scr == nullptr || scr.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running.")); break; } @@ -1247,7 +1243,7 @@ void ScriptEditor::_menu_option(int p_option) { file_system_dock->navigate_to_path(path); // Ensure that the FileSystem dock is visible. TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(file_system_dock->get_position_in_parent()); + tab_container->set_current_tab(file_system_dock->get_index()); } } break; case CLOSE_DOCS: { @@ -1335,7 +1331,7 @@ void ScriptEditor::_menu_option(int p_option) { void ScriptEditor::_theme_option(int p_option) { switch (p_option) { case THEME_IMPORT: { - file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = THEME_IMPORT; file_dialog->clear_filters(); @@ -1360,7 +1356,7 @@ void ScriptEditor::_theme_option(int p_option) { } void ScriptEditor::_show_save_theme_as_dialog() { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_option = THEME_SAVE_AS; file_dialog->clear_filters(); @@ -1395,19 +1391,18 @@ void ScriptEditor::_notification(int p_what) { } case NOTIFICATION_THEME_CHANGED: { - help_search->set_icon(get_icon("HelpSearch", "EditorIcons")); - site_search->set_icon(get_icon("Instance", "EditorIcons")); - request_docs->set_icon(get_icon("Issue", "EditorIcons")); + help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); + site_search->set_icon(get_theme_icon("Instance", "EditorIcons")); - script_forward->set_icon(get_icon("Forward", "EditorIcons")); - script_back->set_icon(get_icon("Back", "EditorIcons")); + script_forward->set_icon(get_theme_icon("Forward", "EditorIcons")); + script_back->set_icon(get_theme_icon("Back", "EditorIcons")); - members_overview_alphabeta_sort_button->set_icon(get_icon("Sort", "EditorIcons")); + members_overview_alphabeta_sort_button->set_icon(get_theme_icon("Sort", "EditorIcons")); - filter_scripts->set_right_icon(get_icon("Search", "EditorIcons")); - filter_methods->set_right_icon(get_icon("Search", "EditorIcons")); + filter_scripts->set_right_icon(get_theme_icon("Search", "EditorIcons")); + filter_methods->set_right_icon(get_theme_icon("Search", "EditorIcons")); - filename->add_style_override("normal", editor->get_gui_base()->get_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); recent_scripts->set_as_minsize(); } break; @@ -1424,7 +1419,7 @@ void ScriptEditor::_notification(int p_what) { editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); } break; - case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + case NOTIFICATION_WM_FOCUS_IN: { _test_script_times_on_disk(); _update_modified_scripts_for_external_editor(); @@ -1466,7 +1461,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { if (se) { Ref<Script> script = se->get_edited_resource(); - if (script == NULL || !script.is_valid()) + if (script == nullptr || !script.is_valid()) continue; if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed @@ -1499,7 +1494,7 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { continue; Ref<Script> script = se->get_edited_resource(); - if (script == NULL) { + if (script == nullptr) { continue; } @@ -1550,7 +1545,7 @@ void ScriptEditor::_help_overview_selected(int p_idx) { void ScriptEditor::_script_selected(int p_idx) { - grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing + grab_focus_block = !InputFilter::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing _go_to_tab(script_list->get_item_metadata(p_idx)); grab_focus_block = false; @@ -1717,8 +1712,8 @@ void ScriptEditor::_update_script_colors() { bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script"); int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size"); - Color hot_color = get_color("accent_color", "Editor"); - Color cold_color = get_color("font_color", "Editor"); + Color hot_color = get_theme_color("accent_color", "Editor"); + Color cold_color = get_theme_color("font_color", "Editor"); for (int i = 0; i < script_list->get_item_count(); i++) { @@ -1775,7 +1770,7 @@ void ScriptEditor::_update_script_names() { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - Ref<Texture2D> icon = se->get_icon(); + Ref<Texture2D> icon = se->get_theme_icon(); String path = se->get_edited_resource()->get_path(); bool built_in = !path.is_resource_file(); String name; @@ -1783,9 +1778,11 @@ void ScriptEditor::_update_script_names() { if (built_in) { name = path.get_file(); - String resource_name = se->get_edited_resource()->get_name(); + const String &resource_name = se->get_edited_resource()->get_name(); if (resource_name != "") { - name = name.substr(0, name.find("::", 0) + 2) + resource_name; + // If the built-in script has a custom resource name defined, + // display the built-in script name as follows: `ResourceName (scene_file.tscn)` + name = vformat("%s (%s)", resource_name, name.substr(0, name.find("::", 0))); } } else { @@ -1836,7 +1833,7 @@ void ScriptEditor::_update_script_names() { if (eh) { String name = eh->get_class(); - Ref<Texture2D> icon = get_icon("Help", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons"); String tooltip = vformat(TTR("%s Class Reference"), name); _ScriptEditorItemData sd; @@ -1991,7 +1988,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra const bool should_open = open_dominant || !EditorNode::get_singleton()->is_changing_scene(); - if (script != NULL && script->get_language()->overrides_external_editor()) { + if (script != nullptr && script->get_language()->overrides_external_editor()) { if (should_open) { Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col); if (err != OK) @@ -2069,7 +2066,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra if (!se) continue; - if ((script != NULL && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { + if ((script != nullptr && se->get_edited_resource() == p_resource) || se->get_edited_resource()->get_path() == p_resource->get_path()) { if (should_open) { if (tab_container->get_current_tab() != i) { @@ -2091,7 +2088,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra // doesn't have it, make a new one - ScriptEditorBase *se = NULL; + ScriptEditorBase *se = nullptr; for (int i = script_editor_func_count - 1; i >= 0; i--) { se = script_editor_funcs[i](p_resource); @@ -2106,7 +2103,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i](); se->add_syntax_highlighter(highlighter); - if (script != NULL && !highlighter_set) { + if (script != nullptr && !highlighter_set) { List<String> languages = highlighter->get_supported_languages(); if (languages.find(script->get_language()->get_name())) { se->set_syntax_highlighter(highlighter); @@ -2187,7 +2184,7 @@ void ScriptEditor::save_all_scripts() { if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) { Ref<TextFile> text_file = edited_res; - if (text_file != NULL) { + if (text_file != nullptr) { _save_text_file(text_file, text_file->get_path()); continue; } @@ -2346,12 +2343,12 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node); if (se) { preview_name = se->get_name(); - preview_icon = se->get_icon(); + preview_icon = se->get_theme_icon(); } EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); if (eh) { preview_name = eh->get_class(); - preview_icon = get_icon("Help", "EditorIcons"); + preview_icon = get_theme_icon("Help", "EditorIcons"); } if (!preview_icon.is_null()) { @@ -2573,7 +2570,7 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_separator(); if (se) { Ref<Script> scr = se->get_edited_resource(); - if (scr != NULL) { + if (scr != nullptr) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); if (!scr.is_null() && scr->is_tool()) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_RUN); @@ -2830,7 +2827,7 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { Object::cast_to<ScriptEditorBase>(n)->ensure_focus(); Ref<Script> script = Object::cast_to<ScriptEditorBase>(n)->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { notify_script_changed(script); } } @@ -2871,7 +2868,7 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { continue; Ref<Script> script = se->get_edited_resource(); - if (script != NULL) { + if (script != nullptr) { out_scripts.push_back(script); } } @@ -2952,7 +2949,7 @@ void ScriptEditor::_on_find_in_files_requested(String text) { find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::SEARCH_MODE); find_in_files_dialog->set_search_text(text); - find_in_files_dialog->popup_centered_minsize(); + find_in_files_dialog->popup_centered(); } void ScriptEditor::_on_replace_in_files_requested(String text) { @@ -2960,7 +2957,7 @@ void ScriptEditor::_on_replace_in_files_requested(String text) { find_in_files_dialog->set_find_in_files_mode(FindInFilesDialog::REPLACE_MODE); find_in_files_dialog->set_search_text(text); find_in_files_dialog->set_replace_text(""); - find_in_files_dialog->popup_centered_minsize(); + find_in_files_dialog->popup_centered(); } void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) { @@ -3111,7 +3108,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { context_menu = memnew(PopupMenu); add_child(context_menu); context_menu->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); - context_menu->set_hide_on_window_lose_focus(true); overview_vbox = memnew(VBoxContainer); overview_vbox->set_custom_minimum_size(Size2(0, 90)); @@ -3124,7 +3120,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { filename = memnew(Label); filename->set_clip_text(true); filename->set_h_size_flags(SIZE_EXPAND_FILL); - filename->add_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "LineEdit")); + filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); buttons_hbox->add_child(filename); members_overview_alphabeta_sort_button = memnew(ToolButton); @@ -3172,7 +3168,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(file_menu); file_menu->set_text(TTR("File")); file_menu->set_switch_on_hover(true); - file_menu->get_popup()->set_hide_on_window_lose_focus(true); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script...")), FILE_NEW); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New Text File...")), FILE_NEW_TEXTFILE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open...")), FILE_OPEN); @@ -3229,7 +3225,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(script_search_menu); script_search_menu->set_text(TTR("Search")); script_search_menu->set_switch_on_hover(true); - script_search_menu->get_popup()->set_hide_on_window_lose_focus(true); script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); MenuButton *debug_menu = memnew(MenuButton); @@ -3261,12 +3256,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(site_search); site_search->set_tooltip(TTR("Open Godot online documentation.")); - request_docs = memnew(ToolButton); - request_docs->set_text(TTR("Request Docs")); - request_docs->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option), varray(REQUEST_DOCS)); - menu_hb->add_child(request_docs); - request_docs->set_tooltip(TTR("Help improve the Godot documentation by giving feedback.")); - help_search = memnew(ToolButton); help_search->set_text(TTR("Search Help")); help_search->connect("pressed", callable_mp(this, &ScriptEditor::_menu_option), varray(SEARCH_HELP)); @@ -3291,7 +3280,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { erase_tab_confirm = memnew(ConfirmationDialog); erase_tab_confirm->get_ok()->set_text(TTR("Save")); - erase_tab_confirm->add_button(TTR("Discard"), OS::get_singleton()->get_swap_ok_cancel(), "discard"); + erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard"); erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); add_child(erase_tab_confirm); @@ -3325,7 +3314,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts)); disk_changed->get_ok()->set_text(TTR("Reload")); - disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts)); } @@ -3366,8 +3355,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { ScriptServer::edit_request_func = _open_script_request; - add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptEditorPanel", "EditorStyles")); - tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptEditor", "EditorStyles")); + 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")); } ScriptEditor::~ScriptEditor() { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 81f9595264..e895867268 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -92,7 +92,7 @@ public: virtual void set_edited_resource(const RES &p_res) = 0; virtual void reload_text() = 0; virtual String get_name() = 0; - virtual Ref<Texture2D> get_icon() = 0; + virtual Ref<Texture2D> get_theme_icon() = 0; virtual bool is_unsaved() = 0; virtual Variant get_edit_state() = 0; virtual void set_edit_state(const Variant &p_state) = 0; @@ -159,7 +159,6 @@ class ScriptEditor : public PanelContainer { REPLACE_IN_FILES, SEARCH_HELP, SEARCH_WEBSITE, - REQUEST_DOCS, HELP_SEARCH_FIND, HELP_SEARCH_FIND_NEXT, HELP_SEARCH_FIND_PREVIOUS, @@ -204,7 +203,6 @@ class ScriptEditor : public PanelContainer { Button *help_search; Button *site_search; - Button *request_docs; EditorHelpSearch *help_search_dialog; ItemList *script_list; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 176df7efb8..1a77eeb9de 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -65,7 +65,8 @@ void ConnectionInfoDialog::popup_connections(String p_method, Vector<Node *> p_n node_item->set_editable(0, false); node_item->set_text(1, connection.signal.get_name()); - node_item->set_icon(1, get_parent_control()->get_icon("Slot", "EditorIcons")); + Control *p = Object::cast_to<Control>(get_parent()); + node_item->set_icon(1, p->get_theme_icon("Slot", "EditorIcons")); node_item->set_selectable(1, false); node_item->set_editable(1, false); @@ -83,10 +84,10 @@ ConnectionInfoDialog::ConnectionInfoDialog() { set_title(TTR("Connections to method:")); VBoxContainer *vbc = memnew(VBoxContainer); - vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE); + vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE); + vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE); add_child(vbc); method = memnew(Label); @@ -101,7 +102,7 @@ ConnectionInfoDialog::ConnectionInfoDialog() { tree->set_column_title(1, TTR("Signal")); tree->set_column_title(2, TTR("Target")); vbc->add_child(tree); - tree->set_v_size_flags(SIZE_EXPAND_FILL); + tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); tree->set_allow_rmb_select(true); } @@ -171,7 +172,7 @@ void ScriptTextEditor::_update_member_keywords() { 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) + if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP) continue; if (name.find("/") != -1) continue; @@ -229,36 +230,36 @@ void ScriptTextEditor::_load_theme_settings() { Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); - text_edit->add_color_override("background_color", background_color); - text_edit->add_color_override("completion_background_color", completion_background_color); - text_edit->add_color_override("completion_selected_color", completion_selected_color); - text_edit->add_color_override("completion_existing_color", completion_existing_color); - text_edit->add_color_override("completion_scroll_color", completion_scroll_color); - text_edit->add_color_override("completion_font_color", completion_font_color); - text_edit->add_color_override("font_color", text_color); - text_edit->add_color_override("line_number_color", line_number_color); - text_edit->add_color_override("safe_line_number_color", safe_line_number_color); - text_edit->add_color_override("caret_color", caret_color); - text_edit->add_color_override("caret_background_color", caret_background_color); - text_edit->add_color_override("font_color_selected", text_selected_color); - text_edit->add_color_override("selection_color", selection_color); - text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); - text_edit->add_color_override("current_line_color", current_line_color); - text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color); - text_edit->add_color_override("word_highlighted_color", word_highlighted_color); - text_edit->add_color_override("number_color", number_color); - text_edit->add_color_override("function_color", function_color); - text_edit->add_color_override("member_variable_color", member_variable_color); - text_edit->add_color_override("bookmark_color", bookmark_color); - text_edit->add_color_override("breakpoint_color", breakpoint_color); - text_edit->add_color_override("executing_line_color", executing_line_color); - text_edit->add_color_override("mark_color", mark_color); - text_edit->add_color_override("code_folding_color", code_folding_color); - text_edit->add_color_override("search_result_color", search_result_color); - text_edit->add_color_override("search_result_border_color", search_result_border_color); - text_edit->add_color_override("symbol_color", symbol_color); - - text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); + text_edit->add_theme_color_override("background_color", background_color); + text_edit->add_theme_color_override("completion_background_color", completion_background_color); + text_edit->add_theme_color_override("completion_selected_color", completion_selected_color); + text_edit->add_theme_color_override("completion_existing_color", completion_existing_color); + text_edit->add_theme_color_override("completion_scroll_color", completion_scroll_color); + text_edit->add_theme_color_override("completion_font_color", completion_font_color); + text_edit->add_theme_color_override("font_color", text_color); + text_edit->add_theme_color_override("line_number_color", line_number_color); + text_edit->add_theme_color_override("safe_line_number_color", safe_line_number_color); + text_edit->add_theme_color_override("caret_color", caret_color); + text_edit->add_theme_color_override("caret_background_color", caret_background_color); + text_edit->add_theme_color_override("font_color_selected", text_selected_color); + text_edit->add_theme_color_override("selection_color", selection_color); + text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color); + text_edit->add_theme_color_override("current_line_color", current_line_color); + text_edit->add_theme_color_override("line_length_guideline_color", line_length_guideline_color); + text_edit->add_theme_color_override("word_highlighted_color", word_highlighted_color); + text_edit->add_theme_color_override("number_color", number_color); + text_edit->add_theme_color_override("function_color", function_color); + text_edit->add_theme_color_override("member_variable_color", member_variable_color); + text_edit->add_theme_color_override("bookmark_color", bookmark_color); + text_edit->add_theme_color_override("breakpoint_color", breakpoint_color); + text_edit->add_theme_color_override("executing_line_color", executing_line_color); + text_edit->add_theme_color_override("mark_color", mark_color); + text_edit->add_theme_color_override("code_folding_color", code_folding_color); + text_edit->add_theme_color_override("search_result_color", search_result_color); + text_edit->add_theme_color_override("search_result_border_color", search_result_border_color); + text_edit->add_theme_color_override("symbol_color", symbol_color); + + text_edit->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); colors_cache.symbol_color = symbol_color; colors_cache.keyword_color = keyword_color; @@ -555,10 +556,10 @@ String ScriptTextEditor::get_name() { return name; } -Ref<Texture2D> ScriptTextEditor::get_icon() { +Ref<Texture2D> ScriptTextEditor::get_theme_icon() { - if (get_parent_control() && get_parent_control()->has_icon(script->get_class(), "EditorIcons")) { - return get_parent_control()->get_icon(script->get_class(), "EditorIcons"); + if (get_parent_control() && get_parent_control()->has_theme_icon(script->get_class(), "EditorIcons")) { + return get_parent_control()->get_theme_icon(script->get_class(), "EditorIcons"); } return Ref<Texture2D>(); @@ -614,7 +615,7 @@ void ScriptTextEditor::_validate_script() { 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_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "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. @@ -634,7 +635,7 @@ void ScriptTextEditor::_validate_script() { warnings_panel->push_cell(); warnings_panel->push_meta(w.line - 1); - warnings_panel->push_color(warnings_panel->get_color("warning_color", "Editor")); + warnings_panel->push_color(warnings_panel->get_theme_color("warning_color", "Editor")); warnings_panel->add_text(TTR("Line") + " " + itos(w.line)); warnings_panel->add_text(" (" + w.string_code + "):"); warnings_panel->pop(); // Color. @@ -746,7 +747,7 @@ static Vector<Node *> _find_all_node_for_script(Node *p_base, Node *p_current, c static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) { if (p_current->get_owner() != p_base && p_base != p_current) - return NULL; + return nullptr; Ref<Script> c = p_current->get_script(); if (c == p_script) return p_current; @@ -756,7 +757,7 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri return found; } - return NULL; + return nullptr; } static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) { @@ -821,7 +822,7 @@ void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) { - if (color_panel->is_visible_in_tree()) return; + if (color_panel->is_visible()) return; Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base, base, script); @@ -998,7 +999,7 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) { } void ScriptTextEditor::update_toggle_scripts_button() { - if (code_editor != NULL) { + if (code_editor != nullptr) { code_editor->update_toggle_scripts_button(); } } @@ -1046,7 +1047,7 @@ void ScriptTextEditor::_update_connected_methods() { String name = functions[j].get_slice(":", 0); if (name == connection.callable.get_method()) { line = functions[j].get_slice(":", 1).to_int(); - text_edit->set_line_info_icon(line - 1, get_parent_control()->get_icon("Slot", "EditorIcons"), connection.callable.get_method()); + text_edit->set_line_info_icon(line - 1, get_parent_control()->get_theme_icon("Slot", "EditorIcons"), connection.callable.get_method()); methods_found.insert(connection.callable.get_method()); break; } @@ -1435,7 +1436,7 @@ void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { TextEdit *te = code_editor->get_text_edit(); te->_set_syntax_highlighting(p_highlighter); - if (p_highlighter != NULL) + if (p_highlighter != nullptr) highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true); else highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(TTR("Standard")), true); @@ -1443,7 +1444,7 @@ void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { Map<String, SyntaxHighlighter *>::Element *el = highlighters.front(); - while (el != NULL) { + while (el != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false); el = el->next(); } @@ -1516,7 +1517,7 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) { if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) - return NULL; + return nullptr; Ref<Script> scr = p_current_node->get_script(); @@ -1529,7 +1530,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const return n; } - return NULL; + return nullptr; } void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { @@ -1779,7 +1780,7 @@ ScriptTextEditor::ScriptTextEditor() { code_editor = memnew(CodeTextEditor); editor_box->add_child(code_editor); - code_editor->add_constant_override("separation", 2); + code_editor->add_theme_constant_override("separation", 2); code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); code_editor->connect("validate_script", callable_mp(this, &ScriptTextEditor::_validate_script)); code_editor->connect("load_theme_settings", callable_mp(this, &ScriptTextEditor::_load_theme_settings)); @@ -1817,7 +1818,6 @@ ScriptTextEditor::ScriptTextEditor() { context_menu = memnew(PopupMenu); add_child(context_menu); context_menu->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option)); - context_menu->set_hide_on_window_lose_focus(true); color_panel = memnew(PopupPanel); add_child(color_panel); @@ -1838,7 +1838,7 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); - edit_menu->get_popup()->set_hide_on_window_lose_focus(true); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); edit_menu->get_popup()->add_separator(); @@ -1877,7 +1877,7 @@ ScriptTextEditor::ScriptTextEditor() { convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize"), KEY_MASK_SHIFT | KEY_F6), EDIT_CAPITALIZE); convert_case->connect("id_pressed", callable_mp(this, &ScriptTextEditor::_edit_option)); - highlighters[TTR("Standard")] = NULL; + highlighters[TTR("Standard")] = nullptr; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); @@ -1889,7 +1889,7 @@ ScriptTextEditor::ScriptTextEditor() { edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); - search_menu->get_popup()->set_hide_on_window_lose_focus(true); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV); @@ -1918,7 +1918,7 @@ ScriptTextEditor::ScriptTextEditor() { goto_menu->get_popup()->add_child(bookmarks_menu); goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks"); _update_bookmark_list(); - bookmarks_menu->connect("about_to_show", callable_mp(this, &ScriptTextEditor::_update_bookmark_list)); + bookmarks_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_bookmark_list)); bookmarks_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_bookmark_item_pressed)); breakpoints_menu = memnew(PopupMenu); @@ -1926,7 +1926,7 @@ ScriptTextEditor::ScriptTextEditor() { goto_menu->get_popup()->add_child(breakpoints_menu); goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "Breakpoints"); _update_breakpoint_list(); - breakpoints_menu->connect("about_to_show", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list)); + breakpoints_menu->connect("about_to_popup", callable_mp(this, &ScriptTextEditor::_update_breakpoint_list)); breakpoints_menu->connect("index_pressed", callable_mp(this, &ScriptTextEditor::_breakpoint_item_pressed)); quick_open = memnew(ScriptEditorQuickOpen); @@ -1944,7 +1944,7 @@ ScriptTextEditor::ScriptTextEditor() { ScriptTextEditor::~ScriptTextEditor() { for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) { - if (E->get() != NULL) { + if (E->get() != nullptr) { memdelete(E->get()); } } @@ -1956,7 +1956,7 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { if (Object::cast_to<Script>(*p_resource)) { return memnew(ScriptTextEditor); } - return NULL; + return nullptr; } void ScriptTextEditor::register_editor() { diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index d2f0b310e6..51ce30c831 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -201,7 +201,7 @@ public: virtual Vector<String> get_functions(); virtual void reload_text(); virtual String get_name(); - virtual Ref<Texture2D> get_icon(); + virtual Ref<Texture2D> get_theme_icon(); virtual bool is_unsaved(); virtual Variant get_edit_state(); virtual void set_edit_state(const Variant &p_state); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 01b1e21153..9ef8148241 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -38,7 +38,8 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/property_editor.h" -#include "servers/visual/shader_types.h" +#include "servers/display_server.h" +#include "servers/rendering/shader_types.h" /*** SHADER SCRIPT EDITOR ****/ @@ -116,49 +117,49 @@ void ShaderTextEditor::_load_theme_settings() { Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color"); Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); - get_text_edit()->add_color_override("background_color", background_color); - get_text_edit()->add_color_override("completion_background_color", completion_background_color); - get_text_edit()->add_color_override("completion_selected_color", completion_selected_color); - get_text_edit()->add_color_override("completion_existing_color", completion_existing_color); - get_text_edit()->add_color_override("completion_scroll_color", completion_scroll_color); - get_text_edit()->add_color_override("completion_font_color", completion_font_color); - get_text_edit()->add_color_override("font_color", text_color); - get_text_edit()->add_color_override("line_number_color", line_number_color); - get_text_edit()->add_color_override("caret_color", caret_color); - get_text_edit()->add_color_override("caret_background_color", caret_background_color); - get_text_edit()->add_color_override("font_color_selected", text_selected_color); - get_text_edit()->add_color_override("selection_color", selection_color); - get_text_edit()->add_color_override("brace_mismatch_color", brace_mismatch_color); - get_text_edit()->add_color_override("current_line_color", current_line_color); - get_text_edit()->add_color_override("line_length_guideline_color", line_length_guideline_color); - get_text_edit()->add_color_override("word_highlighted_color", word_highlighted_color); - get_text_edit()->add_color_override("number_color", number_color); - get_text_edit()->add_color_override("function_color", function_color); - get_text_edit()->add_color_override("member_variable_color", member_variable_color); - get_text_edit()->add_color_override("mark_color", mark_color); - get_text_edit()->add_color_override("bookmark_color", bookmark_color); - get_text_edit()->add_color_override("breakpoint_color", breakpoint_color); - get_text_edit()->add_color_override("executing_line_color", executing_line_color); - get_text_edit()->add_color_override("code_folding_color", code_folding_color); - get_text_edit()->add_color_override("search_result_color", search_result_color); - get_text_edit()->add_color_override("search_result_border_color", search_result_border_color); - get_text_edit()->add_color_override("symbol_color", symbol_color); + get_text_edit()->add_theme_color_override("background_color", background_color); + get_text_edit()->add_theme_color_override("completion_background_color", completion_background_color); + get_text_edit()->add_theme_color_override("completion_selected_color", completion_selected_color); + get_text_edit()->add_theme_color_override("completion_existing_color", completion_existing_color); + get_text_edit()->add_theme_color_override("completion_scroll_color", completion_scroll_color); + get_text_edit()->add_theme_color_override("completion_font_color", completion_font_color); + get_text_edit()->add_theme_color_override("font_color", text_color); + get_text_edit()->add_theme_color_override("line_number_color", line_number_color); + get_text_edit()->add_theme_color_override("caret_color", caret_color); + get_text_edit()->add_theme_color_override("caret_background_color", caret_background_color); + get_text_edit()->add_theme_color_override("font_color_selected", text_selected_color); + get_text_edit()->add_theme_color_override("selection_color", selection_color); + get_text_edit()->add_theme_color_override("brace_mismatch_color", brace_mismatch_color); + get_text_edit()->add_theme_color_override("current_line_color", current_line_color); + get_text_edit()->add_theme_color_override("line_length_guideline_color", line_length_guideline_color); + get_text_edit()->add_theme_color_override("word_highlighted_color", word_highlighted_color); + get_text_edit()->add_theme_color_override("number_color", number_color); + get_text_edit()->add_theme_color_override("function_color", function_color); + get_text_edit()->add_theme_color_override("member_variable_color", member_variable_color); + get_text_edit()->add_theme_color_override("mark_color", mark_color); + get_text_edit()->add_theme_color_override("bookmark_color", bookmark_color); + get_text_edit()->add_theme_color_override("breakpoint_color", breakpoint_color); + get_text_edit()->add_theme_color_override("executing_line_color", executing_line_color); + get_text_edit()->add_theme_color_override("code_folding_color", code_folding_color); + get_text_edit()->add_theme_color_override("search_result_color", search_result_color); + get_text_edit()->add_theme_color_override("search_result_border_color", search_result_border_color); + get_text_edit()->add_theme_color_override("symbol_color", symbol_color); List<String> keywords; ShaderLanguage::get_keyword_list(&keywords); if (shader.is_valid()) { - for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { + for (const Map<StringName, ShaderLanguage::FunctionInfo>::Element *E = ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())).front(); E; E = E->next()) { for (const Map<StringName, ShaderLanguage::BuiltInInfo>::Element *F = E->get().built_ins.front(); F; F = F->next()) { keywords.push_back(F->key()); } } - for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())).size(); i++) { + for (int i = 0; i < ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())).size(); i++) { - keywords.push_back(ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode()))[i]); + keywords.push_back(ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()))[i]); } } @@ -192,6 +193,12 @@ void ShaderTextEditor::_check_shader_mode() { } } +static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) { + + RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable); + return RS::global_variable_type_get_shader_datatype(gvt); +} + void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) { _check_shader_mode(); @@ -199,7 +206,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo ShaderLanguage sl; String calltip; - sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); + sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type, r_options, calltip); get_text_edit()->set_code_hint(calltip); } @@ -214,7 +221,7 @@ void ShaderTextEditor::_validate_script() { ShaderLanguage sl; - Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types()); + Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type); if (err != OK) { String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text(); @@ -351,7 +358,7 @@ void ShaderEditor::_menu_option(int p_option) { void ShaderEditor::_notification(int p_what) { - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + if (p_what == NOTIFICATION_WM_FOCUS_IN) { _check_for_external_edit(); } } @@ -376,7 +383,7 @@ void ShaderEditor::_editor_settings_changed() { shader_editor->get_text_edit()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line")); shader_editor->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink")); shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed")); - shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing")); + shader_editor->get_text_edit()->add_theme_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing")); shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret")); shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling")); shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed")); @@ -595,7 +602,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { shader_editor = memnew(ShaderTextEditor); shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); - shader_editor->add_constant_override("separation", 0); + shader_editor->add_theme_constant_override("separation", 0); shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); shader_editor->connect("script_changed", callable_mp(this, &ShaderEditor::apply_shaders)); @@ -614,7 +621,6 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { context_menu = memnew(PopupMenu); add_child(context_menu); context_menu->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); - context_menu->set_hide_on_window_lose_focus(true); VBoxContainer *main_container = memnew(VBoxContainer); HBoxContainer *hbc = memnew(HBoxContainer); @@ -622,7 +628,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); - edit_menu->get_popup()->set_hide_on_window_lose_focus(true); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); edit_menu->get_popup()->add_separator(); @@ -646,7 +652,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { search_menu = memnew(MenuButton); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); - search_menu->get_popup()->set_hide_on_window_lose_focus(true); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV); @@ -666,13 +672,13 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { goto_menu->get_popup()->add_child(bookmarks_menu); goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks"); _update_bookmark_list(); - bookmarks_menu->connect("about_to_show", callable_mp(this, &ShaderEditor::_update_bookmark_list)); + bookmarks_menu->connect("about_to_popup", callable_mp(this, &ShaderEditor::_update_bookmark_list)); bookmarks_menu->connect("index_pressed", callable_mp(this, &ShaderEditor::_bookmark_item_pressed)); 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_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); + 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()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); add_child(main_container); @@ -681,7 +687,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { hbc->add_child(edit_menu); hbc->add_child(goto_menu); hbc->add_child(help_menu); - hbc->add_style_override("panel", p_node->get_gui_base()->get_stylebox("ScriptEditorPanel", "EditorStyles")); + hbc->add_theme_style_override("panel", p_node->get_gui_base()->get_theme_stylebox("ScriptEditorPanel", "EditorStyles")); main_container->add_child(shader_editor); goto_line_dialog = memnew(GotoLineDialog); @@ -699,7 +705,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); disk_changed->get_ok()->set_text(TTR("Reload")); - disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data)); add_child(disk_changed); @@ -716,7 +722,7 @@ void ShaderEditorPlugin::edit(Object *p_object) { bool ShaderEditorPlugin::handles(Object *p_object) const { Shader *shader = Object::cast_to<Shader>(p_object); - return shader != NULL && shader->is_text_shader(); + return shader != nullptr && shader->is_text_shader(); } void ShaderEditorPlugin::make_visible(bool p_visible) { diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 900b40bd7a..f02ed590fc 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -39,7 +39,7 @@ #include "scene/gui/text_edit.h" #include "scene/main/timer.h" #include "scene/resources/shader.h" -#include "servers/visual/shader_language.h" +#include "servers/rendering/shader_language.h" class ShaderTextEditor : public CodeTextEditor { diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp new file mode 100644 index 0000000000..296c7a01b6 --- /dev/null +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -0,0 +1,303 @@ +#include "shader_file_editor_plugin.h" + +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" +#include "editor/editor_node.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" +#include "editor/property_editor.h" +#include "servers/display_server.h" +#include "servers/rendering/shader_types.h" + +/*** SHADER SCRIPT EDITOR ****/ + +/*** SCRIPT EDITOR ******/ + +void ShaderFileEditor::_update_version(const StringName &p_version_txt, const RD::ShaderStage p_stage) { +} + +void ShaderFileEditor::_version_selected(int p_option) { + + int c = versions->get_current(); + StringName version_txt = versions->get_item_metadata(c); + + RD::ShaderStage stage = RD::SHADER_STAGE_MAX; + int first_found = -1; + + Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_txt); + ERR_FAIL_COND(bytecode.is_null()); + + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + if (bytecode->get_stage_bytecode(RD::ShaderStage(i)).empty() && bytecode->get_stage_compile_error(RD::ShaderStage(i)) == String()) { + stages[i]->set_icon(Ref<Texture2D>()); + continue; + } + + Ref<Texture2D> icon; + if (bytecode->get_stage_compile_error(RD::ShaderStage(i)) != String()) { + icon = get_theme_icon("ImportFail", "EditorIcons"); + } else { + icon = get_theme_icon("ImportCheck", "EditorIcons"); + } + stages[i]->set_icon(icon); + + if (first_found == -1) { + first_found = i; + } + + if (stages[i]->is_pressed()) { + stage = RD::ShaderStage(i); + break; + } + } + + error_text->clear(); + + if (stage == RD::SHADER_STAGE_MAX) { //need to change stage, does not have it + if (first_found == -1) { + error_text->add_text(TTR("No valid shader stages found.")); + return; //well you did not put any stage I guess? + } + stages[first_found]->set_pressed(true); + stage = RD::ShaderStage(first_found); + } + + String error = bytecode->get_stage_compile_error(stage); + + error_text->push_font(get_theme_font("source", "EditorFonts")); + + if (error == String()) { + error_text->add_text(TTR("Shader stage compiled without errors.")); + } else { + error_text->add_text(error); + } +} + +void ShaderFileEditor::_update_options() { + + ERR_FAIL_COND(shader_file.is_null()); + + if (shader_file->get_base_error() != String()) { + stage_hb->hide(); + versions->hide(); + error_text->clear(); + error_text->push_font(get_theme_font("source", "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; + } + + stage_hb->show(); + versions->show(); + + int c = versions->get_current(); + //remember current + versions->clear(); + Vector<StringName> version_list = shader_file->get_version_list(); + + if (c >= version_list.size()) { + c = version_list.size() - 1; + } + if (c < 0) { + c = 0; + } + + StringName current_version; + + for (int i = 0; i < version_list.size(); i++) { + String title = version_list[i]; + if (title == "") { + title = "default"; + } + + Ref<Texture2D> icon; + + Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_list[i]); + ERR_FAIL_COND(bytecode.is_null()); + + bool failed = false; + for (int j = 0; j < RD::SHADER_STAGE_MAX; j++) { + String error = bytecode->get_stage_compile_error(RD::ShaderStage(j)); + if (error != String()) { + failed = true; + } + } + + if (failed) { + icon = get_theme_icon("ImportFail", "EditorIcons"); + } else { + icon = get_theme_icon("ImportCheck", "EditorIcons"); + } + + versions->add_item(title, icon); + versions->set_item_metadata(i, version_list[i]); + + if (i == c) { + versions->select(i); + current_version = version_list[i]; + } + } + + if (version_list.size() == 0) { + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + stages[i]->set_disabled(true); + } + return; + } + + Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(current_version); + ERR_FAIL_COND(bytecode.is_null()); + int first_valid = -1; + int current = -1; + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + Vector<uint8_t> bc = bytecode->get_stage_bytecode(RD::ShaderStage(i)); + String error = bytecode->get_stage_compile_error(RD::ShaderStage(i)); + bool disable = error == String() && bc.empty(); + stages[i]->set_disabled(disable); + if (!disable) { + if (stages[i]->is_pressed()) { + current = i; + } + first_valid = i; + } + } + + if (current == -1 && first_valid != -1) { + stages[first_valid]->set_pressed(true); + } + + _version_selected(0); +} + +void ShaderFileEditor::_notification(int p_what) { + + if (p_what == NOTIFICATION_WM_FOCUS_IN) { + if (is_visible_in_tree() && shader_file.is_valid()) { + _update_options(); + } + } +} + +void ShaderFileEditor::_editor_settings_changed() { + + if (is_visible_in_tree() && shader_file.is_valid()) { + _update_options(); + } +} + +void ShaderFileEditor::_bind_methods() { +} + +void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) { + + if (p_shader.is_null()) { + if (shader_file.is_valid()) { + shader_file->disconnect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed)); + } + return; + } + + if (shader_file == p_shader) + return; + + shader_file = p_shader; + + if (shader_file.is_valid()) { + shader_file->connect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed)); + } + + _update_options(); +} + +void ShaderFileEditor::_shader_changed() { + + if (is_visible_in_tree()) { + _update_options(); + } +} + +ShaderFileEditor *ShaderFileEditor::singleton = nullptr; + +ShaderFileEditor::ShaderFileEditor(EditorNode *p_node) { + singleton = this; + HSplitContainer *main_hs = memnew(HSplitContainer); + + add_child(main_hs); + + versions = memnew(ItemList); + versions->connect("item_selected", callable_mp(this, &ShaderFileEditor::_version_selected)); + versions->set_custom_minimum_size(Size2i(200 * EDSCALE, 0)); + main_hs->add_child(versions); + + VBoxContainer *main_vb = memnew(VBoxContainer); + main_vb->set_h_size_flags(SIZE_EXPAND_FILL); + main_hs->add_child(main_vb); + + static const char *stage_str[RD::SHADER_STAGE_MAX] = { + "Vertex", + "Fragment", + "TessControl", + "TessEval", + "Compute" + }; + + stage_hb = memnew(HBoxContainer); + main_vb->add_child(stage_hb); + + Ref<ButtonGroup> bg; + bg.instance(); + for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { + Button *button = memnew(Button(stage_str[i])); + button->set_toggle_mode(true); + button->set_focus_mode(FOCUS_NONE); + stage_hb->add_child(button); + stages[i] = button; + button->set_button_group(bg); + button->connect("pressed", callable_mp(this, &ShaderFileEditor::_version_selected), varray(i)); + } + + error_text = memnew(RichTextLabel); + error_text->set_v_size_flags(SIZE_EXPAND_FILL); + main_vb->add_child(error_text); +} + +void ShaderFileEditorPlugin::edit(Object *p_object) { + + RDShaderFile *s = Object::cast_to<RDShaderFile>(p_object); + shader_editor->edit(s); +} + +bool ShaderFileEditorPlugin::handles(Object *p_object) const { + + RDShaderFile *shader = Object::cast_to<RDShaderFile>(p_object); + return shader != nullptr; +} + +void ShaderFileEditorPlugin::make_visible(bool p_visible) { + + if (p_visible) { + button->show(); + editor->make_bottom_panel_item_visible(shader_editor); + + } else { + + button->hide(); + if (shader_editor->is_visible_in_tree()) + editor->hide_bottom_panel(); + } +} + +ShaderFileEditorPlugin::ShaderFileEditorPlugin(EditorNode *p_node) { + + editor = p_node; + shader_editor = memnew(ShaderFileEditor(p_node)); + + shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); + button = editor->add_bottom_panel_item(TTR("ShaderFile"), shader_editor); + button->hide(); +} + +ShaderFileEditorPlugin::~ShaderFileEditorPlugin() { +} diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h new file mode 100644 index 0000000000..44d32de2f1 --- /dev/null +++ b/editor/plugins/shader_file_editor_plugin.h @@ -0,0 +1,64 @@ +#ifndef SHADER_FILE_EDITOR_PLUGIN_H +#define SHADER_FILE_EDITOR_PLUGIN_H + +#include "editor/code_editor.h" +#include "editor/editor_plugin.h" +#include "scene/gui/menu_button.h" +#include "scene/gui/panel_container.h" +#include "scene/gui/rich_text_label.h" +#include "scene/gui/tab_container.h" +#include "scene/gui/text_edit.h" +#include "scene/main/timer.h" +#include "servers/rendering/rendering_device_binds.h" + +class ShaderFileEditor : public PanelContainer { + + GDCLASS(ShaderFileEditor, PanelContainer); + + Ref<RDShaderFile> shader_file; + + HBoxContainer *stage_hb; + ItemList *versions; + Button *stages[RD::SHADER_STAGE_MAX]; + RichTextLabel *error_text; + + void _update_version(const StringName &p_version_txt, const RenderingDevice::ShaderStage p_stage); + void _version_selected(int p_stage); + void _editor_settings_changed(); + + void _update_options(); + void _shader_changed(); + +protected: + void _notification(int p_what); + static void _bind_methods(); + +public: + static ShaderFileEditor *singleton; + void edit(const Ref<RDShaderFile> &p_shader); + + ShaderFileEditor(EditorNode *p_node); +}; + +class ShaderFileEditorPlugin : public EditorPlugin { + + GDCLASS(ShaderFileEditorPlugin, EditorPlugin); + + ShaderFileEditor *shader_editor; + EditorNode *editor; + Button *button; + +public: + virtual String get_name() const { return "ShaderFile"; } + bool has_main_screen() const { return false; } + virtual void edit(Object *p_object); + virtual bool handles(Object *p_object) const; + virtual void make_visible(bool p_visible); + + ShaderFileEditor *get_shader_editor() const { return shader_editor; } + + ShaderFileEditorPlugin(EditorNode *p_node); + ~ShaderFileEditorPlugin(); +}; + +#endif // SHADER_FILE_EDITOR_PLUGIN_H diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 0b77b987bf..c81d3f787e 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -38,7 +38,7 @@ void Skeleton2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } @@ -59,7 +59,7 @@ void Skeleton2DEditor::_menu_option(int p_option) { if (node->get_bone_count() == 0) { err_dialog->set_text(TTR("This skeleton has no bones, create some children Bone2D nodes.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -75,7 +75,7 @@ void Skeleton2DEditor::_menu_option(int p_option) { case MENU_OPTION_SET_REST: { if (node->get_bone_count() == 0) { err_dialog->set_text(TTR("This skeleton has no bones, create some children Bone2D nodes.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -101,7 +101,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_icon("Skeleton2D", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton2D", "EditorIcons")); options->get_popup()->add_item(TTR("Make Rest Pose (From Bones)"), MENU_OPTION_MAKE_REST); options->get_popup()->add_separator(); @@ -131,7 +131,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) { } else { sprite_editor->options->hide(); - sprite_editor->edit(NULL); + sprite_editor->edit(nullptr); } } diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 07bd6a0e41..fac4cb19d8 100644 --- a/editor/plugins/skeleton_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* skeleton_editor_plugin.cpp */ +/* skeleton_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,16 +28,16 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "skeleton_editor_plugin.h" +#include "skeleton_3d_editor_plugin.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/physics_body.h" -#include "scene/3d/physics_joint.h" -#include "scene/resources/capsule_shape.h" -#include "scene/resources/sphere_shape.h" -#include "spatial_editor_plugin.h" +#include "node_3d_editor_plugin.h" +#include "scene/3d/collision_shape_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/3d/physics_joint_3d.h" +#include "scene/resources/capsule_shape_3d.h" +#include "scene/resources/sphere_shape_3d.h" -void SkeletonEditor::_on_click_option(int p_option) { +void Skeleton3DEditor::_on_click_option(int p_option) { if (!skeleton) { return; } @@ -49,7 +49,7 @@ void SkeletonEditor::_on_click_option(int p_option) { } } -void SkeletonEditor::create_physical_skeleton() { +void Skeleton3DEditor::create_physical_skeleton() { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); Node *owner = skeleton == get_tree()->get_edited_scene_root() ? skeleton : skeleton->get_owner(); @@ -94,25 +94,25 @@ void SkeletonEditor::create_physical_skeleton() { /// Create joint between parent of parent if (-1 != parent_parent) { - bones_infos[parent].physical_bone->set_joint_type(PhysicalBone::JOINT_TYPE_PIN); + bones_infos[parent].physical_bone->set_joint_type(PhysicalBone3D::JOINT_TYPE_PIN); } } } } } -PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) { +PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) { const Transform child_rest = skeleton->get_bone_rest(bone_child_id); const real_t half_height(child_rest.origin.length() * 0.5); const real_t radius(half_height * 0.2); - CapsuleShape *bone_shape_capsule = memnew(CapsuleShape); + CapsuleShape3D *bone_shape_capsule = memnew(CapsuleShape3D); bone_shape_capsule->set_height((half_height - radius) * 2); bone_shape_capsule->set_radius(radius); - CollisionShape *bone_shape = memnew(CollisionShape); + CollisionShape3D *bone_shape = memnew(CollisionShape3D); bone_shape->set_shape(bone_shape_capsule); Transform body_transform; @@ -122,7 +122,7 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i Transform joint_transform; joint_transform.origin = Vector3(0, 0, half_height); - PhysicalBone *physical_bone = memnew(PhysicalBone); + PhysicalBone3D *physical_bone = memnew(PhysicalBone3D); physical_bone->add_child(bone_shape); physical_bone->set_name("Physical Bone " + skeleton->get_bone_name(bone_id)); physical_bone->set_body_offset(body_transform); @@ -130,66 +130,66 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i return physical_bone; } -void SkeletonEditor::edit(Skeleton *p_node) { +void Skeleton3DEditor::edit(Skeleton3D *p_node) { skeleton = p_node; } -void SkeletonEditor::_notification(int p_what) { +void Skeleton3DEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - get_tree()->connect("node_removed", callable_mp(this, &SkeletonEditor::_node_removed)); + get_tree()->connect("node_removed", callable_mp(this, &Skeleton3DEditor::_node_removed)); } } -void SkeletonEditor::_node_removed(Node *p_node) { +void Skeleton3DEditor::_node_removed(Node *p_node) { if (p_node == skeleton) { - skeleton = NULL; + skeleton = nullptr; options->hide(); } } -void SkeletonEditor::_bind_methods() { +void Skeleton3DEditor::_bind_methods() { } -SkeletonEditor::SkeletonEditor() { - skeleton = NULL; +Skeleton3DEditor::Skeleton3DEditor() { + skeleton = nullptr; options = memnew(MenuButton); - SpatialEditor::get_singleton()->add_control_to_menu_panel(options); + Node3DEditor::get_singleton()->add_control_to_menu_panel(options); - options->set_text(TTR("Skeleton")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Skeleton", "EditorIcons")); + options->set_text(TTR("Skeleton3D")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Skeleton3D", "EditorIcons")); options->get_popup()->add_item(TTR("Create physical skeleton"), MENU_OPTION_CREATE_PHYSICAL_SKELETON); - options->get_popup()->connect("id_pressed", callable_mp(this, &SkeletonEditor::_on_click_option)); + options->get_popup()->connect("id_pressed", callable_mp(this, &Skeleton3DEditor::_on_click_option)); options->hide(); } -SkeletonEditor::~SkeletonEditor() {} +Skeleton3DEditor::~Skeleton3DEditor() {} -void SkeletonEditorPlugin::edit(Object *p_object) { - skeleton_editor->edit(Object::cast_to<Skeleton>(p_object)); +void Skeleton3DEditorPlugin::edit(Object *p_object) { + skeleton_editor->edit(Object::cast_to<Skeleton3D>(p_object)); } -bool SkeletonEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Skeleton"); +bool Skeleton3DEditorPlugin::handles(Object *p_object) const { + return p_object->is_class("Skeleton3D"); } -void SkeletonEditorPlugin::make_visible(bool p_visible) { +void Skeleton3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { skeleton_editor->options->show(); } else { skeleton_editor->options->hide(); - skeleton_editor->edit(NULL); + skeleton_editor->edit(nullptr); } } -SkeletonEditorPlugin::SkeletonEditorPlugin(EditorNode *p_node) { +Skeleton3DEditorPlugin::Skeleton3DEditorPlugin(EditorNode *p_node) { editor = p_node; - skeleton_editor = memnew(SkeletonEditor); + skeleton_editor = memnew(Skeleton3DEditor); editor->get_viewport()->add_child(skeleton_editor); } -SkeletonEditorPlugin::~SkeletonEditorPlugin() {} +Skeleton3DEditorPlugin::~Skeleton3DEditorPlugin() {} diff --git a/editor/plugins/skeleton_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 1dce6d12ed..2ba5a817bc 100644 --- a/editor/plugins/skeleton_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* skeleton_editor_plugin.h */ +/* skeleton_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,37 +28,37 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SKELETON_EDITOR_PLUGIN_H -#define SKELETON_EDITOR_PLUGIN_H +#ifndef SKELETON_3D_EDITOR_PLUGIN_H +#define SKELETON_3D_EDITOR_PLUGIN_H #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/3d/skeleton.h" +#include "scene/3d/skeleton_3d.h" -class PhysicalBone; -class Joint; +class PhysicalBone3D; +class Joint3D; -class SkeletonEditor : public Node { - GDCLASS(SkeletonEditor, Node); +class Skeleton3DEditor : public Node { + GDCLASS(Skeleton3DEditor, Node); enum Menu { MENU_OPTION_CREATE_PHYSICAL_SKELETON }; struct BoneInfo { - PhysicalBone *physical_bone; + PhysicalBone3D *physical_bone; Transform relative_rest; // Relative to skeleton node BoneInfo() : - physical_bone(NULL) {} + physical_bone(nullptr) {} }; - Skeleton *skeleton; + Skeleton3D *skeleton; MenuButton *options; void _on_click_option(int p_option); - friend class SkeletonEditorPlugin; + friend class Skeleton3DEditorPlugin; protected: void _notification(int p_what); @@ -66,31 +66,31 @@ protected: static void _bind_methods(); void create_physical_skeleton(); - PhysicalBone *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos); + PhysicalBone3D *create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos); public: - void edit(Skeleton *p_node); + void edit(Skeleton3D *p_node); - SkeletonEditor(); - ~SkeletonEditor(); + Skeleton3DEditor(); + ~Skeleton3DEditor(); }; -class SkeletonEditorPlugin : public EditorPlugin { +class Skeleton3DEditorPlugin : public EditorPlugin { - GDCLASS(SkeletonEditorPlugin, EditorPlugin); + GDCLASS(Skeleton3DEditorPlugin, EditorPlugin); EditorNode *editor; - SkeletonEditor *skeleton_editor; + Skeleton3DEditor *skeleton_editor; public: - virtual String get_name() const { return "Skeleton"; } + virtual String get_name() const { return "Skeleton3D"; } virtual bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - SkeletonEditorPlugin(EditorNode *p_node); - ~SkeletonEditorPlugin(); + Skeleton3DEditorPlugin(EditorNode *p_node); + ~Skeleton3DEditorPlugin(); }; -#endif // SKELETON_EDITOR_PLUGIN_H +#endif // SKELETON_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/skeleton_ik_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index b031bd71d3..a22534eac0 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* skeleton_ik_editor_plugin.cpp */ +/* skeleton_ik_3d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,11 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "skeleton_ik_editor_plugin.h" +#include "skeleton_ik_3d_editor_plugin.h" -#include "scene/animation/skeleton_ik.h" +#include "scene/3d/skeleton_ik_3d.h" -void SkeletonIKEditorPlugin::_play() { +void SkeletonIK3DEditorPlugin::_play() { if (!skeleton_ik) return; @@ -44,14 +44,11 @@ void SkeletonIKEditorPlugin::_play() { skeleton_ik->start(); } else { skeleton_ik->stop(); - - for (int i = 0; i < skeleton_ik->get_parent_skeleton()->get_bone_count(); ++i) { - skeleton_ik->get_parent_skeleton()->set_bone_global_pose_override(i, Transform(), 0); - } + skeleton_ik->get_parent_skeleton()->clear_bones_global_pose_override(); } } -void SkeletonIKEditorPlugin::edit(Object *p_object) { +void SkeletonIK3DEditorPlugin::edit(Object *p_object) { if (p_object != skeleton_ik) { if (skeleton_ik) { @@ -60,19 +57,19 @@ void SkeletonIKEditorPlugin::edit(Object *p_object) { } } - SkeletonIK *s = Object::cast_to<SkeletonIK>(p_object); + SkeletonIK3D *s = Object::cast_to<SkeletonIK3D>(p_object); if (!s) return; skeleton_ik = s; } -bool SkeletonIKEditorPlugin::handles(Object *p_object) const { +bool SkeletonIK3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("SkeletonIK"); + return p_object->is_class("SkeletonIK3D"); } -void SkeletonIKEditorPlugin::make_visible(bool p_visible) { +void SkeletonIK3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) play_btn->show(); @@ -80,20 +77,20 @@ void SkeletonIKEditorPlugin::make_visible(bool p_visible) { play_btn->hide(); } -void SkeletonIKEditorPlugin::_bind_methods() { +void SkeletonIK3DEditorPlugin::_bind_methods() { } -SkeletonIKEditorPlugin::SkeletonIKEditorPlugin(EditorNode *p_node) { +SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) { editor = p_node; play_btn = memnew(Button); - play_btn->set_icon(editor->get_gui_base()->get_icon("Play", "EditorIcons")); + play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons")); play_btn->set_text(TTR("Play IK")); play_btn->set_toggle_mode(true); play_btn->hide(); - play_btn->connect("pressed", callable_mp(this, &SkeletonIKEditorPlugin::_play)); + play_btn->connect("pressed", callable_mp(this, &SkeletonIK3DEditorPlugin::_play)); add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, play_btn); - skeleton_ik = NULL; + skeleton_ik = nullptr; } -SkeletonIKEditorPlugin::~SkeletonIKEditorPlugin() {} +SkeletonIK3DEditorPlugin::~SkeletonIK3DEditorPlugin() {} diff --git a/editor/plugins/skeleton_ik_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h index 814eb8ff5b..88472a2963 100644 --- a/editor/plugins/skeleton_ik_editor_plugin.h +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* skeleton_ik_editor_plugin.h */ +/* skeleton_ik_3d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,19 +28,19 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SKELETON_IK_EDITOR_PLUGIN_H -#define SKELETON_IK_EDITOR_PLUGIN_H +#ifndef SKELETON_IK_3D_EDITOR_PLUGIN_H +#define SKELETON_IK_3D_EDITOR_PLUGIN_H #include "editor/editor_node.h" #include "editor/editor_plugin.h" -class SkeletonIK; +class SkeletonIK3D; -class SkeletonIKEditorPlugin : public EditorPlugin { +class SkeletonIK3DEditorPlugin : public EditorPlugin { - GDCLASS(SkeletonIKEditorPlugin, EditorPlugin); + GDCLASS(SkeletonIK3DEditorPlugin, EditorPlugin); - SkeletonIK *skeleton_ik; + SkeletonIK3D *skeleton_ik; Button *play_btn; EditorNode *editor; @@ -51,14 +51,14 @@ protected: static void _bind_methods(); public: - virtual String get_name() const { return "SkeletonIK"; } + virtual String get_name() const { return "SkeletonIK3D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - SkeletonIKEditorPlugin(EditorNode *p_node); - ~SkeletonIKEditorPlugin(); + SkeletonIK3DEditorPlugin(EditorNode *p_node); + ~SkeletonIK3DEditorPlugin(); }; -#endif // SKELETON_IK_EDITOR_PLUGIN_H +#endif // SKELETON_IK_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index 2897341f06..ab0f15d3d0 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* sprite_editor_plugin.cpp */ +/* sprite_2d_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "sprite_editor_plugin.h" +#include "sprite_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" #include "editor/editor_scale.h" @@ -39,15 +39,15 @@ #include "scene/gui/box_container.h" #include "thirdparty/misc/clipper.hpp" -void SpriteEditor::_node_removed(Node *p_node) { +void Sprite2DEditor::_node_removed(Node *p_node) { if (p_node == node) { - node = NULL; + node = nullptr; options->hide(); } } -void SpriteEditor::edit(Sprite *p_sprite) { +void Sprite2DEditor::edit(Sprite2D *p_sprite) { node = p_sprite; } @@ -114,7 +114,7 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float return outPoints; } -void SpriteEditor::_menu_option(int p_option) { +void Sprite2DEditor::_menu_option(int p_option) { if (!node) { return; @@ -165,18 +165,18 @@ void SpriteEditor::_menu_option(int p_option) { } } -void SpriteEditor::_update_mesh_data() { +void Sprite2DEditor::_update_mesh_data() { Ref<Texture2D> texture = node->get_texture(); if (texture.is_null()) { - err_dialog->set_text(TTR("Sprite is empty!")); - err_dialog->popup_centered_minsize(); + err_dialog->set_text(TTR("Sprite2D is empty!")); + err_dialog->popup_centered(); return; } if (node->get_hframes() > 1 || node->get_vframes() > 1) { err_dialog->set_text(TTR("Can't convert a sprite using animation frames to mesh.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -296,7 +296,7 @@ void SpriteEditor::_update_mesh_data() { debug_uv->update(); } -void SpriteEditor::_create_node() { +void Sprite2DEditor::_create_node() { switch (selected_menu_item) { case MENU_OPTION_CONVERT_TO_MESH_2D: { _convert_to_mesh_2d_node(); @@ -313,11 +313,11 @@ void SpriteEditor::_create_node() { } } -void SpriteEditor::_convert_to_mesh_2d_node() { +void Sprite2DEditor::_convert_to_mesh_2d_node() { if (computed_vertices.size() < 3) { err_dialog->set_text(TTR("Invalid geometry, can't replace by mesh.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -344,11 +344,11 @@ void SpriteEditor::_convert_to_mesh_2d_node() { ur->commit_action(); } -void SpriteEditor::_convert_to_polygon_2d_node() { +void Sprite2DEditor::_convert_to_polygon_2d_node() { if (computed_outline_lines.empty()) { err_dialog->set_text(TTR("Invalid geometry, can't create polygon.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -403,11 +403,11 @@ void SpriteEditor::_convert_to_polygon_2d_node() { ur->commit_action(); } -void SpriteEditor::_create_collision_polygon_2d_node() { +void Sprite2DEditor::_create_collision_polygon_2d_node() { if (computed_outline_lines.empty()) { err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -427,11 +427,11 @@ void SpriteEditor::_create_collision_polygon_2d_node() { } } -void SpriteEditor::_create_light_occluder_2d_node() { +void Sprite2DEditor::_create_light_occluder_2d_node() { if (computed_outline_lines.empty()) { err_dialog->set_text(TTR("Invalid geometry, can't create light occluder.")); - err_dialog->popup_centered_minsize(); + err_dialog->popup_centered(); return; } @@ -462,7 +462,7 @@ void SpriteEditor::_create_light_occluder_2d_node() { } } -void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) { +void Sprite2DEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) { // Can't make sibling if own node is scene root if (p_own_node != this->get_tree()->get_edited_scene_root()) { p_own_node->get_parent()->add_child(p_new_node, true); @@ -474,7 +474,7 @@ void SpriteEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node) p_new_node->set_owner(this->get_tree()->get_edited_scene_root()); } -void SpriteEditor::_debug_uv_draw() { +void Sprite2DEditor::_debug_uv_draw() { Ref<Texture2D> tex = node->get_texture(); ERR_FAIL_COND(!tex.is_valid()); @@ -502,19 +502,19 @@ void SpriteEditor::_debug_uv_draw() { } } -void SpriteEditor::_bind_methods() { +void Sprite2DEditor::_bind_methods() { - ClassDB::bind_method("_add_as_sibling_or_child", &SpriteEditor::_add_as_sibling_or_child); + ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child); } -SpriteEditor::SpriteEditor() { +Sprite2DEditor::Sprite2DEditor() { options = memnew(MenuButton); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); - options->set_text(TTR("Sprite")); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Sprite", "EditorIcons")); + options->set_text(TTR("Sprite2D")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Sprite2D", "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); @@ -522,7 +522,7 @@ SpriteEditor::SpriteEditor() { options->get_popup()->add_item(TTR("Create LightOccluder2D Sibling"), MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D); options->set_switch_on_hover(true); - options->get_popup()->connect("id_pressed", callable_mp(this, &SpriteEditor::_menu_option)); + options->get_popup()->connect("id_pressed", callable_mp(this, &Sprite2DEditor::_menu_option)); err_dialog = memnew(AcceptDialog); add_child(err_dialog); @@ -538,9 +538,9 @@ SpriteEditor::SpriteEditor() { scroll->set_enable_v_scroll(true); vb->add_margin_child(TTR("Preview:"), scroll, true); debug_uv = memnew(Control); - debug_uv->connect("draw", callable_mp(this, &SpriteEditor::_debug_uv_draw)); + debug_uv->connect("draw", callable_mp(this, &Sprite2DEditor::_debug_uv_draw)); scroll->add_child(debug_uv); - debug_uv_dialog->connect("confirmed", callable_mp(this, &SpriteEditor::_create_node)); + debug_uv_dialog->connect("confirmed", callable_mp(this, &Sprite2DEditor::_create_node)); HBoxContainer *hb = memnew(HBoxContainer); hb->add_child(memnew(Label(TTR("Simplification: ")))); @@ -569,43 +569,43 @@ SpriteEditor::SpriteEditor() { hb->add_spacer(); update_preview = memnew(Button); update_preview->set_text(TTR("Update Preview")); - update_preview->connect("pressed", callable_mp(this, &SpriteEditor::_update_mesh_data)); + update_preview->connect("pressed", callable_mp(this, &Sprite2DEditor::_update_mesh_data)); hb->add_child(update_preview); vb->add_margin_child(TTR("Settings:"), hb); add_child(debug_uv_dialog); } -void SpriteEditorPlugin::edit(Object *p_object) { +void Sprite2DEditorPlugin::edit(Object *p_object) { - sprite_editor->edit(Object::cast_to<Sprite>(p_object)); + sprite_editor->edit(Object::cast_to<Sprite2D>(p_object)); } -bool SpriteEditorPlugin::handles(Object *p_object) const { +bool Sprite2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Sprite"); + return p_object->is_class("Sprite2D"); } -void SpriteEditorPlugin::make_visible(bool p_visible) { +void Sprite2DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { sprite_editor->options->show(); } else { sprite_editor->options->hide(); - sprite_editor->edit(NULL); + sprite_editor->edit(nullptr); } } -SpriteEditorPlugin::SpriteEditorPlugin(EditorNode *p_node) { +Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) { editor = p_node; - sprite_editor = memnew(SpriteEditor); + sprite_editor = memnew(Sprite2DEditor); editor->get_viewport()->add_child(sprite_editor); make_visible(false); //sprite_editor->options->hide(); } -SpriteEditorPlugin::~SpriteEditorPlugin() { +Sprite2DEditorPlugin::~Sprite2DEditorPlugin() { } diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index 998851b6ad..0add77843b 100644 --- a/editor/plugins/sprite_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* sprite_editor_plugin.h */ +/* sprite_2d_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -33,12 +33,12 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" #include "scene/gui/spin_box.h" -class SpriteEditor : public Control { +class Sprite2DEditor : public Control { - GDCLASS(SpriteEditor, Control); + GDCLASS(Sprite2DEditor, Control); enum Menu { MENU_OPTION_CONVERT_TO_MESH_2D, @@ -49,7 +49,7 @@ class SpriteEditor : public Control { Menu selected_menu_item; - Sprite *node; + Sprite2D *node; MenuButton *options; @@ -74,7 +74,7 @@ class SpriteEditor : public Control { void _menu_option(int p_option); //void _create_uv_lines(); - friend class SpriteEditorPlugin; + friend class Sprite2DEditorPlugin; void _debug_uv_draw(); void _update_mesh_data(); @@ -92,26 +92,26 @@ protected: static void _bind_methods(); public: - void edit(Sprite *p_sprite); - SpriteEditor(); + void edit(Sprite2D *p_sprite); + Sprite2DEditor(); }; -class SpriteEditorPlugin : public EditorPlugin { +class Sprite2DEditorPlugin : public EditorPlugin { - GDCLASS(SpriteEditorPlugin, EditorPlugin); + GDCLASS(Sprite2DEditorPlugin, EditorPlugin); - SpriteEditor *sprite_editor; + Sprite2DEditor *sprite_editor; EditorNode *editor; public: - virtual String get_name() const { return "Sprite"; } + virtual String get_name() const { return "Sprite2D"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - SpriteEditorPlugin(EditorNode *p_node); - ~SpriteEditorPlugin(); + Sprite2DEditorPlugin(EditorNode *p_node); + ~Sprite2DEditorPlugin(); }; #endif // SPRITE_EDITOR_PLUGIN_H diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index e6b0e3142c..76e60bb014 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -81,7 +81,7 @@ void SpriteFramesEditor::_sheet_preview_draw() { return; } - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); for (Set<int>::Element *E = frames_selected.front(); E; E = E->next()) { int idx = E->get(); @@ -223,24 +223,24 @@ void SpriteFramesEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - load->set_icon(get_icon("Load", "EditorIcons")); - load_sheet->set_icon(get_icon("SpriteSheet", "EditorIcons")); - copy->set_icon(get_icon("ActionCopy", "EditorIcons")); - paste->set_icon(get_icon("ActionPaste", "EditorIcons")); - empty->set_icon(get_icon("InsertBefore", "EditorIcons")); - empty2->set_icon(get_icon("InsertAfter", "EditorIcons")); - move_up->set_icon(get_icon("MoveLeft", "EditorIcons")); - move_down->set_icon(get_icon("MoveRight", "EditorIcons")); - _delete->set_icon(get_icon("Remove", "EditorIcons")); - new_anim->set_icon(get_icon("New", "EditorIcons")); - remove_anim->set_icon(get_icon("Remove", "EditorIcons")); + 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")); + new_anim->set_icon(get_theme_icon("New", "EditorIcons")); + remove_anim->set_icon(get_theme_icon("Remove", "EditorIcons")); [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - splite_sheet_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); + splite_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } break; case NOTIFICATION_READY: { - add_constant_override("autohide", 1); // Fixes the dragger always showing up. + add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up. } break; } } @@ -262,7 +262,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ //dialog->get_cancel()->set_text("Close"); dialog->get_ok()->set_text(TTR("Close")); - dialog->popup_centered_minsize(); + dialog->popup_centered(); return; ///beh should show an error i guess } @@ -301,7 +301,7 @@ void SpriteFramesEditor::_load_pressed() { for (int i = 0; i < extensions.size(); i++) file->add_filter("*." + extensions[i]); - file->set_mode(EditorFileDialog::MODE_OPEN_FILES); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES); file->popup_centered_ratio(); } @@ -316,7 +316,7 @@ void SpriteFramesEditor::_paste_pressed() { dialog->set_title(TTR("Error!")); //dialog->get_cancel()->set_text("Close"); dialog->get_ok()->set_text(TTR("Close")); - dialog->popup_centered_minsize(); + dialog->popup_centered(); return; ///beh should show an error i guess } @@ -485,7 +485,7 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr return; { - AnimatedSprite *as = Object::cast_to<AnimatedSprite>(p_node); + AnimatedSprite2D *as = Object::cast_to<AnimatedSprite2D>(p_node); if (as && as->get_sprite_frames() == p_sfames) { r_nodes->push_back(p_node); } @@ -591,7 +591,7 @@ void SpriteFramesEditor::_animation_remove() { return; delete_dialog->set_text(TTR("Delete Animation?")); - delete_dialog->popup_centered_minsize(); + delete_dialog->popup_centered(); } void SpriteFramesEditor::_animation_remove_confirmed() { @@ -1058,7 +1058,7 @@ SpriteFramesEditor::SpriteFramesEditor() { file_split_sheet = memnew(EditorFileDialog); file_split_sheet->set_title(TTR("Create Frames from Sprite Sheet")); - file_split_sheet->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_split_sheet->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); add_child(file_split_sheet); file_split_sheet->connect("file_selected", callable_mp(this, &SpriteFramesEditor::_prepare_sprite_sheet)); } @@ -1068,11 +1068,17 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) { frames_editor->set_undo_redo(&get_undo_redo()); SpriteFrames *s; - AnimatedSprite *animated_sprite = Object::cast_to<AnimatedSprite>(p_object); + AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object); if (animated_sprite) { s = *animated_sprite->get_sprite_frames(); } else { - s = Object::cast_to<SpriteFrames>(p_object); + AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object); + if (animated_sprite_3d) { + s = *animated_sprite_3d->get_sprite_frames(); + } else { + + s = Object::cast_to<SpriteFrames>(p_object); + } } frames_editor->edit(s); @@ -1080,9 +1086,12 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) { bool SpriteFramesEditorPlugin::handles(Object *p_object) const { - AnimatedSprite *animated_sprite = Object::cast_to<AnimatedSprite>(p_object); + AnimatedSprite2D *animated_sprite = Object::cast_to<AnimatedSprite2D>(p_object); + AnimatedSprite3D *animated_sprite_3d = Object::cast_to<AnimatedSprite3D>(p_object); if (animated_sprite && *animated_sprite->get_sprite_frames()) { return true; + } else if (animated_sprite_3d && *animated_sprite_3d->get_sprite_frames()) { + return true; } else { return p_object->is_class("SpriteFrames"); } diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 1fa93b5c47..89d9bc6fd3 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -33,7 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/2d/animated_sprite.h" +#include "scene/2d/animated_sprite_2d.h" #include "scene/gui/dialogs.h" #include "scene/gui/file_dialog.h" #include "scene/gui/split_container.h" diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index a92194da17..eb6e261305 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -34,7 +34,7 @@ bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { - return Object::cast_to<StyleBox>(p_object) != NULL; + return Object::cast_to<StyleBox>(p_object) != nullptr; } void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) { @@ -45,7 +45,7 @@ void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) { preview->edit(sb); add_custom_control(preview); } -bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) { +bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { return false; //do not want } void EditorInspectorPluginStyleBox::parse_end() { @@ -57,7 +57,7 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { stylebox->disconnect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed)); stylebox = p_stylebox; if (p_stylebox.is_valid()) { - preview->add_style_override("panel", stylebox); + preview->add_theme_style_override("panel", stylebox); stylebox->connect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed)); } _sb_changed(); diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index f4a72d9d1c..1eea9260b2 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -62,7 +62,7 @@ class EditorInspectorPluginStyleBox : public EditorInspectorPlugin { public: virtual bool can_handle(Object *p_object); virtual void parse_begin(Object *p_object); - virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage); + virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false); virtual void parse_end(); }; diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 35f23ccf1d..2786a568ea 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -41,7 +41,7 @@ void TextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) { void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { TextEdit *te = code_editor->get_text_edit(); te->_set_syntax_highlighting(p_highlighter); - if (p_highlighter != NULL) { + if (p_highlighter != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true); } else { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text("Standard"), true); @@ -49,12 +49,12 @@ void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { // little work around. GDScript highlighter goes through text_edit for colours, // so to remove all colours we need to set and unset them here. - if (p_highlighter == NULL) { // standard + if (p_highlighter == nullptr) { // standard TextEdit *text_edit = code_editor->get_text_edit(); - text_edit->add_color_override("number_color", colors_cache.font_color); - text_edit->add_color_override("function_color", colors_cache.font_color); - text_edit->add_color_override("number_color", colors_cache.font_color); - text_edit->add_color_override("member_variable_color", colors_cache.font_color); + text_edit->add_theme_color_override("number_color", colors_cache.font_color); + text_edit->add_theme_color_override("function_color", colors_cache.font_color); + text_edit->add_theme_color_override("number_color", colors_cache.font_color); + text_edit->add_theme_color_override("member_variable_color", colors_cache.font_color); } else { _load_theme_settings(); } @@ -62,7 +62,7 @@ void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { void TextEditor::_change_syntax_highlighter(int p_idx) { Map<String, SyntaxHighlighter *>::Element *el = highlighters.front(); - while (el != NULL) { + while (el != nullptr) { highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false); el = el->next(); } @@ -107,35 +107,35 @@ void TextEditor::_load_theme_settings() { Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color string_color = EDITOR_GET("text_editor/highlighting/string_color"); - text_edit->add_color_override("background_color", background_color); - text_edit->add_color_override("completion_background_color", completion_background_color); - text_edit->add_color_override("completion_selected_color", completion_selected_color); - text_edit->add_color_override("completion_existing_color", completion_existing_color); - text_edit->add_color_override("completion_scroll_color", completion_scroll_color); - text_edit->add_color_override("completion_font_color", completion_font_color); - text_edit->add_color_override("font_color", text_color); - text_edit->add_color_override("line_number_color", line_number_color); - text_edit->add_color_override("caret_color", caret_color); - text_edit->add_color_override("caret_background_color", caret_background_color); - text_edit->add_color_override("font_color_selected", text_selected_color); - text_edit->add_color_override("selection_color", selection_color); - text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); - text_edit->add_color_override("current_line_color", current_line_color); - text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color); - text_edit->add_color_override("word_highlighted_color", word_highlighted_color); - text_edit->add_color_override("number_color", number_color); - text_edit->add_color_override("function_color", function_color); - text_edit->add_color_override("member_variable_color", member_variable_color); - text_edit->add_color_override("breakpoint_color", breakpoint_color); - text_edit->add_color_override("executing_line_color", executing_line_color); - text_edit->add_color_override("mark_color", mark_color); - text_edit->add_color_override("bookmark_color", bookmark_color); - text_edit->add_color_override("code_folding_color", code_folding_color); - text_edit->add_color_override("search_result_color", search_result_color); - text_edit->add_color_override("search_result_border_color", search_result_border_color); - text_edit->add_color_override("symbol_color", symbol_color); - - text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); + text_edit->add_theme_color_override("background_color", background_color); + text_edit->add_theme_color_override("completion_background_color", completion_background_color); + text_edit->add_theme_color_override("completion_selected_color", completion_selected_color); + text_edit->add_theme_color_override("completion_existing_color", completion_existing_color); + text_edit->add_theme_color_override("completion_scroll_color", completion_scroll_color); + text_edit->add_theme_color_override("completion_font_color", completion_font_color); + text_edit->add_theme_color_override("font_color", text_color); + text_edit->add_theme_color_override("line_number_color", line_number_color); + text_edit->add_theme_color_override("caret_color", caret_color); + text_edit->add_theme_color_override("caret_background_color", caret_background_color); + text_edit->add_theme_color_override("font_color_selected", text_selected_color); + text_edit->add_theme_color_override("selection_color", selection_color); + text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color); + text_edit->add_theme_color_override("current_line_color", current_line_color); + text_edit->add_theme_color_override("line_length_guideline_color", line_length_guideline_color); + text_edit->add_theme_color_override("word_highlighted_color", word_highlighted_color); + text_edit->add_theme_color_override("number_color", number_color); + text_edit->add_theme_color_override("function_color", function_color); + text_edit->add_theme_color_override("member_variable_color", member_variable_color); + text_edit->add_theme_color_override("breakpoint_color", breakpoint_color); + text_edit->add_theme_color_override("executing_line_color", executing_line_color); + text_edit->add_theme_color_override("mark_color", mark_color); + text_edit->add_theme_color_override("bookmark_color", bookmark_color); + text_edit->add_theme_color_override("code_folding_color", code_folding_color); + text_edit->add_theme_color_override("search_result_color", search_result_color); + text_edit->add_theme_color_override("search_result_border_color", search_result_border_color); + text_edit->add_theme_color_override("symbol_color", symbol_color); + + text_edit->add_theme_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 6)); colors_cache.font_color = text_color; colors_cache.symbol_color = symbol_color; @@ -163,7 +163,7 @@ String TextEditor::get_name() { return name; } -Ref<Texture2D> TextEditor::get_icon() { +Ref<Texture2D> TextEditor::get_theme_icon() { return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), ""); } @@ -533,7 +533,7 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { if (Object::cast_to<TextFile>(*p_resource)) { return memnew(TextEditor); } - return NULL; + return nullptr; } void TextEditor::register_editor() { @@ -624,7 +624,7 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is TextEditor::TextEditor() { code_editor = memnew(CodeTextEditor); add_child(code_editor); - code_editor->add_constant_override("separation", 0); + code_editor->add_theme_constant_override("separation", 0); code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings)); code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script)); code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); @@ -694,7 +694,7 @@ TextEditor::TextEditor() { convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE); convert_case->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); - highlighters["Standard"] = NULL; + highlighters["Standard"] = nullptr; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); @@ -716,7 +716,7 @@ TextEditor::TextEditor() { goto_menu->get_popup()->add_child(bookmarks_menu); goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks"); _update_bookmark_list(); - bookmarks_menu->connect("about_to_show", callable_mp(this, &TextEditor::_update_bookmark_list)); + bookmarks_menu->connect("about_to_popup", callable_mp(this, &TextEditor::_update_bookmark_list)); bookmarks_menu->connect("index_pressed", callable_mp(this, &TextEditor::_bookmark_item_pressed)); goto_line_dialog = memnew(GotoLineDialog); @@ -727,7 +727,7 @@ TextEditor::TextEditor() { TextEditor::~TextEditor() { for (const Map<String, SyntaxHighlighter *>::Element *E = highlighters.front(); E; E = E->next()) { - if (E->get() != NULL) { + if (E->get() != nullptr) { memdelete(E->get()); } } diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index c80052e7ba..b41e11c3aa 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -121,7 +121,7 @@ public: virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter); virtual String get_name(); - virtual Ref<Texture2D> get_icon(); + virtual Ref<Texture2D> get_theme_icon(); virtual RES get_edited_resource() const; virtual void set_edited_resource(const RES &p_res); void set_edited_file(const Ref<TextFile> &p_file); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 60f9bb5dc1..c1184c1c89 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -46,7 +46,7 @@ void TextureEditor::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); draw_texture_rect(checkerboard, Rect2(Point2(), size), true); @@ -79,7 +79,7 @@ void TextureEditor::_notification(int p_what) { draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height)); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); String format; if (Object::cast_to<ImageTexture>(*texture)) { @@ -144,7 +144,7 @@ TextureEditor::~TextureEditor() { // bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - return Object::cast_to<ImageTexture>(p_object) != NULL || Object::cast_to<AtlasTexture>(p_object) != NULL || Object::cast_to<StreamTexture>(p_object) != NULL || Object::cast_to<LargeTexture>(p_object) != NULL || Object::cast_to<AnimatedTexture>(p_object) != NULL; + return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture>(p_object) != nullptr || Object::cast_to<LargeTexture>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 2262e12f5d..8892d13f51 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "texture_region_editor_plugin.h" #include "core/core_string_names.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "scene/gui/check_box.h" @@ -43,13 +43,13 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) { Vector2 line = (to - from).normalized() * 10; while ((to - from).length_squared() > 200) { - edit_draw->draw_line(from, from + line, EditorNode::get_singleton()->get_theme_base()->get_color("mono_color", "Editor"), 2); + edit_draw->draw_line(from, from + line, EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"), 2); from += line * 2; } } void TextureRegionEditor::_region_draw() { - Ref<Texture2D> base_tex = NULL; + Ref<Texture2D> base_tex = nullptr; if (node_sprite) base_tex = node_sprite->get_texture(); else if (node_sprite_3d) @@ -68,9 +68,9 @@ void TextureRegionEditor::_region_draw() { mtx.elements[2] = -draw_ofs * draw_zoom; mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); - VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); + RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); edit_draw->draw_texture(base_tex, Point2()); - VS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D()); + RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D()); if (snap_mode == SNAP_GRID) { Color grid_color = Color(1.0, 1.0, 1.0, 0.15); @@ -134,7 +134,7 @@ void TextureRegionEditor::_region_draw() { } } - Ref<Texture2D> select_handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> select_handle = get_theme_icon("EditorHandle", "EditorIcons"); Rect2 scroll_rect(Point2(), base_tex->get_size()); @@ -150,7 +150,7 @@ void TextureRegionEditor::_region_draw() { mtx.basis_xform(raw_endpoints[2]), mtx.basis_xform(raw_endpoints[3]) }; - Color color = get_color("mono_color", "Editor"); + Color color = get_theme_color("mono_color", "Editor"); for (int i = 0; i < 4; i++) { int prev = (i + 3) % 4; @@ -307,7 +307,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { if (E->get().has_point(point)) { rect = E->get(); - if (Input::get_singleton()->is_key_pressed(KEY_CONTROL) && !(Input::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL) && !(InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT | KEY_ALT))) { Rect2 r; if (node_sprite) r = node_sprite->get_region_rect(); @@ -449,7 +449,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { if (mm.is_valid()) { - if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::get_singleton()->is_key_pressed(KEY_SPACE)) { + if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) { Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom); hscroll->set_value(hscroll->get_value() - dragged.x); @@ -672,7 +672,7 @@ void TextureRegionEditor::_update_autoslice() { autoslice_is_dirty = false; autoslice_cache.clear(); - Ref<Texture2D> texture = NULL; + Ref<Texture2D> texture = nullptr; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -741,12 +741,12 @@ void TextureRegionEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - edit_draw->add_style_override("panel", get_stylebox("bg", "Tree")); + edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); } break; case NOTIFICATION_READY: { - zoom_out->set_icon(get_icon("ZoomLess", "EditorIcons")); - zoom_reset->set_icon(get_icon("ZoomReset", "EditorIcons")); - zoom_in->set_icon(get_icon("ZoomMore", "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")); vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE); hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); @@ -756,7 +756,7 @@ void TextureRegionEditor::_notification(int p_what) { _update_autoslice(); } } break; - case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + case NOTIFICATION_WM_FOCUS_IN: { // This happens when the user leaves the Editor and returns, // they could have changed the textures, so the cache is cleared. cache_map.clear(); @@ -767,11 +767,11 @@ void TextureRegionEditor::_notification(int p_what) { void TextureRegionEditor::_node_removed(Object *p_obj) { if (p_obj == node_sprite || p_obj == node_sprite_3d || p_obj == node_ninepatch || p_obj == obj_styleBox.ptr() || p_obj == atlas_tex.ptr()) { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBox>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBox>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); hide(); } } @@ -793,14 +793,14 @@ bool TextureRegionEditor::is_atlas_texture() { } bool TextureRegionEditor::is_ninepatch() { - return node_ninepatch != NULL; + return node_ninepatch != nullptr; } Sprite3D *TextureRegionEditor::get_sprite_3d() { return node_sprite_3d; } -Sprite *TextureRegionEditor::get_sprite() { +Sprite2D *TextureRegionEditor::get_sprite() { return node_sprite; } @@ -816,7 +816,7 @@ void TextureRegionEditor::edit(Object *p_obj) { if (atlas_tex.is_valid()) atlas_tex->remove_change_receptor(this); if (p_obj) { - node_sprite = Object::cast_to<Sprite>(p_obj); + node_sprite = Object::cast_to<Sprite2D>(p_obj); node_sprite_3d = Object::cast_to<Sprite3D>(p_obj); node_ninepatch = Object::cast_to<NinePatchRect>(p_obj); if (Object::cast_to<StyleBoxTexture>(p_obj)) @@ -826,11 +826,11 @@ void TextureRegionEditor::edit(Object *p_obj) { p_obj->add_change_receptor(this); _edit_region(); } else { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBoxTexture>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBoxTexture>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); } edit_draw->update(); if ((node_sprite && !node_sprite->is_region()) || (node_sprite_3d && !node_sprite_3d->is_region())) { @@ -850,7 +850,7 @@ void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_pro } void TextureRegionEditor::_edit_region() { - Ref<Texture2D> texture = NULL; + Ref<Texture2D> texture = nullptr; if (node_sprite) texture = node_sprite->get_texture(); else if (node_sprite_3d) @@ -896,11 +896,11 @@ Vector2 TextureRegionEditor::snap_point(Vector2 p_target) const { } TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { - node_sprite = NULL; - node_sprite_3d = NULL; - node_ninepatch = NULL; - obj_styleBox = Ref<StyleBoxTexture>(NULL); - atlas_tex = Ref<AtlasTexture>(NULL); + node_sprite = nullptr; + node_sprite_3d = nullptr; + node_ninepatch = nullptr; + obj_styleBox = Ref<StyleBoxTexture>(nullptr); + atlas_tex = Ref<AtlasTexture>(nullptr); editor = p_editor; undo_redo = editor->get_undo_redo(); @@ -1030,6 +1030,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { hscroll->connect("value_changed", callable_mp(this, &TextureRegionEditor::_scroll_changed)); updating_scroll = false; + autoslice_is_dirty = true; } void TextureRegionEditorPlugin::edit(Object *p_object) { @@ -1037,7 +1038,7 @@ void TextureRegionEditorPlugin::edit(Object *p_object) { } bool TextureRegionEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture"); + return p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("NinePatchRect") || p_object->is_class("StyleBoxTexture") || p_object->is_class("AtlasTexture"); } void TextureRegionEditorPlugin::_editor_visiblity_changed() { @@ -1057,7 +1058,7 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible) { manually_hidden = false; } texture_region_button->hide(); - region_editor->edit(NULL); + region_editor->edit(nullptr); } } diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index edc55071b7..c6cd648842 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -34,7 +34,7 @@ #include "canvas_item_editor_plugin.h" #include "editor/editor_node.h" #include "editor/editor_plugin.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" #include "scene/3d/sprite_3d.h" #include "scene/gui/nine_patch_rect.h" #include "scene/resources/style_box.h" @@ -84,7 +84,7 @@ class TextureRegionEditor : public VBoxContainer { Vector2 snap_step; Vector2 snap_separation; - Sprite *node_sprite; + Sprite2D *node_sprite; Sprite3D *node_sprite_3d; NinePatchRect *node_ninepatch; Ref<StyleBoxTexture> obj_styleBox; @@ -136,7 +136,7 @@ public: bool is_atlas_texture(); bool is_ninepatch(); Sprite3D *get_sprite_3d(); - Sprite *get_sprite(); + Sprite2D *get_sprite(); void edit(Object *p_obj); TextureRegionEditor(EditorNode *p_editor); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index aa5caf6658..b246b611fd 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -592,7 +592,7 @@ void ThemeEditor::_notification(int p_what) { } } break; case NOTIFICATION_THEME_CHANGED: { - theme_menu->set_icon(get_icon("Theme", "EditorIcons")); + theme_menu->set_icon(get_theme_icon("Theme", "EditorIcons")); } break; } } @@ -645,10 +645,10 @@ ThemeEditor::ThemeEditor() { main_container = memnew(MarginContainer); root_container->add_child(main_container); - main_container->add_constant_override("margin_right", 4 * EDSCALE); - main_container->add_constant_override("margin_top", 4 * EDSCALE); - main_container->add_constant_override("margin_left", 4 * EDSCALE); - main_container->add_constant_override("margin_bottom", 4 * EDSCALE); + main_container->add_theme_constant_override("margin_right", 4 * EDSCALE); + main_container->add_theme_constant_override("margin_top", 4 * EDSCALE); + main_container->add_theme_constant_override("margin_left", 4 * EDSCALE); + main_container->add_theme_constant_override("margin_bottom", 4 * EDSCALE); HBoxContainer *main_hb = memnew(HBoxContainer); main_container->add_child(main_hb); @@ -656,7 +656,7 @@ ThemeEditor::ThemeEditor() { VBoxContainer *first_vb = memnew(VBoxContainer); main_hb->add_child(first_vb); first_vb->set_h_size_flags(SIZE_EXPAND_FILL); - first_vb->add_constant_override("separation", 10 * EDSCALE); + first_vb->add_theme_constant_override("separation", 10 * EDSCALE); first_vb->add_child(memnew(Label("Label"))); @@ -716,7 +716,7 @@ ThemeEditor::ThemeEditor() { VBoxContainer *second_vb = memnew(VBoxContainer); second_vb->set_h_size_flags(SIZE_EXPAND_FILL); main_hb->add_child(second_vb); - second_vb->add_constant_override("separation", 10 * EDSCALE); + second_vb->add_theme_constant_override("separation", 10 * EDSCALE); LineEdit *le = memnew(LineEdit); le->set_text("LineEdit"); second_vb->add_child(le); @@ -756,7 +756,7 @@ ThemeEditor::ThemeEditor() { VBoxContainer *third_vb = memnew(VBoxContainer); third_vb->set_h_size_flags(SIZE_EXPAND_FILL); - third_vb->add_constant_override("separation", 10 * EDSCALE); + third_vb->add_theme_constant_override("separation", 10 * EDSCALE); main_hb->add_child(third_vb); TabContainer *tc = memnew(TabContainer); @@ -776,7 +776,7 @@ ThemeEditor::ThemeEditor() { Tree *test_tree = memnew(Tree); third_vb->add_child(test_tree); test_tree->set_custom_minimum_size(Size2(0, 175) * EDSCALE); - test_tree->add_constant_override("draw_relationship_lines", 1); + test_tree->add_theme_constant_override("draw_relationship_lines", 1); TreeItem *item = test_tree->create_item(); item->set_text(0, "Tree"); @@ -802,7 +802,7 @@ ThemeEditor::ThemeEditor() { item->set_text(0, TTR("Has,Many,Options")); item->set_range(0, 2); - main_hb->add_constant_override("separation", 20 * EDSCALE); + main_hb->add_theme_constant_override("separation", 20 * EDSCALE); //////// @@ -846,7 +846,7 @@ ThemeEditor::ThemeEditor() { name_menu->set_text(".."); name_hbc->add_child(name_menu); - name_menu->get_popup()->connect("about_to_show", callable_mp(this, &ThemeEditor::_name_menu_about_to_show)); + name_menu->get_popup()->connect("about_to_popup", callable_mp(this, &ThemeEditor::_name_menu_about_to_show)); name_menu->get_popup()->connect("id_pressed", callable_mp(this, &ThemeEditor::_name_menu_cbk)); type_select_label = memnew(Label); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 017f986469..9e88cd8889 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -31,13 +31,20 @@ #include "tile_map_editor_plugin.h" #include "canvas_item_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/math/math_funcs.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "scene/gui/split_container.h" +void TileMapEditor::_node_removed(Node *p_node) { + + if (p_node == node) { + node = nullptr; + } +} + void TileMapEditor::_notification(int p_what) { switch (p_what) { @@ -50,35 +57,41 @@ void TileMapEditor::_notification(int p_what) { } break; + case NOTIFICATION_ENTER_TREE: { + + get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); + [[fallthrough]]; + } + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (is_visible_in_tree()) { _update_palette(); } - [[fallthrough]]; - } - case NOTIFICATION_ENTER_TREE: { + paint_button->set_icon(get_theme_icon("Edit", "EditorIcons")); + bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons")); + picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons")); + select_button->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - paint_button->set_icon(get_icon("Edit", "EditorIcons")); - bucket_fill_button->set_icon(get_icon("Bucket", "EditorIcons")); - picker_button->set_icon(get_icon("ColorPick", "EditorIcons")); - select_button->set_icon(get_icon("ActionCopy", "EditorIcons")); + rotate_left_button->set_icon(get_theme_icon("RotateLeft", "EditorIcons")); + rotate_right_button->set_icon(get_theme_icon("RotateRight", "EditorIcons")); + flip_horizontal_button->set_icon(get_theme_icon("MirrorX", "EditorIcons")); + flip_vertical_button->set_icon(get_theme_icon("MirrorY", "EditorIcons")); + clear_transform_button->set_icon(get_theme_icon("Clear", "EditorIcons")); - rotate_left_button->set_icon(get_icon("RotateLeft", "EditorIcons")); - rotate_right_button->set_icon(get_icon("RotateRight", "EditorIcons")); - flip_horizontal_button->set_icon(get_icon("MirrorX", "EditorIcons")); - flip_vertical_button->set_icon(get_icon("MirrorY", "EditorIcons")); - clear_transform_button->set_icon(get_icon("Clear", "EditorIcons")); - - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_box->set_right_icon(get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); PopupMenu *p = options->get_popup(); - p->set_item_icon(p->get_item_index(OPTION_CUT), get_icon("ActionCut", "EditorIcons")); - p->set_item_icon(p->get_item_index(OPTION_COPY), get_icon("Duplicate", "EditorIcons")); - p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_icon("Remove", "EditorIcons")); + p->set_item_icon(p->get_item_index(OPTION_CUT), get_theme_icon("ActionCut", "EditorIcons")); + p->set_item_icon(p->get_item_index(OPTION_COPY), get_theme_icon("Duplicate", "EditorIcons")); + p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_theme_icon("Remove", "EditorIcons")); + + } break; + case NOTIFICATION_EXIT_TREE: { + get_tree()->disconnect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); } break; } } @@ -421,7 +434,7 @@ void TileMapEditor::_update_palette() { bool show_tile_ids = bool(EDITOR_DEF("editors/tile_map/show_tile_ids", false)); bool sort_by_name = bool(EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true)); - palette->add_constant_override("hseparation", hseparation * EDSCALE); + palette->add_theme_constant_override("hseparation", hseparation * EDSCALE); palette->set_fixed_icon_size(Size2(min_size, min_size)); palette->set_fixed_column_width(min_size * MAX(size_slider->get_value(), 1)); @@ -627,7 +640,7 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, if (r != bucket_cache_rect) _clear_bucket_cache(); // Cache grid is not initialized - if (bucket_cache_visited == NULL) { + if (bucket_cache_visited == nullptr) { bucket_cache_visited = new bool[area]; invalidate_cache = true; } @@ -894,7 +907,7 @@ void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Po void TileMapEditor::_clear_bucket_cache() { if (bucket_cache_visited) { delete[] bucket_cache_visited; - bucket_cache_visited = NULL; + bucket_cache_visited = nullptr; } } @@ -984,7 +997,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mb->is_pressed()) { - if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) + if (InputFilter::get_singleton()->is_key_pressed(KEY_SPACE)) return false; // Drag. if (tool == TOOL_NONE) { @@ -1365,7 +1378,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } - if (tool == TOOL_PICKING && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + if (tool == TOOL_PICKING && InputFilter::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { _pick_tile(over_tile); @@ -1773,7 +1786,7 @@ void TileMapEditor::edit(Node *p_tile_map) { _update_palette(); } else { - node = NULL; + node = nullptr; if (canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter))) canvas_item_editor_viewport->disconnect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)); @@ -1889,11 +1902,11 @@ void TileMapEditor::_clear_transform() { TileMapEditor::TileMapEditor(EditorNode *p_editor) { - node = NULL; + node = nullptr; manual_autotile = false; priority_atlastile = false; manual_position = Vector2(0, 0); - canvas_item_editor_viewport = NULL; + canvas_item_editor_viewport = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -1906,7 +1919,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { transpose = false; bucket_cache_tile = -1; - bucket_cache_visited = NULL; + bucket_cache_visited = nullptr; invalid_cell.resize(1); invalid_cell.write[0] = TileMap::INVALID_CELL; @@ -1960,7 +1973,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { palette->set_icon_mode(ItemList::ICON_MODE_TOP); palette->set_max_text_lines(2); palette->set_select_mode(ItemList::SELECT_MULTI); - palette->add_constant_override("vseparation", 8 * EDSCALE); + palette->add_theme_constant_override("vseparation", 8 * EDSCALE); palette->connect("item_selected", callable_mp(this, &TileMapEditor::_palette_selected)); palette->connect("multi_selected", callable_mp(this, &TileMapEditor::_palette_multi_selected)); palette_container->add_child(palette); @@ -2031,7 +2044,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { tile_info = memnew(Label); tile_info->set_modulate(Color(1, 1, 1, 0.8)); tile_info->set_mouse_filter(MOUSE_FILTER_IGNORE); - tile_info->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts")); + tile_info->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); // The tile info is only displayed after a tile has been hovered. tile_info->hide(); CanvasItemEditor::get_singleton()->add_control_to_info_overlay(tile_info); @@ -2039,7 +2052,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { // Menu. options = memnew(MenuButton); options->set_text("TileMap"); - options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("TileMap", "EditorIcons")); + options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("TileMap", "EditorIcons")); options->set_process_unhandled_key_input(false); toolbar_right->add_child(options); @@ -2142,7 +2155,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { tile_map_editor->get_toolbar()->hide(); tile_map_editor->get_toolbar_right()->hide(); tile_map_editor->get_tile_info()->hide(); - tile_map_editor->edit(NULL); + tile_map_editor->edit(nullptr); } } diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index 74969d3e64..f43e5bb5cb 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -211,6 +211,7 @@ class TileMapEditor : public VBoxContainer { protected: void _notification(int p_what); + void _node_removed(Node *p_node); static void _bind_methods(); CellOp _get_op_from_cell(const Point2i &p_pos); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index a5a667802e..d1dda68c1d 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -30,12 +30,12 @@ #include "tile_set_editor_plugin.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "editor/editor_scale.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "scene/2d/physics_body_2d.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" void TileSetEditor::edit(const Ref<TileSet> &p_tileset) { @@ -53,7 +53,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { Node *child = p_node->get_child(i); - if (!Object::cast_to<Sprite>(child)) { + if (!Object::cast_to<Sprite2D>(child)) { if (child->get_child_count() > 0) { _import_node(child, p_library); } @@ -61,7 +61,7 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { continue; } - Sprite *mi = Object::cast_to<Sprite>(child); + Sprite2D *mi = Object::cast_to<Sprite2D>(child); Ref<Texture2D> texture = mi->get_texture(); Ref<Texture2D> normal_map = mi->get_normal_map(); Ref<ShaderMaterial> material = mi->get_material(); @@ -284,47 +284,47 @@ void TileSetEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - add_constant_override("autohide", 1); // Fixes the dragger always showing up. + add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up. } break; case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_icon("ToolAddNode", "EditorIcons")); - tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_icon(get_icon("Remove", "EditorIcons")); - tileset_toolbar_tools->set_icon(get_icon("Tools", "EditorIcons")); - - tool_workspacemode[WORKSPACE_EDIT]->set_icon(get_icon("Edit", "EditorIcons")); - tool_workspacemode[WORKSPACE_CREATE_SINGLE]->set_icon(get_icon("AddSingleTile", "EditorIcons")); - tool_workspacemode[WORKSPACE_CREATE_AUTOTILE]->set_icon(get_icon("AddAutotile", "EditorIcons")); - tool_workspacemode[WORKSPACE_CREATE_ATLAS]->set_icon(get_icon("AddAtlasTile", "EditorIcons")); - - tools[TOOL_SELECT]->set_icon(get_icon("ToolSelect", "EditorIcons")); - tools[BITMASK_COPY]->set_icon(get_icon("Duplicate", "EditorIcons")); - tools[BITMASK_PASTE]->set_icon(get_icon("Override", "EditorIcons")); - tools[BITMASK_CLEAR]->set_icon(get_icon("Clear", "EditorIcons")); - tools[SHAPE_NEW_POLYGON]->set_icon(get_icon("CollisionPolygon2D", "EditorIcons")); - tools[SHAPE_NEW_RECTANGLE]->set_icon(get_icon("CollisionShape2D", "EditorIcons")); - tools[SELECT_PREVIOUS]->set_icon(get_icon("ArrowLeft", "EditorIcons")); - tools[SELECT_NEXT]->set_icon(get_icon("ArrowRight", "EditorIcons")); - tools[SHAPE_DELETE]->set_icon(get_icon("Remove", "EditorIcons")); - tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_icon("Snap", "EditorIcons")); - tools[TOOL_GRID_SNAP]->set_icon(get_icon("SnapGrid", "EditorIcons")); - tools[ZOOM_OUT]->set_icon(get_icon("ZoomLess", "EditorIcons")); - tools[ZOOM_1]->set_icon(get_icon("ZoomReset", "EditorIcons")); - tools[ZOOM_IN]->set_icon(get_icon("ZoomMore", "EditorIcons")); - tools[VISIBLE_INFO]->set_icon(get_icon("InformationSign", "EditorIcons")); + tileset_toolbar_buttons[TOOL_TILESET_ADD_TEXTURE]->set_icon(get_theme_icon("ToolAddNode", "EditorIcons")); + tileset_toolbar_buttons[TOOL_TILESET_REMOVE_TEXTURE]->set_icon(get_theme_icon("Remove", "EditorIcons")); + tileset_toolbar_tools->set_icon(get_theme_icon("Tools", "EditorIcons")); + + tool_workspacemode[WORKSPACE_EDIT]->set_icon(get_theme_icon("Edit", "EditorIcons")); + tool_workspacemode[WORKSPACE_CREATE_SINGLE]->set_icon(get_theme_icon("AddSingleTile", "EditorIcons")); + tool_workspacemode[WORKSPACE_CREATE_AUTOTILE]->set_icon(get_theme_icon("AddAutotile", "EditorIcons")); + tool_workspacemode[WORKSPACE_CREATE_ATLAS]->set_icon(get_theme_icon("AddAtlasTile", "EditorIcons")); + + tools[TOOL_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); + tools[BITMASK_COPY]->set_icon(get_theme_icon("Duplicate", "EditorIcons")); + tools[BITMASK_PASTE]->set_icon(get_theme_icon("Override", "EditorIcons")); + tools[BITMASK_CLEAR]->set_icon(get_theme_icon("Clear", "EditorIcons")); + tools[SHAPE_NEW_POLYGON]->set_icon(get_theme_icon("CollisionPolygon2D", "EditorIcons")); + tools[SHAPE_NEW_RECTANGLE]->set_icon(get_theme_icon("CollisionShape2D", "EditorIcons")); + tools[SELECT_PREVIOUS]->set_icon(get_theme_icon("ArrowLeft", "EditorIcons")); + tools[SELECT_NEXT]->set_icon(get_theme_icon("ArrowRight", "EditorIcons")); + tools[SHAPE_DELETE]->set_icon(get_theme_icon("Remove", "EditorIcons")); + tools[SHAPE_KEEP_INSIDE_TILE]->set_icon(get_theme_icon("Snap", "EditorIcons")); + tools[TOOL_GRID_SNAP]->set_icon(get_theme_icon("SnapGrid", "EditorIcons")); + tools[ZOOM_OUT]->set_icon(get_theme_icon("ZoomLess", "EditorIcons")); + tools[ZOOM_1]->set_icon(get_theme_icon("ZoomReset", "EditorIcons")); + tools[ZOOM_IN]->set_icon(get_theme_icon("ZoomMore", "EditorIcons")); + tools[VISIBLE_INFO]->set_icon(get_theme_icon("InformationSign", "EditorIcons")); _update_toggle_shape_button(); - tool_editmode[EDITMODE_REGION]->set_icon(get_icon("RegionEdit", "EditorIcons")); - tool_editmode[EDITMODE_COLLISION]->set_icon(get_icon("StaticBody2D", "EditorIcons")); - tool_editmode[EDITMODE_OCCLUSION]->set_icon(get_icon("LightOccluder2D", "EditorIcons")); - tool_editmode[EDITMODE_NAVIGATION]->set_icon(get_icon("Navigation2D", "EditorIcons")); - tool_editmode[EDITMODE_BITMASK]->set_icon(get_icon("PackedDataContainer", "EditorIcons")); - tool_editmode[EDITMODE_PRIORITY]->set_icon(get_icon("MaterialPreviewLight1", "EditorIcons")); - tool_editmode[EDITMODE_ICON]->set_icon(get_icon("LargeTexture", "EditorIcons")); - tool_editmode[EDITMODE_Z_INDEX]->set_icon(get_icon("Sort", "EditorIcons")); + tool_editmode[EDITMODE_REGION]->set_icon(get_theme_icon("RegionEdit", "EditorIcons")); + tool_editmode[EDITMODE_COLLISION]->set_icon(get_theme_icon("StaticBody2D", "EditorIcons")); + tool_editmode[EDITMODE_OCCLUSION]->set_icon(get_theme_icon("LightOccluder2D", "EditorIcons")); + tool_editmode[EDITMODE_NAVIGATION]->set_icon(get_theme_icon("Navigation2D", "EditorIcons")); + tool_editmode[EDITMODE_BITMASK]->set_icon(get_theme_icon("PackedDataContainer", "EditorIcons")); + tool_editmode[EDITMODE_PRIORITY]->set_icon(get_theme_icon("MaterialPreviewLight1", "EditorIcons")); + tool_editmode[EDITMODE_ICON]->set_icon(get_theme_icon("LargeTexture", "EditorIcons")); + tool_editmode[EDITMODE_Z_INDEX]->set_icon(get_theme_icon("Sort", "EditorIcons")); - scroll->add_style_override("bg", get_stylebox("bg", "Tree")); + scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } break; } } @@ -528,8 +528,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { toolbar->add_child(spin_priority); spin_z_index = memnew(SpinBox); - spin_z_index->set_min(VS::CANVAS_ITEM_Z_MIN); - spin_z_index->set_max(VS::CANVAS_ITEM_Z_MAX); + spin_z_index->set_min(RS::CANVAS_ITEM_Z_MIN); + spin_z_index->set_max(RS::CANVAS_ITEM_Z_MAX); spin_z_index->set_step(1); spin_z_index->set_custom_minimum_size(Size2(100, 0)); spin_z_index->connect("value_changed", callable_mp(this, &TileSetEditor::_on_z_index_changed)); @@ -601,7 +601,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { workspace->set_draw_behind_parent(true); workspace_overlay->add_child(workspace); - preview = memnew(Sprite); + preview = memnew(Sprite2D); workspace->add_child(preview); preview->set_centered(false); preview->set_draw_behind_parent(true); @@ -619,7 +619,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { //--------------- texture_dialog = memnew(EditorFileDialog); texture_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES); - texture_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILES); + texture_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES); texture_dialog->clear_filters(); List<String> extensions; @@ -725,7 +725,7 @@ void TileSetEditor::_on_texture_list_selected(int p_index) { update_workspace_minsize(); } else { current_item_index = -1; - preview->set_texture(NULL); + preview->set_texture(nullptr); workspace->set_custom_minimum_size(Size2i()); update_workspace_tile_mode(); } @@ -1113,7 +1113,7 @@ void TileSetEditor::_on_workspace_draw() { void TileSetEditor::_on_workspace_process() { - if (Input::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_ALT) || tools[VISIBLE_INFO]->is_pressed()) { if (!tile_names_visible) { tile_names_visible = true; workspace_overlay->update(); @@ -1153,7 +1153,7 @@ void TileSetEditor::_on_workspace_overlay_draw() { else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) c = COLOR_ATLAS; String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); region.set_size(font->get_string_size(tile_id_name)); workspace_overlay->draw_rect(region, c); region.position.y += region.size.y - 2; @@ -1167,7 +1167,7 @@ void TileSetEditor::_on_workspace_overlay_draw() { if (t_id < 0) return; - Ref<Texture2D> handle = get_icon("EditorHandle", "EditorIcons"); + Ref<Texture2D> handle = get_theme_icon("EditorHandle", "EditorIcons"); if (draw_handles) { for (int i = 0; i < current_shape.size(); i++) { workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5); @@ -1395,7 +1395,7 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { if ((mb->get_button_index() == BUTTON_RIGHT || mb->get_button_index() == BUTTON_LEFT) && current_tile_region.has_point(mb->get_position())) { dragging = true; erasing = (mb->get_button_index() == BUTTON_RIGHT); - alternative = Input::get_singleton()->is_key_pressed(KEY_SHIFT); + alternative = InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT); Vector2 coord((int)((mb->get_position().x - current_tile_region.position.x) / (spacing + size.x)), (int)((mb->get_position().y - current_tile_region.position.y) / (spacing + size.y))); Vector2 pos(coord.x * (spacing + size.x), coord.y * (spacing + size.y)); pos = mb->get_position() - (pos + current_tile_region.position); @@ -2019,10 +2019,10 @@ void TileSetEditor::_update_toggle_shape_button() { separator_shape_toggle->hide(); tools[SHAPE_TOGGLE_TYPE]->hide(); } else if (concave.is_valid()) { - tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConvexPolygonShape2D", "EditorIcons")); + tools[SHAPE_TOGGLE_TYPE]->set_icon(get_theme_icon("ConvexPolygonShape2D", "EditorIcons")); tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Convex")); } else if (convex.is_valid()) { - tools[SHAPE_TOGGLE_TYPE]->set_icon(get_icon("ConcavePolygonShape2D", "EditorIcons")); + tools[SHAPE_TOGGLE_TYPE]->set_icon(get_theme_icon("ConcavePolygonShape2D", "EditorIcons")); tools[SHAPE_TOGGLE_TYPE]->set_text(TTR("Make Concave")); } else { // Shouldn't happen @@ -3003,7 +3003,7 @@ void TileSetEditor::select_coord(const Vector2 &coord) { } } if (!found_collision_shape) - _set_edited_collision_shape(Ref<ConvexPolygonShape2D>(NULL)); + _set_edited_collision_shape(Ref<ConvexPolygonShape2D>(nullptr)); if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord)) edited_occlusion_shape = tileset->autotile_get_light_occluder(get_current_tile(), coord); if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord)) @@ -3485,7 +3485,7 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_navigation_offset")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "tile_shape_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR)); - p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1")); + p_list->push_back(PropertyInfo(Variant::INT, "tile_z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1")); } if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_COLLISION && tileset_editor->edited_collision_shape.is_valid()) { p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class())); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 0d106ed454..53f8e8c4d6 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -32,7 +32,7 @@ #define TILE_SET_EDITOR_PLUGIN_H #include "editor/editor_node.h" -#include "scene/2d/sprite.h" +#include "scene/2d/sprite_2d.h" #include "scene/resources/concave_polygon_shape_2d.h" #include "scene/resources/convex_polygon_shape_2d.h" #include "scene/resources/tile_set.h" @@ -136,7 +136,7 @@ class TileSetEditor : public HSplitContainer { Ref<NavigationPolygon> edited_navigation_shape; int current_item_index; - Sprite *preview; + Sprite2D *preview; ScrollContainer *scroll; Label *empty_message; Control *workspace_container; diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index da80eee253..fe8392593b 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -35,7 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_scale.h" -VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = NULL; +VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr; void VersionControlEditorPlugin::_bind_methods() { @@ -171,7 +171,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() { for (int i = 0; i < modified_file_paths.size(); i++) { file_path = modified_file_paths.get_key_at_index(i); - TreeItem *found = stage_files->search_item_text(file_path, 0, true); + TreeItem *found = stage_files->search_item_text(file_path, nullptr, true); if (!found) { ChangeType change_index = (ChangeType)(int)modified_file_paths.get_value_at_index(i); @@ -217,12 +217,12 @@ void VersionControlEditorPlugin::_stage_selected() { 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_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "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_color("error_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); } file_entry = file_entry->get_next(); @@ -248,7 +248,7 @@ void VersionControlEditorPlugin::_stage_all() { 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_color("success_color", "Editor")); + file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); file_entry->set_checked(0, true); staged_files_count++; @@ -275,20 +275,20 @@ 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_font("source", "EditorFonts")); + diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "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_color("success_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); } else if (line_result["status"] == "-") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); } else { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_color("font_color", "Label")); + diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label")); } diff->add_text((String)line_result["content"]); @@ -385,7 +385,7 @@ void VersionControlEditorPlugin::shut_down() { } EditorVCSInterface::get_singleton()->shut_down(); memdelete(EditorVCSInterface::get_singleton()); - EditorVCSInterface::set_singleton(NULL); + EditorVCSInterface::set_singleton(nullptr); EditorNode::get_singleton()->remove_control_from_dock(version_commit_dock); EditorNode::get_singleton()->remove_bottom_panel_item(version_control_dock); @@ -408,11 +408,10 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { staged_files_count = 0; version_control_actions = memnew(PopupMenu); - version_control_actions->set_v_size_flags(BoxContainer::SIZE_SHRINK_CENTER); set_up_dialog = memnew(AcceptDialog); set_up_dialog->set_title(TTR("Set Up Version Control")); - set_up_dialog->set_custom_minimum_size(Size2(400, 100)); + set_up_dialog->set_min_size(Size2(400, 100)); version_control_actions->add_child(set_up_dialog); set_up_ok_button = set_up_dialog->get_ok(); @@ -439,16 +438,13 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_choice->connect("item_selected", callable_mp(this, &VersionControlEditorPlugin::_selected_a_vcs)); set_up_hbc->add_child(set_up_choice); - set_up_init_settings = NULL; + set_up_init_settings = nullptr; set_up_init_button = memnew(Button); set_up_init_button->set_text(TTR("Initialize")); set_up_init_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_initialize_vcs)); set_up_vbc->add_child(set_up_init_button); - version_control_actions->set_v_size_flags(PopupMenu::SIZE_EXPAND_FILL); - version_control_actions->set_h_size_flags(PopupMenu::SIZE_EXPAND_FILL); - version_commit_dock = memnew(VBoxContainer); version_commit_dock->set_visible(false); @@ -470,7 +466,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_icon("Reload", "EditorIcons")); + refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "EditorIcons")); refresh_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); stage_tools->add_child(refresh_button); @@ -495,11 +491,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_color("success_color", "Editor"); - change_type_to_color[CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor"); - change_type_to_color[CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_gui_base()->get_color("disabled_font_color", "Editor"); - change_type_to_color[CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"); - change_type_to_color[CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_gui_base()->get_color("font_color", "Editor"); + 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"); stage_buttons = memnew(HSplitContainer); stage_buttons->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN_COLLAPSED); @@ -562,7 +558,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_icon("Reload", "EditorIcons")); + diff_refresh_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Reload", "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 9100e28352..d5128db0d5 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -30,9 +30,9 @@ #include "visual_shader_editor_plugin.h" +#include "core/input/input_filter.h" #include "core/io/resource_loader.h" #include "core/math/math_defs.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "core/version.h" @@ -42,16 +42,17 @@ #include "scene/animation/animation_player.h" #include "scene/gui/menu_button.h" #include "scene/gui/panel.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/visual_shader_nodes.h" -#include "servers/visual/shader_types.h" +#include "servers/display_server.h" +#include "servers/rendering/shader_types.h" Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { if (get_script_instance()) { return get_script_instance()->call("create_editor", p_parent_resource, p_node); } - return NULL; + return nullptr; } void VisualShaderNodePlugin::_bind_methods() { @@ -312,8 +313,8 @@ void VisualShaderEditor::_update_options_menu() { bool is_first_item = true; - Color unsupported_color = get_color("error_color", "Editor"); - Color supported_color = get_color("warning_color", "Editor"); + Color unsupported_color = get_theme_color("error_color", "Editor"); + Color supported_color = get_theme_color("warning_color", "Editor"); static bool low_driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES2"; @@ -351,7 +352,7 @@ void VisualShaderEditor::_update_options_menu() { for (int i = 0; i < options.size(); i++) { String path = options[i].category; Vector<String> subfolders = path.split("/"); - TreeItem *category = NULL; + TreeItem *category = nullptr; if (!folders.has(path)) { category = root; @@ -385,22 +386,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_icon("float", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("float", "EditorIcons")); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("int", "EditorIcons")); break; case VisualShaderNode::PORT_TYPE_VECTOR: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Vector3", "EditorIcons")); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("bool", "EditorIcons")); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Transform", "EditorIcons")); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons")); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons")); break; default: break; @@ -420,7 +421,7 @@ void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) { if (!button) return; - Ref<StyleBox> normal = get_stylebox("normal", "Button"); + Ref<StyleBox> normal = get_theme_stylebox("normal", "Button"); button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color); } @@ -436,7 +437,7 @@ static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_ void VisualShaderEditor::_update_created_node(GraphNode *node) { if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) { - Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode"); + Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode"); Color c = sb->get_border_color(); Color ic; Color mono_color; @@ -450,10 +451,10 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) { mono_color.a = 0.85; c = mono_color; - node->add_color_override("title_color", c); + node->add_theme_color_override("title_color", c); c.a = 0.7; - node->add_color_override("close_color", c); - node->add_color_override("resizer_color", ic); + node->add_theme_color_override("close_color", c); + node->add_theme_color_override("resizer_color", ic); } } @@ -535,7 +536,7 @@ void VisualShaderEditor::_update_graph() { node->connect("dragged", callable_mp(this, &VisualShaderEditor::_node_dragged), varray(nodes[n_i])); - Control *custom_editor = NULL; + Control *custom_editor = nullptr; int port_offset = 0; if (is_group) { @@ -555,6 +556,17 @@ void VisualShaderEditor::_update_graph() { uniform_name->connect("text_entered", callable_mp(this, &VisualShaderEditor::_line_edit_changed), varray(uniform_name, nodes[n_i])); uniform_name->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_line_edit_focus_out), varray(uniform_name, nodes[n_i])); + String error = vsnode->get_warning(visual_shader->get_mode(), type); + if (error != String()) { + offset = memnew(Control); + offset->set_custom_minimum_size(Size2(0, 4 * EDSCALE)); + node->add_child(offset); + Label *error_label = memnew(Label); + error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); + error_label->set_text(error); + node->add_child(error_label); + } + if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") { //shortcut VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0); @@ -583,7 +595,7 @@ void VisualShaderEditor::_update_graph() { custom_editor->call_deferred("_show_prop_names", true); continue; } - custom_editor = NULL; + custom_editor = nullptr; } if (is_group) { @@ -641,7 +653,7 @@ void VisualShaderEditor::_update_graph() { } HBoxContainer *hb = memnew(HBoxContainer); - hb->add_constant_override("separation", 7 * EDSCALE); + hb->add_theme_constant_override("separation", 7 * EDSCALE); Variant default_value; @@ -705,7 +717,7 @@ void VisualShaderEditor::_update_graph() { name_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_port_name_focus_out), varray(name_box, nodes[n_i], i, false)); Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -713,15 +725,15 @@ void VisualShaderEditor::_update_graph() { Label *label = memnew(Label); label->set_text(name_left); - label->add_style_override("normal", label_style); //more compact + label->add_theme_style_override("normal", label_style); //more compact hb->add_child(label); 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_color_override("font_color", get_color("font_color_readonly", "TextEdit")); - hint_label->add_style_override("normal", label_style); + hint_label->add_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit")); + hint_label->add_theme_style_override("normal", label_style); hb->add_child(hint_label); } } @@ -734,7 +746,7 @@ void VisualShaderEditor::_update_graph() { if (valid_right) { if (is_group) { Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Remove", "EditorIcons")); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons")); remove_btn->set_tooltip(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_output_port), varray(nodes[n_i], i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -760,7 +772,7 @@ void VisualShaderEditor::_update_graph() { } else { Label *label = memnew(Label); label->set_text(name_right); - label->add_style_override("normal", label_style); //more compact + label->add_theme_style_override("normal", label_style); //more compact hb->add_child(label); } } @@ -769,8 +781,8 @@ void VisualShaderEditor::_update_graph() { if (valid_right && edit_type->get_selected() == 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(get_icon("GuiVisibilityHidden", "EditorIcons")); - preview->set_pressed_texture(get_icon("GuiVisibilityVisible", "EditorIcons")); + preview->set_normal_texture(get_theme_icon("GuiVisibilityHidden", "EditorIcons")); + preview->set_pressed_texture(get_theme_icon("GuiVisibilityVisible", "EditorIcons")); preview->set_v_size_flags(SIZE_SHRINK_CENTER); if (vsnode->get_output_port_for_preview() == i) { @@ -815,7 +827,7 @@ void VisualShaderEditor::_update_graph() { String error = vsnode->get_warning(visual_shader->get_mode(), type); if (error != String()) { Label *error_label = memnew(Label); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); error_label->set_text(error); node->add_child(error_label); } @@ -833,16 +845,16 @@ void VisualShaderEditor::_update_graph() { Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); expression_box->set_syntax_coloring(true); - expression_box->add_color_override("background_color", background_color); + expression_box->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { expression_box->add_keyword_color(E->get(), keyword_color); } - expression_box->add_font_override("font", get_font("expression", "EditorFonts")); - expression_box->add_color_override("font_color", text_color); - expression_box->add_color_override("symbol_color", symbol_color); + expression_box->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); + expression_box->add_theme_color_override("font_color", text_color); + expression_box->add_theme_color_override("symbol_color", symbol_color); expression_box->add_color_region("/*", "*/", comment_color, false); expression_box->add_color_region("//", "", comment_color, false); @@ -1086,7 +1098,7 @@ void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) { } void VisualShaderEditor::_rebuild() { - if (visual_shader != NULL) { + if (visual_shader != nullptr) { EditorNode::get_singleton()->get_log()->clear(); visual_shader->rebuild(); } @@ -1110,7 +1122,7 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p group_node->set_size(size); - GraphNode *gn = NULL; + GraphNode *gn = nullptr; if (edit_type->get_selected() == p_type) { // check - otherwise the error will be emitted Node *node2 = graph->get_node(itos(p_node)); gn = Object::cast_to<GraphNode>(node2); @@ -1125,7 +1137,7 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p if (!expression_node.is_null()) { Control *text_box = expression_node->get_control(0); Size2 box_size = size; - if (gn != NULL) { + if (gn != nullptr) { if (box_size.x < 150 * EDSCALE || box_size.y < 0) { box_size.x = gn->get_size().x; } @@ -1272,8 +1284,8 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, Button *button = Object::cast_to<Button>(p_button); ERR_FAIL_COND(!button); Variant value = vsn->get_input_port_default_value(p_port); - property_editor->set_global_position(button->get_global_position() + Vector2(0, button->get_size().height)); - property_editor->edit(NULL, "", value.get_type(), value, 0, ""); + property_editor->set_position(button->get_screen_position() + Vector2(0, button->get_size().height)); + property_editor->edit(nullptr, "", value.get_type(), value, 0, ""); property_editor->popup(); editing_node = p_node; editing_port = p_port; @@ -1303,7 +1315,7 @@ void VisualShaderEditor::_add_texture_node(const String &p_path) { VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { - ERR_FAIL_INDEX_V(p_idx, add_options.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr); Ref<VisualShaderNode> vsnode; @@ -1311,7 +1323,7 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { if (!is_custom && add_options[p_idx].type != String()) { VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type)); - ERR_FAIL_COND_V(!vsn, NULL); + ERR_FAIL_COND_V(!vsn, nullptr); VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn); @@ -1409,10 +1421,10 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { vsnode = Ref<VisualShaderNode>(vsn); } else { - ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), NULL); + ERR_FAIL_COND_V(add_options[p_idx].script.is_null(), nullptr); String base_type = add_options[p_idx].script->get_instance_base_type(); VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(base_type)); - ERR_FAIL_COND_V(!vsn, NULL); + ERR_FAIL_COND_V(!vsn, nullptr); vsnode = Ref<VisualShaderNode>(vsn); vsnode->set_script(add_options[p_idx].script); } @@ -1623,7 +1635,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty()); popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty()); menu_point = graph->get_local_mouse_position(); - Point2 gpos = Input::get_singleton()->get_mouse_position(); + Point2 gpos = InputFilter::get_singleton()->get_mouse_position(); popup_menu->set_position(gpos); popup_menu->popup(); } @@ -1636,7 +1648,7 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { saved_node_pos_dirty = true; saved_node_pos = graph->get_local_mouse_position(); - Point2 gpos = Input::get_singleton()->get_mouse_position(); + Point2 gpos = InputFilter::get_singleton()->get_mouse_position(); members_dialog->popup(); members_dialog->set_position(gpos); } else { @@ -1646,8 +1658,8 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { } // keep dialog within window bounds - Size2 window_size = OS::get_singleton()->get_window_size(); - Rect2 dialog_rect = members_dialog->get_global_rect(); + Size2 window_size = DisplayServer::get_singleton()->window_get_size(); + Rect2 dialog_rect = Rect2(members_dialog->get_position(), members_dialog->get_size()); if (dialog_rect.position.y + dialog_rect.size.y > window_size.y) { int difference = dialog_rect.position.y + dialog_rect.size.y - window_size.y; members_dialog->set_position(members_dialog->get_position() - Point2(0, difference)); @@ -1703,14 +1715,14 @@ void VisualShaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - highend_label->set_modulate(get_color("vulkan_color", "Editor")); + highend_label->set_modulate(get_theme_color("vulkan_color", "Editor")); - error_panel->add_style_override("panel", get_stylebox("bg", "Tree")); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); + 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")); - node_filter->set_right_icon(Control::get_icon("Search", "EditorIcons")); + node_filter->set_right_icon(Control::get_theme_icon("Search", "EditorIcons")); - preview_shader->set_icon(Control::get_icon("Shader", "EditorIcons")); + preview_shader->set_icon(Control::get_theme_icon("Shader", "EditorIcons")); { Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); @@ -1719,24 +1731,24 @@ void VisualShaderEditor::_notification(int p_what) { Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color"); Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color"); - preview_text->add_color_override("background_color", background_color); + preview_text->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { preview_text->add_keyword_color(E->get(), keyword_color); } - preview_text->add_font_override("font", get_font("expression", "EditorFonts")); - preview_text->add_color_override("font_color", text_color); - preview_text->add_color_override("symbol_color", symbol_color); + preview_text->add_theme_font_override("font", get_theme_font("expression", "EditorFonts")); + preview_text->add_theme_color_override("font_color", text_color); + preview_text->add_theme_color_override("symbol_color", symbol_color); preview_text->add_color_region("/*", "*/", comment_color, false); preview_text->add_color_region("//", "", comment_color, false); - error_text->add_font_override("font", get_font("status_source", "EditorFonts")); - error_text->add_color_override("font_color", get_color("error_color", "Editor")); + error_text->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); + error_text->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); } - tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Tools", "EditorIcons")); + tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Tools", "EditorIcons")); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) _update_graph(); @@ -2067,7 +2079,7 @@ void VisualShaderEditor::_member_filter_changed(const String &p_text) { void VisualShaderEditor::_member_selected() { TreeItem *item = members->get_selected(); - if (item != NULL && item->has_meta("id")) { + if (item != nullptr && item->has_meta("id")) { members_dialog->get_ok()->set_disabled(false); highend_label->set_visible(add_options[item->get_meta("id")].highend); node_desc->set_text(_get_description(item->get_meta("id"))); @@ -2083,7 +2095,7 @@ void VisualShaderEditor::_member_unselected() { void VisualShaderEditor::_member_create() { TreeItem *item = members->get_selected(); - if (item != NULL && item->has_meta("id")) { + if (item != nullptr && item->has_meta("id")) { int idx = members->get_selected()->get_meta("id"); _add_node(idx, add_options[idx].sub_func); members_dialog->hide(); @@ -2249,6 +2261,12 @@ void VisualShaderEditor::_show_preview_text() { } } +static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) { + + RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable); + return RS::global_variable_type_get_shader_datatype(gvt); +} + void VisualShaderEditor::_update_preview() { if (!preview_showed) { @@ -2262,7 +2280,7 @@ void VisualShaderEditor::_update_preview() { ShaderLanguage sl; - Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types()); + Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type); for (int i = 0; i < preview_text->get_line_count(); i++) { preview_text->set_line_as_marked(i, false); @@ -2297,7 +2315,7 @@ void VisualShaderEditor::_bind_methods() { ClassDB::bind_method("_is_available", &VisualShaderEditor::_is_available); } -VisualShaderEditor *VisualShaderEditor::singleton = NULL; +VisualShaderEditor *VisualShaderEditor::singleton = nullptr; VisualShaderEditor::VisualShaderEditor() { @@ -2489,13 +2507,10 @@ VisualShaderEditor::VisualShaderEditor() { members_dialog->get_ok()->set_text(TTR("Create")); members_dialog->get_ok()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create)); members_dialog->get_ok()->set_disabled(true); - members_dialog->set_resizable(true); - members_dialog->set_as_minsize(); - members_dialog->connect("hide", callable_mp(this, &VisualShaderEditor::_member_cancel)); + members_dialog->connect("cancelled", callable_mp(this, &VisualShaderEditor::_member_cancel)); add_child(members_dialog); alert = memnew(AcceptDialog); - alert->set_as_minsize(); alert->get_label()->set_autowrap(true); alert->get_label()->set_align(Label::ALIGN_CENTER); alert->get_label()->set_valign(Label::VALIGN_CENTER); @@ -2669,6 +2684,38 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES)); add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES)); + // SKY INPUTS + + add_options.push_back(AddOption("AtCubeMapPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_cubemap_pass"), "at_cubemap_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("AtHalfResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_half_res_pass"), "at_half_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("AtQuarterResPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "at_quarter_res_pass"), "at_quarter_res_pass", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("EyeDir", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "eyedir"), "eyedir", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("HalfResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_color"), "half_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("HalfResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "half_res_alpha"), "half_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_color"), "light0_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_direction"), "light0_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_enabled"), "light0_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light0Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light0_energy"), "light0_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_color"), "light1_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_direction"), "light1_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_enabled"), "light1_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light1Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light1_energy"), "light1_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_color"), "light2_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_direction"), "light2_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_enabled"), "light2_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light2Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light2_energy"), "light2_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_color"), "light3_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Direction", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_direction"), "light3_direction", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Enabled", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_enabled"), "light3_enabled", VisualShaderNode::PORT_TYPE_BOOLEAN, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Light3Energy", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "light3_energy"), "light3_energy", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Position", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "position"), "position", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("QuarterResColor", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_color"), "quarter_res_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("QuarterResAlpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "quarter_res_alpha"), "quarter_res_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Radiance", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "radiance"), "radiance", VisualShaderNode::PORT_TYPE_SAMPLER, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("SkyCoords", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "sky_coords"), "sky_coords", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + add_options.push_back(AddOption("Time", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_shader_mode, "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SKY)); + // SCALAR add_options.push_back(AddOption("FloatFunc", "Scalar", "Common", "VisualShaderNodeFloatFunc", TTR("Float function."), -1, VisualShaderNode::PORT_TYPE_SCALAR)); @@ -2950,12 +2997,12 @@ public: void setup(const Ref<VisualShaderNodeInput> &p_input) { input = p_input; Ref<Texture2D> type_icon[6] = { - EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_icon("int", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"), - EditorNode::get_singleton()->get_gui_base()->get_icon("ImageTexture", "EditorIcons"), + 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("Transform", "EditorIcons"), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon("ImageTexture", "EditorIcons"), }; add_item("[None]"); @@ -3099,7 +3146,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<StringName> properties = p_node->get_editable_properties(); if (properties.size() == 0) { - return NULL; + return nullptr; } List<PropertyInfo> props; @@ -3117,7 +3164,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par } if (pinfo.size() == 0) - return NULL; + return nullptr; properties.clear(); @@ -3128,7 +3175,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par EditorProperty *prop = EditorInspector::instantiate_property_editor(node.ptr(), pinfo[i].type, pinfo[i].name, pinfo[i].hint, pinfo[i].hint_string, pinfo[i].usage); if (!prop) - return NULL; + return nullptr; if (Object::cast_to<EditorPropertyResource>(prop)) { Object::cast_to<EditorPropertyResource>(prop)->set_use_sub_inspector(false); @@ -3250,7 +3297,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) { //do none } -bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) { +bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) { diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 473c1bb070..a495b09b5c 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -338,7 +338,7 @@ class EditorInspectorShaderModePlugin : public EditorInspectorPlugin { public: virtual bool can_handle(Object *p_object); virtual void parse_begin(Object *p_object); - virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage); + virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false); virtual void parse_end(); }; |