diff options
Diffstat (limited to 'editor')
325 files changed, 7536 insertions, 7366 deletions
diff --git a/editor/SCsub b/editor/SCsub index 4431166ee6..13ae85bbf0 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -1,43 +1,42 @@ #!/usr/bin/env python -Import('env') +Import("env") env.editor_sources = [] import os import os.path from platform_methods import run_in_subprocess -from compat import open_utf8 import editor_builders def _make_doc_data_class_path(to_path): # NOTE: It is safe to generate this file here, since this is still executed serially - g = open_utf8(os.path.join(to_path, "doc_data_class_path.gen.h"), "w") + g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8") g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n") g.write("struct _DocDataClassPath { const char* name; const char* path; };\n") - g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n"); + g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n") for c in sorted(env.doc_class_path): - g.write("\t{\"" + c + "\", \"" + env.doc_class_path[c] + "\"},\n") - g.write("\t{NULL, NULL}\n") + g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n') + g.write("\t{nullptr, nullptr}\n") g.write("};\n") g.close() -if env['tools']: +if env["tools"]: # Register exporters reg_exporters_inc = '#include "register_exporters.h"\n' - reg_exporters = 'void register_exporters() {\n' + reg_exporters = "void register_exporters() {\n" for e in env.platform_exporters: env.add_source_files(env.editor_sources, "#platform/" + e + "/export/export.cpp") - reg_exporters += '\tregister_' + e + '_exporter();\n' + reg_exporters += "\tregister_" + e + "_exporter();\n" reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n' - reg_exporters += '}\n' + reg_exporters += "}\n" # NOTE: It is safe to generate this file here, since this is still executed serially - with open_utf8("register_exporters.gen.cpp", "w") as f: + with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f: f.write(reg_exporters_inc) f.write(reg_exporters) @@ -51,12 +50,12 @@ if env['tools']: for d in doc_dirs: try: - for f in os.listdir(os.path.join(env.Dir('#').abspath, d)): + for f in os.listdir(os.path.join(env.Dir("#").abspath, d)): docs.append("#" + os.path.join(d, f)) except OSError: pass - _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc")) + _make_doc_data_class_path(os.path.join(env.Dir("#").abspath, "editor")) docs = sorted(docs) env.Depends("#editor/doc_data_compressed.gen.h", docs) @@ -64,29 +63,36 @@ if env['tools']: import glob - path = env.Dir('.').abspath + path = env.Dir(".").abspath - # Translations + # Editor translations tlist = glob.glob(path + "/translations/*.po") - env.Depends('#editor/translations.gen.h', tlist) - env.CommandNoCache('#editor/translations.gen.h', tlist, run_in_subprocess(editor_builders.make_translations_header)) + env.Depends("#editor/editor_translations.gen.h", tlist) + env.CommandNoCache( + "#editor/editor_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_editor_translations_header) + ) + + # Documentation translations + tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po") + env.Depends("#editor/doc_translations.gen.h", tlist) + env.CommandNoCache( + "#editor/doc_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_doc_translations_header) + ) # Fonts flist = glob.glob(path + "/../thirdparty/fonts/*.ttf") flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf")) flist.sort() - env.Depends('#editor/builtin_fonts.gen.h', flist) - env.CommandNoCache('#editor/builtin_fonts.gen.h', flist, run_in_subprocess(editor_builders.make_fonts_header)) + env.Depends("#editor/builtin_fonts.gen.h", flist) + env.CommandNoCache("#editor/builtin_fonts.gen.h", flist, run_in_subprocess(editor_builders.make_fonts_header)) env.add_source_files(env.editor_sources, "*.cpp") - SConscript('collada/SCsub') - SConscript('doc/SCsub') - SConscript('debugger/SCsub') - SConscript('fileserver/SCsub') - SConscript('icons/SCsub') - SConscript('import/SCsub') - SConscript('plugins/SCsub') + SConscript("debugger/SCsub") + SConscript("fileserver/SCsub") + SConscript("icons/SCsub") + SConscript("import/SCsub") + SConscript("plugins/SCsub") lib = env.add_library("editor", env.editor_sources) env.Prepend(LIBS=[lib]) diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index e0839a9f27..e6a020bf41 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -215,20 +215,20 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V void AnimationBezierTrackEdit::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - bezier_icon = get_icon("KeyBezierPoint", "EditorIcons"); - bezier_handle_icon = get_icon("KeyBezierHandle", "EditorIcons"); - selected_icon = get_icon("KeyBezierSelected", "EditorIcons"); + bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons"); + bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons"); + selected_icon = get_theme_icon("KeyBezierSelected", "EditorIcons"); if (handle_mode_option->get_item_count() == 0) { - handle_mode_option->add_icon_item(get_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE); - handle_mode_option->add_icon_item(get_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED); - handle_mode_option->add_icon_item(get_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR); + handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesFree", "EditorIcons"), TTR("Free"), HANDLE_MODE_FREE); + handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesBalanced", "EditorIcons"), TTR("Balanced"), HANDLE_MODE_BALANCED); + handle_mode_option->add_icon_item(get_theme_icon("BezierHandlesMirror", "EditorIcons"), TTR("Mirror"), HANDLE_MODE_MIRROR); } } if (p_what == NOTIFICATION_RESIZED) { int right_limit = get_size().width - timeline->get_buttons_width(); - int hsep = get_constant("hseparation", "ItemList"); - int vsep = get_constant("vseparation", "ItemList"); + int hsep = get_theme_constant("hseparation", "ItemList"); + int vsep = get_theme_constant("vseparation", "ItemList"); handle_mode_option->set_position(Vector2(right_limit + hsep, get_size().height - handle_mode_option->get_combined_minimum_size().height - vsep)); handle_mode_option->set_size(Vector2(timeline->get_buttons_width() - hsep * 2, handle_mode_option->get_combined_minimum_size().height)); @@ -240,15 +240,15 @@ void AnimationBezierTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } - Ref<Font> font = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); - int hsep = get_constant("hseparation", "ItemList"); - int vsep = get_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font("font", "Label"); + Color color = get_theme_color("font_color", "Label"); + int hsep = get_theme_constant("hseparation", "ItemList"); + int vsep = get_theme_constant("vseparation", "ItemList"); Color linecolor = color; linecolor.a = 0.2; @@ -258,7 +258,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { draw_line(Point2(right_limit, 0), Point2(right_limit, get_size().height), linecolor); - Ref<Texture2D> close_icon = get_icon("Close", "EditorIcons"); + Ref<Texture2D> close_icon = get_theme_icon("Close", "EditorIcons"); close_icon_rect.position = Vector2(get_size().width - close_icon->get_width() - hsep, hsep); close_icon_rect.size = close_icon->get_size(); @@ -277,7 +277,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { NodePath path = animation->track_get_path(track); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); @@ -340,7 +340,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { subtracks[i] = rect; } else { - Color ac = get_color("accent_color", "Editor"); + Color ac = get_theme_color("accent_color", "Editor"); ac.a = 0.5; draw_rect(rect, ac); } @@ -349,7 +349,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { vofs += font->get_height() + vsep; } - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); { //guides float min_left_scale = font->get_height() + vsep; @@ -391,7 +391,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { { //draw OTHER curves float scale = timeline->get_zoom_scale(); - Ref<Texture2D> point = get_icon("KeyValue", "EditorIcons"); + Ref<Texture2D> point = get_theme_icon("KeyValue", "EditorIcons"); for (Map<int, Color>::Element *E = subtrack_colors.front(); E; E = E->next()) { _draw_track(E->key(), E->get()); @@ -410,7 +410,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } //draw edited curve - const Color highlight = get_color("highlight_color", "Editor"); + const Color highlight = get_theme_color("highlight_color", "Editor"); _draw_track(track, highlight); } @@ -540,7 +540,7 @@ void AnimationBezierTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); play_position->draw_line(Point2(px, 0), Point2(px, h), color); } } @@ -657,9 +657,9 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(bezier_icon, TTR("Insert Key Here"), MENU_KEY_INSERT); if (selection.size()) { menu->add_separator(); - menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Selected Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Selected Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); @@ -1076,7 +1076,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { undo_redo->create_action(TTR("Anim Duplicate Keys")); - List<Pair<int, float> > new_selection_values; + List<Pair<int, float>> new_selection_values; for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { @@ -1103,7 +1103,7 @@ void AnimationBezierTrackEdit::duplicate_selection() { //reselect duplicated selection.clear(); - for (List<Pair<int, float> >::Element *E = new_selection_values.front(); E; E = E->next()) { + for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { int track = E->get().first; float time = E->get().second; @@ -1162,11 +1162,11 @@ void AnimationBezierTrackEdit::_bind_methods() { } AnimationBezierTrackEdit::AnimationBezierTrackEdit() { - undo_redo = NULL; - timeline = NULL; - root = NULL; - menu = NULL; - block_animation_update_ptr = NULL; + undo_redo = nullptr; + timeline = nullptr; + root = nullptr; + menu = nullptr; + block_animation_update_ptr = nullptr; moving_selection_attempt = false; moving_selection = false; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 095dbd6849..f10e439f10 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -31,13 +31,13 @@ #include "animation_track_editor.h" #include "animation_track_editor_plugins.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "editor/animation_bezier_editor.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "servers/audio/audio_stream.h" class AnimationTrackKeyEdit : public Object { @@ -242,7 +242,7 @@ public: args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, NULL, 0, err); + args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; @@ -693,7 +693,7 @@ public: key_ofs = 0; track = -1; setting = false; - root_path = NULL; + root_path = nullptr; } }; @@ -752,7 +752,7 @@ public: if (animation != p_anim) return; - for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) { + for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { for (List<float>::Element *F = E->value().front(); F; F = F->next()) { @@ -777,7 +777,7 @@ public: bool update_obj = false; bool change_notify_deserved = false; - for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) { + for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); for (List<float>::Element *F = E->value().front(); F; F = F->next()) { @@ -905,7 +905,7 @@ public: args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, NULL, 0, err); + args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; @@ -1060,7 +1060,7 @@ public: bool _get(const StringName &p_name, Variant &r_ret) const { - for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) { + for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); for (List<float>::Element *F = E->value().front(); F; F = F->next()) { @@ -1208,7 +1208,7 @@ public: bool show_time = true; bool same_track_type = true; bool same_key_type = true; - for (Map<int, List<float> >::Element *E = key_ofs_map.front(); E; E = E->next()) { + for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { int track = E->key(); ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -1362,7 +1362,7 @@ public: Ref<Animation> animation; - Map<int, List<float> > key_ofs_map; + Map<int, List<float>> key_ofs_map; Map<int, NodePath> base_map; PropertyInfo hint; @@ -1389,7 +1389,7 @@ public: AnimationMultiTrackKeyEdit() { use_fps = false; setting = false; - root_path = NULL; + root_path = nullptr; } }; @@ -1402,7 +1402,7 @@ void AnimationTimelineEdit::_zoom_changed(double) { float AnimationTimelineEdit::get_zoom_scale() const { - float zv = zoom->get_value(); + float zv = zoom->get_max() - zoom->get_value(); if (zv < 1) { zv = 1.0 - zv; return Math::pow(1.0f + zv, 8.0f) * 100; @@ -1442,11 +1442,11 @@ void AnimationTimelineEdit::_anim_loop_pressed() { int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_icon("TrackContinuous", "EditorIcons"); - Ref<Texture2D> interp_type = get_icon("InterpRaw", "EditorIcons"); - Ref<Texture2D> loop_type = get_icon("InterpWrapClamp", "EditorIcons"); - Ref<Texture2D> remove_icon = get_icon("Remove", "EditorIcons"); - Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons"); + Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons"); + Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons"); + Ref<Texture2D> remove_icon = get_theme_icon("Remove", "EditorIcons"); + Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); int total_w = interp_mode->get_width() + interp_type->get_width() + loop_type->get_width() + remove_icon->get_width(); total_w += (down_icon->get_width() + 4 * EDSCALE) * 4; @@ -1456,7 +1456,7 @@ int AnimationTimelineEdit::get_buttons_width() const { int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1468,17 +1468,17 @@ int AnimationTimelineEdit::get_name_limit() const { void AnimationTimelineEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - add_track->set_icon(get_icon("Add", "EditorIcons")); - loop->set_icon(get_icon("Loop", "EditorIcons")); - time_icon->set_texture(get_icon("Time", "EditorIcons")); + add_track->set_icon(get_theme_icon("Add", "EditorIcons")); + loop->set_icon(get_theme_icon("Loop", "EditorIcons")); + time_icon->set_texture(get_theme_icon("Time", "EditorIcons")); add_track->get_popup()->clear(); - add_track->get_popup()->add_icon_item(get_icon("KeyValue", "EditorIcons"), TTR("Property Track")); - add_track->get_popup()->add_icon_item(get_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track")); - add_track->get_popup()->add_icon_item(get_icon("KeyCall", "EditorIcons"), TTR("Call Method Track")); - add_track->get_popup()->add_icon_item(get_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track")); - add_track->get_popup()->add_icon_item(get_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track")); - add_track->get_popup()->add_icon_item(get_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyValue", "EditorIcons"), TTR("Property Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyXform", "EditorIcons"), TTR("3D Transform Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyCall", "EditorIcons"), TTR("Call Method Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyBezier", "EditorIcons"), TTR("Bezier Curve Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyAudio", "EditorIcons"), TTR("Audio Playback Track")); + add_track->get_popup()->add_icon_item(get_theme_icon("KeyAnimation", "EditorIcons"), TTR("Animation Playback Track")); } if (p_what == NOTIFICATION_RESIZED) { @@ -1493,8 +1493,8 @@ void AnimationTimelineEdit::_notification(int p_what) { if (!animation.is_valid()) return; - Ref<Font> font = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); + Color color = get_theme_color("font_color", "Label"); int zoomw = key_range; float scale = get_zoom_scale(); @@ -1504,7 +1504,7 @@ void AnimationTimelineEdit::_notification(int p_what) { if (l <= 0) l = 0.001; //avoid crashor - Ref<Texture2D> hsize_icon = get_icon("Hsize", "EditorIcons"); + Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); hsize_rect = Rect2(get_name_limit() - hsize_icon->get_width() - 2 * EDSCALE, (get_size().height - hsize_icon->get_height()) / 2, hsize_icon->get_width(), hsize_icon->get_height()); draw_texture(hsize_icon, hsize_rect.position); @@ -1554,7 +1554,7 @@ void AnimationTimelineEdit::_notification(int p_what) { int end_px = (l - get_value()) * scale; int begin_px = -get_value() * scale; - Color notimecol = get_color("dark_color_2", "Editor"); + Color notimecol = get_theme_color("dark_color_2", "Editor"); Color timecolor = color; timecolor.a = 0.2; Color linecolor = color; @@ -1685,9 +1685,9 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { Size2 AnimationTimelineEdit::get_minimum_size() const { Size2 ms = add_track->get_minimum_size(); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); ms.height = MAX(ms.height, font->get_height()); - ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_icon("Hsize", "EditorIcons")->get_width() + 2; + ms.width = get_buttons_width() + add_track->get_minimum_size().width + get_theme_icon("Hsize", "EditorIcons")->get_width() + 2; return ms; } @@ -1746,11 +1746,11 @@ void AnimationTimelineEdit::_play_position_draw() { int px = (-get_value() + play_position_pos) * scale + get_name_limit(); if (px >= get_name_limit() && px < (play_position->get_size().width - get_buttons_width())) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); play_position->draw_texture( - get_icon("TimelineIndicator", "EditorIcons"), - Point2(px - get_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), + get_theme_icon("TimelineIndicator", "EditorIcons"), + Point2(px - get_theme_icon("TimelineIndicator", "EditorIcons")->get_width() * 0.5, 0), color); } } @@ -1859,7 +1859,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { use_fps = false; editing = false; name_limit = 150 * EDSCALE; - zoom = NULL; + zoom = nullptr; play_position_pos = 0; play_position = memnew(Control); @@ -1921,23 +1921,23 @@ void AnimationTrackEdit::_notification(int p_what) { int limit = timeline->get_name_limit(); if (has_focus()) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); accent.a *= 0.7; // Offside so the horizontal sides aren't cutoff. draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false); } - Ref<Font> font = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); + Color color = get_theme_color("font_color", "Label"); Ref<Texture2D> type_icons[6] = { - get_icon("KeyValue", "EditorIcons"), - get_icon("KeyXform", "EditorIcons"), - get_icon("KeyCall", "EditorIcons"), - get_icon("KeyBezier", "EditorIcons"), - get_icon("KeyAudio", "EditorIcons"), - get_icon("KeyAnimation", "EditorIcons") + get_theme_icon("KeyValue", "EditorIcons"), + get_theme_icon("KeyXform", "EditorIcons"), + get_theme_icon("KeyCall", "EditorIcons"), + get_theme_icon("KeyBezier", "EditorIcons"), + get_theme_icon("KeyAudio", "EditorIcons"), + get_theme_icon("KeyAnimation", "EditorIcons") }; - int hsep = get_constant("hseparation", "ItemList"); + int hsep = get_theme_constant("hseparation", "ItemList"); Color linecolor = color; linecolor.a = 0.2; @@ -1945,7 +1945,7 @@ void AnimationTrackEdit::_notification(int p_what) { { - Ref<Texture2D> check = animation->track_is_enabled(track) ? get_icon("checked", "CheckBox") : get_icon("unchecked", "CheckBox"); + Ref<Texture2D> check = animation->track_is_enabled(track) ? get_theme_icon("checked", "CheckBox") : get_theme_icon("unchecked", "CheckBox"); int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. @@ -1958,7 +1958,7 @@ void AnimationTrackEdit::_notification(int p_what) { ofs += type_icon->get_width() + hsep; NodePath path = animation->track_get_path(track); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); } @@ -1966,7 +1966,7 @@ void AnimationTrackEdit::_notification(int p_what) { String text; Color text_color = color; if (node && EditorNode::get_singleton()->get_editor_selection()->is_selected(node)) { - text_color = get_color("accent_color", "Editor"); + text_color = get_theme_color("accent_color", "Editor"); } if (in_group) { @@ -2045,25 +2045,25 @@ void AnimationTrackEdit::_notification(int p_what) { { Ref<Texture2D> wrap_icon[2] = { - get_icon("InterpWrapClamp", "EditorIcons"), - get_icon("InterpWrapLoop", "EditorIcons"), + get_theme_icon("InterpWrapClamp", "EditorIcons"), + get_theme_icon("InterpWrapLoop", "EditorIcons"), }; Ref<Texture2D> interp_icon[3] = { - get_icon("InterpRaw", "EditorIcons"), - get_icon("InterpLinear", "EditorIcons"), - get_icon("InterpCubic", "EditorIcons") + get_theme_icon("InterpRaw", "EditorIcons"), + get_theme_icon("InterpLinear", "EditorIcons"), + get_theme_icon("InterpCubic", "EditorIcons") }; Ref<Texture2D> cont_icon[4] = { - get_icon("TrackContinuous", "EditorIcons"), - get_icon("TrackDiscrete", "EditorIcons"), - get_icon("TrackTrigger", "EditorIcons"), - get_icon("TrackCapture", "EditorIcons") + get_theme_icon("TrackContinuous", "EditorIcons"), + get_theme_icon("TrackDiscrete", "EditorIcons"), + get_theme_icon("TrackTrigger", "EditorIcons"), + get_theme_icon("TrackCapture", "EditorIcons") }; int ofs = get_size().width - timeline->get_buttons_width(); - Ref<Texture2D> down_icon = get_icon("select_arrow", "Tree"); + Ref<Texture2D> down_icon = get_theme_icon("select_arrow", "Tree"); draw_line(Point2(ofs, 0), Point2(ofs, get_size().height), linecolor, Math::round(EDSCALE)); @@ -2100,7 +2100,7 @@ void AnimationTrackEdit::_notification(int p_what) { update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect = Rect2(); } else if (animation->track_get_type(track) == Animation::TYPE_BEZIER) { - Ref<Texture2D> bezier_icon = get_icon("EditBezier", "EditorIcons"); + Ref<Texture2D> bezier_icon = get_theme_icon("EditBezier", "EditorIcons"); update_mode_rect.size.x += down_icon->get_width(); bezier_edit_rect.position = update_mode_rect.position + (update_mode_rect.size - bezier_icon->get_size()) / 2; bezier_edit_rect.size = bezier_icon->get_size(); @@ -2185,7 +2185,7 @@ void AnimationTrackEdit::_notification(int p_what) { { //erase - Ref<Texture2D> icon = get_icon("Remove", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon("Remove", "EditorIcons"); remove_rect.position.x = ofs + ((get_size().width - ofs) - icon->get_width()) / 2; remove_rect.position.y = int(get_size().height - icon->get_height()) / 2; @@ -2202,7 +2202,7 @@ void AnimationTrackEdit::_notification(int p_what) { } if (dropping_at != 0) { - Color drop_color = get_color("accent_color", "Editor"); + Color drop_color = get_theme_color("accent_color", "Editor"); if (dropping_at < 0) { draw_line(Vector2(0, 0), Vector2(get_size().width, 0), drop_color, Math::round(EDSCALE)); } else { @@ -2249,7 +2249,7 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, if (current != next) return; - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); color.a = 0.5; int from_x = MAX(p_x, p_clip_left); @@ -2273,15 +2273,15 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool const Variant &v = animation->track_get_key_value(track, p_index); Variant::Type valid_type = Variant::NIL; if (!_is_value_key_valid(v, valid_type)) { - icon_to_draw = get_icon("KeyInvalid", "EditorIcons"); + icon_to_draw = get_theme_icon("KeyInvalid", "EditorIcons"); } } Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { - Ref<Font> font = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); + Color color = get_theme_color("font_color", "Label"); color.a = 0.5; Dictionary d = animation->track_get_key_value(track, p_index); @@ -2387,19 +2387,19 @@ void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animati update(); Ref<Texture2D> type_icons[6] = { - get_icon("KeyValue", "EditorIcons"), - get_icon("KeyXform", "EditorIcons"), - get_icon("KeyCall", "EditorIcons"), - get_icon("KeyBezier", "EditorIcons"), - get_icon("KeyAudio", "EditorIcons"), - get_icon("KeyAnimation", "EditorIcons") + get_theme_icon("KeyValue", "EditorIcons"), + get_theme_icon("KeyXform", "EditorIcons"), + get_theme_icon("KeyCall", "EditorIcons"), + get_theme_icon("KeyBezier", "EditorIcons"), + get_theme_icon("KeyAudio", "EditorIcons"), + get_theme_icon("KeyAnimation", "EditorIcons") }; ERR_FAIL_INDEX(track, animation->get_track_count()); node_path = animation->track_get_path(p_track); type_icon = type_icons[animation->track_get_type(track)]; - selected_icon = get_icon("KeySelected", "EditorIcons"); + selected_icon = get_theme_icon("KeySelected", "EditorIcons"); } NodePath AnimationTrackEdit::get_path() const { @@ -2408,9 +2408,9 @@ NodePath AnimationTrackEdit::get_path() const { Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_icon("Object", "EditorIcons"); - Ref<Font> font = get_font("font", "Label"); - int separation = get_constant("vseparation", "ItemList"); + Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons"); + Ref<Font> font = get_theme_font("font", "Label"); + int separation = get_theme_constant("vseparation", "ItemList"); int max_h = MAX(texture->get_height(), font->get_height()); max_h = MAX(max_h, get_key_height()); @@ -2442,7 +2442,7 @@ void AnimationTrackEdit::_play_position_draw() { int px = (-timeline->get_value() + play_position_pos) * scale + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE)); } } @@ -2471,6 +2471,7 @@ void AnimationTrackEdit::_path_entered(const String &p_text) { undo_redo->add_do_method(animation.ptr(), "track_set_path", track, p_text); undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); undo_redo->commit_action(); + path_popup->hide(); } bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const { @@ -2482,7 +2483,7 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant Vector<StringName> leftover_path; Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path); - Object *obj = NULL; + Object *obj = nullptr; if (res.is_valid()) { obj = res.ptr(); } else if (node) { @@ -2689,14 +2690,14 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); - menu->add_icon_item(get_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); - menu->add_icon_item(get_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); - menu->add_icon_item(get_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE); + menu->add_icon_item(get_theme_icon("TrackContinuous", "EditorIcons"), TTR("Continuous"), MENU_CALL_MODE_CONTINUOUS); + menu->add_icon_item(get_theme_icon("TrackDiscrete", "EditorIcons"), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); + menu->add_icon_item(get_theme_icon("TrackTrigger", "EditorIcons"), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); + menu->add_icon_item(get_theme_icon("TrackCapture", "EditorIcons"), TTR("Capture"), MENU_CALL_MODE_CAPTURE); menu->set_as_minsize(); - Vector2 popup_pos = get_global_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); - menu->set_global_position(popup_pos); + Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); + menu->set_position(popup_pos); menu->popup(); accept_event(); } @@ -2708,13 +2709,13 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); - menu->add_icon_item(get_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR); - menu->add_icon_item(get_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); + menu->add_icon_item(get_theme_icon("InterpRaw", "EditorIcons"), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); + menu->add_icon_item(get_theme_icon("InterpLinear", "EditorIcons"), TTR("Linear"), MENU_INTERPOLATION_LINEAR); + menu->add_icon_item(get_theme_icon("InterpCubic", "EditorIcons"), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); menu->set_as_minsize(); - Vector2 popup_pos = get_global_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); - menu->set_global_position(popup_pos); + Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); + menu->set_position(popup_pos); menu->popup(); accept_event(); } @@ -2726,12 +2727,12 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { menu->connect("id_pressed", callable_mp(this, &AnimationTrackEdit::_menu_selected)); } menu->clear(); - menu->add_icon_item(get_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); - menu->add_icon_item(get_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); + menu->add_icon_item(get_theme_icon("InterpWrapClamp", "EditorIcons"), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); + menu->add_icon_item(get_theme_icon("InterpWrapLoop", "EditorIcons"), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); menu->set_as_minsize(); - Vector2 popup_pos = get_global_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height); - menu->set_global_position(popup_pos); + Vector2 popup_pos = get_screen_position() + loop_mode_rect.position + Vector2(0, loop_mode_rect.size.height); + menu->set_position(popup_pos); menu->popup(); accept_event(); } @@ -2822,17 +2823,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } menu->clear(); - menu->add_icon_item(get_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT); + menu->add_icon_item(get_theme_icon("Key", "EditorIcons"), TTR("Insert Key"), MENU_KEY_INSERT); if (editor->is_selection_active()) { menu->add_separator(); - menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); + menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate Key(s)"), MENU_KEY_DUPLICATE); menu->add_separator(); - menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE); + menu->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete Key(s)"), MENU_KEY_DELETE); } menu->set_as_minsize(); - Vector2 popup_pos = get_global_transform().xform(get_local_mouse_position()); - menu->set_global_position(popup_pos); + Vector2 popup_pos = get_screen_transform().xform(get_local_mouse_position()); + menu->set_position(popup_pos); menu->popup(); insert_at_pos = offset + timeline->get_value(); @@ -2843,17 +2844,20 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && clicking_on_name) { if (!path) { + path_popup = memnew(Popup); + path_popup->set_wrap_controls(true); + add_child(path_popup); path = memnew(LineEdit); - add_child(path); - path->set_as_toplevel(true); + path_popup->add_child(path); + path->set_anchors_and_margins_preset(PRESET_WIDE); path->connect("text_entered", callable_mp(this, &AnimationTrackEdit::_path_entered)); } path->set_text(animation->track_get_path(track)); - Vector2 theme_ofs = path->get_stylebox("normal", "LineEdit")->get_offset(); - path->set_position(get_global_position() + path_rect.position - theme_ofs); - path->set_size(path_rect.size); - path->show_modal(); + Vector2 theme_ofs = path->get_theme_stylebox("normal", "LineEdit")->get_offset(); + path_popup->set_position(get_screen_position() + path_rect.position - theme_ofs); + path_popup->set_size(path_rect.size); + path_popup->popup(); path->grab_focus(); path->set_cursor_position(path->get_text().length()); clicking_on_name = false; @@ -3086,11 +3090,12 @@ void AnimationTrackEdit::_bind_methods() { } AnimationTrackEdit::AnimationTrackEdit() { - undo_redo = NULL; - timeline = NULL; - root = NULL; - path = NULL; - menu = NULL; + undo_redo = nullptr; + timeline = nullptr; + root = nullptr; + path = nullptr; + path_popup = nullptr; + menu = nullptr; clicking_on_name = false; dropping_at = 0; @@ -3135,7 +3140,7 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_ Callable::CallError ce; return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_value_track_edit", (const Variant **)&argptrs, 6, ce).operator Object *()); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditPlugin::create_audio_track_edit() { @@ -3143,14 +3148,14 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_audio_track_edit() { if (get_script_instance()) { return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_audio_track_edit").operator Object *()); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object *p_object) { if (get_script_instance()) { return Object::cast_to<AnimationTrackEdit>(get_script_instance()->call("create_animation_track_edit", p_object).operator Object *()); } - return NULL; + return nullptr; } /////////////////////////////////////// @@ -3158,18 +3163,18 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object void AnimationTrackEditGroup::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_font("font", "Label"); - int separation = get_constant("hseparation", "ItemList"); - Color color = get_color("font_color", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); + int separation = get_theme_constant("hseparation", "ItemList"); + Color color = get_theme_color("font_color", "Label"); if (root && root->has_node(node)) { Node *n = root->get_node(node); if (n && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { - color = get_color("accent_color", "Editor"); + color = get_theme_color("accent_color", "Editor"); } } - Color bgcol = get_color("dark_color_2", "Editor"); + Color bgcol = get_theme_color("dark_color_2", "Editor"); bgcol.a *= 0.6; draw_rect(Rect2(Point2(), get_size()), bgcol); Color linecolor = color; @@ -3187,7 +3192,7 @@ void AnimationTrackEditGroup::_notification(int p_what) { int px = (-timeline->get_value() + timeline->get_play_position()) * timeline->get_zoom_scale() + timeline->get_name_limit(); if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_line(Point2(px, 0), Point2(px, get_size().height), accent, Math::round(2 * EDSCALE)); } } @@ -3203,8 +3208,8 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co Size2 AnimationTrackEditGroup::get_minimum_size() const { - Ref<Font> font = get_font("font", "Label"); - int separation = get_constant("vseparation", "ItemList"); + Ref<Font> font = get_theme_font("font", "Label"); + int separation = get_theme_constant("vseparation", "ItemList"); return Vector2(0, MAX(font->get_height(), icon->get_height()) + separation); } @@ -3299,7 +3304,7 @@ Ref<Animation> AnimationTrackEditor::get_current_animation() const { } void AnimationTrackEditor::_root_removed(Node *p_root) { - root = NULL; + root = nullptr; } void AnimationTrackEditor::set_root(Node *p_root) { @@ -3443,7 +3448,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { if (insert_frame != Engine::get_singleton()->get_frames_drawn()) { //clear insert list for the frame if frame changed - if (insert_confirm->is_visible_in_tree()) + if (insert_confirm->is_visible()) return; //do nothing insert_data.clear(); insert_query = false; @@ -3496,7 +3501,7 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { insert_confirm_bezier->set_visible(all_bezier); insert_confirm->get_ok()->set_text(TTR("Create")); - insert_confirm->popup_centered_minsize(); + insert_confirm->popup_centered(); insert_query = true; } else { call_deferred("_insert_delay"); @@ -3549,7 +3554,7 @@ void AnimationTrackEditor::_insert_delay() { insert_queue = false; } -void AnimationTrackEditor::insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform) { +void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) { if (!keying) return; @@ -3897,7 +3902,7 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b return PropertyInfo(); } -static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool *r_valid = NULL) { +static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool *r_valid = nullptr) { Vector<String> subindices; if (r_valid) { *r_valid = true; @@ -4095,7 +4100,7 @@ bool AnimationTrackEditor::is_selection_active() const { } bool AnimationTrackEditor::is_snap_enabled() const { - return snap->is_pressed() ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL); + return snap->is_pressed() ^ InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL); } void AnimationTrackEditor::_update_tracks() { @@ -4118,7 +4123,7 @@ void AnimationTrackEditor::_update_tracks() { bool use_filter = selected_filter->is_pressed(); for (int i = 0; i < animation->get_track_count(); i++) { - AnimationTrackEdit *track_edit = NULL; + AnimationTrackEdit *track_edit = nullptr; //find hint and info for plugin @@ -4179,7 +4184,7 @@ void AnimationTrackEditor::_update_tracks() { if (animation->track_get_type(i) == Animation::TYPE_ANIMATION) { NodePath path = animation->track_get_path(i); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); } @@ -4194,7 +4199,7 @@ void AnimationTrackEditor::_update_tracks() { } } - if (track_edit == NULL) { + if (track_edit == nullptr) { //no valid plugin_found track_edit = memnew(AnimationTrackEdit); } @@ -4207,7 +4212,7 @@ void AnimationTrackEditor::_update_tracks() { if (!group_sort.has(base_path)) { AnimationTrackEditGroup *g = memnew(AnimationTrackEditGroup); - Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); String name = base_path; String tooltip; if (root && root->has_node(base_path)) { @@ -4225,7 +4230,7 @@ void AnimationTrackEditor::_update_tracks() { g->set_timeline(timeline); groups.push_back(g); VBoxContainer *vb = memnew(VBoxContainer); - vb->add_constant_override("separation", 0); + vb->add_theme_constant_override("separation", 0); vb->add_child(g); track_vbox->add_child(vb); group_sort[base_path] = vb; @@ -4368,12 +4373,12 @@ MenuButton *AnimationTrackEditor::get_edit_menu() { void AnimationTrackEditor::_notification(int p_what) { if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { - zoom_icon->set_texture(get_icon("Zoom", "EditorIcons")); - snap->set_icon(get_icon("Snap", "EditorIcons")); - view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); - selected_filter->set_icon(get_icon("AnimationFilter", "EditorIcons")); - imported_anim_warning->set_icon(get_icon("NodeWarning", "EditorIcons")); - main_panel->add_style_override("panel", get_stylebox("bg", "Tree")); + zoom_icon->set_texture(get_theme_icon("Zoom", "EditorIcons")); + snap->set_icon(get_theme_icon("Snap", "EditorIcons")); + view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); + selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); + imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); } if (p_what == NOTIFICATION_READY) { @@ -4441,8 +4446,8 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { ERR_FAIL_COND(!node); NodePath path_to = root->get_path_to(node); - if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Spatial")) { - EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to Spatial-based nodes.")); + if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Node3D")) { + EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to 3D-based nodes.")); return; } @@ -4633,10 +4638,10 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key.")); return; } - Spatial *base = Object::cast_to<Spatial>(root->get_node(animation->track_get_path(p_track))); + Node3D *base = Object::cast_to<Node3D>(root->get_node(animation->track_get_path(p_track))); if (!base) { - EditorNode::get_singleton()->show_warning(TTR("Track is not of type Spatial, can't insert key")); + EditorNode::get_singleton()->show_warning(TTR("Track is not of type Node3D, can't insert key")); return; } @@ -4747,7 +4752,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { params.push_back(arg); } else { Callable::CallError ce; - Variant arg = Variant::construct(E->get().arguments[i].type, NULL, 0, ce); + Variant arg = Variant::construct(E->get().arguments[i].type, nullptr, 0, ce); params.push_back(arg); } } @@ -4833,21 +4838,21 @@ void AnimationTrackEditor::_clear_key_edit() { if (key_edit) { //if key edit is the object being inspected, remove it first if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == key_edit) { - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } //then actually delete it memdelete(key_edit); - key_edit = NULL; + key_edit = nullptr; } if (multi_key_edit) { if (EditorNode::get_singleton()->get_inspector()->get_edited_object() == multi_key_edit) { - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } memdelete(multi_key_edit); - multi_key_edit = NULL; + multi_key_edit = nullptr; } } @@ -4892,7 +4897,7 @@ void AnimationTrackEditor::_update_key_edit() { multi_key_edit = memnew(AnimationMultiTrackKeyEdit); multi_key_edit->animation = animation; - Map<int, List<float> > key_ofs_map; + Map<int, List<float>> key_ofs_map; Map<int, NodePath> base_map; int first_track = -1; for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) { @@ -5050,8 +5055,8 @@ float AnimationTrackEditor::get_moving_selection_offset() const { void AnimationTrackEditor::_box_selection_draw() { const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); - box_selection->draw_rect(selection_rect, get_color("box_selection_fill_color", "Editor")); - box_selection->draw_rect(selection_rect, get_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); + box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor")); + box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { @@ -5186,7 +5191,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { undo_redo->create_action(TTR("Anim Duplicate Keys")); - List<Pair<int, float> > new_selection_values; + List<Pair<int, float>> new_selection_values; for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { @@ -5224,7 +5229,7 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //reselect duplicated Map<SelectedKey, KeyInfo> new_selection; - for (List<Pair<int, float> >::Element *E = new_selection_values.front(); E; E = E->next()) { + for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { int track = E->get().first; float time = E->get().second; @@ -5259,17 +5264,17 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { for (int i = 0; i < animation->get_track_count(); i++) { NodePath path = animation->track_get_path(i); - Node *node = NULL; + Node *node = nullptr; if (root && root->has_node(path)) { node = root->get_node(path); } String text; - Ref<Texture2D> icon = get_icon("Node", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon("Node", "EditorIcons"); if (node) { - if (has_icon(node->get_class(), "EditorIcons")) { - icon = get_icon(node->get_class(), "EditorIcons"); + if (has_theme_icon(node->get_class(), "EditorIcons")) { + icon = get_theme_icon(node->get_class(), "EditorIcons"); } text = node->get_name(); @@ -5309,7 +5314,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { it->set_metadata(0, md); } - track_copy_dialog->popup_centered_minsize(Size2(350, 500) * EDSCALE); + track_copy_dialog->popup_centered(Size2(350, 500) * EDSCALE); } break; case EDIT_COPY_TRACKS_CONFIRM: { @@ -5356,7 +5361,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->create_action(TTR("Paste Tracks")); for (int i = 0; i < track_clipboard.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", track_clipboard[i].track_type); - Node *exists = NULL; + Node *exists = nullptr; NodePath path = track_clipboard[i].base_path; if (root) { @@ -5578,7 +5583,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } break; case EDIT_CLEAN_UP_ANIMATION: { - cleanup_dialog->popup_centered_minsize(Size2(300, 0) * EDSCALE); + cleanup_dialog->popup_centered(Size2(300, 0) * EDSCALE); } break; case EDIT_CLEAN_UP_ANIMATION_CONFIRM: { @@ -5602,7 +5607,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { bool prop_exists = false; Variant::Type valid_type = Variant::NIL; - Object *obj = NULL; + Object *obj = nullptr; RES res; Vector<StringName> leftover_path; @@ -5652,7 +5657,7 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { void AnimationTrackEditor::_view_group_toggle() { _update_tracks(); - view_group->set_icon(get_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); + view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); } bool AnimationTrackEditor::is_grouping_tracks() { @@ -5748,7 +5753,7 @@ void AnimationTrackEditor::_bind_methods() { } AnimationTrackEditor::AnimationTrackEditor() { - root = NULL; + root = nullptr; undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -5763,7 +5768,7 @@ AnimationTrackEditor::AnimationTrackEditor() { timeline_scroll->add_child(timeline_vbox); timeline_vbox->set_v_size_flags(SIZE_EXPAND_FILL); timeline_vbox->set_h_size_flags(SIZE_EXPAND_FILL); - timeline_vbox->add_constant_override("separation", 0); + timeline_vbox->add_theme_constant_override("separation", 0); info_message = memnew(Label); info_message->set_text(TTR("Select an AnimationPlayer node to create and edit animations.")); @@ -5814,7 +5819,7 @@ AnimationTrackEditor::AnimationTrackEditor() { track_vbox->set_h_size_flags(SIZE_EXPAND_FILL); scroll->set_enable_h_scroll(false); scroll->set_enable_v_scroll(true); - track_vbox->add_constant_override("separation", 0); + track_vbox->add_theme_constant_override("separation", 0); HBoxContainer *bottom_hb = memnew(HBoxContainer); add_child(bottom_hb); @@ -5940,8 +5945,8 @@ AnimationTrackEditor::AnimationTrackEditor() { icvb->add_child(insert_confirm_bezier); keying = false; moving_selection = 0; - key_edit = NULL; - multi_key_edit = NULL; + key_edit = nullptr; + multi_key_edit = nullptr; box_selection = memnew(Control); add_child(box_selection); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 26f9c15f6c..96a60cc135 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -140,6 +140,7 @@ class AnimationTrackEdit : public Control { }; AnimationTimelineEdit *timeline; UndoRedo *undo_redo; + Popup *path_popup; LineEdit *path; Node *root; Control *play_position; //separate control used to draw so updates for only position changed are much faster @@ -378,7 +379,7 @@ class AnimationTrackEditor : public VBoxContainer { void _root_removed(Node *p_root); - PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = NULL); + PropertyInfo _find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val = nullptr); void _timeline_value_changed(double); @@ -430,7 +431,7 @@ class AnimationTrackEditor : public VBoxContainer { Rect2 box_select_rect; void _scroll_input(const Ref<InputEvent> &p_event); - Vector<Ref<AnimationTrackEditPlugin> > track_edit_plugins; + Vector<Ref<AnimationTrackEditPlugin>> track_edit_plugins; void _cancel_bezier_edit(); void _bezier_edit(int p_for_track); @@ -512,7 +513,7 @@ public: void set_anim_pos(float p_pos); void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false); void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance); - void insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform); + void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform); void show_select_node_warning(bool p_show); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index fc47a69a2c..695c294ad2 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -33,8 +33,8 @@ #include "editor/audio_stream_preview.h" #include "editor_resource_preview.h" #include "editor_scale.h" -#include "scene/2d/animated_sprite.h" -#include "scene/2d/sprite.h" +#include "scene/2d/animated_sprite_2d.h" +#include "scene/2d/sprite_2d.h" #include "scene/3d/sprite_3d.h" #include "scene/animation/animation_player.h" #include "servers/audio/audio_stream.h" @@ -42,12 +42,12 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - Ref<Texture2D> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); return checked->get_height(); } Rect2 AnimationTrackEditBool::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Texture2D> checked = get_icon("checked", "CheckBox"); + Ref<Texture2D> checked = get_theme_icon("checked", "CheckBox"); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } @@ -58,7 +58,7 @@ bool AnimationTrackEditBool::is_key_selectable_by_distance() const { void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { bool checked = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Texture2D> icon = get_icon(checked ? "checked" : "unchecked", "CheckBox"); + Ref<Texture2D> icon = get_theme_icon(checked ? "checked" : "unchecked", "CheckBox"); Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2); @@ -71,7 +71,7 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, draw_texture(icon, ofs); if (p_selected) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); draw_rect_clipped(Rect2(ofs, icon->get_size()), color, false); } } @@ -80,12 +80,12 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, int AnimationTrackEditColor::get_key_height() const { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return font->get_height() * 0.8; } Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; return Rect2(-fh / 2, 0, fh, get_size().height); } @@ -97,7 +97,7 @@ bool AnimationTrackEditColor::is_key_selectable_by_distance() const { void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = (font->get_height() * 0.8); int x_from = p_x + fh / 2 - 1; @@ -146,7 +146,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, Color color = get_animation()->track_get_key_value(get_track(), p_index); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; Rect2 rect(Vector2(p_x - fh / 2, int(get_size().height - fh) / 2), Size2(fh, fh)); @@ -158,7 +158,7 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, draw_rect_clipped(rect, color); if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect_clipped(rect, accent, false); } } @@ -185,7 +185,7 @@ int AnimationTrackEditAudio::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { @@ -218,7 +218,7 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -279,7 +279,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, if (to_x <= from_x) return; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); float fh = int(font->get_height() * 1.5); Rect2 rect = Rect2(from_x, (get_size().height - fh) / 2, to_x - from_x, fh); draw_rect(rect, Color(0.25, 0.25, 0.25)); @@ -303,22 +303,22 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, Vector<Color> color; color.push_back(Color(0.75, 0.75, 0.75)); - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); draw_rect(rect, color); if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } @@ -344,7 +344,7 @@ int AnimationTrackEditSpriteFrame::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return int(font->get_height() * 2); } Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) { @@ -357,7 +357,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se Size2 size; - if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { + if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) { Ref<Texture2D> texture = object->call("get_texture"); if (!texture.is_valid()) { @@ -379,7 +379,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se if (vframes > 1) { size.y /= vframes; } - } else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) { + } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) { Ref<SpriteFrames> sf = object->call("get_sprite_frames"); if (sf.is_null()) { @@ -413,7 +413,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se size = size.floor(); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int height = int(font->get_height() * 2); int width = height * size.width / size.height; @@ -436,7 +436,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in Ref<Texture2D> texture; Rect2 region; - if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) { + if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) { texture = object->call("get_texture"); if (!texture.is_valid()) { @@ -473,7 +473,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.position.x += region.size.x * coords.x; region.position.y += region.size.y * coords.y; - } else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) { + } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) { Ref<SpriteFrames> sf = object->call("get_sprite_frames"); if (sf.is_null()) { @@ -507,7 +507,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.size = texture->get_size(); } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int height = int(font->get_height() * 2); int width = height * region.size.width / region.size.height; @@ -520,7 +520,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in if (rect.position.x > p_clip_right) return; - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); Color bg = accent; bg.a = 0.15; @@ -551,7 +551,7 @@ int AnimationTrackEditSubAnim::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { @@ -580,7 +580,7 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -633,12 +633,12 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ if (to_x <= from_x) return; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -673,7 +673,7 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (lines.size() > 2) { - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); } int limit = to_x - from_x - 4; @@ -682,19 +682,19 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); draw_rect(rect, color); if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } @@ -709,13 +709,13 @@ void AnimationTrackEditSubAnim::set_node(Object *p_object) { int AnimationTrackEditVolumeDB::get_key_height() const { - Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); return volume_texture->get_height() * 1.2; } void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -727,7 +727,7 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; int db0 = y_from + (24 / 80.0) * tex_h; @@ -762,12 +762,12 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, to_x = p_clip_right; } - Ref<Texture2D> volume_texture = get_icon("ColorTrackVu", "EditorIcons"); + Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); color.a *= 0.7; draw_line(Point2(from_x, y_from + h * tex_h), Point2(to_x, y_from + h_n * tex_h), color, 2); @@ -790,7 +790,7 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { int AnimationTrackEditTypeAudio::get_key_height() const { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) { @@ -854,7 +854,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); float fh = int(font->get_height() * 1.5); float len = stream->get_length(); @@ -926,9 +926,9 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int Vector<Color> color; color.push_back(Color(0.75, 0.75, 0.75)); - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, color); - Color cut_color = get_color("accent_color", "Editor"); + Color cut_color = get_theme_color("accent_color", "Editor"); cut_color.a = 0.7; if (start_ofs > 0 && pixel_begin > p_clip_left) { draw_rect(Rect2(pixel_begin, rect.position.y, 1, rect.size.y), cut_color); @@ -938,7 +938,7 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int } if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } @@ -1133,7 +1133,7 @@ int AnimationTrackEditTypeAnimation::get_key_height() const { return AnimationTrackEdit::get_key_height(); } - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) { @@ -1162,7 +1162,7 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_ return Rect2(0, 0, len * p_pixels_sec, get_size().height); } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; return Rect2(0, 0, fh, get_size().height); } @@ -1215,12 +1215,12 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, if (to_x <= from_x) return; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 1.5; Rect2 rect(from_x, int(get_size().height - fh) / 2, to_x - from_x, fh); - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); Color bg = color; bg.r = 1 - color.r; bg.g = 1 - color.g; @@ -1255,7 +1255,7 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (lines.size() > 2) { - VS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); + RS::get_singleton()->canvas_item_add_multiline(get_canvas_item(), lines, colorv); } int limit = to_x - from_x - 4; @@ -1264,19 +1264,19 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } else { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); - Color color = get_color("font_color", "Label"); + Color color = get_theme_color("font_color", "Label"); draw_rect(rect, color); if (p_selected) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); draw_rect(rect, accent, false); } } @@ -1300,14 +1300,14 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj return audio; } - if (p_property == "frame" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite") || p_object->is_class("AnimatedSprite3D"))) { + if (p_property == "frame" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite2D") || p_object->is_class("AnimatedSprite3D"))) { AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame); sprite->set_node(p_object); return sprite; } - if (p_property == "frame_coords" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D"))) { + if (p_property == "frame_coords" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D"))) { AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame); sprite->set_as_coords(); @@ -1335,7 +1335,7 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj return memnew(AnimationTrackEditColor); } - return NULL; + return nullptr; } AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_audio_track_edit() { diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index f14b12b132..9f6785ec06 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -43,7 +43,7 @@ Variant ArrayPropertyEdit::get_array() const { Variant arr = o->get(property); if (!arr.is_array()) { Callable::CallError ce; - arr = Variant::construct(default_type, NULL, 0, ce); + arr = Variant::construct(default_type, nullptr, 0, ce); } return arr; } @@ -110,7 +110,7 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { new_type = arr.get(size - 1).get_type(); } if (new_type != Variant::NIL) { - init = Variant::construct(new_type, NULL, 0, ce); + init = Variant::construct(new_type, nullptr, 0, ce); for (int i = size; i < newsize; i++) { ur->add_do_method(this, "_set_value", i, init); } @@ -140,7 +140,7 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { Variant value = arr.get(idx); if (value.get_type() != type && type >= 0 && type < Variant::VARIANT_MAX) { Callable::CallError ce; - Variant new_value = Variant::construct(Variant::Type(type), NULL, 0, ce); + Variant new_value = Variant::construct(Variant::Type(type), nullptr, 0, ce); UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Array Value Type")); diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 64d435a901..fe28c913a7 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -212,7 +212,7 @@ void AudioStreamPreviewGenerator::_bind_methods() { ADD_SIGNAL(MethodInfo("preview_updated", PropertyInfo(Variant::INT, "obj_id"))); } -AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = NULL; +AudioStreamPreviewGenerator *AudioStreamPreviewGenerator::singleton = nullptr; void AudioStreamPreviewGenerator::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { @@ -221,7 +221,7 @@ void AudioStreamPreviewGenerator::_notification(int p_what) { if (!E->get().generating) { if (E->get().thread) { Thread::wait_to_finish(E->get().thread); - E->get().thread = NULL; + E->get().thread = nullptr; } if (!ObjectDB::get_instance(E->key())) { //no longer in use, get rid of preview to_erase.push_back(E->key()); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index ddd702fc6c..77e20b971c 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -30,7 +30,7 @@ #include "code_editor.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "core/string_builder.h" #include "editor/editor_scale.h" @@ -69,10 +69,10 @@ GotoLineDialog::GotoLineDialog() { set_title(TTR("Go to Line")); 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); Label *l = memnew(Label); @@ -82,7 +82,7 @@ GotoLineDialog::GotoLineDialog() { line = memnew(LineEdit); vbc->add_child(line); register_text_enter(line); - text_editor = NULL; + text_editor = nullptr; set_hide_on_ok(false); } @@ -91,25 +91,25 @@ void FindReplaceBar::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - find_prev->set_icon(get_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); + find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); + hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { set_process_unhandled_input(is_visible_in_tree()); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - find_prev->set_icon(get_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); + find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); + hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); } } @@ -226,6 +226,10 @@ void FindReplaceBar::_replace_all() { text_edit->begin_complex_operation(); + if (selection_enabled && is_selection_only()) { + text_edit->cursor_set_line(selection_begin.width); + text_edit->cursor_set_column(selection_begin.height); + } if (search_current()) { do { // replace area @@ -243,7 +247,7 @@ void FindReplaceBar::_replace_all() { if (selection_enabled && is_selection_only()) { if (match_from < selection_begin || match_to > selection_end) { - continue; + break; // Done. } // Replace but adjust selection bounds. @@ -277,7 +281,7 @@ void FindReplaceBar::_replace_all() { } text_edit->set_v_scroll(vsval); - matches_label->add_color_override("font_color", rc > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", rc > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); matches_label->set_text(vformat(TTR("%d replaced."), rc)); text_edit->call_deferred("connect", "text_changed", Callable(this, "_editor_text_changed")); @@ -289,6 +293,10 @@ void FindReplaceBar::_get_search_from(int &r_line, int &r_col) { r_line = text_edit->cursor_get_line(); r_col = text_edit->cursor_get_column(); + if (text_edit->is_selection_active() && is_selection_only()) { + return; + } + if (r_line == result_line && r_col >= result_col && r_col <= result_col + get_search_text().length()) { r_col = result_col; } @@ -331,7 +339,7 @@ void FindReplaceBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } @@ -505,7 +513,7 @@ void FindReplaceBar::_search_text_changed(const String &p_text) { void FindReplaceBar::_search_text_entered(const String &p_text) { - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { search_prev(); } else { search_next(); @@ -517,7 +525,7 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) { if (selection_only->is_pressed() && text_edit->is_selection_active()) { _replace_all(); _hide_bar(); - } else if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + } else if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { _replace(); search_prev(); } else { @@ -712,7 +720,7 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMagnifyGesture> magnify_gesture = p_event; if (magnify_gesture.is_valid()) { - Ref<DynamicFont> font = text_editor->get_font("font"); + Ref<DynamicFont> font = text_editor->get_theme_font("font"); if (font.is_valid()) { if (font->get_size() != (int)font_size) { @@ -760,7 +768,7 @@ void CodeTextEditor::_zoom_changed() { } void CodeTextEditor::_reset_zoom() { - Ref<DynamicFont> font = text_editor->get_font("font"); // Reset source font size to default. + Ref<DynamicFont> font = text_editor->get_theme_font("font"); // Reset source font size to default. if (font.is_valid()) { EditorSettings::get_singleton()->set("interface/editor/code_font_size", 14); @@ -828,41 +836,41 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp Ref<Texture2D> tex; switch (p_option.kind) { case ScriptCodeCompletionOption::KIND_CLASS: { - if (has_icon(p_option.display, "EditorIcons")) { - tex = get_icon(p_option.display, "EditorIcons"); + if (has_theme_icon(p_option.display, "EditorIcons")) { + tex = get_theme_icon(p_option.display, "EditorIcons"); } else { - tex = get_icon("Object", "EditorIcons"); + tex = get_theme_icon("Object", "EditorIcons"); } } break; case ScriptCodeCompletionOption::KIND_ENUM: - tex = get_icon("Enum", "EditorIcons"); + tex = get_theme_icon("Enum", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_FILE_PATH: - tex = get_icon("File", "EditorIcons"); + tex = get_theme_icon("File", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_NODE_PATH: - tex = get_icon("NodePath", "EditorIcons"); + tex = get_theme_icon("NodePath", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_VARIABLE: - tex = get_icon("Variant", "EditorIcons"); + tex = get_theme_icon("Variant", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_CONSTANT: - tex = get_icon("MemberConstant", "EditorIcons"); + tex = get_theme_icon("MemberConstant", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_MEMBER: - tex = get_icon("MemberProperty", "EditorIcons"); + tex = get_theme_icon("MemberProperty", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_SIGNAL: - tex = get_icon("MemberSignal", "EditorIcons"); + tex = get_theme_icon("MemberSignal", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_FUNCTION: - tex = get_icon("MemberMethod", "EditorIcons"); + tex = get_theme_icon("MemberMethod", "EditorIcons"); break; case ScriptCodeCompletionOption::KIND_PLAIN_TEXT: - tex = get_icon("CubeMesh", "EditorIcons"); + tex = get_theme_icon("CubeMesh", "EditorIcons"); break; default: - tex = get_icon("String", "EditorIcons"); + tex = get_theme_icon("String", "EditorIcons"); break; } return tex; @@ -877,7 +885,7 @@ void CodeTextEditor::_font_resize_timeout() { bool CodeTextEditor::_add_font_size(int p_delta) { - Ref<DynamicFont> font = text_editor->get_font("font"); + Ref<DynamicFont> font = text_editor->get_theme_font("font"); if (font.is_valid()) { int new_size = CLAMP(font->get_size() + p_delta, 8 * EDSCALE, 96 * EDSCALE); @@ -1454,18 +1462,18 @@ void CodeTextEditor::goto_error() { void CodeTextEditor::_update_font() { - text_editor->add_font_override("font", get_font("source", "EditorFonts")); + text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); - error->add_font_override("font", get_font("status_source", "EditorFonts")); - error->add_color_override("font_color", get_color("error_color", "Editor")); + error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); + error->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); - Ref<Font> status_bar_font = get_font("status_source", "EditorFonts"); - error->add_font_override("font", status_bar_font); + Ref<Font> status_bar_font = get_theme_font("status_source", "EditorFonts"); + error->add_theme_font_override("font", status_bar_font); int count = status_bar->get_child_count(); for (int i = 0; i < count; i++) { Control *n = Object::cast_to<Control>(status_bar->get_child(i)); if (n) - n->add_font_override("font", status_bar_font); + n->add_theme_font_override("font", status_bar_font); } } @@ -1516,7 +1524,7 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) { } void CodeTextEditor::_toggle_scripts_pressed() { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); } void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) { @@ -1540,8 +1548,8 @@ void CodeTextEditor::_notification(int p_what) { _update_font(); } break; case NOTIFICATION_ENTER_TREE: { - warning_button->set_icon(get_icon("NodeWarning", "EditorIcons")); - add_constant_override("separation", 4 * EDSCALE); + warning_button->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + add_theme_constant_override("separation", 4 * EDSCALE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { if (toggle_scripts_button->is_visible()) { @@ -1650,13 +1658,13 @@ void CodeTextEditor::show_toggle_scripts_button() { } void CodeTextEditor::update_toggle_scripts_button() { - toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons")); + toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_theme_icon("Back", "EditorIcons") : get_theme_icon("Forward", "EditorIcons")); toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")"); } CodeTextEditor::CodeTextEditor() { - code_complete_func = NULL; + code_complete_func = nullptr; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS); ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0); @@ -1729,8 +1737,8 @@ CodeTextEditor::CodeTextEditor() { warning_count_label->set_default_cursor_shape(CURSOR_POINTING_HAND); warning_count_label->set_mouse_filter(MOUSE_FILTER_STOP); warning_count_label->set_tooltip(TTR("Warnings")); - warning_count_label->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor")); - warning_count_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + warning_count_label->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("warning_color", "Editor")); + warning_count_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); warning_count_label->connect("gui_input", callable_mp(this, &CodeTextEditor::_warning_label_gui_input)); is_warnings_panel_opened = false; @@ -1740,7 +1748,7 @@ CodeTextEditor::CodeTextEditor() { line_and_col_txt = memnew(Label); status_bar->add_child(line_and_col_txt); line_and_col_txt->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER); - line_and_col_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + line_and_col_txt->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("status_source", "EditorFonts")); line_and_col_txt->set_tooltip(TTR("Line and column numbers.")); line_and_col_txt->set_mouse_filter(MOUSE_FILTER_STOP); diff --git a/editor/collada/SCsub b/editor/collada/SCsub deleted file mode 100644 index 2b1e889fb0..0000000000 --- a/editor/collada/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index eea92fb7ed..bef5c3c2b0 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -40,7 +40,7 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { if (p_node != p_root && p_node->get_owner() != p_root) { - return NULL; + return nullptr; } if (!p_node->get_script().is_null()) { return p_node; @@ -54,7 +54,7 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { } } - return NULL; + return nullptr; } class ConnectDialogBinds : public Object { @@ -115,7 +115,7 @@ void ConnectDialog::ok_pressed() { if (dst_method->get_text() == "") { error->set_text(TTR("Method in target node must be specified.")); - error->popup_centered_minsize(); + error->popup_centered(); return; } Node *target = tree->get_selected(); @@ -125,7 +125,7 @@ void ConnectDialog::ok_pressed() { if (target->get_script().is_null()) { if (!target->has_method(dst_method->get_text())) { error->set_text(TTR("Target method not found. Specify a valid method or attach a script to the target node.")); - error->popup_centered_minsize(); + error->popup_centered(); return; } } @@ -315,7 +315,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { source = static_cast<Node *>(c.source); signal = c.signal; - tree->set_selected(NULL); + tree->set_selected(nullptr); tree->set_marked(source, true); if (c.target) { @@ -341,7 +341,7 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { void ConnectDialog::popup_dialog(const String &p_for_signal) { from_signal->set_text(p_for_signal); - error_label->add_color_override("font_color", get_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor")); if (!advanced->is_pressed()) error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root())); @@ -351,14 +351,14 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) { void ConnectDialog::_advanced_pressed() { if (advanced->is_pressed()) { - set_custom_minimum_size(Size2(900, 500) * EDSCALE); + set_min_size(Size2(900, 500) * EDSCALE); connect_to_label->set_text(TTR("Connect to Node:")); tree->set_connect_to_script_mode(false); vbc_right->show(); error_label->hide(); } else { - set_custom_minimum_size(Size2(600, 500) * EDSCALE); + set_min_size(Size2(600, 500) * EDSCALE); set_size(Size2()); connect_to_label->set_text(TTR("Connect to Script:")); tree->set_connect_to_script_mode(true); @@ -369,23 +369,23 @@ void ConnectDialog::_advanced_pressed() { _update_ok_enabled(); - set_position((get_viewport_rect().size - get_custom_minimum_size()) / 2); + popup_centered(); } ConnectDialog::ConnectDialog() { - set_custom_minimum_size(Size2(600, 500) * EDSCALE); + set_min_size(Size2(600, 500) * EDSCALE); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); HBoxContainer *main_hb = memnew(HBoxContainer); vbc->add_child(main_hb); - main_hb->set_v_size_flags(SIZE_EXPAND_FILL); + main_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); VBoxContainer *vbc_left = memnew(VBoxContainer); main_hb->add_child(vbc_left); - vbc_left->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL); from_signal = memnew(LineEdit); from_signal->set_editable(false); @@ -407,13 +407,13 @@ ConnectDialog::ConnectDialog() { vbc_right = memnew(VBoxContainer); main_hb->add_child(vbc_right); - vbc_right->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_right->set_h_size_flags(Control::SIZE_EXPAND_FILL); vbc_right->hide(); HBoxContainer *add_bind_hb = memnew(HBoxContainer); type_list = memnew(OptionButton); - type_list->set_h_size_flags(SIZE_EXPAND_FILL); + type_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_bind_hb->add_child(type_list); type_list->add_item("bool", Variant::BOOL); type_list->add_item("int", Variant::INT); @@ -451,7 +451,7 @@ ConnectDialog::ConnectDialog() { vbc_left->add_margin_child(TTR("Receiver Method:"), dstm_hb); dst_method = memnew(LineEdit); - dst_method->set_h_size_flags(SIZE_EXPAND_FILL); + dst_method->set_h_size_flags(Control::SIZE_EXPAND_FILL); dst_method->connect("text_entered", callable_mp(this, &ConnectDialog::_text_entered)); dstm_hb->add_child(dst_method); @@ -477,8 +477,6 @@ ConnectDialog::ConnectDialog() { oneshot->set_tooltip(TTR("Disconnects the signal after its first emission.")); vbc_right->add_child(oneshot); - set_as_toplevel(true); - cdbinds = memnew(ConnectDialogBinds); error = memnew(AcceptDialog); @@ -499,7 +497,7 @@ ConnectDialog::~ConnectDialog() { Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); + help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); String text = TTR("Signal:") + " [u][b]" + p_text.get_slice("::", 0) + "[/b][/u]"; @@ -576,7 +574,7 @@ void ConnectionsDock::_make_or_edit_connection() { } // IMPORTANT NOTE: _disconnect and _connect cause an update_tree, which will delete the object "it" is pointing to. - it = NULL; + it = nullptr; if (add_script_function) { editor->emit_signal("script_add_function_request", target, cToMake.method, script_function_args); @@ -909,24 +907,24 @@ void ConnectionsDock::update_tree() { else name = scr->get_class(); - if (has_icon(scr->get_class(), "EditorIcons")) { - icon = get_icon(scr->get_class(), "EditorIcons"); + if (has_theme_icon(scr->get_class(), "EditorIcons")) { + icon = get_theme_icon(scr->get_class(), "EditorIcons"); } } } else { ClassDB::get_signal_list(base, &node_signals2, true); - if (has_icon(base, "EditorIcons")) { - icon = get_icon(base, "EditorIcons"); + if (has_theme_icon(base, "EditorIcons")) { + icon = get_theme_icon(base, "EditorIcons"); } name = base; } if (!icon.is_valid()) { - icon = get_icon("Object", "EditorIcons"); + icon = get_theme_icon("Object", "EditorIcons"); } - TreeItem *pitem = NULL; + TreeItem *pitem = nullptr; if (node_signals2.size()) { pitem = tree->create_item(root); @@ -934,7 +932,7 @@ void ConnectionsDock::update_tree() { pitem->set_icon(0, icon); pitem->set_selectable(0, false); pitem->set_editable(0, false); - pitem->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); + pitem->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); node_signals2.sort(); } @@ -970,14 +968,14 @@ void ConnectionsDock::update_tree() { sinfo["name"] = signal_name; sinfo["args"] = argnames; item->set_metadata(0, sinfo); - item->set_icon(0, get_icon("Signal", "EditorIcons")); + item->set_icon(0, get_theme_icon("Signal", "EditorIcons")); // Set tooltip with the signal's documentation. { String descr; bool found = false; - Map<StringName, Map<StringName, String> >::Element *G = descr_cache.find(base); + Map<StringName, Map<StringName, String>>::Element *G = descr_cache.find(base); if (G) { Map<StringName, String>::Element *F = G->get().find(signal_name); if (F) { @@ -992,7 +990,7 @@ void ConnectionsDock::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().signals.size(); i++) { if (F->get().signals[i].name == signal_name.operator String()) { - descr = F->get().signals[i].description.strip_edges(); + descr = DTR(F->get().signals[i].description.strip_edges()); break; } } @@ -1045,7 +1043,7 @@ void ConnectionsDock::update_tree() { item2->set_text(0, path); Connection cd = c; item2->set_metadata(0, cd); - item2->set_icon(0, get_icon("Slot", "EditorIcons")); + item2->set_icon(0, get_theme_icon("Slot", "EditorIcons")); } } @@ -1072,7 +1070,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { tree->set_select_mode(Tree::SELECT_ROW); tree->set_hide_root(true); 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); connect_button = memnew(Button); @@ -1083,11 +1081,9 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { connect_button->connect("pressed", callable_mp(this, &ConnectionsDock::_connect_pressed)); connect_dialog = memnew(ConnectDialog); - connect_dialog->set_as_toplevel(true); add_child(connect_dialog); disconnect_all_dialog = memnew(ConfirmationDialog); - disconnect_all_dialog->set_as_toplevel(true); add_child(disconnect_all_dialog); disconnect_all_dialog->connect("confirmed", callable_mp(this, &ConnectionsDock::_disconnect_all)); disconnect_all_dialog->set_text(TTR("Are you sure you want to remove all connections from this signal?")); @@ -1110,7 +1106,7 @@ ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { tree->connect("item_activated", callable_mp(this, &ConnectionsDock::_tree_item_activated)); tree->connect("item_rmb_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed)); - add_constant_override("separation", 3 * EDSCALE); + add_theme_constant_override("separation", 3 * EDSCALE); } ConnectionsDock::~ConnectionsDock() { diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 988a8a1271..91d0d5c32c 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -173,7 +173,7 @@ class ConnectionsDock : public VBoxContainer { PopupMenu *slot_menu; UndoRedo *undo_redo; - Map<StringName, Map<StringName, String> > descr_cache; + Map<StringName, Map<StringName, String>> descr_cache; void _make_or_edit_connection(); void _connect(ConnectDialog::ConnectionData cToMake); @@ -203,7 +203,7 @@ public: void set_node(Node *p_node); void update_tree(); - ConnectionsDock(EditorNode *p_editor = NULL); + ConnectionsDock(EditorNode *p_editor = nullptr); ~ConnectionsDock(); }; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 3e09a9a760..6cbb1b1791 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -193,7 +193,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p item->set_text(0, p_type + " (" + ScriptServer::get_global_class_path(p_type).get_file() + ")"); } if (!can_instance) { - item->set_custom_color(0, get_color("disabled_font_color", "Editor")); + item->set_custom_color(0, search_options->get_theme_color("disabled_font_color", "Editor")); item->set_selectable(0, false); } else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) { String search_term = search_box->get_text().to_lower(); @@ -248,7 +248,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p item->set_collapsed(collapse); } - const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description; + const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description); item->set_tooltip(0, description); item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, base_type)); @@ -310,11 +310,11 @@ void CreateDialog::_update_search() { EditorData &ed = EditorNode::get_editor_data(); root->set_text(0, base_type); - if (has_icon(base_type, "EditorIcons")) { - root->set_icon(0, get_icon(base_type, "EditorIcons")); + if (search_options->has_theme_icon(base_type, "EditorIcons")) { + root->set_icon(0, search_options->get_theme_icon(base_type, "EditorIcons")); } - TreeItem *to_select = search_box->get_text() == base_type ? root : NULL; + TreeItem *to_select = search_box->get_text() == base_type ? root : nullptr; for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) { @@ -417,7 +417,7 @@ void CreateDialog::_update_search() { favorite->set_pressed(favorite_list.find(to_select->get_text(0)) != -1); } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void CreateDialog::_confirmed() { @@ -460,23 +460,22 @@ void CreateDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - favorite->set_icon(get_icon("Favorites", "EditorIcons")); + favorite->set_icon(search_options->get_theme_icon("Favorites", "EditorIcons")); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) { + if (is_visible()) { search_box->call_deferred("grab_focus"); // still not visible search_box->select_all(); + } else { + EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2(get_position(), get_size())); + search_loaded_scripts.clear(); } } break; - case NOTIFICATION_POPUP_HIDE: { - EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", get_rect()); - search_loaded_scripts.clear(); - } break; } } @@ -539,7 +538,7 @@ Object *CreateDialog::instance_selected() { } } - return NULL; + return nullptr; } void CreateDialog::_item_selected() { @@ -556,13 +555,13 @@ void CreateDialog::_item_selected() { if (!EditorHelp::get_doc_data()->class_list.has(name)) return; - help_bit->set_text(EditorHelp::get_doc_data()->class_list[name].brief_description); + help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[name].brief_description)); get_ok()->set_disabled(false); } void CreateDialog::_hide_requested() { - _closed(); // From WindowDialog. + _cancel_pressed(); // From AcceptDialog. } void CreateDialog::_favorite_toggled() { @@ -662,7 +661,7 @@ Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) { ToolButton *tb = memnew(ToolButton); tb->set_icon(ti->get_icon(0)); tb->set_text(ti->get_text(0)); - set_drag_preview(tb); + favorites->set_drag_preview(tb); return d; } @@ -743,8 +742,6 @@ CreateDialog::CreateDialog() { is_replace_mode = false; - set_resizable(true); - HSplitContainer *hsc = memnew(HSplitContainer); add_child(hsc); @@ -754,7 +751,7 @@ CreateDialog::CreateDialog() { VBoxContainer *fav_vb = memnew(VBoxContainer); vsc->add_child(fav_vb); fav_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE); - fav_vb->set_v_size_flags(SIZE_EXPAND_FILL); + fav_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); favorites = memnew(Tree); fav_vb->add_margin_child(TTR("Favorites:"), favorites, true); @@ -763,13 +760,16 @@ CreateDialog::CreateDialog() { favorites->set_allow_reselect(true); favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected)); favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated)); - favorites->set_drag_forwarding(this); - favorites->add_constant_override("draw_guides", 1); +#ifndef _MSC_VER +#warning cant forward drag data to a non control, must be fixed +#endif + //favorites->set_drag_forwarding(this); + favorites->add_theme_constant_override("draw_guides", 1); VBoxContainer *rec_vb = memnew(VBoxContainer); vsc->add_child(rec_vb); rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE); - rec_vb->set_v_size_flags(SIZE_EXPAND_FILL); + rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); recent = memnew(Tree); rec_vb->add_margin_child(TTR("Recent:"), recent, true); @@ -778,15 +778,15 @@ CreateDialog::CreateDialog() { recent->set_allow_reselect(true); recent->connect("cell_selected", callable_mp(this, &CreateDialog::_history_selected)); recent->connect("item_activated", callable_mp(this, &CreateDialog::_history_activated)); - recent->add_constant_override("draw_guides", 1); + recent->add_theme_constant_override("draw_guides", 1); VBoxContainer *vbc = memnew(VBoxContainer); hsc->add_child(vbc); vbc->set_custom_minimum_size(Size2(300, 0) * EDSCALE); - vbc->set_h_size_flags(SIZE_EXPAND_FILL); + vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); HBoxContainer *search_hb = memnew(HBoxContainer); search_box = memnew(LineEdit); - search_box->set_h_size_flags(SIZE_EXPAND_FILL); + search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_hb->add_child(search_box); favorite = memnew(Button); favorite->set_flat(true); diff --git a/editor/debugger/SCsub b/editor/debugger/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/debugger/SCsub +++ b/editor/debugger/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/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 9587daf93e..00ed2bbc4c 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -125,7 +125,7 @@ void EditorDebuggerInspector::_object_selected(ObjectID p_object) { } ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { - EditorDebuggerRemoteObject *debugObj = NULL; + EditorDebuggerRemoteObject *debugObj = nullptr; SceneDebuggerObject obj; obj.deserialize(p_arr); @@ -211,7 +211,7 @@ void EditorDebuggerInspector::clear_cache() { for (Map<ObjectID, EditorDebuggerRemoteObject *>::Element *E = remote_objects.front(); E; E = E->next()) { EditorNode *editor = EditorNode::get_singleton(); if (editor->get_editor_history()->get_current() == E->value()->get_instance_id()) { - editor->push_item(NULL); + editor->push_item(nullptr); } memdelete(E->value()); } @@ -221,7 +221,7 @@ void EditorDebuggerInspector::clear_cache() { Object *EditorDebuggerInspector::get_object(ObjectID p_id) { if (remote_objects.has(p_id)) return remote_objects[p_id]; - return NULL; + return nullptr; } void EditorDebuggerInspector::add_stack_variable(const Array &p_array) { diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index f4a8102b79..3302b50103 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -47,14 +47,14 @@ void _for_all(TabContainer *p_node, const Func &p_func) { } } -EditorDebuggerNode *EditorDebuggerNode::singleton = NULL; +EditorDebuggerNode *EditorDebuggerNode::singleton = nullptr; EditorDebuggerNode::EditorDebuggerNode() { if (!singleton) singleton = this; - add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); - add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); @@ -64,7 +64,7 @@ EditorDebuggerNode::EditorDebuggerNode() { Ref<StyleBoxEmpty> empty; empty.instance(); - tabs->add_style_override("panel", empty); + tabs->add_theme_style_override("panel", empty); auto_switch_remote_scene_tree = EDITOR_DEF("debugger/auto_switch_to_remote_scene_tree", false); _add_debugger(); @@ -110,7 +110,7 @@ ScriptEditorDebugger *EditorDebuggerNode::_add_debugger() { if (tabs->get_tab_count() > 1) { node->clear_style(); tabs->set_tabs_visible(true); - tabs->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); } return node; @@ -223,10 +223,10 @@ void EditorDebuggerNode::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (tabs->get_tab_count() > 1) { - add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); - add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); + add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); + add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); - tabs->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); } } break; default: @@ -262,9 +262,9 @@ void EditorDebuggerNode::_notification(int p_what) { } else { debugger_button->set_text(TTR("Debugger") + " (" + itos(error_count + warning_count) + ")"); if (error_count == 0) { - debugger_button->set_icon(get_icon("Warning", "EditorIcons")); + debugger_button->set_icon(get_theme_icon("Warning", "EditorIcons")); } else { - debugger_button->set_icon(get_icon("Error", "EditorIcons")); + debugger_button->set_icon(get_theme_icon("Error", "EditorIcons")); } } last_error_count = error_count; @@ -291,13 +291,13 @@ void EditorDebuggerNode::_notification(int p_what) { // Take connections. if (server->is_connection_available()) { - ScriptEditorDebugger *debugger = NULL; + ScriptEditorDebugger *debugger = nullptr; _for_all(tabs, [&](ScriptEditorDebugger *dbg) { if (debugger || dbg->is_session_active()) return; debugger = dbg; }); - if (debugger == NULL) { + if (debugger == nullptr) { if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active. debugger = _add_debugger(); } else { @@ -356,7 +356,7 @@ void EditorDebuggerNode::_debugger_changed(int p_tab) { if (get_inspected_remote_object()) { // Clear inspected object, you can only inspect objects in selected debugger. // Hopefully, in the future, we will have one inspector per debugger. - EditorNode::get_singleton()->push_item(NULL); + EditorNode::get_singleton()->push_item(nullptr); } if (remote_scene_tree->is_visible_in_tree()) { get_current_debugger()->request_remote_tree(); @@ -371,7 +371,6 @@ void EditorDebuggerNode::set_script_debug_button(MenuButton *p_button) { script_menu->set_text(TTR("Debug")); script_menu->set_switch_on_hover(true); PopupMenu *p = script_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); p->add_shortcut(ED_GET_SHORTCUT("debugger/step_into"), DEBUG_STEP); p->add_shortcut(ED_GET_SHORTCUT("debugger/step_over"), DEBUG_NEXT); p->add_separator(); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 6181ccdb5f..9467442c9a 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -85,9 +85,9 @@ private: }; Ref<EditorDebuggerServer> server; - TabContainer *tabs = NULL; - Button *debugger_button = NULL; - MenuButton *script_menu = NULL; + TabContainer *tabs = nullptr; + Button *debugger_button = nullptr; + MenuButton *script_menu = nullptr; Ref<Script> stack_script; // Why?!? @@ -95,7 +95,7 @@ private: int last_warning_count = 0; float inspect_edited_object_timeout = 0; - EditorDebuggerTree *remote_scene_tree = NULL; + EditorDebuggerTree *remote_scene_tree = nullptr; float remote_scene_tree_timeout = 0.0; bool auto_switch_remote_scene_tree = false; bool debug_with_external_editor = false; diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 441f6082c3..c2b94c79bb 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -33,6 +33,7 @@ #include "editor/editor_node.h" #include "scene/debugger/scene_debugger.h" #include "scene/resources/packed_scene.h" +#include "servers/display_server.h" EditorDebuggerTree::EditorDebuggerTree() { set_v_size_flags(SIZE_EXPAND_FILL); @@ -106,9 +107,9 @@ void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { item->select(0); item_menu->clear(); - item_menu->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); - item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); - item_menu->set_global_position(get_global_mouse_position()); + item_menu->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("Save Branch as Scene"), ITEM_MENU_SAVE_REMOTE_NODE); + item_menu->add_icon_item(get_theme_icon("CopyNodePath", "EditorIcons"), TTR("Copy Node Path"), ITEM_MENU_COPY_NODE_PATH); + item_menu->set_position(get_screen_transform().xform(get_local_mouse_position())); item_menu->popup(); } @@ -132,9 +133,9 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int const String filter = EditorNode::get_singleton()->get_scene_tree_dock()->get_filter(); // Nodes are in a flatten list, depth first. Use a stack of parents, avoid recursion. - List<Pair<TreeItem *, int> > parents; + List<Pair<TreeItem *, int>> parents; for (int i = 0; i < p_tree->nodes.size(); i++) { - TreeItem *parent = NULL; + TreeItem *parent = nullptr; if (parents.size()) { // Find last parent. Pair<TreeItem *, int> &p = parents[0]; parent = p.first; @@ -190,7 +191,7 @@ void EditorDebuggerTree::update_scene_tree(const SceneDebuggerTree *p_tree, int // Check if parent expects more children. for (int j = 0; j < parents.size(); j++) { if (parents[j].first == item) { - parent = NULL; + parent = nullptr; break; // Might have more children. } } @@ -210,7 +211,7 @@ String EditorDebuggerTree::get_selected_path() { String EditorDebuggerTree::_get_path(TreeItem *p_item) { ERR_FAIL_COND_V(!p_item, ""); - if (p_item->get_parent() == NULL) { + if (p_item->get_parent() == nullptr) { return "/root"; } String text = p_item->get_text(0); @@ -229,7 +230,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { case ITEM_MENU_SAVE_REMOTE_NODE: { file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES); - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); List<String> extensions; Ref<PackedScene> sd = memnew(PackedScene); @@ -257,7 +258,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { text = text.substr(slash + 1); } } - OS::get_singleton()->set_clipboard(text); + DisplayServer::get_singleton()->clipboard_set(text); } break; } } diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index d9084bc596..342eb23194 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -50,8 +50,8 @@ private: int debugger_id = 0; bool updating_scene_tree = false; Set<ObjectID> unfold_cache; - PopupMenu *item_menu = NULL; - EditorFileDialog *file_dialog = NULL; + PopupMenu *item_menu = nullptr; + EditorFileDialog *file_dialog = nullptr; String _get_path(TreeItem *p_item); void _scene_tree_folded(Object *p_obj); diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index 21ef66d1aa..b8c795d9ca 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -41,14 +41,14 @@ void EditorNetworkProfiler::_bind_methods() { void EditorNetworkProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - activate->set_icon(get_icon("Play", "EditorIcons")); - clear_button->set_icon(get_icon("Clear", "EditorIcons")); - incoming_bandwidth_text->set_right_icon(get_icon("ArrowDown", "EditorIcons")); - outgoing_bandwidth_text->set_right_icon(get_icon("ArrowUp", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); + clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); + incoming_bandwidth_text->set_right_icon(get_theme_icon("ArrowDown", "EditorIcons")); + outgoing_bandwidth_text->set_right_icon(get_theme_icon("ArrowUp", "EditorIcons")); // This needs to be done here to set the faded color when the profiler is first opened - incoming_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); - outgoing_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); + incoming_bandwidth_text->add_theme_color_override("font_color_uneditable", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); + outgoing_bandwidth_text->add_theme_color_override("font_color_uneditable", get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); } } @@ -77,10 +77,10 @@ void EditorNetworkProfiler::_update_frame() { void EditorNetworkProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); activate->set_text(TTR("Start")); } emit_signal("enable_profiling", activate->is_pressed()); @@ -118,12 +118,12 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing))); // Make labels more prominent when the bandwidth is greater than 0 to attract user attention - incoming_bandwidth_text->add_color_override( + incoming_bandwidth_text->add_theme_color_override( "font_color_uneditable", - get_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); - outgoing_bandwidth_text->add_color_override( + get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); + outgoing_bandwidth_text->add_theme_color_override( "font_color_uneditable", - get_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); + get_theme_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); } bool EditorNetworkProfiler::is_profiling() { @@ -133,7 +133,7 @@ bool EditorNetworkProfiler::is_profiling() { EditorNetworkProfiler::EditorNetworkProfiler() { HBoxContainer *hb = memnew(HBoxContainer); - hb->add_constant_override("separation", 8 * EDSCALE); + hb->add_theme_constant_override("separation", 8 * EDSCALE); add_child(hb); activate = memnew(Button); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 2f3ad210b2..1577e24ac0 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -132,11 +132,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_color("error_color", "Editor"); + Color bc = get_theme_color("error_color", "Editor"); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_color("base_color", "Editor"), 0.07); + return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); } void EditorProfiler::_item_edited() { @@ -176,7 +176,7 @@ void EditorProfiler::_update_plot() { } uint8_t *wr = graph_image.ptrw(); - const Color background_color = get_color("dark_color_2", "Editor"); + const Color background_color = get_theme_color("dark_color_2", "Editor"); // Clear the previous frame and set the background color. for (int i = 0; i < desired_len; i += 4) { @@ -420,10 +420,10 @@ void EditorProfiler::_update_frame() { void EditorProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); } else { - activate->set_icon(get_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); activate->set_text(TTR("Start")); } emit_signal("enable_profiling", activate->is_pressed()); @@ -438,8 +438,8 @@ void EditorProfiler::_clear_pressed() { void EditorProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - activate->set_icon(get_icon("Play", "EditorIcons")); - clear_button->set_icon(get_icon("Clear", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); + clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); } } @@ -611,8 +611,8 @@ bool EditorProfiler::is_profiling() { return activate->is_pressed(); } -Vector<Vector<String> > EditorProfiler::get_data_as_csv() const { - Vector<Vector<String> > res; +Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { + Vector<Vector<String>> res; if (frame_metrics.empty()) { return res; @@ -712,7 +712,7 @@ EditorProfiler::EditorProfiler() { hb->add_child(cursor_metric_edit); cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorProfiler::_cursor_metric_changed)); - hb->add_constant_override("separation", 8 * EDSCALE); + hb->add_theme_constant_override("separation", 8 * EDSCALE); h_split = memnew(HSplitContainer); add_child(h_split); diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 0a442ddd5c..4afd2c8302 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -169,7 +169,7 @@ public: void clear(); - Vector<Vector<String> > get_data_as_csv() const; + Vector<Vector<String>> get_data_as_csv() const; EditorProfiler(); }; diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 52aa418922..d2edba5970 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -128,11 +128,11 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) { Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_color("error_color", "Editor"); + Color bc = get_theme_color("error_color", "Editor"); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; c.set_hsv(rot, bc.get_s(), bc.get_v()); - return c.linear_interpolate(get_color("base_color", "Editor"), 0.07); + return c.linear_interpolate(get_theme_color("base_color", "Editor"), 0.07); } void EditorVisualProfiler::_item_selected() { @@ -327,7 +327,7 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { int cursor_metric = _get_cursor_index(); - Ref<Texture> track_icon = get_icon("TrackColor", "EditorIcons"); + Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons"); ERR_FAIL_INDEX(cursor_metric, frame_metrics.size()); @@ -418,11 +418,11 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { void EditorVisualProfiler::_activate_pressed() { if (activate->is_pressed()) { - activate->set_icon(get_icon("Stop", "EditorIcons")); + activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); _clear_pressed(); //always clear on start } else { - activate->set_icon(get_icon("Play", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); activate->set_text(TTR("Start")); } emit_signal("enable_profiling", activate->is_pressed()); @@ -437,8 +437,8 @@ void EditorVisualProfiler::_clear_pressed() { void EditorVisualProfiler::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - activate->set_icon(get_icon("Play", "EditorIcons")); - clear_button->set_icon(get_icon("Clear", "EditorIcons")); + activate->set_icon(get_theme_icon("Play", "EditorIcons")); + clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); } } @@ -446,7 +446,7 @@ void EditorVisualProfiler::_graph_tex_draw() { if (last_metric < 0) return; - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); if (seeking) { int max_frames = frame_metrics.size(); @@ -678,8 +678,8 @@ bool EditorVisualProfiler::is_profiling() { return activate->is_pressed(); } -Vector<Vector<String> > EditorVisualProfiler::get_data_as_csv() const { - Vector<Vector<String> > res; +Vector<Vector<String>> EditorVisualProfiler::get_data_as_csv() const { + Vector<Vector<String>> res; #if 0 if (frame_metrics.empty()) { return res; @@ -777,7 +777,7 @@ EditorVisualProfiler::EditorVisualProfiler() { hb->add_child(cursor_metric_edit); cursor_metric_edit->connect("value_changed", callable_mp(this, &EditorVisualProfiler::_cursor_metric_changed)); - hb->add_constant_override("separation", 8 * EDSCALE); + hb->add_theme_constant_override("separation", 8 * EDSCALE); h_split = memnew(HSplitContainer); add_child(h_split); diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index 5194c08b96..d3a758557c 100644 --- a/editor/debugger/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h @@ -146,7 +146,7 @@ public: void clear(); - Vector<Vector<String> > get_data_as_csv() const; + Vector<Vector<String>> get_data_as_csv() const; EditorVisualProfiler(); }; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 3d567ed2b3..1971abadc4 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -42,10 +42,10 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/canvas_item_editor_plugin.h" -#include "editor/plugins/spatial_editor_plugin.h" +#include "editor/plugins/node_3d_editor_plugin.h" #include "editor/property_editor.h" #include "main/performance.h" -#include "scene/3d/camera.h" +#include "scene/3d/camera_3d.h" #include "scene/debugger/scene_debugger.h" #include "scene/gui/dialogs.h" #include "scene/gui/label.h" @@ -58,6 +58,7 @@ #include "scene/gui/texture_button.h" #include "scene/gui/tree.h" #include "scene/resources/packed_scene.h" +#include "servers/display_server.h" using CameraOverride = EditorDebuggerNode::CameraOverride; @@ -73,15 +74,15 @@ void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { void ScriptEditorDebugger::debug_copy() { String msg = reason->get_text(); if (msg == "") return; - OS::get_singleton()->set_clipboard(msg); + DisplayServer::get_singleton()->clipboard_set(msg); } void ScriptEditorDebugger::debug_skip_breakpoints() { skip_breakpoints_value = !skip_breakpoints_value; if (skip_breakpoints_value) - skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOn", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOn", "EditorIcons")); else - skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); Array msg; msg.push_back(skip_breakpoints_value); @@ -116,7 +117,7 @@ void ScriptEditorDebugger::debug_continue() { // Allow focus stealing only if we actually run this client for security. if (remote_pid && EditorNode::get_singleton()->has_child_process(remote_pid)) - OS::get_singleton()->enable_for_stealing_focus(remote_pid); + DisplayServer::get_singleton()->enable_for_stealing_focus(remote_pid); _clear_execution(); _put_msg("continue", Array()); @@ -129,15 +130,15 @@ void ScriptEditorDebugger::update_tabs() { } else { errors_tab->set_name(TTR("Errors") + " (" + itos(error_count + warning_count) + ")"); if (error_count == 0) { - tabs->set_tab_icon(errors_tab->get_index(), get_icon("Warning", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Warning", "EditorIcons")); } else { - tabs->set_tab_icon(errors_tab->get_index(), get_icon("Error", "EditorIcons")); + tabs->set_tab_icon(errors_tab->get_index(), get_theme_icon("Error", "EditorIcons")); } } } void ScriptEditorDebugger::clear_style() { - tabs->add_style_override("panel", NULL); + tabs->add_theme_style_override("panel", nullptr); } void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) { @@ -165,7 +166,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { file->store_csv_line(line); // values - List<Vector<float> >::Element *E = perf_history.back(); + List<Vector<float>>::Element *E = perf_history.back(); while (E) { Vector<float> &perf_data = E->get(); @@ -178,7 +179,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { } file->store_string("\n"); - Vector<Vector<String> > profiler_data = profiler->get_data_as_csv(); + Vector<Vector<String>> profiler_data = profiler->get_data_as_csv(); for (int i = 0; i < profiler_data.size(); i++) { file->store_csv_line(profiler_data[i]); } @@ -253,7 +254,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da _update_buttons_state(); _set_reason_text(error, MESSAGE_ERROR); emit_signal("breaked", true, can_continue); - OS::get_singleton()->move_window_to_foreground(); + DisplayServer::get_singleton()->window_move_to_foreground(); if (error != "") { tabs->set_current_tab(0); } @@ -310,8 +311,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da it->set_text(3, String::humanize_size(bytes)); total += bytes; - if (has_icon(type, "EditorIcons")) - it->set_icon(0, get_icon(type, "EditorIcons")); + if (has_theme_icon(type, "EditorIcons")) + it->set_icon(0, get_theme_icon(type, "EditorIcons")); } vmem_total->set_tooltip(TTR("Bytes:") + " " + itos(total)); @@ -442,7 +443,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da TreeItem *error = error_tree->create_item(r); error->set_collapsed(true); - error->set_icon(0, get_icon(oe.warning ? "Warning" : "Error", "EditorIcons")); + error->set_icon(0, get_theme_icon(oe.warning ? "Warning" : "Error", "EditorIcons")); error->set_text(0, time); error->set_text_align(0, TreeItem::ALIGN_LEFT); @@ -660,13 +661,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType p_type) { switch (p_type) { case MESSAGE_ERROR: - reason->add_color_override("font_color", get_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); break; case MESSAGE_WARNING: - reason->add_color_override("font_color", get_color("warning_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); break; default: - reason->add_color_override("font_color", get_color("success_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color("success_color", "Editor")); } reason->set_text(p_reason); reason->set_tooltip(p_reason.word_wrap(80)); @@ -693,8 +694,8 @@ void ScriptEditorDebugger::_performance_draw() { info_message->hide(); - Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit"); - Ref<Font> graph_font = get_font("font", "TextEdit"); + Ref<StyleBox> graph_sb = get_theme_stylebox("normal", "TextEdit"); + Ref<Font> graph_font = get_theme_font("font", "TextEdit"); int cols = Math::ceil(Math::sqrt((float)which.size())); int rows = Math::ceil((float)which.size() / cols); @@ -714,7 +715,7 @@ void ScriptEditorDebugger::_performance_draw() { r.position += graph_sb->get_offset(); r.size -= graph_sb->get_minimum_size(); int pi = which[i]; - Color c = get_color("accent_color", "Editor"); + Color c = get_theme_color("accent_color", "Editor"); float h = (float)which[i] / (float)(perf_items.size()); // Use a darker color on light backgrounds for better visibility float value_multiplier = EditorSettings::get_singleton()->is_dark_theme() ? 1.4 : 0.55; @@ -728,7 +729,7 @@ void ScriptEditorDebugger::_performance_draw() { float spacing = point_sep / float(cols); float from = r.size.width; - List<Vector<float> >::Element *E = perf_history.front(); + List<Vector<float>>::Element *E = perf_history.front(); float prev = -1; while (from >= 0 && E) { @@ -753,20 +754,20 @@ void ScriptEditorDebugger::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_icon("DebugSkipBreakpointsOff", "EditorIcons")); - copy->set_icon(get_icon("ActionCopy", "EditorIcons")); + skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); + copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); - step->set_icon(get_icon("DebugStep", "EditorIcons")); - next->set_icon(get_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_icon("DebugContinue", "EditorIcons")); + step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); + next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); + dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); + docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear)); error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); - vmem_refresh->set_icon(get_icon("Reload", "EditorIcons")); + vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); - reason->add_color_override("font_color", get_color("error_color", "Editor")); + reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); } break; case NOTIFICATION_PROCESS: { @@ -790,12 +791,12 @@ void ScriptEditorDebugger::_notification(int p_what) { } else if (camera_override >= CameraOverride::OVERRIDE_3D_1) { int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1; - SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx); - Camera *const cam = viewport->get_camera(); + Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx); + Camera3D *const cam = viewport->get_camera(); Array msg; msg.push_back(cam->get_camera_transform()); - if (cam->get_projection() == Camera::PROJECTION_ORTHOGONAL) { + if (cam->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) { msg.push_back(false); msg.push_back(cam->get_size()); } else { @@ -810,7 +811,7 @@ void ScriptEditorDebugger::_notification(int p_what) { const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; - while (peer->has_message()) { + while (peer.is_valid() && peer->has_message()) { Array arr = peer->get_message(); if (arr.size() != 2 || arr[0].get_type() != Variant::STRING || arr[1].get_type() != Variant::ARRAY) { @@ -829,16 +830,16 @@ void ScriptEditorDebugger::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - if (tabs->has_stylebox_override("panel")) { - tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); + if (tabs->has_theme_stylebox_override("panel")) { + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); } - copy->set_icon(get_icon("ActionCopy", "EditorIcons")); - step->set_icon(get_icon("DebugStep", "EditorIcons")); - next->set_icon(get_icon("DebugNext", "EditorIcons")); - dobreak->set_icon(get_icon("Pause", "EditorIcons")); - docontinue->set_icon(get_icon("DebugContinue", "EditorIcons")); - vmem_refresh->set_icon(get_icon("Reload", "EditorIcons")); + copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); + step->set_icon(get_theme_icon("DebugStep", "EditorIcons")); + next->set_icon(get_theme_icon("DebugNext", "EditorIcons")); + dobreak->set_icon(get_theme_icon("Pause", "EditorIcons")); + docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons")); + vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons")); } break; } } @@ -922,7 +923,7 @@ void ScriptEditorDebugger::stop() { res_path_cache.clear(); profiler_signature.clear(); - inspector->edit(NULL); + inspector->edit(nullptr); _update_buttons_state(); } @@ -972,13 +973,13 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { msg.push_back(frame); _put_msg("get_stack_frame_vars", msg); } else { - inspector->edit(NULL); + inspector->edit(nullptr); } } void ScriptEditorDebugger::_export_csv() { - 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->popup_centered_ratio(); } @@ -1388,7 +1389,7 @@ void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (error_tree->is_anything_selected()) { - item_menu->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), 0); + item_menu->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Error"), 0); } if (item_menu->get_item_count() > 0) { @@ -1404,9 +1405,9 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { String type; - if (ti->get_icon(0) == get_icon("Warning", "EditorIcons")) { + if (ti->get_icon(0) == get_theme_icon("Warning", "EditorIcons")) { type = "W "; - } else if (ti->get_icon(0) == get_icon("Error", "EditorIcons")) { + } else if (ti->get_icon(0) == get_theme_icon("Error", "EditorIcons")) { type = "E "; } @@ -1420,7 +1421,7 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { ci = ci->get_next(); } - OS::get_singleton()->set_clipboard(text); + DisplayServer::get_singleton()->clipboard_set(text); } void ScriptEditorDebugger::_tab_changed(int p_tab) { @@ -1461,7 +1462,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { tabs = memnew(TabContainer); tabs->set_tab_align(TabContainer::ALIGN_LEFT); - tabs->add_style_override("panel", editor->get_gui_base()->get_stylebox("DebuggerPanel", "EditorStyles")); + tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); tabs->connect("tab_changed", callable_mp(this, &ScriptEditorDebugger::_tab_changed)); add_child(tabs); diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index e7ce917543..9cb7dc2edf 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -107,9 +107,9 @@ private: Button *docontinue; // Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state. // Each debugger should have it's tree in the future I guess. - const Tree *editor_remote_tree = NULL; + const Tree *editor_remote_tree = nullptr; - List<Vector<float> > perf_history; + List<Vector<float>> perf_history; Vector<float> perf_max; Vector<TreeItem *> perf_items; @@ -255,7 +255,7 @@ public: bool is_skip_breakpoints(); virtual Size2 get_minimum_size() const; - ScriptEditorDebugger(EditorNode *p_editor = NULL); + ScriptEditorDebugger(EditorNode *p_editor = nullptr); ~ScriptEditorDebugger(); }; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 0c95a64d06..2302fb0780 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -63,7 +63,7 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { search->popup_centered_ratio(0.65); // So it doesn't completely cover the dialog below it. } -void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates) { +void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates) { for (int i = 0; i < efsd->get_subdir_count(); i++) { _fix_and_find(efsd->get_subdir(i), candidates); @@ -124,7 +124,7 @@ void DependencyEditor::_fix_all() { if (!EditorFileSystem::get_singleton()->get_filesystem()) return; - Map<String, Map<String, String> > candidates; + Map<String, Map<String, String>> candidates; for (List<String>::Element *E = missing.front(); E; E = E->next()) { @@ -140,7 +140,7 @@ void DependencyEditor::_fix_all() { Map<String, String> remaps; - for (Map<String, Map<String, String> >::Element *E = candidates.front(); E; E = E->next()) { + for (Map<String, Map<String, String>>::Element *E = candidates.front(); E; E = E->next()) { for (Map<String, String>::Element *F = E->get().front(); F; F = F->next()) { @@ -174,7 +174,7 @@ void DependencyEditor::_update_list() { TreeItem *root = tree->create_item(); - Ref<Texture2D> folder = get_icon("folder", "FileDialog"); + Ref<Texture2D> folder = tree->get_theme_icon("folder", "FileDialog"); bool broken = false; @@ -256,7 +256,7 @@ DependencyEditor::DependencyEditor() { vb->add_child(hbc); MarginContainer *mc = memnew(MarginContainer); - mc->set_v_size_flags(SIZE_EXPAND_FILL); + mc->set_v_size_flags(Control::SIZE_EXPAND_FILL); mc->add_child(tree); vb->add_child(mc); @@ -264,7 +264,7 @@ DependencyEditor::DependencyEditor() { set_title(TTR("Dependency Editor")); search = memnew(EditorFileDialog); search->connect("file_selected", callable_mp(this, &DependencyEditor::_searched)); - search->set_mode(EditorFileDialog::MODE_OPEN_FILE); + search->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); search->set_title(TTR("Search Replacement Resource:")); add_child(search); } @@ -422,17 +422,17 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed if (!tree_items.has(rd.dependency_folder)) { TreeItem *folder_item = owners->create_item(owners->get_root()); folder_item->set_text(0, rd.dependency_folder); - folder_item->set_icon(0, get_icon("Folder", "EditorIcons")); + folder_item->set_icon(0, owners->get_theme_icon("Folder", "EditorIcons")); tree_items[rd.dependency_folder] = folder_item; } TreeItem *dependency_item = owners->create_item(tree_items[rd.dependency_folder]); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, get_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); tree_items[rd.dependency] = dependency_item; } else { TreeItem *dependency_item = owners->create_item(owners->get_root()); dependency_item->set_text(0, rd.dependency); - dependency_item->set_icon(0, get_icon("Warning", "EditorIcons")); + dependency_item->set_icon(0, owners->get_theme_icon("Warning", "EditorIcons")); tree_items[rd.dependency] = dependency_item; } } @@ -580,7 +580,7 @@ DependencyRemoveDialog::DependencyRemoveDialog() { owners = memnew(Tree); owners->set_hide_root(true); vb->add_child(owners); - owners->set_v_size_flags(SIZE_EXPAND_FILL); + owners->set_v_size_flags(Control::SIZE_EXPAND_FILL); } ////////////// @@ -592,7 +592,7 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve set_title(TTR("Error loading:") + " " + p_for_file.get_file()); files->clear(); - TreeItem *root = files->create_item(NULL); + TreeItem *root = files->create_item(nullptr); for (int i = 0; i < report.size(); i++) { String dep; @@ -636,9 +636,9 @@ DependencyErrorDialog::DependencyErrorDialog() { files = memnew(Tree); files->set_hide_root(true); vb->add_margin_child(TTR("Load failed due to missing dependencies:"), files, true); - files->set_v_size_flags(SIZE_EXPAND_FILL); + files->set_v_size_flags(Control::SIZE_EXPAND_FILL); - set_custom_minimum_size(Size2(500, 220) * EDSCALE); + set_min_size(Size2(500, 220) * EDSCALE); get_ok()->set_text(TTR("Open Anyway")); get_cancel()->set_text(TTR("Close")); @@ -662,7 +662,7 @@ void OrphanResourcesDialog::ok_pressed() { return; delete_confirm->set_text(vformat(TTR("Permanently delete %d item(s)? (No undo!)"), paths.size())); - delete_confirm->popup_centered_clamped(delete_confirm->get_minimum_size()); + delete_confirm->popup_centered(); } bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) { @@ -674,11 +674,11 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa for (int i = 0; i < efsd->get_subdir_count(); i++) { - TreeItem *dir_item = NULL; + TreeItem *dir_item = nullptr; if (p_parent) { dir_item = files->create_item(p_parent); dir_item->set_text(0, efsd->get_subdir(i)->get_name()); - dir_item->set_icon(0, get_icon("folder", "FileDialog")); + dir_item->set_icon(0, files->get_theme_icon("folder", "FileDialog")); } bool children = _fill_owners(efsd->get_subdir(i), refs, dir_item); @@ -717,7 +717,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa int ds = efsd->get_file_deps(i).size(); ti->set_text(1, itos(ds)); if (ds) { - ti->add_button(1, get_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies")); + ti->add_button(1, files->get_theme_icon("GuiVisibilityVisible", "EditorIcons"), -1, false, TTR("Show Dependencies")); } ti->set_metadata(0, path); has_children = true; @@ -730,7 +730,7 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa void OrphanResourcesDialog::refresh() { HashMap<String, int> refs; - _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, NULL); + _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, nullptr); files->clear(); TreeItem *root = files->create_item(); _fill_owners(EditorFileSystem::get_singleton()->get_filesystem(), refs, root); diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index be8d34f406..ee74072731 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -52,7 +52,7 @@ class DependencyEditor : public AcceptDialog { String editing; List<String> missing; - void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates); + void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String>> &candidates); void _searched(const String &p_path); void _load_pressed(Object *p_item, int p_cell, int p_button); diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index 82db639379..7169986b14 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -96,7 +96,7 @@ Node *DictionaryPropertyEdit::get_node() { Object *o = ObjectDB::get_instance(obj); if (!o) - return NULL; + return nullptr; return cast_to<Node>(o); } diff --git a/editor/doc/SCsub b/editor/doc/SCsub deleted file mode 100644 index 2b1e889fb0..0000000000 --- a/editor/doc/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp deleted file mode 100644 index b0a89ff4b8..0000000000 --- a/editor/doc/doc_dump.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/*************************************************************************/ -/* doc_dump.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "doc_dump.h" - -#include "core/os/file_access.h" -#include "core/version.h" -#include "scene/main/node.h" - -static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { - - String tab; - for (int i = 0; i < p_tablevel; i++) - tab += "\t"; - f->store_string(tab + p_string + "\n"); -} - -struct _ConstantSort { - - String name; - int value; - bool operator<(const _ConstantSort &p_c) const { - - String left_a = name.find("_") == -1 ? name : name.substr(0, name.find("_")); - String left_b = p_c.name.find("_") == -1 ? p_c.name : p_c.name.substr(0, p_c.name.find("_")); - if (left_a == left_b) - return value < p_c.value; - else - return left_a < left_b; - } -}; - -static String _escape_string(const String &p_str) { - - String ret = p_str; - ret = ret.replace("&", "&"); - ret = ret.replace("<", ">"); - ret = ret.replace(">", "<"); - ret = ret.replace("'", "'"); - ret = ret.replace("\"", """); - for (char i = 1; i < 32; i++) { - - char chr[2] = { i, 0 }; - ret = ret.replace(chr, "&#" + String::num(i) + ";"); - } - ret = ret.utf8(); - return ret; -} -void DocDump::dump(const String &p_file) { - - List<StringName> class_list; - ClassDB::get_class_list(&class_list); - - class_list.sort_custom<StringName::AlphCompare>(); - - FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE); - - _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); - _write_string(f, 0, String("<doc version=\"") + VERSION_BRANCH + "\" name=\"Engine Types\">"); - - while (class_list.size()) { - - String name = class_list.front()->get(); - - String header = "<class name=\"" + name + "\""; - String inherits = ClassDB::get_parent_class(name); - if (inherits != "") - header += " inherits=\"" + inherits + "\""; - _write_string(f, 0, header); - - _write_string(f, 1, "<brief_description>"); - _write_string(f, 1, "</brief_description>"); - - _write_string(f, 1, "<description>"); - _write_string(f, 1, "</description>"); - - _write_string(f, 1, "<methods>"); - - List<MethodInfo> method_list; - ClassDB::get_method_list(name, &method_list, true); - method_list.sort(); - - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || E->get().name[0] == '_') - continue; //hidden - - MethodBind *m = ClassDB::get_method(name, E->get().name); - - String qualifiers; - if (E->get().flags & METHOD_FLAG_CONST) - qualifiers += "qualifiers=\"const\""; - - _write_string(f, 2, "<method name=\"" + _escape_string(E->get().name) + "\" " + qualifiers + " >"); - - for (int i = -1; i < E->get().arguments.size(); i++) { - - PropertyInfo arginfo; - - if (i == -1) { - - arginfo = E->get().return_val; - String type_name = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type); - - if (arginfo.type == Variant::NIL) - continue; - _write_string(f, 3, "<return type=\"" + type_name + "\">"); - } else { - - arginfo = E->get().arguments[i]; - - String type_name; - - if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) - type_name = arginfo.hint_string; - else if (arginfo.type == Variant::NIL) - type_name = "Variant"; - else - type_name = Variant::get_type_name(arginfo.type); - - if (m && m->has_default_argument(i)) { - Variant default_arg = m->get_default_argument(i); - String default_arg_text = String(_escape_string(m->get_default_argument(i))); - - switch (default_arg.get_type()) { - - case Variant::NIL: - default_arg_text = "NULL"; - break; - // atomic types - case Variant::BOOL: - if (bool(default_arg)) - default_arg_text = "true"; - else - default_arg_text = "false"; - break; - case Variant::INT: - case Variant::FLOAT: - //keep it - break; - case Variant::STRING: - case Variant::STRING_NAME: - default_arg_text = "@\"" + default_arg_text + "\""; - break; - case Variant::NODE_PATH: - default_arg_text = "\"" + default_arg_text + "\""; - break; - case Variant::TRANSFORM: - if (default_arg.operator Transform() == Transform()) { - default_arg_text = ""; - } - - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; - break; - - case Variant::VECTOR2: - case Variant::RECT2: - case Variant::VECTOR3: - case Variant::PLANE: - case Variant::QUAT: - case Variant::AABB: - case Variant::BASIS: - case Variant::COLOR: - case Variant::PACKED_BYTE_ARRAY: - case Variant::PACKED_INT32_ARRAY: - case Variant::PACKED_FLOAT32_ARRAY: - case Variant::PACKED_INT64_ARRAY: - case Variant::PACKED_FLOAT64_ARRAY: - case Variant::PACKED_STRING_ARRAY: - case Variant::PACKED_VECTOR3_ARRAY: - case Variant::PACKED_COLOR_ARRAY: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; - break; - case Variant::OBJECT: - case Variant::DICTIONARY: - case Variant::ARRAY: - case Variant::_RID: - - default: { - } - } - - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + _escape_string(arginfo.name) + "\" type=\"" + type_name + "\" default=\"" + _escape_string(default_arg_text) + "\">"); - } else - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + type_name + "\">"); - } - - String hint; - switch (arginfo.hint) { - case PROPERTY_HINT_DIR: hint = "A directory."; break; - case PROPERTY_HINT_RANGE: hint = "Range - min: " + arginfo.hint_string.get_slice(",", 0) + " max: " + arginfo.hint_string.get_slice(",", 1) + " step: " + arginfo.hint_string.get_slice(",", 2); break; - case PROPERTY_HINT_ENUM: - hint = "Values: "; - for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) { - if (j > 0) hint += ", "; - hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(j); - } - break; - case PROPERTY_HINT_LENGTH: hint = "Length: " + arginfo.hint_string; break; - case PROPERTY_HINT_FLAGS: - hint = "Values: "; - for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) { - if (j > 0) hint += ", "; - hint += arginfo.hint_string.get_slice(",", j) + "=" + itos((uint64_t)1 << j); - } - break; - case PROPERTY_HINT_FILE: hint = "A file:"; break; - default: { - } - //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break; - }; - if (hint != "") - _write_string(f, 4, hint); - - _write_string(f, 3, (i == -1) ? "</return>" : "</argument>"); - } - - _write_string(f, 3, "<description>"); - _write_string(f, 3, "</description>"); - - _write_string(f, 2, "</method>"); - } - - _write_string(f, 1, "</methods>"); - - List<MethodInfo> signal_list; - ClassDB::get_signal_list(name, &signal_list, true); - - if (signal_list.size()) { - - _write_string(f, 1, "<signals>"); - for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) { - - _write_string(f, 2, "<signal name=\"" + EV->get().name + "\">"); - for (int i = 0; i < EV->get().arguments.size(); i++) { - PropertyInfo arginfo = EV->get().arguments[i]; - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + Variant::get_type_name(arginfo.type) + "\">"); - _write_string(f, 3, "</argument>"); - } - _write_string(f, 3, "<description>"); - _write_string(f, 3, "</description>"); - - _write_string(f, 2, "</signal>"); - } - - _write_string(f, 1, "</signals>"); - } - - _write_string(f, 1, "<constants>"); - - List<String> constant_list; - ClassDB::get_integer_constant_list(name, &constant_list, true); - - /* constants are sorted in a special way */ - - List<_ConstantSort> constant_sort; - - for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { - _ConstantSort cs; - cs.name = E->get(); - cs.value = ClassDB::get_integer_constant(name, E->get()); - constant_sort.push_back(cs); - } - - constant_sort.sort(); - - for (List<_ConstantSort>::Element *E = constant_sort.front(); E; E = E->next()) { - - _write_string(f, 2, "<constant name=\"" + E->get().name + "\" value=\"" + itos(E->get().value) + "\">"); - _write_string(f, 2, "</constant>"); - } - - _write_string(f, 1, "</constants>"); - _write_string(f, 0, "</class>"); - - class_list.erase(name); - } - - _write_string(f, 0, "</doc>"); - f->close(); - memdelete(f); -} diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h deleted file mode 100644 index f8f1b6f805..0000000000 --- a/editor/doc/doc_dump.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* doc_dump.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef DOC_DUMP_H -#define DOC_DUMP_H - -#include "core/class_db.h" - -class DocDump { -public: - static void dump(const String &p_file); -}; - -#endif // DOC_DUMP_H diff --git a/editor/doc/doc_data.cpp b/editor/doc_data.cpp index 38ff9cd5fc..096be1fe4b 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc_data.cpp @@ -265,7 +265,7 @@ void DocData::generate(bool p_basic_types) { List<PropertyInfo>::Element *EO = own_properties.front(); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - bool inherited = EO == NULL; + bool inherited = EO == nullptr; if (EO && EO->get() == E->get()) { inherited = false; EO = EO->next(); @@ -372,7 +372,7 @@ void DocData::generate(bool p_basic_types) { if (skip_setter_getter_methods && setters_getters.has(E->get().name)) { // Don't skip parametric setters and getters, i.e. method which require // one or more parameters to define what property should be set or retrieved. - // E.g. CPUParticles::set_param(Parameter param, float value). + // E.g. CPUParticles3D::set_param(Parameter param, float value). if (E->get().arguments.size() == 0 /* getter */ || (E->get().arguments.size() == 1 && E->get().return_val.type == Variant::NIL /* setter */)) { continue; } @@ -534,7 +534,7 @@ void DocData::generate(bool p_basic_types) { c.name = cname; Callable::CallError cerror; - Variant v = Variant::construct(Variant::Type(i), NULL, 0, cerror); + Variant v = Variant::construct(Variant::Type(i), nullptr, 0, cerror); List<MethodInfo> method_list; v.get_method_list(&method_list); @@ -687,10 +687,10 @@ void DocData::generate(bool p_basic_types) { c.methods.push_back(md); } - List<Pair<String, Variant> > cinfo; + List<Pair<String, Variant>> cinfo; lang->get_public_constants(&cinfo); - for (List<Pair<String, Variant> >::Element *E = cinfo.front(); E; E = E->next()) { + for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) { ConstantDoc cd; cd.name = E->get().first; diff --git a/editor/doc/doc_data.h b/editor/doc_data.h index 073705f0b1..073705f0b1 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc_data.h diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index a223cee360..b0bcc2b448 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -37,20 +37,23 @@ #include "core/version.h" #include "core/version_hash.gen.h" +void EditorAbout::_theme_changed() { + + Control *base = EditorNode::get_singleton()->get_gui_base(); + Ref<Font> font = base->get_theme_font("source", "EditorFonts"); + _tpl_text->add_theme_font_override("normal_font", font); + _tpl_text->add_theme_constant_override("line_separation", 6 * EDSCALE); + _license_text->add_theme_font_override("normal_font", font); + _license_text->add_theme_constant_override("line_separation", 6 * EDSCALE); + _logo->set_texture(base->get_theme_icon("Logo", "EditorIcons")); +} + void EditorAbout::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: - case NOTIFICATION_THEME_CHANGED: { - - Control *base = EditorNode::get_singleton()->get_gui_base(); - Ref<Font> font = base->get_font("source", "EditorFonts"); - _tpl_text->add_font_override("normal_font", font); - _tpl_text->add_constant_override("line_separation", 6 * EDSCALE); - _license_text->add_font_override("normal_font", font); - _license_text->add_constant_override("line_separation", 6 * EDSCALE); - _logo->set_texture(base->get_icon("Logo", "EditorIcons")); + case NOTIFICATION_ENTER_TREE: { + _theme_changed(); } break; } } @@ -95,9 +98,9 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St il->set_same_column_width(true); il->set_auto_height(true); il->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); - il->add_constant_override("hseparation", 16 * EDSCALE); + il->add_theme_constant_override("hseparation", 16 * EDSCALE); while (*names_ptr) { - il->add_item(String::utf8(*names_ptr++), NULL, false); + il->add_item(String::utf8(*names_ptr++), nullptr, false); } il->set_max_columns(il->get_item_count() < 4 || single_column ? 1 : 16); vbc->add_child(il); @@ -115,13 +118,13 @@ EditorAbout::EditorAbout() { set_title(TTR("Thanks from the Godot community!")); set_hide_on_ok(true); - set_resizable(true); VBoxContainer *vbc = memnew(VBoxContainer); + vbc->connect("theme_changed", callable_mp(this, &EditorAbout::_theme_changed)); HBoxContainer *hbc = memnew(HBoxContainer); hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->set_alignment(BoxContainer::ALIGN_CENTER); - hbc->add_constant_override("separation", 30 * EDSCALE); + hbc->add_theme_constant_override("separation", 30 * EDSCALE); add_child(vbc); vbc->add_child(hbc); diff --git a/editor/editor_about.h b/editor/editor_about.h index 51438ee953..83e9e9f490 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -57,6 +57,8 @@ private: RichTextLabel *_tpl_text; TextureRect *_logo; + void _theme_changed(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 73c70f422d..74c4102003 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -85,7 +85,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { package_path = p_path; Set<String> files_sorted; - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io); @@ -102,7 +102,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { //get filename unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String name = fname; files_sorted.insert(name); @@ -110,19 +110,19 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { ret = unzGoToNextFile(pkg); } - Map<String, Ref<Texture2D> > extension_guess; + Map<String, Ref<Texture2D>> extension_guess; { - extension_guess["png"] = get_icon("ImageTexture", "EditorIcons"); - extension_guess["jpg"] = get_icon("ImageTexture", "EditorIcons"); - extension_guess["atlastex"] = get_icon("AtlasTexture", "EditorIcons"); - extension_guess["scn"] = get_icon("PackedScene", "EditorIcons"); - extension_guess["tscn"] = get_icon("PackedScene", "EditorIcons"); - extension_guess["shader"] = get_icon("Shader", "EditorIcons"); - extension_guess["gd"] = get_icon("GDScript", "EditorIcons"); - extension_guess["vs"] = get_icon("VisualScript", "EditorIcons"); + extension_guess["png"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); + extension_guess["jpg"] = tree->get_theme_icon("ImageTexture", "EditorIcons"); + extension_guess["atlastex"] = tree->get_theme_icon("AtlasTexture", "EditorIcons"); + extension_guess["scn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); + extension_guess["tscn"] = tree->get_theme_icon("PackedScene", "EditorIcons"); + extension_guess["shader"] = tree->get_theme_icon("Shader", "EditorIcons"); + extension_guess["gd"] = tree->get_theme_icon("GDScript", "EditorIcons"); + extension_guess["vs"] = tree->get_theme_icon("VisualScript", "EditorIcons"); } - Ref<Texture2D> generic_extension = get_icon("Object", "EditorIcons"); + Ref<Texture2D> generic_extension = tree->get_theme_icon("Object", "EditorIcons"); unzClose(pkg); @@ -131,7 +131,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { TreeItem *root = tree->create_item(); root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); root->set_checked(0, true); - root->set_icon(0, get_icon("folder", "FileDialog")); + root->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); root->set_text(0, "res://"); root->set_editable(0, true); Map<String, TreeItem *> dir_map; @@ -180,7 +180,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { if (isdir) { dir_map[path] = ti; ti->set_text(0, path.get_file() + "/"); - ti->set_icon(0, get_icon("folder", "FileDialog")); + ti->set_icon(0, tree->get_theme_icon("folder", "FileDialog")); ti->set_metadata(0, String()); } else { String file = path.get_file(); @@ -194,7 +194,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { String res_path = "res://" + path; if (FileAccess::exists(res_path)) { - ti->set_custom_color(0, get_color("error_color", "Editor")); + ti->set_custom_color(0, tree->get_theme_color("error_color", "Editor")); ti->set_tooltip(0, vformat(TTR("%s (Already Exists)"), res_path)); ti->set_checked(0, false); } else { @@ -212,7 +212,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { void EditorAssetInstaller::ok_pressed() { - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io); @@ -234,7 +234,7 @@ void EditorAssetInstaller::ok_pressed() { //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String name = fname; @@ -297,10 +297,10 @@ void EditorAssetInstaller::ok_pressed() { } msg += failed_files[i]; } - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(msg); } else { - if (EditorNode::get_singleton() != NULL) + if (EditorNode::get_singleton() != nullptr) EditorNode::get_singleton()->show_warning(TTR("Package installed successfully!"), TTR("Success!")); } EditorFileSystem::get_singleton()->scan_changes(); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index d77216697e..7e499facd5 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -30,8 +30,8 @@ #include "editor_audio_buses.h" +#include "core/input/input_filter.h" #include "core/io/resource_saver.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor_node.h" #include "editor_scale.h" @@ -69,27 +69,27 @@ void EditorAudioBus::_notification(int p_what) { case NOTIFICATION_READY: { for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); + channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); channel[i].prev_active = true; } - disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); + disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); Color solo_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.89, 0.22) : Color(1.0, 0.92, 0.44); Color mute_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1.0, 0.16, 0.16) : Color(1.0, 0.44, 0.44); Color bypass_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(0.13, 0.8, 1.0) : Color(0.44, 0.87, 1.0); - solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); - solo->add_color_override("icon_color_pressed", solo_color); - mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); - mute->add_color_override("icon_color_pressed", mute_color); - bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); - bypass->add_color_override("icon_color_pressed", bypass_color); + solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); + solo->add_theme_color_override("icon_color_pressed", solo_color); + mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); + mute->add_theme_color_override("icon_color_pressed", mute_color); + bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); + bypass->add_theme_color_override("icon_color_pressed", bypass_color); - bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons")); + bus_options->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); update_bus(); set_process(true); @@ -97,15 +97,15 @@ void EditorAudioBus::_notification(int p_what) { case NOTIFICATION_DRAW: { if (is_master) { - draw_style_box(get_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); } else if (has_focus()) { - draw_style_box(get_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox("focus", "Button"), Rect2(Vector2(), get_size())); } else { - draw_style_box(get_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox("panel", "TabContainer"), Rect2(Vector2(), get_size())); } if (get_index() != 0 && hovering_drop) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -168,20 +168,20 @@ void EditorAudioBus::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_l->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); - channel[i].vu_r->set_under_texture(get_icon("BusVuEmpty", "EditorIcons")); - channel[i].vu_r->set_progress_texture(get_icon("BusVuFull", "EditorIcons")); + channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); + channel[i].vu_r->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); + channel[i].vu_r->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); channel[i].prev_active = true; } - disabled_vu = get_icon("BusVuFrozen", "EditorIcons"); + disabled_vu = get_theme_icon("BusVuFrozen", "EditorIcons"); - solo->set_icon(get_icon("AudioBusSolo", "EditorIcons")); - mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); - bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); + solo->set_icon(get_theme_icon("AudioBusSolo", "EditorIcons")); + mute->set_icon(get_theme_icon("AudioBusMute", "EditorIcons")); + bypass->set_icon(get_theme_icon("AudioBusBypass", "EditorIcons")); - bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons")); + bus_options->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { @@ -325,7 +325,7 @@ void EditorAudioBus::_volume_changed(float p_normalized) { const float p_db = this->_normalized_volume_to_scaled_db(p_normalized); - if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) { // Snap the value when holding Ctrl for easier editing. // To do so, it needs to be converted back to normalized volume (as the slider uses that unit). slider->set_value(_scaled_db_to_normalized_volume(Math::round(p_db))); @@ -386,7 +386,7 @@ float EditorAudioBus::_scaled_db_to_normalized_volume(float db) { void EditorAudioBus::_show_value(float slider_value) { float db; - if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_CONTROL)) { // Display the correct (snapped) value when holding Ctrl db = Math::round(_normalized_volume_to_scaled_db(slider_value)); } else { @@ -586,7 +586,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { Panel *p = memnew(Panel); c->add_child(p); p->set_modulate(Color(1, 1, 1, 0.7)); - p->add_style_override("panel", get_stylebox("focus", "Button")); + p->add_theme_style_override("panel", get_theme_stylebox("focus", "Button")); p->set_size(get_size()); p->set_position(-p_point); set_drag_preview(c); @@ -819,10 +819,10 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty); for (int i = 0; i < hbc->get_child_count(); i++) { Control *child = Object::cast_to<Control>(hbc->get_child(i)); - child->add_style_override("normal", sbempty); - child->add_style_override("hover", sbempty); - child->add_style_override("focus", sbempty); - child->add_style_override("pressed", sbempty); + child->add_theme_style_override("normal", sbempty); + child->add_theme_style_override("hover", sbempty); + child->add_theme_style_override("focus", sbempty); + child->add_theme_style_override("pressed", sbempty); } HSeparator *separator = memnew(HSeparator); @@ -854,7 +854,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { audio_value_preview_box->set_as_toplevel(true); Ref<StyleBoxFlat> panel_style = memnew(StyleBoxFlat); panel_style->set_bg_color(Color(0.0f, 0.0f, 0.0f, 0.8f)); - audio_value_preview_box->add_style_override("panel", panel_style); + audio_value_preview_box->add_theme_style_override("panel", panel_style); audio_value_preview_box->set_mouse_filter(MOUSE_FILTER_PASS); audio_value_preview_box->hide(); @@ -953,10 +953,10 @@ void EditorAudioBusDrop::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { - draw_style_box(get_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); + draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); if (hovering_drop) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); accent.a *= 0.7; draw_rect(Rect2(Point2(), get_size()), accent, false); } @@ -1007,7 +1007,7 @@ void EditorAudioBuses::_update_buses() { memdelete(bus_hb->get_child(0)); } - drop_end = NULL; + drop_end = nullptr; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { @@ -1035,7 +1035,7 @@ void EditorAudioBuses::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - bus_scroll->add_style_override("bg", get_stylebox("bg", "Tree")); + bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } break; case NOTIFICATION_READY: { @@ -1045,7 +1045,7 @@ void EditorAudioBuses::_notification(int p_what) { if (drop_end) { drop_end->queue_delete(); - drop_end = NULL; + drop_end = nullptr; } } break; case NOTIFICATION_PROCESS: { @@ -1204,7 +1204,7 @@ void EditorAudioBuses::_select_layout() { void EditorAudioBuses::_save_as_layout() { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_title(TTR("Save Audio Bus Layout As...")); file_dialog->set_current_path(edited_path); file_dialog->popup_centered_ratio(); @@ -1213,7 +1213,7 @@ void EditorAudioBuses::_save_as_layout() { void EditorAudioBuses::_new_layout() { - file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_title(TTR("Location for New Layout...")); file_dialog->set_current_path(edited_path); file_dialog->popup_centered_ratio(); @@ -1222,7 +1222,7 @@ void EditorAudioBuses::_new_layout() { void EditorAudioBuses::_load_layout() { - file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_dialog->set_title(TTR("Open Audio Bus Layout")); file_dialog->set_current_path(edited_path); file_dialog->popup_centered_ratio(); @@ -1249,7 +1249,7 @@ void EditorAudioBuses::_load_default_layout() { void EditorAudioBuses::_file_dialog_callback(const String &p_string) { - if (file_dialog->get_mode() == EditorFileDialog::MODE_OPEN_FILE) { + if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_OPEN_FILE) { Ref<AudioBusLayout> state = ResourceLoader::load(p_string, "", true); if (state.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Invalid file, not an audio bus layout.")); @@ -1263,7 +1263,7 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { EditorNode::get_singleton()->get_undo_redo()->clear_history(); call_deferred("_select_layout"); - } else if (file_dialog->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + } else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { if (new_layout) { Ref<AudioBusLayout> empty_state; @@ -1296,7 +1296,7 @@ void EditorAudioBuses::_bind_methods() { EditorAudioBuses::EditorAudioBuses() { - drop_end = NULL; + drop_end = nullptr; top_hb = memnew(HBoxContainer); add_child(top_hb); @@ -1402,7 +1402,7 @@ void AudioBusesEditorPlugin::edit(Object *p_node) { bool AudioBusesEditorPlugin::handles(Object *p_node) const { - return (Object::cast_to<AudioBusLayout>(p_node) != NULL); + return (Object::cast_to<AudioBusLayout>(p_node) != nullptr); } void AudioBusesEditorPlugin::make_visible(bool p_visible) { @@ -1423,7 +1423,7 @@ void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_va Size2 EditorAudioMeterNotches::get_minimum_size() const { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); float font_height = font->get_height(); float width = 0; @@ -1460,7 +1460,7 @@ void EditorAudioMeterNotches::_notification(int p_what) { void EditorAudioMeterNotches::_draw_audio_notches() { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); float font_height = font->get_height(); for (int i = 0; i < notches.size(); i++) { diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 72098c7232..be1551629d 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -133,7 +133,7 @@ public: void update_bus(); void update_send(); - EditorAudioBus(EditorAudioBuses *p_buses = NULL, bool p_is_master = false); + EditorAudioBus(EditorAudioBuses *p_buses = nullptr, bool p_is_master = false); }; class EditorAudioBusDrop : public Control { diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 83a1e2fca2..6917b2b775 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -35,7 +35,7 @@ #include "editor_node.h" #include "editor_scale.h" #include "project_settings_editor.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" #define PREVIEW_LIST_MAX_SIZE 10 @@ -48,8 +48,6 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - EditorFileDialog *file_dialog = autoload_add_path->get_file_dialog(); - for (List<String>::Element *E = afn.front(); E; E = E->next()) { file_dialog->add_filter("*." + E->get()); @@ -61,6 +59,9 @@ void EditorAutoloadSettings::_notification(int p_what) { get_tree()->get_root()->call_deferred("add_child", info.node); } } + browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + } else if (p_what == NOTIFICATION_THEME_CHANGED) { + browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); } } @@ -116,8 +117,8 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin void EditorAutoloadSettings::_autoload_add() { - if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_line_edit()->get_text())) - autoload_add_path->get_line_edit()->set_text(""); + if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) + autoload_add_path->set_text(""); autoload_add_name->set_text(""); add_autoload->set_disabled(true); @@ -240,7 +241,7 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu case BUTTON_MOVE_UP: case BUTTON_MOVE_DOWN: { - TreeItem *swap = NULL; + TreeItem *swap = nullptr; if (p_button == BUTTON_MOVE_UP) { swap = ti->get_prev(); @@ -326,7 +327,7 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { - if (autoload_add_path->get_line_edit()->get_text() != "" && _autoload_name_is_valid(p_name, NULL)) { + if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } @@ -334,19 +335,19 @@ void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { add_autoload->set_disabled( - p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), NULL)); + p_path == "" || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { add_autoload->set_disabled( - autoload_add_path->get_line_edit()->get_text() == "" || !_autoload_name_is_valid(p_name, NULL)); + autoload_add_path->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr)); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { RES res = ResourceLoader::load(p_path); - ERR_FAIL_COND_V_MSG(res.is_null(), NULL, "Can't autoload: " + p_path + "."); - Node *n = NULL; + ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + "."); + Node *n = nullptr; if (res->is_class("PackedScene")) { Ref<PackedScene> ps = res; n = ps->instance(); @@ -354,17 +355,17 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { Ref<Script> s = res; StringName ibt = s->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); - ERR_FAIL_COND_V_MSG(!valid_type, NULL, "Script does not inherit a Node: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + "."); Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); n = Object::cast_to<Node>(obj); n->set_script(s); } - ERR_FAIL_COND_V_MSG(!n, NULL, "Path in autoload not a node or script: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in autoload not a node or script: " + p_path + "."); return n; } @@ -429,7 +430,7 @@ void EditorAutoloadSettings::update_autoload() { to_remove.erase(name); need_to_add = false; } else { - info.node = NULL; + info.node = nullptr; } } } @@ -452,10 +453,10 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_icon("Load", "EditorIcons"), BUTTON_OPEN); - item->add_button(3, get_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); - item->add_button(3, get_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); - item->add_button(3, get_icon("Remove", "EditorIcons"), BUTTON_DELETE); + item->add_button(3, get_theme_icon("Load", "EditorIcons"), BUTTON_OPEN); + item->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); + item->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); + item->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_DELETE); item->set_selectable(3, false); } @@ -474,7 +475,7 @@ void EditorAutoloadSettings::update_autoload() { if (info.node) { info.node->queue_delete(); - info.node = NULL; + info.node = nullptr; } } @@ -505,7 +506,7 @@ void EditorAutoloadSettings::update_autoload() { if (!info->in_editor && !info->is_singleton) { // No reason to keep this node memdelete(info->node); - info->node = NULL; + info->node = nullptr; } } @@ -523,7 +524,7 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control PackedStringArray autoloads; - TreeItem *next = tree->get_next_selected(NULL); + TreeItem *next = tree->get_next_selected(nullptr); while (next) { autoloads.push_back(next->get_text(0)); @@ -604,7 +605,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & int order = ProjectSettings::get_singleton()->get_order("autoload/" + name); AutoLoadInfo aux; - List<AutoLoadInfo>::Element *E = NULL; + List<AutoLoadInfo>::Element *E = nullptr; if (!move_to_back) { aux.order = order; @@ -805,9 +806,9 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } } - if (!info.is_singleton && !info.in_editor && info.node != NULL) { + if (!info.is_singleton && !info.in_editor && info.node != nullptr) { memdelete(info.node); - info.node = NULL; + info.node = nullptr; } } @@ -823,13 +824,24 @@ EditorAutoloadSettings::EditorAutoloadSettings() { l->set_text(TTR("Path:")); hbc->add_child(l); - autoload_add_path = memnew(EditorLineEditFileChooser); - autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL); - autoload_add_path->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); - autoload_add_path->get_file_dialog()->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_file_callback)); - autoload_add_path->get_line_edit()->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed)); - + autoload_add_path = memnew(LineEdit); hbc->add_child(autoload_add_path); + autoload_add_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); + autoload_add_path->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed)); + + browse_button = memnew(Button); + hbc->add_child(browse_button); + browse_button->connect("pressed", callable_mp(this, &EditorAutoloadSettings::_browse_autoload_add_path)); + + file_dialog = memnew(EditorFileDialog); + hbc->add_child(file_dialog); + file_dialog->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + file_dialog->connect("dir_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + file_dialog->connect("files_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + + hbc->set_h_size_flags(SIZE_EXPAND_FILL); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); + file_dialog->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_file_callback)); l = memnew(Label); l->set_text(TTR("Node Name:")); @@ -890,3 +902,14 @@ EditorAutoloadSettings::~EditorAutoloadSettings() { } } } + +void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) { + + autoload_add_path->set_text(p_text); + autoload_add_path->emit_signal("text_entered", p_text); +} + +void EditorAutoloadSettings::_browse_autoload_add_path() { + + file_dialog->popup_centered_ratio(); +}
\ No newline at end of file diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index 653a1b0a78..94a581401c 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -63,7 +63,7 @@ class EditorAutoloadSettings : public VBoxContainer { AutoLoadInfo() { is_singleton = false; in_editor = false; - node = NULL; + node = nullptr; } }; @@ -74,11 +74,13 @@ class EditorAutoloadSettings : public VBoxContainer { String selected_autoload; Tree *tree; - EditorLineEditFileChooser *autoload_add_path; LineEdit *autoload_add_name; Button *add_autoload; + LineEdit *autoload_add_path; + Button *browse_button; + EditorFileDialog *file_dialog; - bool _autoload_name_is_valid(const String &p_name, String *r_error = NULL); + bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr); void _autoload_add(); void _autoload_selected(); @@ -96,6 +98,9 @@ class EditorAutoloadSettings : public VBoxContainer { bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control); + void _set_autoload_add_path(const String &p_text); + void _browse_autoload_add_path(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_builders.py b/editor/editor_builders.py index 910c53e2ff..ea32e24f6e 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -6,26 +6,26 @@ All such functions are invoked in a subprocess on Windows to prevent build flaki import os import os.path from platform_methods import subprocess_main -from compat import encode_utf8, byte_to_str, open_utf8 def make_doc_header(target, source, env): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") buf = "" docbegin = "" docend = "" for src in source: if not src.endswith(".xml"): continue - with open_utf8(src, "r") as f: + with open(src, "r", encoding="utf-8") as f: content = f.read() buf += content - buf = encode_utf8(docbegin + buf + docend) + buf = (docbegin + buf + docend).encode("utf-8") decomp_size = len(buf) import zlib + buf = zlib.compress(buf) g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") @@ -35,7 +35,7 @@ def make_doc_header(target, source, env): g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n") g.write("static const unsigned char _doc_data_compressed[] = {\n") for i in range(len(buf)): - g.write("\t" + byte_to_str(buf[i]) + ",\n") + g.write("\t" + str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -47,7 +47,7 @@ def make_fonts_header(target, source, env): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_FONTS_H\n") @@ -56,7 +56,7 @@ def make_fonts_header(target, source, env): # saving uncompressed, since freetype will reference from memory pointer xl_names = [] for i in range(len(source)): - with open(source[i], "rb")as f: + with open(source[i], "rb") as f: buf = f.read() name = os.path.splitext(os.path.basename(source[i]))[0] @@ -64,7 +64,7 @@ def make_fonts_header(target, source, env): g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n") g.write("static const unsigned char _font_" + name + "[] = {\n") for j in range(len(buf)): - g.write("\t" + byte_to_str(buf[j]) + ",\n") + g.write("\t" + str(buf[j]) + ",\n") g.write("};\n") @@ -73,15 +73,15 @@ def make_fonts_header(target, source, env): g.close() -def make_translations_header(target, source, env): +def make_translations_header(target, source, env, category): dst = target[0] - g = open_utf8(dst, "w") + g = open(dst, "w", encoding="utf-8") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") - g.write("#define _EDITOR_TRANSLATIONS_H\n") + g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper())) + g.write("#define _{}_TRANSLATIONS_H\n".format(category.upper())) import zlib import os.path @@ -96,29 +96,40 @@ def make_translations_header(target, source, env): buf = zlib.compress(buf) name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - g.write("static const unsigned char _translation_" + name + "_compressed[] = {\n") + g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name)) for j in range(len(buf)): - g.write("\t" + byte_to_str(buf[j]) + ",\n") + g.write("\t" + str(buf[j]) + ",\n") g.write("};\n") xl_names.append([name, len(buf), str(decomp_size)]) - g.write("struct EditorTranslationList {\n") + g.write("struct {}TranslationList {{\n".format(category.capitalize())) g.write("\tconst char* lang;\n") g.write("\tint comp_size;\n") g.write("\tint uncomp_size;\n") g.write("\tconst unsigned char* data;\n") g.write("};\n\n") - g.write("static EditorTranslationList _editor_translations[] = {\n") + g.write("static {}TranslationList _{}_translations[] = {{\n".format(category.capitalize(), category)) for x in xl_names: - g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ", _translation_" + x[0] + "_compressed},\n") - g.write("\t{NULL, 0, 0, NULL}\n") + g.write( + '\t{{ "{}", {}, {}, _{}_translation_{}_compressed }},\n'.format(x[0], str(x[1]), str(x[2]), category, x[0]) + ) + g.write("\t{nullptr, 0, 0, nullptr}\n") g.write("};\n") g.write("#endif") g.close() -if __name__ == '__main__': + +def make_editor_translations_header(target, source, env): + make_translations_header(target, source, env, "editor") + + +def make_doc_translations_header(target, source, env): + make_translations_header(target, source, env, "doc") + + +if __name__ == "__main__": subprocess_main(globals()) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 192e7d286f..942b4a8ee6 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -270,7 +270,7 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { return editor_plugins[i]; } - return NULL; + return nullptr; } EditorPlugin *EditorData::get_subeditor(Object *p_object) { @@ -281,7 +281,7 @@ EditorPlugin *EditorData::get_subeditor(Object *p_object) { return editor_plugins[i]; } - return NULL; + return nullptr; } Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { @@ -302,7 +302,7 @@ EditorPlugin *EditorData::get_editor(String p_name) { return editor_plugins[i]; } - return NULL; + return nullptr; } void EditorData::copy_object_params(Object *p_object) { @@ -464,7 +464,7 @@ UndoRedo &EditorData::get_undo_redo() { void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = NULL; + p_plugin->undo_redo = nullptr; editor_plugins.erase(p_plugin); } @@ -479,7 +479,7 @@ int EditorData::get_editor_plugin_count() const { } EditorPlugin *EditorData::get_editor_plugin(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), nullptr); return editor_plugins[p_idx]; } @@ -506,7 +506,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i Ref<Script> script = get_custom_types()[p_inherits][i].script; Object *ob = ClassDB::instance(p_inherits); - ERR_FAIL_COND_V(!ob, NULL); + ERR_FAIL_COND_V(!ob, nullptr); if (ob->is_class("Node")) { ob->call("set_name", p_type); } @@ -516,12 +516,12 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i } } - return NULL; + return nullptr; } void EditorData::remove_custom_type(const String &p_type) { - for (Map<String, Vector<CustomType> >::Element *E = custom_types.front(); E; E = E->next()) { + for (Map<String, Vector<CustomType>>::Element *E = custom_types.front(); E; E = E->next()) { for (int i = 0; i < E->get().size(); i++) { if (E->get()[i].name == p_type) { @@ -540,7 +540,7 @@ int EditorData::add_edited_scene(int p_at_pos) { if (p_at_pos < 0) p_at_pos = edited_scene.size(); EditedScene es; - es.root = NULL; + es.root = nullptr; es.path = String(); es.history_current = -1; es.version = 0; @@ -680,10 +680,10 @@ void EditorData::set_edited_scene(int p_idx) { } Node *EditorData::get_edited_scene_root(int p_idx) { if (p_idx < 0) { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), NULL); + ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), nullptr); return edited_scene[current_edited_scene].root; } else { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), nullptr); return edited_scene[p_idx].root; } } @@ -915,7 +915,7 @@ Object *EditorData::script_class_instance(const String &p_class) { return obj; } } - return NULL; + return nullptr; } Ref<Script> EditorData::script_class_load_script(const String &p_class) const { @@ -1018,7 +1018,7 @@ void EditorSelection::add_node(Node *p_node) { changed = true; nl_changed = true; - Object *meta = NULL; + Object *meta = nullptr; for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { meta = E->get()->call("_get_editor_data", p_node); diff --git a/editor/editor_data.h b/editor/editor_data.h index 8a6f2f63f6..4f5d68bfed 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -135,7 +135,7 @@ private: String name; Variant value; }; - Map<String, Vector<CustomType> > custom_types; + Map<String, Vector<CustomType>> custom_types; List<PropertyData> clipboard; UndoRedo undo_redo; @@ -181,7 +181,7 @@ public: void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon); Object *instance_custom_type(const String &p_type, const String &p_inherits); void remove_custom_type(const String &p_type); - const Map<String, Vector<CustomType> > &get_custom_types() const { return custom_types; } + const Map<String, Vector<CustomType>> &get_custom_types() const { return custom_types; } int add_edited_scene(int p_at_pos); void move_edited_scene_index(int p_idx, int p_to_idx); @@ -265,7 +265,7 @@ public: template <class T> T *get_node_editor_data(Node *p_node) { if (!selection.has(p_node)) - return NULL; + return nullptr; return Object::cast_to<T>(selection[p_node]); } diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 20fe349ef6..cb87656382 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -35,6 +35,7 @@ #include "editor/editor_file_system.h" #include "editor/editor_settings.h" #include "editor_scale.h" +#include "servers/display_server.h" void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) { @@ -43,7 +44,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p String path = p_dir->get_path(); p_item->set_metadata(0, p_dir->get_path()); - p_item->set_icon(0, get_icon("Folder", "EditorIcons")); + p_item->set_icon(0, tree->get_theme_icon("Folder", "EditorIcons")); if (!p_item->get_parent()) { p_item->set_text(0, "res://"); @@ -68,7 +69,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p void EditorDirDialog::reload(const String &p_path) { - if (!is_visible_in_tree()) { + if (!is_visible()) { must_reload = true; return; } @@ -102,7 +103,7 @@ void EditorDirDialog::_notification(int p_what) { } if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (must_reload && is_visible_in_tree()) { + if (must_reload && is_visible()) { reload(); } } @@ -141,11 +142,11 @@ void EditorDirDialog::_make_dir() { TreeItem *ti = tree->get_selected(); if (!ti) { mkdirerr->set_text(TTR("Please select a base directory first.")); - mkdirerr->popup_centered_minsize(); + mkdirerr->popup_centered(); return; } - makedialog->popup_centered_minsize(Size2(250, 80)); + makedialog->popup_centered(Size2(250, 80)); makedirname->grab_focus(); } @@ -162,7 +163,7 @@ void EditorDirDialog::_make_dir_confirm() { Error err = d->make_dir(makedirname->get_text()); if (err != OK) { - mkdirerr->popup_centered_minsize(Size2(250, 80) * EDSCALE); + mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { opened_paths.insert(dir); //reload(dir.plus_file(makedirname->get_text())); @@ -188,7 +189,7 @@ EditorDirDialog::EditorDirDialog() { tree->connect("item_activated", callable_mp(this, &EditorDirDialog::_item_activated)); - makedir = add_button(TTR("Create Folder"), OS::get_singleton()->get_swap_ok_cancel(), "makedir"); + makedir = add_button(TTR("Create Folder"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "makedir"); makedir->connect("pressed", callable_mp(this, &EditorDirDialog::_make_dir)); makedialog = memnew(ConfirmationDialog); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 4941f295d7..e8167070d4 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -358,12 +358,12 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat zipOpenNewFileInZip(zip, path.utf8().get_data(), - NULL, - NULL, + nullptr, + nullptr, 0, - NULL, + nullptr, 0, - NULL, + nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION); @@ -582,6 +582,14 @@ String EditorExportPlugin::get_ios_cpp_code() const { return ios_cpp_code; } +void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { + ios_project_static_libs.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { + return ios_project_static_libs; +} + void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { if (get_script_instance()) { @@ -617,6 +625,7 @@ void EditorExportPlugin::skip() { void EditorExportPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content); @@ -664,7 +673,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { FeatureContainers features = p_platform.get_feature_containers(p_preset); - Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins(); + Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); //initial export plugin callback for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based @@ -676,7 +685,7 @@ EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_pla } EditorExportPlatform::ExportNotifier::~ExportNotifier() { - Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins(); + Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { export_plugins.write[i]->_export_end_script(); @@ -712,7 +721,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & _edit_filter_list(paths, p_preset->get_include_filter(), false); _edit_filter_list(paths, p_preset->get_exclude_filter(), true); - Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins(); + Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); for (int i = 0; i < export_plugins.size(); i++) { export_plugins.write[i]->set_export_preset(p_preset); @@ -1070,7 +1079,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co FileAccess *src_f; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io); + zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); ZipData zd; zd.ep = &ep; @@ -1080,7 +1089,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co if (err != OK && err != ERR_SKIP) ERR_PRINT("Failed to export project files"); - zipClose(zip, NULL); + zipClose(zip, nullptr); return OK; } @@ -1153,7 +1162,7 @@ EditorExportPlatform::EditorExportPlatform() { //// -EditorExport *EditorExport::singleton = NULL; +EditorExport *EditorExport::singleton = nullptr; void EditorExport::_save() { @@ -1284,7 +1293,7 @@ void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) export_plugins.erase(p_plugin); } -Vector<Ref<EditorExportPlugin> > EditorExport::get_export_plugins() { +Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() { return export_plugins; } @@ -1686,7 +1695,7 @@ void EditorExportPlatformPC::set_fixup_embedded_pck_func(FixUpEmbeddedPckFunc p_ EditorExportPlatformPC::EditorExportPlatformPC() { chmod_flags = -1; - fixup_embedded_pck_func = NULL; + fixup_embedded_pck_func = nullptr; } /////////////////////// diff --git a/editor/editor_export.h b/editor/editor_export.h index 139d672cb8..f47fe9c95e 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -212,7 +212,7 @@ protected: FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset); bool exists_export_template(String template_file_name, String *err) const; - String find_export_template(String template_file_name, String *err = NULL) const; + String find_export_template(String template_file_name, String *err = nullptr) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); public: @@ -238,9 +238,9 @@ public: virtual String get_name() const = 0; virtual Ref<Texture2D> get_logo() const = 0; - Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL); + Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); - Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = NULL, bool p_embed = false, int64_t *r_embedded_start = NULL, int64_t *r_embedded_size = NULL); + Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path); virtual bool poll_export() { return false; } @@ -291,6 +291,7 @@ class EditorExportPlugin : public Reference { bool skipped; Vector<String> ios_frameworks; + Vector<String> ios_project_static_libs; String ios_plist_content; String ios_linker_flags; Vector<String> ios_bundle_files; @@ -322,6 +323,7 @@ protected: void add_shared_object(const String &p_path, const Vector<String> &tags); void add_ios_framework(const String &p_path); + void add_ios_project_static_lib(const String &p_path); void add_ios_plist_content(const String &p_plist_content); void add_ios_linker_flags(const String &p_flags); void add_ios_bundle_file(const String &p_path); @@ -336,6 +338,7 @@ protected: public: Vector<String> get_ios_frameworks() const; + Vector<String> get_ios_project_static_libs() const; String get_ios_plist_content() const; String get_ios_linker_flags() const; Vector<String> get_ios_bundle_files() const; @@ -347,9 +350,9 @@ public: class EditorExport : public Node { GDCLASS(EditorExport, Node); - Vector<Ref<EditorExportPlatform> > export_platforms; - Vector<Ref<EditorExportPreset> > export_presets; - Vector<Ref<EditorExportPlugin> > export_plugins; + Vector<Ref<EditorExportPlatform>> export_platforms; + Vector<Ref<EditorExportPreset>> export_presets; + Vector<Ref<EditorExportPlugin>> export_plugins; Timer *save_timer; bool block_save; @@ -379,7 +382,7 @@ public: void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin); void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin); - Vector<Ref<EditorExportPlugin> > get_export_plugins(); + Vector<Ref<EditorExportPlugin>> get_export_plugins(); void load_config(); diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 959507535b..e2b79efb43 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -153,7 +153,7 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { Array dis_props; - for (Map<StringName, Set<StringName> >::Element *E = disabled_properties.front(); E; E = E->next()) { + for (Map<StringName, Set<StringName>>::Element *E = disabled_properties.front(); E; E = E->next()) { for (Set<StringName>::Element *F = E->get().front(); F; F = F->next()) { dis_props.push_back(String(E->key()) + ":" + String(F->get())); } @@ -420,7 +420,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { } break; case PROFILE_NEW: { - new_profile_dialog->popup_centered_minsize(); + new_profile_dialog->popup_centered(); new_profile_name->clear(); new_profile_name->grab_focus(); } break; @@ -430,7 +430,7 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { ERR_FAIL_COND(selected == String()); erase_profile_dialog->set_text(vformat(TTR("Erase profile '%s'? (no undo)"), selected)); - erase_profile_dialog->popup_centered_minsize(); + erase_profile_dialog->popup_centered(); } break; } } @@ -485,7 +485,7 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S bool disabled_editor = edited->is_class_editor_disabled(p_class); bool disabled_properties = edited->has_class_properties_disabled(p_class); if (disabled) { - class_item->set_custom_color(0, get_color("disabled_font_color", "Editor")); + class_item->set_custom_color(0, class_list->get_theme_color("disabled_font_color", "Editor")); } else if (disabled_editor && disabled_properties) { text += " " + TTR("(Editor Disabled, Properties Disabled)"); } else if (disabled_properties) { @@ -787,7 +787,7 @@ Ref<EditorFeatureProfile> EditorFeatureProfileManager::get_current_profile() { return current; } -EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = NULL; +EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = nullptr; void EditorFeatureProfileManager::_bind_methods() { @@ -805,7 +805,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { current_profile_name = memnew(LineEdit); name_hbc->add_child(current_profile_name); current_profile_name->set_editable(false); - current_profile_name->set_h_size_flags(SIZE_EXPAND_FILL); + current_profile_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Unset"))); name_hbc->add_child(profile_actions[PROFILE_CLEAR]); profile_actions[PROFILE_CLEAR]->set_disabled(true); @@ -815,7 +815,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { HBoxContainer *profiles_hbc = memnew(HBoxContainer); profile_list = memnew(OptionButton); - profile_list->set_h_size_flags(SIZE_EXPAND_FILL); + profile_list->set_h_size_flags(Control::SIZE_EXPAND_FILL); profiles_hbc->add_child(profile_list); profile_list->connect("item_selected", callable_mp(this, &EditorFeatureProfileManager::_profile_selected)); @@ -849,12 +849,12 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { main_vbc->add_margin_child(TTR("Available Profiles:"), profiles_hbc); h_split = memnew(HSplitContainer); - h_split->set_v_size_flags(SIZE_EXPAND_FILL); + h_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); main_vbc->add_child(h_split); VBoxContainer *class_list_vbc = memnew(VBoxContainer); h_split->add_child(class_list_vbc); - class_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL); + class_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); class_list = memnew(Tree); class_list_vbc->add_margin_child(TTR("Enabled Classes:"), class_list, true); @@ -865,7 +865,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { VBoxContainer *property_list_vbc = memnew(VBoxContainer); h_split->add_child(property_list_vbc); - property_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL); + property_list_vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); property_list = memnew(Tree); property_list_vbc->add_margin_child(TTR("Class Options"), property_list, true); @@ -891,7 +891,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { import_profiles = memnew(EditorFileDialog); add_child(import_profiles); - import_profiles->set_mode(EditorFileDialog::MODE_OPEN_FILES); + import_profiles->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES); import_profiles->add_filter("*.profile; " + TTR("Godot Feature Profile")); import_profiles->connect("files_selected", callable_mp(this, &EditorFeatureProfileManager::_import_profiles)); import_profiles->set_title(TTR("Import Profile(s)")); @@ -899,7 +899,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { export_profile = memnew(EditorFileDialog); add_child(export_profile); - export_profile->set_mode(EditorFileDialog::MODE_SAVE_FILE); + export_profile->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); export_profile->add_filter("*.profile; " + TTR("Godot Feature Profile")); export_profile->connect("file_selected", callable_mp(this, &EditorFeatureProfileManager::_export_profile)); export_profile->set_title(TTR("Export Profile")); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index a5ab73da60..5ae2398027 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -58,7 +58,7 @@ public: private: Set<StringName> disabled_classes; Set<StringName> disabled_editors; - Map<StringName, Set<StringName> > disabled_properties; + Map<StringName, Set<StringName>> disabled_properties; bool features_disabled[FEATURE_MAX]; static const char *feature_names[FEATURE_MAX]; diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 250fa6b3e0..6a06c6657e 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -42,12 +42,13 @@ #include "scene/gui/center_container.h" #include "scene/gui/label.h" #include "scene/gui/margin_container.h" +#include "servers/display_server.h" -EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = NULL; -EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = NULL; +EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func = nullptr; +EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func = nullptr; -EditorFileDialog::RegisterFunc EditorFileDialog::register_func = NULL; -EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = NULL; +EditorFileDialog::RegisterFunc EditorFileDialog::register_func = nullptr; +EditorFileDialog::RegisterFunc EditorFileDialog::unregister_func = nullptr; VBoxContainer *EditorFileDialog::get_vbox() { return vbox; @@ -58,17 +59,17 @@ void EditorFileDialog::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { // update icons - mode_thumbnails->set_icon(get_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(get_icon("FileList", "EditorIcons")); - dir_prev->set_icon(get_icon("Back", "EditorIcons")); - dir_next->set_icon(get_icon("Forward", "EditorIcons")); - dir_up->set_icon(get_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(get_icon("Reload", "EditorIcons")); - favorite->set_icon(get_icon("Favorites", "EditorIcons")); - show_hidden->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons")); - - fav_up->set_icon(get_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(get_icon("MoveDown", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); + mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); + refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); + favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); + show_hidden->set_icon(item_list->get_theme_icon("GuiVisibilityVisible", "EditorIcons")); + + fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); + fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); } else if (p_what == NOTIFICATION_PROCESS) { @@ -78,14 +79,11 @@ void EditorFileDialog::_notification(int p_what) { preview_wheel_index++; if (preview_wheel_index >= 8) preview_wheel_index = 0; - Ref<Texture2D> frame = get_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); + Ref<Texture2D> frame = item_list->get_theme_icon("Progress" + itos(preview_wheel_index + 1), "EditorIcons"); preview->set_texture(frame); preview_wheel_timeout = 0.1; } } - } else if (p_what == NOTIFICATION_POPUP_HIDE) { - - set_process_unhandled_input(false); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { @@ -95,18 +93,23 @@ void EditorFileDialog::_notification(int p_what) { set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); // update icons - mode_thumbnails->set_icon(get_icon("FileThumbnail", "EditorIcons")); - mode_list->set_icon(get_icon("FileList", "EditorIcons")); - dir_prev->set_icon(get_icon("Back", "EditorIcons")); - dir_next->set_icon(get_icon("Forward", "EditorIcons")); - dir_up->set_icon(get_icon("ArrowUp", "EditorIcons")); - refresh->set_icon(get_icon("Reload", "EditorIcons")); - favorite->set_icon(get_icon("Favorites", "EditorIcons")); - - fav_up->set_icon(get_icon("MoveUp", "EditorIcons")); - fav_down->set_icon(get_icon("MoveDown", "EditorIcons")); + mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); + mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); + dir_prev->set_icon(item_list->get_theme_icon("Back", "EditorIcons")); + dir_next->set_icon(item_list->get_theme_icon("Forward", "EditorIcons")); + dir_up->set_icon(item_list->get_theme_icon("ArrowUp", "EditorIcons")); + refresh->set_icon(item_list->get_theme_icon("Reload", "EditorIcons")); + favorite->set_icon(item_list->get_theme_icon("Favorites", "EditorIcons")); + + fav_up->set_icon(item_list->get_theme_icon("MoveUp", "EditorIcons")); + fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); // DO NOT CALL UPDATE FILE LIST HERE, ALL HUNDREDS OF HIDDEN DIALOGS WILL RESPOND, CALL INVALIDATE INSTEAD invalidate(); + } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + + if (!is_visible()) { + set_process_unhandled_input(false); + } } } @@ -114,7 +117,7 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (k.is_valid() && is_window_modal_on_top()) { + if (k.is_valid()) { if (k->is_pressed()) { @@ -176,7 +179,7 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } if (handled) { - accept_event(); + set_input_as_handled(); } } } @@ -208,15 +211,15 @@ void EditorFileDialog::update_dir() { get_ok()->set_disabled(_is_open_should_be_disabled()); switch (mode) { - case MODE_OPEN_FILE: - case MODE_OPEN_FILES: + case FILE_MODE_OPEN_FILE: + case FILE_MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); break; - case MODE_OPEN_DIR: + case FILE_MODE_OPEN_DIR: get_ok()->set_text(TTR("Select Current Folder")); break; - case MODE_OPEN_ANY: - case MODE_SAVE_FILE: + case FILE_MODE_OPEN_ANY: + case FILE_MODE_SAVE_FILE: // FIXME: Implement, or refactor to avoid duplication with set_mode break; } @@ -251,23 +254,23 @@ void EditorFileDialog::_post_popup() { update_file_list(); invalidated = false; } - if (mode == MODE_SAVE_FILE) + if (mode == FILE_MODE_SAVE_FILE) file->grab_focus(); else item_list->grab_focus(); - if (mode == MODE_OPEN_DIR) { + if (mode == FILE_MODE_OPEN_DIR) { file_box->set_visible(false); } else { file_box->set_visible(true); } - if (is_visible_in_tree() && get_current_file() != "") + if (is_visible() && get_current_file() != "") _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); - if (is_visible_in_tree()) { - Ref<Texture2D> folder = get_icon("folder", "FileDialog"); - const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); + if (is_visible()) { + Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); + const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); recent->clear(); bool res = access == ACCESS_RESOURCES; @@ -346,7 +349,7 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) { void EditorFileDialog::_action_pressed() { - if (mode == MODE_OPEN_FILES) { + if (mode == FILE_MODE_OPEN_FILES) { String fbase = dir_access->get_current_dir(); @@ -367,11 +370,11 @@ void EditorFileDialog::_action_pressed() { String f = dir_access->get_current_dir().plus_file(file->get_text()); - if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) { + if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) { _save_to_recent(); hide(); emit_signal("file_selected", f); - } else if (mode == MODE_OPEN_ANY || mode == MODE_OPEN_DIR) { + } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) { String path = dir_access->get_current_dir(); @@ -393,7 +396,7 @@ void EditorFileDialog::_action_pressed() { emit_signal("dir_selected", path); } - if (mode == MODE_SAVE_FILE) { + if (mode == FILE_MODE_SAVE_FILE) { bool valid = false; @@ -446,7 +449,7 @@ void EditorFileDialog::_action_pressed() { if (!valid) { - exterr->popup_centered_minsize(Size2(250, 80) * EDSCALE); + exterr->popup_centered(Size2(250, 80) * EDSCALE); return; } @@ -481,7 +484,7 @@ void EditorFileDialog::_item_selected(int p_item) { file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); - } else if (mode == MODE_OPEN_DIR) { + } else if (mode == FILE_MODE_OPEN_DIR) { get_ok()->set_text(TTR("Select This Folder")); } @@ -512,19 +515,19 @@ void EditorFileDialog::_items_clear_selection() { // If nothing is selected, then block Open button. switch (mode) { - case MODE_OPEN_FILE: - case MODE_OPEN_FILES: + case FILE_MODE_OPEN_FILE: + case FILE_MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); get_ok()->set_disabled(!item_list->is_anything_selected()); break; - case MODE_OPEN_DIR: + case FILE_MODE_OPEN_DIR: get_ok()->set_disabled(false); get_ok()->set_text(TTR("Select Current Folder")); break; - case MODE_OPEN_ANY: - case MODE_SAVE_FILE: + case FILE_MODE_OPEN_ANY: + case FILE_MODE_SAVE_FILE: // FIXME: Implement, or refactor to avoid duplication with set_mode break; } @@ -586,16 +589,16 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p } if (single_item_selected) { - item_menu->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH); + item_menu->add_icon_item(item_list->get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH); } if (allow_delete) { - item_menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); + item_menu->add_icon_item(item_list->get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); } if (single_item_selected) { item_menu->add_separator(); Dictionary item_meta = item_list->get_item_metadata(p_item); String item_text = item_meta["dir"] ? TTR("Open in File Manager") : TTR("Show in File Manager"); - item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), item_text, ITEM_MENU_SHOW_IN_EXPLORER); } if (item_menu->get_item_count() > 0) { @@ -615,11 +618,11 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { item_menu->set_size(Size2(1, 1)); if (can_create_dir) { - item_menu->add_icon_item(get_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); + item_menu->add_icon_item(item_list->get_theme_icon("folder", "FileDialog"), TTR("New Folder..."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); } - item_menu->add_icon_item(get_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); + item_menu->add_icon_item(item_list->get_theme_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); item_menu->add_separator(); - item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + item_menu->add_icon_item(item_list->get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); item_menu->set_position(item_list->get_global_position() + p_pos); item_menu->popup(); @@ -631,7 +634,7 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) { case ITEM_MENU_COPY_PATH: { Dictionary item_meta = item_list->get_item_metadata(item_list->get_current()); - OS::get_singleton()->set_clipboard(item_meta["path"]); + DisplayServer::get_singleton()->clipboard_set(item_meta["path"]); } break; case ITEM_MENU_DELETE: { @@ -667,18 +670,18 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) { bool EditorFileDialog::_is_open_should_be_disabled() { - if (mode == MODE_OPEN_ANY || mode == MODE_SAVE_FILE) + if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE) return false; Vector<int> items = item_list->get_selected_items(); if (items.size() == 0) - return mode != MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder. + return mode != FILE_MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder. for (int i = 0; i < items.size(); i++) { Dictionary d = item_list->get_item_metadata(items.get(i)); - if (((mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES) && d["dir"]) || (mode == MODE_OPEN_DIR && !d["dir"])) + if (((mode == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || (mode == FILE_MODE_OPEN_DIR && !d["dir"])) return true; } @@ -724,11 +727,11 @@ void EditorFileDialog::update_file_list() { item_list->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_icon("FolderMediumThumb", "EditorIcons"); - file_thumbnail = get_icon("FileMediumThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon("FolderMediumThumb", "EditorIcons"); + file_thumbnail = item_list->get_theme_icon("FileMediumThumb", "EditorIcons"); } else { - folder_thumbnail = get_icon("FolderBigThumb", "EditorIcons"); - file_thumbnail = get_icon("FileBigThumb", "EditorIcons"); + folder_thumbnail = item_list->get_theme_icon("FolderBigThumb", "EditorIcons"); + file_thumbnail = item_list->get_theme_icon("FileBigThumb", "EditorIcons"); } preview_vb->hide(); @@ -748,8 +751,8 @@ void EditorFileDialog::update_file_list() { dir_access->list_dir_begin(); - Ref<Texture2D> folder = get_icon("folder", "FileDialog"); - const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder = item_list->get_theme_icon("folder", "FileDialog"); + const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); List<String> files; List<String> dirs; @@ -978,7 +981,7 @@ void EditorFileDialog::set_current_file(const String &p_file) { file->grab_focus(); } - if (is_visible_in_tree()) + if (is_visible()) _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } void EditorFileDialog::set_current_path(const String &p_path) { @@ -998,39 +1001,39 @@ void EditorFileDialog::set_current_path(const String &p_path) { } } -void EditorFileDialog::set_mode(Mode p_mode) { +void EditorFileDialog::set_file_mode(FileMode p_mode) { mode = p_mode; switch (mode) { - case MODE_OPEN_FILE: + case FILE_MODE_OPEN_FILE: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a File")); can_create_dir = false; break; - case MODE_OPEN_FILES: + case FILE_MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); set_title(TTR("Open File(s)")); can_create_dir = false; break; - case MODE_OPEN_DIR: + case FILE_MODE_OPEN_DIR: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a Directory")); can_create_dir = true; break; - case MODE_OPEN_ANY: + case FILE_MODE_OPEN_ANY: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a File or Directory")); can_create_dir = true; break; - case MODE_SAVE_FILE: + case FILE_MODE_SAVE_FILE: get_ok()->set_text(TTR("Save")); set_title(TTR("Save a File")); can_create_dir = true; break; } - if (mode == MODE_OPEN_FILES) { + if (mode == FILE_MODE_OPEN_FILES) { item_list->set_select_mode(ItemList::SELECT_MULTI); } else { item_list->set_select_mode(ItemList::SELECT_SINGLE); @@ -1043,7 +1046,7 @@ void EditorFileDialog::set_mode(Mode p_mode) { } } -EditorFileDialog::Mode EditorFileDialog::get_mode() const { +EditorFileDialog::FileMode EditorFileDialog::get_file_mode() const { return mode; } @@ -1077,7 +1080,7 @@ void EditorFileDialog::set_access(Access p_access) { void EditorFileDialog::invalidate() { - if (is_visible_in_tree()) { + if (is_visible()) { update_file_list(); _update_favorites(); invalidated = false; @@ -1102,14 +1105,14 @@ void EditorFileDialog::_make_dir_confirm() { _push_history(); EditorFileSystem::get_singleton()->scan_changes(); //we created a dir, so rescan changes } else { - mkdirerr->popup_centered_minsize(Size2(250, 50) * EDSCALE); + mkdirerr->popup_centered(Size2(250, 50) * EDSCALE); } makedirname->set_text(""); // reset label } void EditorFileDialog::_make_dir() { - makedialog->popup_centered_minsize(Size2(250, 80) * EDSCALE); + makedialog->popup_centered(Size2(250, 80) * EDSCALE); makedirname->grab_focus(); } @@ -1224,8 +1227,8 @@ void EditorFileDialog::_update_favorites() { bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); - Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); - const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = item_list->get_theme_icon("Folder", "EditorIcons"); + const Color folder_color = item_list->get_theme_color("folder_icon_modulate", "FileDialog"); favorites->clear(); favorite->set_pressed(false); @@ -1383,8 +1386,8 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("set_current_dir", "dir"), &EditorFileDialog::set_current_dir); ClassDB::bind_method(D_METHOD("set_current_file", "file"), &EditorFileDialog::set_current_file); ClassDB::bind_method(D_METHOD("set_current_path", "path"), &EditorFileDialog::set_current_path); - ClassDB::bind_method(D_METHOD("set_mode", "mode"), &EditorFileDialog::set_mode); - ClassDB::bind_method(D_METHOD("get_mode"), &EditorFileDialog::get_mode); + ClassDB::bind_method(D_METHOD("set_file_mode", "mode"), &EditorFileDialog::set_file_mode); + ClassDB::bind_method(D_METHOD("get_file_mode"), &EditorFileDialog::get_file_mode); ClassDB::bind_method(D_METHOD("get_vbox"), &EditorFileDialog::get_vbox); ClassDB::bind_method(D_METHOD("set_access", "access"), &EditorFileDialog::set_access); ClassDB::bind_method(D_METHOD("get_access"), &EditorFileDialog::get_access); @@ -1408,18 +1411,18 @@ void EditorFileDialog::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access"); ADD_PROPERTY(PropertyInfo(Variant::INT, "display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List"), "set_display_mode", "get_display_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_mode", "get_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "file_mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_file_mode", "get_file_mode"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_dir", PROPERTY_HINT_DIR), "set_current_dir", "get_current_dir"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_file", PROPERTY_HINT_FILE, "*"), "set_current_file", "get_current_file"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_path"), "set_current_path", "get_current_path"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_overwrite_warning"), "set_disable_overwrite_warning", "is_overwrite_warning_disabled"); - BIND_ENUM_CONSTANT(MODE_OPEN_FILE); - BIND_ENUM_CONSTANT(MODE_OPEN_FILES); - BIND_ENUM_CONSTANT(MODE_OPEN_DIR); - BIND_ENUM_CONSTANT(MODE_OPEN_ANY); - BIND_ENUM_CONSTANT(MODE_SAVE_FILE); + BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILE); + BIND_ENUM_CONSTANT(FILE_MODE_OPEN_FILES); + BIND_ENUM_CONSTANT(FILE_MODE_OPEN_DIR); + BIND_ENUM_CONSTANT(FILE_MODE_OPEN_ANY); + BIND_ENUM_CONSTANT(FILE_MODE_SAVE_FILE); BIND_ENUM_CONSTANT(ACCESS_RESOURCES); BIND_ENUM_CONSTANT(ACCESS_USERDATA); @@ -1483,8 +1486,6 @@ bool EditorFileDialog::is_overwrite_warning_disabled() const { EditorFileDialog::EditorFileDialog() { - set_resizable(true); - show_hidden_files = default_show_hidden_files; display_mode = default_display_mode; local_history_pos = 0; @@ -1492,7 +1493,7 @@ EditorFileDialog::EditorFileDialog() { VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); - mode = MODE_SAVE_FILE; + mode = FILE_MODE_SAVE_FILE; set_title(TTR("Save a File")); ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT | KEY_LEFT); @@ -1532,7 +1533,7 @@ EditorFileDialog::EditorFileDialog() { dir = memnew(LineEdit); pathhb->add_child(dir); - dir->set_h_size_flags(SIZE_EXPAND_FILL); + dir->set_h_size_flags(Control::SIZE_EXPAND_FILL); refresh = memnew(ToolButton); refresh->set_tooltip(TTR("Refresh files.")); @@ -1578,6 +1579,7 @@ EditorFileDialog::EditorFileDialog() { drives = memnew(OptionButton); drives->connect("item_selected", callable_mp(this, &EditorFileDialog::_select_drive)); + pathhb->add_child(drives); makedir = memnew(Button); makedir->set_text(TTR("Create Folder")); @@ -1588,7 +1590,7 @@ EditorFileDialog::EditorFileDialog() { vbc->add_child(pathhb); vbc->add_child(list_hb); - list_hb->set_v_size_flags(SIZE_EXPAND_FILL); + list_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); VSplitContainer *vsc = memnew(VSplitContainer); list_hb->add_child(vsc); @@ -1596,7 +1598,7 @@ EditorFileDialog::EditorFileDialog() { VBoxContainer *fav_vb = memnew(VBoxContainer); vsc->add_child(fav_vb); fav_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE); - fav_vb->set_v_size_flags(SIZE_EXPAND_FILL); + fav_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); HBoxContainer *fav_hb = memnew(HBoxContainer); fav_vb->add_child(fav_hb); fav_hb->add_child(memnew(Label(TTR("Favorites:")))); @@ -1610,13 +1612,13 @@ EditorFileDialog::EditorFileDialog() { favorites = memnew(ItemList); fav_vb->add_child(favorites); - favorites->set_v_size_flags(SIZE_EXPAND_FILL); + favorites->set_v_size_flags(Control::SIZE_EXPAND_FILL); favorites->connect("item_selected", callable_mp(this, &EditorFileDialog::_favorite_selected)); VBoxContainer *rec_vb = memnew(VBoxContainer); vsc->add_child(rec_vb); rec_vb->set_custom_minimum_size(Size2(150, 100) * EDSCALE); - rec_vb->set_v_size_flags(SIZE_EXPAND_FILL); + rec_vb->set_v_size_flags(Control::SIZE_EXPAND_FILL); recent = memnew(ItemList); recent->set_allow_reselect(true); rec_vb->add_margin_child(TTR("Recent:"), recent, true); @@ -1627,18 +1629,18 @@ EditorFileDialog::EditorFileDialog() { item_vb->set_custom_minimum_size(Size2(320, 0) * EDSCALE); HBoxContainer *preview_hb = memnew(HBoxContainer); - preview_hb->set_v_size_flags(SIZE_EXPAND_FILL); + preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); item_vb->add_child(preview_hb); VBoxContainer *list_vb = memnew(VBoxContainer); - list_vb->set_h_size_flags(SIZE_EXPAND_FILL); + list_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); list_vb->add_child(memnew(Label(TTR("Directories & Files:")))); preview_hb->add_child(list_vb); // Item (files and folders) list with context menu. item_list = memnew(ItemList); - item_list->set_v_size_flags(SIZE_EXPAND_FILL); + item_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); item_list->connect("item_rmb_selected", callable_mp(this, &EditorFileDialog::_item_list_item_rmb_selected)); item_list->connect("rmb_clicked", callable_mp(this, &EditorFileDialog::_item_list_rmb_clicked)); item_list->set_allow_rmb_select(true); @@ -1662,14 +1664,14 @@ EditorFileDialog::EditorFileDialog() { file_box->add_child(memnew(Label(TTR("File:")))); file = memnew(LineEdit); file->set_stretch_ratio(4); - file->set_h_size_flags(SIZE_EXPAND_FILL); + file->set_h_size_flags(Control::SIZE_EXPAND_FILL); file_box->add_child(file); filter = memnew(OptionButton); filter->set_stretch_ratio(3); - filter->set_h_size_flags(SIZE_EXPAND_FILL); + filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_clip_text(true); // Too many extensions overflow it. file_box->add_child(filter); - file_box->set_h_size_flags(SIZE_EXPAND_FILL); + file_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); item_vb->add_child(file_box); dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); @@ -1686,7 +1688,7 @@ EditorFileDialog::EditorFileDialog() { filter->connect("item_selected", callable_mp(this, &EditorFileDialog::_filter_selected)); confirm_save = memnew(ConfirmationDialog); - confirm_save->set_as_toplevel(true); + //confirm_save->set_as_toplevel(true); add_child(confirm_save); confirm_save->connect("confirmed", callable_mp(this, &EditorFileDialog::_save_confirm_pressed)); @@ -1732,42 +1734,3 @@ EditorFileDialog::~EditorFileDialog() { unregister_func(this); memdelete(dir_access); } - -void EditorLineEditFileChooser::_notification(int p_what) { - - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) - button->set_icon(get_icon("Folder", "EditorIcons")); -} - -void EditorLineEditFileChooser::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_button"), &EditorLineEditFileChooser::get_button); - ClassDB::bind_method(D_METHOD("get_line_edit"), &EditorLineEditFileChooser::get_line_edit); - ClassDB::bind_method(D_METHOD("get_file_dialog"), &EditorLineEditFileChooser::get_file_dialog); -} - -void EditorLineEditFileChooser::_chosen(const String &p_text) { - - line_edit->set_text(p_text); - line_edit->emit_signal("text_entered", p_text); -} - -void EditorLineEditFileChooser::_browse() { - - dialog->popup_centered_ratio(); -} - -EditorLineEditFileChooser::EditorLineEditFileChooser() { - - line_edit = memnew(LineEdit); - add_child(line_edit); - line_edit->set_h_size_flags(SIZE_EXPAND_FILL); - button = memnew(Button); - add_child(button); - button->connect("pressed", callable_mp(this, &EditorLineEditFileChooser::_browse)); - dialog = memnew(EditorFileDialog); - add_child(dialog); - dialog->connect("file_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); - dialog->connect("dir_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); - dialog->connect("files_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); -} diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 998ac33761..8efb8f5368 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -60,12 +60,12 @@ public: ACCESS_FILESYSTEM }; - enum Mode { - MODE_OPEN_FILE, - MODE_OPEN_FILES, - MODE_OPEN_DIR, - MODE_OPEN_ANY, - MODE_SAVE_FILE + enum FileMode { + FILE_MODE_OPEN_FILE, + FILE_MODE_OPEN_FILES, + FILE_MODE_OPEN_DIR, + FILE_MODE_OPEN_ANY, + FILE_MODE_SAVE_FILE }; typedef Ref<Texture2D> (*GetIconFunc)(const String &); @@ -92,7 +92,7 @@ private: Access access; //Button *action; VBoxContainer *vbox; - Mode mode; + FileMode mode; bool can_create_dir; LineEdit *dir; @@ -221,8 +221,8 @@ public: void set_display_mode(DisplayMode p_mode); DisplayMode get_display_mode() const; - void set_mode(Mode p_mode); - Mode get_mode() const; + void set_file_mode(FileMode p_mode); + FileMode get_file_mode() const; VBoxContainer *get_vbox(); LineEdit *get_line_edit() { return file; } @@ -245,29 +245,7 @@ public: ~EditorFileDialog(); }; -class EditorLineEditFileChooser : public HBoxContainer { - - GDCLASS(EditorLineEditFileChooser, HBoxContainer); - Button *button; - LineEdit *line_edit; - EditorFileDialog *dialog; - - void _chosen(const String &p_text); - void _browse(); - -protected: - void _notification(int p_what); - static void _bind_methods(); - -public: - Button *get_button() { return button; } - LineEdit *get_line_edit() { return line_edit; } - EditorFileDialog *get_file_dialog() { return dialog; } - - EditorLineEditFileChooser(); -}; - -VARIANT_ENUM_CAST(EditorFileDialog::Mode); +VARIANT_ENUM_CAST(EditorFileDialog::FileMode); VARIANT_ENUM_CAST(EditorFileDialog::Access); VARIANT_ENUM_CAST(EditorFileDialog::DisplayMode); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index b5ec08ef60..c211d5852a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -41,7 +41,7 @@ #include "editor_resource_preview.h" #include "editor_settings.h" -EditorFileSystem *EditorFileSystem::singleton = NULL; +EditorFileSystem *EditorFileSystem::singleton = nullptr; //the name is the version, to keep compatibility with different versions of Godot #define CACHE_FILE_NAME "filesystem_cache6" @@ -75,7 +75,7 @@ int EditorFileSystemDirectory::get_subdir_count() const { EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, subdirs.size(), NULL); + ERR_FAIL_INDEX_V(p_idx, subdirs.size(), nullptr); return subdirs[p_idx]; } @@ -176,7 +176,7 @@ void EditorFileSystemDirectory::_bind_methods() { EditorFileSystemDirectory::EditorFileSystemDirectory() { modified_time = 0; - parent = NULL; + parent = nullptr; verified = false; } @@ -300,7 +300,7 @@ void EditorFileSystem::_scan_filesystem() { sp.progress = &scan_progress; new_filesystem = memnew(EditorFileSystemDirectory); - new_filesystem->parent = NULL; + new_filesystem->parent = nullptr; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); d->change_dir("res://"); @@ -383,7 +383,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { break; } else if (err != OK) { @@ -430,7 +430,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&md5_stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&md5_stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { break; @@ -622,7 +622,7 @@ void EditorFileSystem::scan() { memdelete(filesystem); //file_type_cache.clear(); filesystem = new_filesystem; - new_filesystem = NULL; + new_filesystem = nullptr; _update_scan_actions(); scanning = false; emit_signal("filesystem_changed"); @@ -1124,8 +1124,8 @@ void EditorFileSystem::_notification(int p_what) { } Thread::wait_to_finish(active_thread); memdelete(active_thread); - thread = NULL; - thread_sources = NULL; + thread = nullptr; + thread_sources = nullptr; WARN_PRINT("Scan thread aborted..."); set_process(false); } @@ -1134,8 +1134,8 @@ void EditorFileSystem::_notification(int p_what) { memdelete(filesystem); if (new_filesystem) memdelete(new_filesystem); - filesystem = NULL; - new_filesystem = NULL; + filesystem = nullptr; + new_filesystem = nullptr; } break; case NOTIFICATION_PROCESS: { @@ -1152,7 +1152,7 @@ void EditorFileSystem::_notification(int p_what) { Thread::wait_to_finish(thread_sources); memdelete(thread_sources); - thread_sources = NULL; + thread_sources = nullptr; if (_update_scan_actions()) emit_signal("filesystem_changed"); emit_signal("sources_changed", sources_changed.size() > 0); @@ -1166,10 +1166,10 @@ void EditorFileSystem::_notification(int p_what) { if (filesystem) memdelete(filesystem); filesystem = new_filesystem; - new_filesystem = NULL; + new_filesystem = nullptr; Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; _update_scan_actions(); emit_signal("filesystem_changed"); emit_signal("sources_changed", sources_changed.size() > 0); @@ -1308,7 +1308,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector String EditorFileSystem::get_file_type(const String &p_file) const { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { @@ -1322,13 +1322,13 @@ String EditorFileSystem::get_file_type(const String &p_file) const { EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int *r_index) const { if (!filesystem || scanning) - return NULL; + return nullptr; - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { - return NULL; + return nullptr; } if (r_index) @@ -1340,12 +1340,12 @@ EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) { if (!filesystem || scanning) - return NULL; + return nullptr; String f = ProjectSettings::get_singleton()->localize_path(p_path); if (!f.begins_with("res://")) - return NULL; + return nullptr; f = f.substr(6, f.length()); f = f.replace("\\", "/"); @@ -1358,7 +1358,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p Vector<String> path = f.split("/"); if (path.size() == 0) - return NULL; + return nullptr; EditorFileSystemDirectory *fs = filesystem; @@ -1374,7 +1374,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p } if (idx == -1) { - return NULL; + return nullptr; } else { fs = fs->get_subdir(idx); @@ -1483,7 +1483,7 @@ void EditorFileSystem::_queue_update_script_classes() { void EditorFileSystem::update_file(const String &p_file) { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { @@ -1558,7 +1558,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector String importer_name; - Map<String, Map<StringName, Variant> > source_file_options; + Map<String, Map<StringName, Variant>> source_file_options; Map<String, String> base_paths; for (int i = 0; i < p_files.size(); i++) { @@ -1610,7 +1610,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector Error err = importer->import_group_file(p_group_file, source_file_options, base_paths); //all went well, overwrite config files with proper remaps and md5s - for (Map<String, Map<StringName, Variant> >::Element *E = source_file_options.front(); E; E = E->next()) { + for (Map<String, Map<StringName, Variant>>::Element *E = source_file_options.front(); E; E = E->next()) { const String &file = E->key(); String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file); @@ -1684,7 +1684,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector } md5s->close(); - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(file, &fs, cpos); ERR_FAIL_COND_V_MSG(!found, ERR_UNCONFIGURED, "Can't find file '" + file + "'."); @@ -1718,7 +1718,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector void EditorFileSystem::_reimport_file(const String &p_file) { - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); ERR_FAIL_COND_MSG(!found, "Can't find file '" + p_file + "'."); @@ -1921,7 +1921,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } -void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String> > &group_files, Set<String> &groups_to_reimport) { +void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String>> &group_files, Set<String> &groups_to_reimport) { int fc = efd->files.size(); const EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptr(); @@ -1980,7 +1980,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } //group may have changed, so also update group reference - EditorFileSystemDirectory *fs = NULL; + EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (_find_file(p_files[i], &fs, cpos)) { @@ -1998,9 +1998,9 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { //reimport groups if (groups_to_reimport.size()) { - Map<String, Vector<String> > group_files; + Map<String, Vector<String>> group_files; _find_group_files(filesystem, group_files, groups_to_reimport); - for (Map<String, Vector<String> >::Element *E = group_files.front(); E; E = E->next()) { + for (Map<String, Vector<String>>::Element *E = group_files.front(); E; E = E->next()) { Error err = _reimport_group(E->key(), E->get()); if (err == OK) { @@ -2131,14 +2131,14 @@ EditorFileSystem::EditorFileSystem() { singleton = this; filesystem = memnew(EditorFileSystemDirectory); //like, empty - filesystem->parent = NULL; + filesystem->parent = nullptr; - thread = NULL; + thread = nullptr; scanning = false; importing = false; use_threads = true; - thread_sources = NULL; - new_filesystem = NULL; + thread_sources = nullptr; + new_filesystem = nullptr; abort_scan = false; scanning_changes = false; diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 381acc0fe2..55a2ed3d09 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -129,9 +129,9 @@ class EditorFileSystem : public Node { ItemAction() { action = ACTION_NONE; - dir = NULL; - new_dir = NULL; - new_file = NULL; + dir = nullptr; + new_dir = nullptr; + new_file = nullptr; } }; @@ -240,7 +240,7 @@ class EditorFileSystem : public Node { bool using_fat32_or_exfat; // Workaround for projects in FAT32 or exFAT filesystem (pendrives, most of the time) - void _find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String> > &group_files, Set<String> &groups_to_reimport); + void _find_group_files(EditorFileSystemDirectory *efd, Map<String, Vector<String>> &group_files, Set<String> &groups_to_reimport); void _move_group_files(EditorFileSystemDirectory *efd, const String &p_group_file, const String &p_new_location); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 171b7a2176..8aadf02ea6 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -231,7 +231,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { // Default font MAKE_DEFAULT_FONT(df, default_font_size); - p_theme->set_default_theme_font(df); + p_theme->set_font("font", "Node", df); // Default theme font p_theme->set_font("main", "EditorFonts", df); // Bold font diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index b26fa77e16..a36e2f360e 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -30,7 +30,7 @@ #include "editor_help.h" -#include "core/os/input.h" +#include "core/input/input_filter.h" #include "core/os/keyboard.h" #include "doc_data_compressed.gen.h" #include "editor/plugins/script_editor_plugin.h" @@ -39,24 +39,22 @@ #include "editor_settings.h" #define CONTRIBUTE_URL "https://docs.godotengine.org/en/latest/community/contributing/updating_the_class_reference.html" -#define CONTRIBUTE2_URL "https://github.com/godotengine/godot-docs" -#define REQUEST_URL "https://github.com/godotengine/godot-docs/issues/new" -DocData *EditorHelp::doc = NULL; +DocData *EditorHelp::doc = nullptr; void EditorHelp::_init_colors() { - title_color = get_color("accent_color", "Editor"); - text_color = get_color("default_color", "RichTextLabel"); - headline_color = get_color("headline_color", "EditorHelp"); + title_color = get_theme_color("accent_color", "Editor"); + text_color = get_theme_color("default_color", "RichTextLabel"); + headline_color = get_theme_color("headline_color", "EditorHelp"); base_type_color = title_color.linear_interpolate(text_color, 0.5); comment_color = text_color * Color(1, 1, 1, 0.6); symbol_color = comment_color; value_color = text_color * Color(1, 1, 1, 0.6); qualifier_color = text_color * Color(1, 1, 1, 0.8); - type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); - class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); - class_desc->add_constant_override("line_separation", Math::round(5 * EDSCALE)); + type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) { @@ -109,7 +107,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { String link = p_select.substr(tag_end + 1, p_select.length()).lstrip(" "); String topic; - Map<String, int> *table = NULL; + Map<String, int> *table = nullptr; if (tag == "method") { topic = "class_method"; @@ -173,14 +171,14 @@ void EditorHelp::_class_desc_input(const Ref<InputEvent> &p_input) { void EditorHelp::_class_desc_resized() { // Add extra horizontal margins for better readability. // The margins increase as the width of the editor help container increases. - Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); + Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); real_t char_width = doc_code_font->get_char_size('x').width; const int display_margin = MAX(30 * EDSCALE, get_parent_anchorable_rect().size.width - char_width * 120 * EDSCALE) * 0.5; - Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "RichTextLabel")->duplicate(); + Ref<StyleBox> class_desc_stylebox = EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "RichTextLabel")->duplicate(); class_desc_stylebox->set_default_margin(MARGIN_LEFT, display_margin); class_desc_stylebox->set_default_margin(MARGIN_RIGHT, display_margin); - class_desc->add_style_override("normal", class_desc_stylebox); + class_desc->add_theme_style_override("normal", class_desc_stylebox); } void EditorHelp::_add_type(const String &p_type, const String &p_enum) { @@ -197,8 +195,8 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { t = p_enum.get_slice(".", 0); } } - const Color text_color = get_color("default_color", "RichTextLabel"); - const Color type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + const Color text_color = get_theme_color("default_color", "RichTextLabel"); + const Color type_color = get_theme_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); class_desc->push_color(type_color); if (can_ref) { if (p_enum.empty()) { @@ -346,10 +344,10 @@ void EditorHelp::_update_doc() { DocData::ClassDoc cd = doc->class_list[edited_class]; //make a copy, so we can sort without worrying - Ref<Font> doc_font = get_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = get_font("doc_bold", "EditorFonts"); - Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts"); - Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); + Ref<Font> doc_font = get_theme_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = get_theme_font("doc_bold", "EditorFonts"); + Ref<Font> doc_title_font = get_theme_font("doc_title", "EditorFonts"); + Ref<Font> doc_code_font = get_theme_font("doc_source", "EditorFonts"); String link_color_text = title_color.to_html(false); // Class name @@ -433,7 +431,7 @@ void EditorHelp::_update_doc() { class_desc->push_color(text_color); class_desc->push_font(doc_bold_font); class_desc->push_indent(1); - _add_text(cd.brief_description); + _add_text(DTR(cd.brief_description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); @@ -458,7 +456,7 @@ void EditorHelp::_update_doc() { class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); - _add_text(cd.description); + _add_text(DTR(cd.description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); @@ -480,7 +478,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (int i = 0; i < cd.tutorials.size(); i++) { - const String link = cd.tutorials[i]; + const String link = DTR(cd.tutorials[i]); String linktxt = link; const int seppos = linktxt.find("//"); if (seppos != -1) { @@ -726,7 +724,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->add_text(" "); class_desc->push_color(comment_color); - _add_text(cd.theme_properties[i].description); + _add_text(DTR(cd.theme_properties[i].description)); class_desc->pop(); class_desc->pop(); } @@ -796,7 +794,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); - _add_text(cd.signals[i].description); + _add_text(DTR(cd.signals[i].description)); class_desc->pop(); // indent class_desc->pop(); class_desc->pop(); // font @@ -812,7 +810,7 @@ void EditorHelp::_update_doc() { // Constants and enums if (cd.constants.size()) { - Map<String, Vector<DocData::ConstantDoc> > enums; + Map<String, Vector<DocData::ConstantDoc>> enums; Vector<DocData::ConstantDoc> constants; for (int i = 0; i < cd.constants.size(); i++) { @@ -842,7 +840,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); - for (Map<String, Vector<DocData::ConstantDoc> >::Element *E = enums.front(); E; E = E->next()) { + for (Map<String, Vector<DocData::ConstantDoc>>::Element *E = enums.front(); E; E = E->next()) { enum_line[E->key()] = class_desc->get_line_count() - 2; @@ -893,7 +891,7 @@ void EditorHelp::_update_doc() { //class_desc->add_text(" "); class_desc->push_indent(1); class_desc->push_color(comment_color); - _add_text(enum_list[i].description); + _add_text(DTR(enum_list[i].description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); // indent @@ -959,7 +957,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); class_desc->push_color(comment_color); - _add_text(constants[i].description); + _add_text(DTR(constants[i].description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); // indent @@ -1070,9 +1068,9 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); if (cd.properties[i].description.strip_edges() != String()) { - _add_text(cd.properties[i].description); + _add_text(DTR(cd.properties[i].description)); } else { - class_desc->add_image(get_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon("Error", "EditorIcons")); class_desc->add_text(" "); class_desc->push_color(comment_color); class_desc->append_bbcode(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); @@ -1123,9 +1121,9 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); if (methods_filtered[i].description.strip_edges() != String()) { - _add_text(methods_filtered[i].description); + _add_text(DTR(methods_filtered[i].description)); } else { - class_desc->add_image(get_icon("Error", "EditorIcons")); + class_desc->add_image(get_theme_icon("Error", "EditorIcons")); class_desc->add_text(" "); class_desc->push_color(comment_color); class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); @@ -1188,7 +1186,7 @@ void EditorHelp::_help_callback(const String &p_topic) { if (constant_line.has(name)) line = constant_line[name]; else { - Map<String, Map<String, int> >::Element *iter = enum_values_line.front(); + Map<String, Map<String, int>>::Element *iter = enum_values_line.front(); while (true) { if (iter->value().has(name)) { line = iter->value()[name]; @@ -1209,12 +1207,12 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { DocData *doc = EditorHelp::get_doc_data(); String base_path; - Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts"); - Ref<Font> doc_bold_font = p_rt->get_font("doc_bold", "EditorFonts"); - Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts"); + Ref<Font> doc_font = p_rt->get_theme_font("doc", "EditorFonts"); + Ref<Font> doc_bold_font = p_rt->get_theme_font("doc_bold", "EditorFonts"); + Ref<Font> doc_code_font = p_rt->get_theme_font("doc_source", "EditorFonts"); - Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); - Color accent_color = p_rt->get_color("accent_color", "Editor"); + Color font_color_hl = p_rt->get_theme_color("headline_color", "EditorHelp"); + Color accent_color = p_rt->get_theme_color("accent_color", "Editor"); Color link_color = accent_color.linear_interpolate(font_color_hl, 0.8); Color code_color = accent_color.linear_interpolate(font_color_hl, 0.6); @@ -1449,7 +1447,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } void EditorHelp::_add_text(const String &p_bbcode) { - _add_text_to_rt(p_bbcode, class_desc); } @@ -1489,8 +1486,8 @@ void EditorHelp::go_to_class(const String &p_class, int p_scroll) { _goto_desc(p_class, p_scroll); } -Vector<Pair<String, int> > EditorHelp::get_sections() { - Vector<Pair<String, int> > sections; +Vector<Pair<String, int>> EditorHelp::get_sections() { + Vector<Pair<String, int>> sections; for (int i = 0; i < section_line.size(); i++) { sections.push_back(Pair<String, int>(section_line[i].first, i)); @@ -1546,7 +1543,7 @@ EditorHelp::EditorHelp() { class_desc = memnew(RichTextLabel); add_child(class_desc); class_desc->set_v_size_flags(SIZE_EXPAND_FILL); - class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + class_desc->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); class_desc->connect("meta_clicked", callable_mp(this, &EditorHelp::_class_desc_select)); class_desc->connect("gui_input", callable_mp(this, &EditorHelp::_class_desc_input)); @@ -1611,9 +1608,14 @@ void EditorHelpBit::_bind_methods() { void EditorHelpBit::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_READY: { + rich_text->clear(); + _add_text_to_rt(text, rich_text); + + } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - rich_text->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); } break; default: break; } @@ -1621,8 +1623,9 @@ void EditorHelpBit::_notification(int p_what) { void EditorHelpBit::set_text(const String &p_text) { + text = p_text; rich_text->clear(); - _add_text_to_rt(p_text, rich_text); + _add_text_to_rt(text, rich_text); } EditorHelpBit::EditorHelpBit() { @@ -1630,7 +1633,7 @@ EditorHelpBit::EditorHelpBit() { rich_text = memnew(RichTextLabel); add_child(rich_text); rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked)); - rich_text->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); + rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); rich_text->set_override_selected_font_color(false); set_custom_minimum_size(Size2(0, 70 * EDSCALE)); } @@ -1694,13 +1697,13 @@ void FindBar::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - find_prev->set_icon(get_icon("MoveUp", "EditorIcons")); - find_next->set_icon(get_icon("MoveDown", "EditorIcons")); - hide_button->set_normal_texture(get_icon("Close", "EditorIcons")); - hide_button->set_hover_texture(get_icon("Close", "EditorIcons")); - hide_button->set_pressed_texture(get_icon("Close", "EditorIcons")); + find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); + find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); + hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_hover_texture(get_theme_icon("Close", "EditorIcons")); + hide_button->set_pressed_texture(get_theme_icon("Close", "EditorIcons")); hide_button->set_custom_minimum_size(hide_button->get_normal_texture()->get_size()); - matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -1781,7 +1784,7 @@ void FindBar::_update_matches_label() { } else { matches_label->show(); - matches_label->add_color_override("font_color", results_count > 0 ? get_color("font_color", "Label") : get_color("error_color", "Editor")); + matches_label->add_theme_color_override("font_color", results_count > 0 ? get_theme_color("font_color", "Label") : get_theme_color("error_color", "Editor")); matches_label->set_text(vformat(results_count == 1 ? TTR("%d match.") : TTR("%d matches."), results_count)); } } @@ -1829,7 +1832,7 @@ void FindBar::_search_text_changed(const String &p_text) { void FindBar::_search_text_entered(const String &p_text) { - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { search_prev(); } else { search_next(); diff --git a/editor/editor_help.h b/editor/editor_help.h index 83c279aec3..2e053e674f 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -32,7 +32,7 @@ #define EDITOR_HELP_H #include "editor/code_editor.h" -#include "editor/doc/doc_data.h" +#include "editor/doc_data.h" #include "editor/editor_plugin.h" #include "scene/gui/margin_container.h" #include "scene/gui/menu_button.h" @@ -108,14 +108,14 @@ class EditorHelp : public VBoxContainer { String edited_class; - Vector<Pair<String, int> > section_line; + Vector<Pair<String, int>> section_line; Map<String, int> method_line; Map<String, int> signal_line; Map<String, int> property_line; Map<String, int> theme_property_line; Map<String, int> constant_line; Map<String, int> enum_line; - Map<String, Map<String, int> > enum_values_line; + Map<String, Map<String, int>> enum_values_line; int description_line; RichTextLabel *class_desc; @@ -175,7 +175,7 @@ public: void go_to_help(const String &p_help); void go_to_class(const String &p_class, int p_scroll = 0); - Vector<Pair<String, int> > get_sections(); + Vector<Pair<String, int>> get_sections(); void scroll_to_section(int p_section_index); void popup_search(); @@ -192,14 +192,16 @@ public: ~EditorHelp(); }; -class EditorHelpBit : public PanelContainer { +class EditorHelpBit : public MarginContainer { - GDCLASS(EditorHelpBit, PanelContainer); + GDCLASS(EditorHelpBit, MarginContainer); RichTextLabel *rich_text; void _go_to_help(String p_what); void _meta_clicked(String p_select); + String text; + protected: static void _bind_methods(); void _notification(int p_what); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index f7ce2dd4fc..01a50cad2c 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -37,13 +37,13 @@ void EditorHelpSearch::_update_icons() { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); - case_sensitive_button->set_icon(get_icon("MatchCase", "EditorIcons")); - hierarchy_button->set_icon(get_icon("ClassList", "EditorIcons")); + search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons")); + case_sensitive_button->set_icon(results_tree->get_theme_icon("MatchCase", "EditorIcons")); + hierarchy_button->set_icon(results_tree->get_theme_icon("ClassList", "EditorIcons")); - if (is_visible_in_tree()) + if (is_visible()) _update_results(); } @@ -57,7 +57,7 @@ void EditorHelpSearch::_update_results() { if (hierarchy_button->is_pressed()) search_flags |= SEARCH_SHOW_HIERARCHY; - search = Ref<Runner>(memnew(Runner(this, results_tree, term, search_flags))); + search = Ref<Runner>(memnew(Runner(results_tree, results_tree, term, search_flags))); set_process(true); } @@ -105,6 +105,13 @@ void EditorHelpSearch::_confirmed() { void EditorHelpSearch::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation. + get_ok()->set_disabled(true); + EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size())); + } + } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); @@ -114,12 +121,7 @@ void EditorHelpSearch::_notification(int p_what) { connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed)); _update_icons(); } break; - case NOTIFICATION_POPUP_HIDE: { - results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation. - get_ok()->set_disabled(true); - EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", get_rect()); - } break; case NOTIFICATION_PROCESS: { // Update background search. @@ -184,7 +186,7 @@ EditorHelpSearch::EditorHelpSearch() { old_search = false; set_hide_on_ok(false); - set_resizable(true); + set_title(TTR("Search Help")); get_ok()->set_disabled(true); @@ -200,7 +202,7 @@ EditorHelpSearch::EditorHelpSearch() { search_box = memnew(LineEdit); search_box->set_custom_minimum_size(Size2(200, 0) * EDSCALE); - search_box->set_h_size_flags(SIZE_EXPAND_FILL); + search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_box->connect("gui_input", callable_mp(this, &EditorHelpSearch::_search_box_gui_input)); search_box->connect("text_changed", callable_mp(this, &EditorHelpSearch::_search_box_text_changed)); register_text_enter(search_box); @@ -210,7 +212,7 @@ EditorHelpSearch::EditorHelpSearch() { case_sensitive_button->set_tooltip(TTR("Case Sensitive")); case_sensitive_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results)); case_sensitive_button->set_toggle_mode(true); - case_sensitive_button->set_focus_mode(FOCUS_NONE); + case_sensitive_button->set_focus_mode(Control::FOCUS_NONE); hbox->add_child(case_sensitive_button); hierarchy_button = memnew(ToolButton); @@ -218,7 +220,7 @@ EditorHelpSearch::EditorHelpSearch() { hierarchy_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results)); hierarchy_button->set_toggle_mode(true); hierarchy_button->set_pressed(true); - hierarchy_button->set_focus_mode(FOCUS_NONE); + hierarchy_button->set_focus_mode(Control::FOCUS_NONE); hbox->add_child(hierarchy_button); filter_combo = memnew(OptionButton); @@ -237,7 +239,7 @@ EditorHelpSearch::EditorHelpSearch() { // Create the results tree. results_tree = memnew(Tree); - results_tree->set_v_size_flags(SIZE_EXPAND_FILL); + results_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); results_tree->set_columns(2); results_tree->set_column_title(0, TTR("Name")); results_tree->set_column_title(1, TTR("Member Type")); @@ -315,7 +317,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() { iterator_doc = EditorHelp::get_doc_data()->class_list.front(); matches.clear(); - matched_item = NULL; + matched_item = nullptr; return true; } @@ -479,10 +481,10 @@ TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) { Ref<Texture2D> icon = empty_icon; - if (ui_service->has_icon(p_doc->name, "EditorIcons")) - icon = ui_service->get_icon(p_doc->name, "EditorIcons"); + if (ui_service->has_theme_icon(p_doc->name, "EditorIcons")) + icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons"); else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) - icon = ui_service->get_icon("Object", "EditorIcons"); + icon = ui_service->get_theme_icon("Object", "EditorIcons"); String tooltip = p_doc->brief_description.strip_edges(); TreeItem *item = results_tree->create_item(p_parent); @@ -557,10 +559,10 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { - icon = ui_service->get_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); text = p_name; } else { - icon = ui_service->get_icon(p_icon, "EditorIcons"); + icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); /*// In flat mode, show the class icon. if (ui_service->has_icon(p_class_name, "EditorIcons")) icon = ui_service->get_icon(p_class_name, "EditorIcons"); @@ -598,6 +600,6 @@ EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, results_tree(p_results_tree), term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), search_flags(p_search_flags), - empty_icon(ui_service->get_icon("ArrowRight", "EditorIcons")), - disabled_color(ui_service->get_color("disabled_font_color", "Editor")) { + empty_icon(ui_service->get_theme_icon("ArrowRight", "EditorIcons")), + disabled_color(ui_service->get_theme_color("disabled_font_color", "Editor")) { } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index ed5a411d8b..a0f8b59117 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -41,7 +41,7 @@ Size2 EditorProperty::get_minimum_size() const { Size2 ms; - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); ms.height = font->get_height(); for (int i = 0; i < get_child_count(); i++) { @@ -62,17 +62,17 @@ Size2 EditorProperty::get_minimum_size() const { } if (keying) { - Ref<Texture2D> key = get_icon("Key", "EditorIcons"); - ms.width += key->get_width() + get_constant("hseparator", "Tree"); + Ref<Texture2D> key = get_theme_icon("Key", "EditorIcons"); + ms.width += key->get_width() + get_theme_constant("hseparator", "Tree"); } if (checkable) { - Ref<Texture2D> check = get_icon("checked", "CheckBox"); - ms.width += check->get_width() + get_constant("hseparation", "CheckBox") + get_constant("hseparator", "Tree"); + Ref<Texture2D> check = get_theme_icon("checked", "CheckBox"); + ms.width += check->get_width() + get_theme_constant("hseparation", "CheckBox") + get_theme_constant("hseparator", "Tree"); } - if (bottom_editor != NULL && bottom_editor->is_visible()) { - ms.height += get_constant("vseparation", "Tree"); + if (bottom_editor != nullptr && bottom_editor->is_visible()) { + ms.height += get_theme_constant("vseparation", "Tree"); Size2 bems = bottom_editor->get_combined_minimum_size(); //bems.width += get_constant("item_margin", "Tree"); ms.height += bems.height; @@ -103,7 +103,7 @@ void EditorProperty::_notification(int p_what) { { int child_room = size.width * (1.0 - split_ratio); - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); int height = font->get_height(); bool no_children = true; @@ -136,19 +136,19 @@ void EditorProperty::_notification(int p_what) { int m = 0; //get_constant("item_margin", "Tree"); - bottom_rect = Rect2(m, rect.size.height + get_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height); + bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height); } if (keying) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_icon("KeyNext", "EditorIcons"); + key = get_theme_icon("KeyNext", "EditorIcons"); } else { - key = get_icon("Key", "EditorIcons"); + key = get_theme_icon("Key", "EditorIcons"); } - rect.size.x -= key->get_width() + get_constant("hseparator", "Tree"); + rect.size.x -= key->get_width() + get_theme_constant("hseparator", "Tree"); if (no_children) { text_size -= key->get_width() + 4 * EDSCALE; @@ -180,8 +180,8 @@ void EditorProperty::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Font> font = get_font("font", "Tree"); - Color dark_color = get_color("dark_color_2", "Editor"); + Ref<Font> font = get_theme_font("font", "Tree"); + Color dark_color = get_theme_color("dark_color_2", "Editor"); Size2 size = get_size(); if (bottom_editor) { @@ -191,7 +191,7 @@ void EditorProperty::_notification(int p_what) { } if (selected) { - Ref<StyleBox> sb = get_stylebox("selected", "Tree"); + Ref<StyleBox> sb = get_theme_stylebox("selected", "Tree"); draw_style_box(sb, Rect2(Vector2(), size)); } @@ -204,9 +204,9 @@ void EditorProperty::_notification(int p_what) { Color color; if (draw_red) { - color = get_color("error_color", "Editor"); + color = get_theme_color("error_color", "Editor"); } else { - color = get_color("property_color", "Editor"); + color = get_theme_color("property_color", "Editor"); } if (label.find(".") != -1) { color.a = 0.5; //this should be un-hacked honestly, as it's used for editor overrides @@ -218,9 +218,9 @@ void EditorProperty::_notification(int p_what) { if (checkable) { Ref<Texture2D> checkbox; if (checked) - checkbox = get_icon("GuiChecked", "EditorIcons"); + checkbox = get_theme_icon("GuiChecked", "EditorIcons"); else - checkbox = get_icon("GuiUnchecked", "EditorIcons"); + checkbox = get_theme_icon("GuiUnchecked", "EditorIcons"); Color color2(1, 1, 1); if (check_hover) { @@ -230,16 +230,16 @@ void EditorProperty::_notification(int p_what) { } check_rect = Rect2(ofs, ((size.height - checkbox->get_height()) / 2), checkbox->get_width(), checkbox->get_height()); draw_texture(checkbox, check_rect.position, color2); - ofs += get_constant("hseparator", "Tree") + checkbox->get_width() + get_constant("hseparation", "CheckBox"); + ofs += get_theme_constant("hseparator", "Tree") + checkbox->get_width() + get_theme_constant("hseparation", "CheckBox"); text_limit -= ofs; } else { check_rect = Rect2(); } if (can_revert) { - Ref<Texture2D> reload_icon = get_icon("ReloadSmall", "EditorIcons"); - text_limit -= reload_icon->get_width() + get_constant("hseparator", "Tree") * 2; - revert_rect = Rect2(text_limit + get_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); + Ref<Texture2D> reload_icon = get_theme_icon("ReloadSmall", "EditorIcons"); + text_limit -= reload_icon->get_width() + get_theme_constant("hseparator", "Tree") * 2; + revert_rect = Rect2(text_limit + get_theme_constant("hseparator", "Tree"), (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height()); Color color2(1, 1, 1); if (revert_hover) { @@ -260,12 +260,12 @@ void EditorProperty::_notification(int p_what) { Ref<Texture2D> key; if (use_keying_next()) { - key = get_icon("KeyNext", "EditorIcons"); + key = get_theme_icon("KeyNext", "EditorIcons"); } else { - key = get_icon("Key", "EditorIcons"); + key = get_theme_icon("Key", "EditorIcons"); } - ofs = size.width - key->get_width() - get_constant("hseparator", "Tree"); + ofs = size.width - key->get_width() - get_theme_constant("hseparator", "Tree"); Color color2(1, 1, 1); if (keying_hover) { @@ -646,7 +646,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { emit_signal("property_keyed", property, use_keying_next()); if (use_keying_next()) { - if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) { + if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) { Vector2 new_coords = object->get(property); new_coords.x++; if (new_coords.x >= object->get("hframes").operator int64_t()) { @@ -776,13 +776,14 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const { tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); + //help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); + String text; PackedStringArray slices = p_text.split("::", false); if (!slices.empty()) { String property_name = slices[0].strip_edges(); - String text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]"; + text = TTR("Property:") + " [u][b]" + property_name + "[/b][/u]"; if (slices.size() > 1) { String property_doc = slices[1].strip_edges(); @@ -790,7 +791,7 @@ Control *EditorProperty::make_custom_tooltip(const String &p_text) const { text += "\n" + property_doc; } } - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + help_bit->set_text(text); } return help_bit; @@ -855,7 +856,7 @@ void EditorProperty::_bind_methods() { EditorProperty::EditorProperty() { draw_top_bg = true; - object = NULL; + object = nullptr; split_ratio = 0.5; selectable = true; text_size = 0; @@ -872,8 +873,8 @@ EditorProperty::EditorProperty() { property_usage = 0; selected = false; selected_focusable = -1; - label_reference = NULL; - bottom_editor = NULL; + label_reference = nullptr; + bottom_editor = nullptr; } //////////////////////////////////////////////// //////////////////////////////////////////////// @@ -887,7 +888,7 @@ void EditorInspectorPlugin::add_custom_control(Control *control) { void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop) { - ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == NULL); + ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == nullptr); AddedEditor ae; ae.properties.push_back(p_for_property); @@ -987,9 +988,9 @@ void EditorInspectorCategory::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { draw_rect(Rect2(Vector2(), get_size()), bg_color); - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); - int hs = get_constant("hseparation", "Tree"); + int hs = get_theme_constant("hseparation", "Tree"); int w = font->get_string_size(label).width; if (icon.is_valid()) { @@ -1003,7 +1004,7 @@ void EditorInspectorCategory::_notification(int p_what) { ofs += hs + icon->get_width(); } - Color color = get_color("font_color", "Tree"); + Color color = get_theme_color("font_color", "Tree"); draw_string(font, Point2(ofs, font->get_ascent() + (get_size().height - font->get_height()) / 2).floor(), label, color, get_size().width); } } @@ -1012,7 +1013,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel")); + help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); PackedStringArray slices = p_text.split("::", false); @@ -1026,7 +1027,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons text += "\n" + property_doc; } } - help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene + help_bit->set_text(text); //hack so it uses proper theme once inside scene } return help_bit; @@ -1034,7 +1035,7 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons Size2 EditorInspectorCategory::get_minimum_size() const { - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); Size2 ms; ms.width = 1; @@ -1042,7 +1043,7 @@ Size2 EditorInspectorCategory::get_minimum_size() const { if (icon.is_valid()) { ms.height = MAX(icon->get_height(), ms.height); } - ms.height += get_constant("vseparation", "Tree"); + ms.height += get_theme_constant("vseparation", "Tree"); return ms; } @@ -1074,14 +1075,14 @@ void EditorInspectorSection::_notification(int p_what) { if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); Ref<Texture2D> arrow; if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_icon("arrow", "Tree"); + arrow = get_theme_icon("arrow", "Tree"); } else { - arrow = get_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon("arrow_collapsed", "Tree"); } } @@ -1092,8 +1093,8 @@ void EditorInspectorSection::_notification(int p_what) { offset.y = MAX(offset.y, arrow->get_height()); } - offset.y += get_constant("vseparation", "Tree"); - offset.x += get_constant("inspector_margin", "Editor"); + offset.y += get_theme_constant("vseparation", "Tree"); + offset.x += get_theme_constant("inspector_margin", "Editor"); Rect2 rect(offset, size - offset); @@ -1120,24 +1121,24 @@ void EditorInspectorSection::_notification(int p_what) { if (foldable) { if (object->editor_is_section_unfolded(section)) { - arrow = get_icon("arrow", "Tree"); + arrow = get_theme_icon("arrow", "Tree"); } else { - arrow = get_icon("arrow_collapsed", "Tree"); + arrow = get_theme_icon("arrow_collapsed", "Tree"); } } - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); int h = font->get_height(); if (arrow.is_valid()) { h = MAX(h, arrow->get_height()); } - h += get_constant("vseparation", "Tree"); + h += get_theme_constant("vseparation", "Tree"); draw_rect(Rect2(Vector2(), Vector2(get_size().width, h)), bg_color); const int arrow_margin = 3; - Color color = get_color("font_color", "Tree"); + Color color = get_theme_color("font_color", "Tree"); draw_string(font, Point2(Math::round((16 + arrow_margin) * EDSCALE), font->get_ascent() + (h - font->get_height()) / 2).floor(), label, color, get_size().width); if (arrow.is_valid()) { @@ -1163,9 +1164,9 @@ Size2 EditorInspectorSection::get_minimum_size() const { ms.height = MAX(ms.height, minsize.height); } - Ref<Font> font = get_font("font", "Tree"); - ms.height += font->get_height() + get_constant("vseparation", "Tree"); - ms.width += get_constant("inspector_margin", "Editor"); + Ref<Font> font = get_theme_font("font", "Tree"); + ms.height += font->get_height() + get_theme_constant("vseparation", "Tree"); + ms.width += get_theme_constant("inspector_margin", "Editor"); return ms; } @@ -1201,7 +1202,7 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Ref<Font> font = get_font("font", "Tree"); + Ref<Font> font = get_theme_font("font", "Tree"); if (mb->get_position().y > font->get_height()) { //clicked outside return; } @@ -1256,7 +1257,7 @@ void EditorInspectorSection::_bind_methods() { } EditorInspectorSection::EditorInspectorSection() { - object = NULL; + object = nullptr; foldable = false; vbox = memnew(VBoxContainer); vbox_added = false; @@ -1296,7 +1297,7 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V } } } - return NULL; + return nullptr; } void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { @@ -1454,7 +1455,7 @@ void EditorInspector::update_tree() { if (!object) return; - List<Ref<EditorInspectorPlugin> > valid_plugins; + List<Ref<EditorInspectorPlugin>> valid_plugins; for (int i = inspector_plugin_count - 1; i >= 0; i--) { //start by last, so lastly added can override newly added if (!inspector_plugins[i]->can_handle(object)) @@ -1472,12 +1473,14 @@ void EditorInspector::update_tree() { } } - // TreeItem *current_category = NULL; + // TreeItem *current_category = nullptr; String filter = search_box ? search_box->get_text() : ""; String group; String group_base; - VBoxContainer *category_vbox = NULL; + String subgroup; + String subgroup_base; + VBoxContainer *category_vbox = nullptr; List<PropertyInfo> plist; @@ -1488,9 +1491,9 @@ void EditorInspector::update_tree() { item_path[""] = main_vbox; - Color sscolor = get_color("prop_subsection", "Editor"); + Color sscolor = get_theme_color("prop_subsection", "Editor"); - for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) { + for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { Ref<EditorInspectorPlugin> ped = E->get(); ped->parse_begin(object); _parse_added_editors(main_vbox, ped); @@ -1502,10 +1505,19 @@ void EditorInspector::update_tree() { //make sure the property can be edited - if (p.usage & PROPERTY_USAGE_GROUP) { + if (p.usage & PROPERTY_USAGE_SUBGROUP) { + + subgroup = p.name; + subgroup_base = p.hint_string; + + continue; + + } else if (p.usage & PROPERTY_USAGE_GROUP) { group = p.name; group_base = p.hint_string; + subgroup = ""; + subgroup_base = ""; continue; @@ -1513,6 +1525,8 @@ void EditorInspector::update_tree() { group = ""; group_base = ""; + subgroup = ""; + subgroup_base = ""; if (!show_categories) continue; @@ -1534,13 +1548,13 @@ void EditorInspector::update_tree() { EditorInspectorCategory *category = memnew(EditorInspectorCategory); main_vbox->add_child(category); - category_vbox = NULL; //reset + category_vbox = nullptr; //reset String type = p.name; category->icon = EditorNode::get_singleton()->get_class_icon(type, "Object"); category->label = type; - category->bg_color = get_color("prop_category", "Editor"); + category->bg_color = get_theme_color("prop_category", "Editor"); if (use_doc_hints) { StringName type2 = p.name; if (!class_descr_cache.has(type2)) { @@ -1551,13 +1565,13 @@ void EditorInspector::update_tree() { if (E) { descr = E->get().brief_description; } - class_descr_cache[type2] = descr; + class_descr_cache[type2] = DTR(descr); } category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); } - for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) { + for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { Ref<EditorInspectorPlugin> ped = E->get(); ped->parse_category(object, p.name); _parse_added_editors(main_vbox, ped); @@ -1568,7 +1582,7 @@ void EditorInspector::update_tree() { } else if (!(p.usage & PROPERTY_USAGE_EDITOR) || _is_property_disabled_by_feature_profile(p.name)) continue; - if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && VS::get_singleton()->is_low_end()) + if (p.usage & PROPERTY_USAGE_HIGH_END_GFX && RS::get_singleton()->is_low_end()) continue; //do not show this property in low end gfx if (p.name == "script" && (hide_script || bool(object->call("_hide_script_from_inspector")))) { @@ -1576,18 +1590,33 @@ void EditorInspector::update_tree() { } String basename = p.name; + + if (subgroup != "") { + if (subgroup_base != "") { + if (basename.begins_with(subgroup_base)) { + basename = basename.replace_first(subgroup_base, ""); + } else if (subgroup_base.begins_with(basename)) { + //keep it, this is used pretty often + } else { + subgroup = ""; //no longer using subgroup base, clear + } + } + } if (group != "") { - if (group_base != "") { + if (group_base != "" && subgroup == "") { if (basename.begins_with(group_base)) { basename = basename.replace_first(group_base, ""); } else if (group_base.begins_with(basename)) { //keep it, this is used pretty often } else { group = ""; //no longer using group base, clear + subgroup = ""; } } } - + if (subgroup != "") { + basename = subgroup + "/" + basename; + } if (group != "") { basename = group + "/" + basename; } @@ -1620,7 +1649,7 @@ void EditorInspector::update_tree() { continue; } - if (category_vbox == NULL) { + if (category_vbox == nullptr) { category_vbox = memnew(VBoxContainer); main_vbox->add_child(category_vbox); } @@ -1658,7 +1687,7 @@ void EditorInspector::update_tree() { if (current_vbox == main_vbox) { //do not add directly to the main vbox, given it has no spacing - if (category_vbox == NULL) { + if (category_vbox == nullptr) { category_vbox = memnew(VBoxContainer); } current_vbox = category_vbox; @@ -1688,7 +1717,7 @@ void EditorInspector::update_tree() { String descr; bool found = false; - Map<StringName, Map<StringName, String> >::Element *E = descr_cache.find(classname); + Map<StringName, Map<StringName, String>>::Element *E = descr_cache.find(classname); if (E) { Map<StringName, String>::Element *F = E->get().find(propname); if (F) { @@ -1703,10 +1732,22 @@ void EditorInspector::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().properties.size(); i++) { if (F->get().properties[i].name == propname.operator String()) { - descr = F->get().properties[i].description.strip_edges(); + descr = DTR(F->get().properties[i].description.strip_edges()); break; } } + + Vector<String> slices = propname.operator String().split("/"); + if (slices.size() == 2 && slices[0].begins_with("custom_")) { + // Likely a theme property. + for (int i = 0; i < F->get().theme_properties.size(); i++) { + if (F->get().theme_properties[i].name == slices[1]) { + descr = DTR(F->get().theme_properties[i].description.strip_edges()); + break; + } + } + } + if (!F->get().inherits.empty()) { F = dd->class_list.find(F->get().inherits); } else { @@ -1719,7 +1760,7 @@ void EditorInspector::update_tree() { doc_hint = descr; } - for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) { + for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { Ref<EditorInspectorPlugin> ped = E->get(); bool exclusive = ped->parse_property(object, p.type, p.name, p.hint, p.hint_string, p.usage); @@ -1802,7 +1843,7 @@ void EditorInspector::update_tree() { } } - for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) { + for (List<Ref<EditorInspectorPlugin>>::Element *E = valid_plugins.front(); E; E = E->next()) { Ref<EditorInspectorPlugin> ped = E->get(); ped->parse_end(); _parse_added_editors(main_vbox, ped); @@ -1933,7 +1974,7 @@ void EditorInspector::collapse_all_folding() { E->get()->fold(); } - for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) { + for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { E->get()->collapse_all_folding(); } @@ -1944,7 +1985,7 @@ void EditorInspector::expand_all_folding() { for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { E->get()->unfold(); } - for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) { + for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { E->get()->expand_all_folding(); } @@ -1966,9 +2007,9 @@ void EditorInspector::set_sub_inspector(bool p_enable) { return; if (sub_inspector) { - add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor")); + add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor")); } else { - add_style_override("bg", get_stylebox("bg", "Tree")); + add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } } @@ -2130,7 +2171,7 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (E->get().name == p_path) { Callable::CallError ce; - to_create = Variant::construct(E->get().type, NULL, 0, ce); + to_create = Variant::construct(E->get().type, nullptr, 0, ce); break; } } @@ -2154,7 +2195,7 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) property_selected = p_path; property_focusable = p_focusable; //deselect the others - for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) { + for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { if (F->key() == property_selected) continue; for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { @@ -2178,7 +2219,7 @@ void EditorInspector::_resource_selected(const String &p_path, RES p_resource) { void EditorInspector::_node_removed(Node *p_node) { if (p_node == object) { - edit(NULL); + edit(nullptr); } } @@ -2191,21 +2232,21 @@ void EditorInspector::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { if (sub_inspector) { - add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor")); + add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor")); } else { - add_style_override("bg", get_stylebox("bg", "Tree")); + add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } } if (p_what == NOTIFICATION_PREDELETE) { - edit(NULL); //just in case + edit(nullptr); //just in case } if (p_what == NOTIFICATION_EXIT_TREE) { if (!sub_inspector) { get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } - edit(NULL); + edit(nullptr); } if (p_what == NOTIFICATION_PROCESS) { @@ -2217,7 +2258,7 @@ void EditorInspector::_notification(int p_what) { if (refresh_countdown > 0) { refresh_countdown -= get_process_delta_time(); if (refresh_countdown <= 0) { - for (Map<StringName, List<EditorProperty *> >::Element *F = editor_property_map.front(); F; F = F->next()) { + for (Map<StringName, List<EditorProperty *>>::Element *F = editor_property_map.front(); F; F = F->next()) { for (List<EditorProperty *>::Element *E = F->get().front(); E; E = E->next()) { E->get()->update_property(); E->get()->update_reload_status(); @@ -2254,9 +2295,9 @@ void EditorInspector::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { if (sub_inspector) { - add_style_override("bg", get_stylebox("sub_inspector_bg", "Editor")); + add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor")); } else if (is_inside_tree()) { - add_style_override("bg", get_stylebox("bg", "Tree")); + add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } update_tree(); @@ -2315,11 +2356,11 @@ void EditorInspector::_bind_methods() { } EditorInspector::EditorInspector() { - object = NULL; - undo_redo = NULL; + object = nullptr; + undo_redo = nullptr; main_vbox = memnew(VBoxContainer); main_vbox->set_h_size_flags(SIZE_EXPAND_FILL); - main_vbox->add_constant_override("separation", 0); + main_vbox->add_theme_constant_override("separation", 0); add_child(main_vbox); set_enable_h_scroll(false); set_enable_v_scroll(true); @@ -2336,7 +2377,7 @@ EditorInspector::EditorInspector() { update_tree_pending = false; refresh_countdown = 0; read_only = false; - search_box = NULL; + search_box = nullptr; keying = false; _prop_edited = "property_edited"; set_process(true); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 7a1542d30f..b49a4424f6 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -261,7 +261,7 @@ class EditorInspector : public ScrollContainer { VBoxContainer *main_vbox; //map use to cache the instanced editors - Map<StringName, List<EditorProperty *> > editor_property_map; + Map<StringName, List<EditorProperty *>> editor_property_map; List<EditorInspectorSection *> sections; Set<StringName> pending; @@ -291,7 +291,7 @@ class EditorInspector : public ScrollContainer { int property_focusable; int update_scroll_request; - Map<StringName, Map<StringName, String> > descr_cache; + Map<StringName, Map<StringName, String>> descr_cache; Map<StringName, String> class_descr_cache; Set<StringName> restart_request_props; diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 776fbd9314..dbd043c494 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -52,12 +52,12 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { if (get_hide_on_ok()) hide(); ok_pressed(); - accept_event(); + set_input_as_handled(); } break; case KEY_ESCAPE: { hide(); - accept_event(); + set_input_as_handled(); } break; } } @@ -110,15 +110,15 @@ EditorLayoutsDialog::EditorLayoutsDialog() { makevb = memnew(VBoxContainer); add_child(makevb); - makevb->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); - makevb->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); + makevb->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); + makevb->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); layout_names = memnew(ItemList); makevb->add_child(layout_names); layout_names->set_visible(true); layout_names->set_margin(MARGIN_TOP, 5); - layout_names->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); - layout_names->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); + layout_names->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); + layout_names->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL); layout_names->set_select_mode(ItemList::SELECT_MULTI); layout_names->set_allow_rmb_select(true); @@ -126,8 +126,8 @@ EditorLayoutsDialog::EditorLayoutsDialog() { name = memnew(LineEdit); makevb->add_child(name); name->set_margin(MARGIN_TOP, 5); - name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); - name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); + name->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); + name->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5); name->connect("gui_input", callable_mp(this, &EditorLayoutsDialog::_line_gui_input)); name->connect("focus_entered", callable_mp(layout_names, &ItemList::unselect_all)); } diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 0e50a5e95c..c89a7bcf23 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -62,12 +62,12 @@ void EditorLog::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { //button->set_icon(get_icon("Console","EditorIcons")); - log->add_font_override("normal_font", get_font("output_source", "EditorFonts")); + log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - Ref<DynamicFont> df_output_code = get_font("output_source", "EditorFonts"); + Ref<DynamicFont> df_output_code = get_theme_font("output_source", "EditorFonts"); if (df_output_code.is_valid()) { - if (log != NULL) { - log->add_font_override("normal_font", get_font("output_source", "EditorFonts")); + if (log != nullptr) { + log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); } } } @@ -101,22 +101,22 @@ void EditorLog::add_message(const String &p_msg, MessageType p_type) { case MSG_TYPE_STD: { } break; case MSG_TYPE_ERROR: { - log->push_color(get_color("error_color", "Editor")); - Ref<Texture2D> icon = get_icon("Error", "EditorIcons"); + log->push_color(get_theme_color("error_color", "Editor")); + Ref<Texture2D> icon = get_theme_icon("Error", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_WARNING: { - log->push_color(get_color("warning_color", "Editor")); - Ref<Texture2D> icon = get_icon("Warning", "EditorIcons"); + log->push_color(get_theme_color("warning_color", "Editor")); + Ref<Texture2D> icon = get_theme_icon("Warning", "EditorIcons"); log->add_image(icon); log->add_text(" "); tool_button->set_icon(icon); } break; case MSG_TYPE_EDITOR: { // Distinguish editor messages from messages printed by the project - log->push_color(get_color("font_color", "Editor") * Color(1, 1, 1, 0.6)); + log->push_color(get_theme_color("font_color", "Editor") * Color(1, 1, 1, 0.6)); } break; } @@ -181,7 +181,7 @@ EditorLog::EditorLog() { current = Thread::get_caller_id(); - add_constant_override("separation", get_constant("separation", "VBoxContainer")); + add_theme_constant_override("separation", get_theme_constant("separation", "VBoxContainer")); EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk, this); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 323684effe..6f6287ccb5 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -32,6 +32,7 @@ #include "core/bind/core_bind.h" #include "core/class_db.h" +#include "core/input/input_filter.h" #include "core/io/config_file.h" #include "core/io/image_loader.h" #include "core/io/resource_loader.h" @@ -39,7 +40,6 @@ #include "core/io/stream_peer_ssl.h" #include "core/message_queue.h" #include "core/os/file_access.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/path_remap.h" @@ -47,7 +47,6 @@ #include "core/project_settings.h" #include "core/translation.h" #include "core/version.h" -#include "main/input_default.h" #include "main/main.h" #include "scene/gui/center_container.h" #include "scene/gui/control.h" @@ -62,9 +61,9 @@ #include "scene/gui/texture_progress.h" #include "scene/gui/tool_button.h" #include "scene/resources/packed_scene.h" -#include "servers/navigation_2d_server.h" -#include "servers/navigation_server.h" -#include "servers/physics_2d_server.h" +#include "servers/navigation_server_2d.h" +#include "servers/navigation_server_3d.h" +#include "servers/physics_server_2d.h" #include "editor/audio_stream_preview.h" #include "editor/debugger/editor_debugger_node.h" @@ -115,32 +114,33 @@ #include "editor/plugins/asset_library_editor_plugin.h" #include "editor/plugins/audio_stream_editor_plugin.h" #include "editor/plugins/baked_lightmap_editor_plugin.h" -#include "editor/plugins/camera_editor_plugin.h" +#include "editor/plugins/camera_3d_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/collision_polygon_2d_editor_plugin.h" -#include "editor/plugins/collision_polygon_editor_plugin.h" +#include "editor/plugins/collision_polygon_3d_editor_plugin.h" #include "editor/plugins/collision_shape_2d_editor_plugin.h" #include "editor/plugins/cpu_particles_2d_editor_plugin.h" -#include "editor/plugins/cpu_particles_editor_plugin.h" +#include "editor/plugins/cpu_particles_3d_editor_plugin.h" #include "editor/plugins/curve_editor_plugin.h" #include "editor/plugins/debugger_editor_plugin.h" #include "editor/plugins/editor_preview_plugins.h" #include "editor/plugins/gi_probe_editor_plugin.h" +#include "editor/plugins/gpu_particles_2d_editor_plugin.h" +#include "editor/plugins/gpu_particles_3d_editor_plugin.h" #include "editor/plugins/gradient_editor_plugin.h" #include "editor/plugins/item_list_editor_plugin.h" #include "editor/plugins/light_occluder_2d_editor_plugin.h" #include "editor/plugins/line_2d_editor_plugin.h" #include "editor/plugins/material_editor_plugin.h" #include "editor/plugins/mesh_editor_plugin.h" -#include "editor/plugins/mesh_instance_editor_plugin.h" +#include "editor/plugins/mesh_instance_3d_editor_plugin.h" #include "editor/plugins/mesh_library_editor_plugin.h" #include "editor/plugins/multimesh_editor_plugin.h" #include "editor/plugins/navigation_polygon_editor_plugin.h" -#include "editor/plugins/particles_2d_editor_plugin.h" -#include "editor/plugins/particles_editor_plugin.h" +#include "editor/plugins/node_3d_editor_plugin.h" #include "editor/plugins/path_2d_editor_plugin.h" -#include "editor/plugins/path_editor_plugin.h" -#include "editor/plugins/physical_bone_plugin.h" +#include "editor/plugins/path_3d_editor_plugin.h" +#include "editor/plugins/physical_bone_3d_editor_plugin.h" #include "editor/plugins/polygon_2d_editor_plugin.h" #include "editor/plugins/resource_preloader_editor_plugin.h" #include "editor/plugins/root_motion_editor_plugin.h" @@ -148,10 +148,9 @@ #include "editor/plugins/script_text_editor.h" #include "editor/plugins/shader_editor_plugin.h" #include "editor/plugins/skeleton_2d_editor_plugin.h" -#include "editor/plugins/skeleton_editor_plugin.h" -#include "editor/plugins/skeleton_ik_editor_plugin.h" -#include "editor/plugins/spatial_editor_plugin.h" -#include "editor/plugins/sprite_editor_plugin.h" +#include "editor/plugins/skeleton_3d_editor_plugin.h" +#include "editor/plugins/skeleton_ik_3d_editor_plugin.h" +#include "editor/plugins/sprite_2d_editor_plugin.h" #include "editor/plugins/sprite_frames_editor_plugin.h" #include "editor/plugins/style_box_editor_plugin.h" #include "editor/plugins/text_editor.h" @@ -170,20 +169,23 @@ #include "editor/register_exporters.h" #include "editor/run_settings_dialog.h" #include "editor/settings_config_dialog.h" - +#include "scene/main/window.h" +#include "servers/display_server.h" #include <stdio.h> #include <stdlib.h> -EditorNode *EditorNode::singleton = NULL; +EditorNode *EditorNode::singleton = nullptr; void EditorNode::_update_scene_tabs() { bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button"); - OS::get_singleton()->global_menu_clear("_dock"); + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { + DisplayServer::get_singleton()->global_menu_clear("_dock"); + } scene_tabs->clear_tabs(); - Ref<Texture2D> script_icon = gui_base->get_icon("Script", "EditorIcons"); + Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons"); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *type_node = editor_data.get_edited_scene_root(i); @@ -196,15 +198,19 @@ void EditorNode::_update_scene_tabs() { bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0; scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon); - OS::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), GLOBAL_SCENE, i); + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { + DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), callable_mp(this, &EditorNode::_global_menu_scene), i); + } if (show_rb && editor_data.get_scene_root_script(i).is_valid()) { scene_tabs->set_tab_right_button(i, script_icon); } } - OS::get_singleton()->global_menu_add_separator("_dock"); - OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant()); + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { + DisplayServer::get_singleton()->global_menu_add_separator("_dock"); + DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &EditorNode::_global_menu_new_window)); + } scene_tabs->set_current_tab(editor_data.get_edited_scene()); @@ -253,16 +259,13 @@ void EditorNode::_update_title() { if (unsaved_cache) title += " (*)"; - OS::get_singleton()->set_window_title(title); + DisplayServer::get_singleton()->window_set_title(title); } void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { - if (Node::get_viewport()->get_modal_stack_top()) - return; //ignore because of modal window - Ref<InputEventKey> k = p_event; - if (k.is_valid() && k->is_pressed() && !k->is_echo() && !gui_base->get_viewport()->gui_has_modal_stack()) { + if (k.is_valid() && k->is_pressed() && !k->is_echo()) { EditorPlugin *old_editor = editor_plugin_screen; @@ -297,7 +300,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { } if (old_editor != editor_plugin_screen) { - get_tree()->set_input_as_handled(); + get_tree()->get_root()->set_input_as_handled(); } } } @@ -335,13 +338,13 @@ void EditorNode::_notification(int p_what) { // update the icon itself only when the spinner is visible if (EditorSettings::get_singleton()->get("interface/editor/show_update_spinner")) { - update_spinner->set_icon(gui_base->get_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons")); + update_spinner->set_icon(gui_base->get_theme_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons")); } } editor_selection->update(); - scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); + //scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); { //TODO should only happen on settings changed int current_filter = GLOBAL_GET("rendering/canvas_textures/default_texture_filter"); @@ -355,13 +358,26 @@ void EditorNode::_notification(int p_what) { scene_root->set_default_canvas_item_texture_repeat(tr); } - VS::DOFBokehShape dof_shape = VS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))); - VS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape); - VS::DOFBlurQuality dof_quality = VS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))); - bool dof_jitter = GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter"); - VS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter); - VS::get_singleton()->environment_set_ssao_quality(VS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); - VS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve")); + RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_shape"))); + RS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape); + RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_quality"))); + bool dof_jitter = GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_use_jitter"); + RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter); + RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size")); + RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_curve")); + bool glow_bicubic = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0; + RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic); + RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality"))); + RS::get_singleton()->environment_set_ssr_roughness_quality(ssr_roughness_quality); + RS::SubSurfaceScatteringQuality sss_quality = RS::SubSurfaceScatteringQuality(int(GLOBAL_GET("rendering/quality/subsurface_scattering/subsurface_scattering_quality"))); + RS::get_singleton()->sub_surface_scattering_set_quality(sss_quality); + float sss_scale = GLOBAL_GET("rendering/quality/subsurface_scattering/subsurface_scattering_scale"); + float sss_depth_scale = GLOBAL_GET("rendering/quality/subsurface_scattering/subsurface_scattering_depth_scale"); + RS::get_singleton()->sub_surface_scattering_set_scale(sss_scale, sss_depth_scale); + RS::ShadowQuality shadows_quality = RS::ShadowQuality(int(GLOBAL_GET("rendering/quality/shadows/soft_shadow_quality"))); + RS::get_singleton()->shadows_quality_set(shadows_quality); + RS::ShadowQuality directional_shadow_quality = RS::ShadowQuality(int(GLOBAL_GET("rendering/quality/directional_shadow/soft_shadow_quality"))); + RS::get_singleton()->directional_shadow_quality_set(directional_shadow_quality); } ResourceImporterTexture::get_singleton()->update_imports(); @@ -374,15 +390,14 @@ void EditorNode::_notification(int p_what) { get_tree()->get_root()->set_as_audio_listener(false); get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->set_auto_accept_quit(false); - get_tree()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files)); - get_tree()->connect("global_menu_action", callable_mp(this, &EditorNode::_global_menu_action)); + get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files)); /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; case NOTIFICATION_EXIT_TREE: { editor_data.save_editor_external_data(); - FileAccess::set_file_close_fail_notify_callback(NULL); + FileAccess::set_file_close_fail_notify_callback(nullptr); log->deinit(); // do not get messages anymore editor_data.clear_edited_scenes(); } break; @@ -402,9 +417,9 @@ void EditorNode::_notification(int p_what) { _initializing_addons = false; } - VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); feature_profile_manager->notify_changed(); @@ -417,7 +432,7 @@ void EditorNode::_notification(int p_what) { /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; - case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + case NOTIFICATION_WM_FOCUS_IN: { // Restore the original FPS cap after focusing back on the editor OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); @@ -425,18 +440,18 @@ void EditorNode::_notification(int p_what) { EditorFileSystem::get_singleton()->scan_changes(); } break; - case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { + case NOTIFICATION_WM_FOCUS_OUT: { // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec"))); } break; - case MainLoop::NOTIFICATION_WM_ABOUT: { + case NOTIFICATION_WM_ABOUT: { show_about(); } break; - case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: { + case NOTIFICATION_WM_CLOSE_REQUEST: { _menu_option_confirm(FILE_QUIT, false); } break; @@ -448,17 +463,17 @@ void EditorNode::_notification(int p_what) { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); - scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); - scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); + scene_tabs->add_theme_style_override("tab_fg", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); + scene_tabs->add_theme_style_override("tab_bg", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); - file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); @@ -471,7 +486,7 @@ void EditorNode::_notification(int p_what) { // debugger area if (EditorDebuggerNode::get_singleton()->is_visible()) - bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); // update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { @@ -482,36 +497,38 @@ void EditorNode::_notification(int p_what) { if (icon.is_valid()) { tb->set_icon(icon); - } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) { - tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), "EditorIcons")) { + tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons")); } } _build_icon_type_cache(); - play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); - play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); - play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); - pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); - stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); + pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); + stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); - prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); - distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); - scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); + distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); + scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); - bottom_panel_raise->set_icon(gui_base->get_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons")); dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); PopupMenu *p = help_menu->get_popup(); - p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_icon("HelpSearch", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_icon("Godot", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_theme_icon("HelpSearch", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_REPORT_A_BUG), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_SEND_DOCS_FEEDBACK), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_theme_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_theme_icon("Godot", "EditorIcons")); _update_update_spinner(); } break; @@ -547,7 +564,7 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam void EditorNode::_resources_changed(const Vector<String> &p_resources) { - List<Ref<Resource> > changed; + List<Ref<Resource>> changed; int rc = p_resources.size(); for (int i = 0; i < rc; i++) { @@ -573,7 +590,7 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } if (changed.size()) { - for (List<Ref<Resource> >::Element *E = changed.front(); E; E = E->next()) { + for (List<Ref<Resource>>::Element *E = changed.front(); E; E = E->next()) { E->get()->reload_from_file(); } } @@ -822,7 +839,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } } - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); saving_resource = p_resource; current_option = RESOURCE_SAVE_AS; @@ -859,7 +876,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String 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())); } } @@ -1105,7 +1122,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { if (p_node->is_class("CanvasItem")) count_2d++; - else if (p_node->is_class("Spatial")) + else if (p_node->is_class("Node3D")) count_3d++; for (int i = 0; i < p_node->get_child_count(); i++) @@ -1116,7 +1133,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { EditorProgress save("save", TTR("Saving Scene"), 4); - if (editor_data.get_edited_scene_root() != NULL) { + if (editor_data.get_edited_scene_root() != nullptr) { save.step(TTR("Analyzing"), 0); int c2d = 0; @@ -1137,7 +1154,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { if (is2d) { img = scene_root->get_texture()->get_data(); } else { - img = SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data(); + img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data(); } if (img.is_valid()) { @@ -1210,7 +1227,7 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod return false; } -static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Resource> > &edited_resources) { +static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Resource>> &edited_resources) { if (p_resource->is_edited()) { edited_resources.insert(p_resource); @@ -1247,11 +1264,11 @@ int EditorNode::_save_external_resources() { flg |= ResourceSaver::FLAG_COMPRESS; flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; - Set<Ref<Resource> > edited_subresources; + Set<Ref<Resource>> edited_subresources; int saved = 0; - List<Ref<Resource> > cached; + List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) { + for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { Ref<Resource> res = E->get(); if (!res->get_path().is_resource_file()) @@ -1266,7 +1283,7 @@ int EditorNode::_save_external_resources() { // clear later, because user may have put the same subresource in two different resources, // which will be shared until the next reload - for (Set<Ref<Resource> >::Element *E = edited_subresources.front(); E; E = E->next()) { + for (Set<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) { Ref<Resource> res = E->get(); res->set_edited(false); } @@ -1466,7 +1483,7 @@ void EditorNode::_dialog_action(String p_file) { int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing; - if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { bool same_open_scene = false; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { if (editor_data.get_scene_path(i) == p_file && i != scene_idx) @@ -1490,7 +1507,7 @@ void EditorNode::_dialog_action(String p_file) { } break; case FILE_SAVE_AND_RUN: { - if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { _save_default_environment(); _save_scene_with_preview(p_file); @@ -1555,7 +1572,7 @@ void EditorNode::_dialog_action(String p_file) { save_resource_in_path(saving_resource, p_file); saving_resource = Ref<Resource>(); ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!current_obj); current_obj->_change_notify(); } break; @@ -1620,7 +1637,7 @@ void EditorNode::_dialog_action(String p_file) { } break; default: { //save scene? - if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { + if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { _save_scene_with_preview(p_file); } @@ -1701,10 +1718,10 @@ void EditorNode::edit_item(Object *p_object) { void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) { if (!p_object) { - get_inspector()->edit(NULL); - node_dock->set_node(NULL); - scene_tree_dock->set_selected(NULL); - inspector_dock->update(NULL); + get_inspector()->edit(nullptr); + node_dock->set_node(nullptr); + scene_tree_dock->set_selected(nullptr); + inspector_dock->update(nullptr); return; } @@ -1765,17 +1782,17 @@ static bool overrides_external_editor(Object *p_object) { void EditorNode::_edit_current() { ObjectID current = editor_history.get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; bool inspector_only = editor_history.is_current_inspector_only(); this->current = current_obj; if (!current_obj) { - scene_tree_dock->set_selected(NULL); - get_inspector()->edit(NULL); - node_dock->set_node(NULL); - inspector_dock->update(NULL); + scene_tree_dock->set_selected(nullptr); + get_inspector()->edit(nullptr); + node_dock->set_node(nullptr); + inspector_dock->update(nullptr); _display_top_editors(false); @@ -1796,9 +1813,9 @@ void EditorNode::_edit_current() { Resource *current_res = Object::cast_to<Resource>(current_obj); ERR_FAIL_COND(!current_res); get_inspector()->edit(current_res); - scene_tree_dock->set_selected(NULL); - node_dock->set_node(NULL); - inspector_dock->update(NULL); + scene_tree_dock->set_selected(nullptr); + node_dock->set_node(nullptr); + inspector_dock->update(nullptr); EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path()); int subr_idx = current_res->get_path().find("::"); @@ -1827,9 +1844,9 @@ void EditorNode::_edit_current() { scene_tree_dock->set_selected(current_node); inspector_dock->update(current_node); } else { - node_dock->set_node(NULL); - scene_tree_dock->set_selected(NULL); - inspector_dock->update(NULL); + node_dock->set_node(nullptr); + scene_tree_dock->set_selected(nullptr); + inspector_dock->update(nullptr); } if (get_edited_scene() && get_edited_scene()->get_filename() != String()) { @@ -1841,7 +1858,7 @@ void EditorNode::_edit_current() { } else { - Node *selected_node = NULL; + Node *selected_node = nullptr; if (current_obj->is_class("EditorDebuggerRemoteObject")) { editable_warning = TTR("This is a remote object, so changes to it won't be kept.\nPlease read the documentation relevant to debugging to better understand this workflow."); @@ -1870,9 +1887,9 @@ void EditorNode::_edit_current() { } get_inspector()->edit(current_obj); - node_dock->set_node(NULL); + node_dock->set_node(nullptr); scene_tree_dock->set_selected(selected_node); - inspector_dock->update(NULL); + inspector_dock->update(nullptr); } if (current_obj == prev_inspected_object) { @@ -1898,7 +1915,7 @@ void EditorNode::_edit_current() { for (int i = 0; i < editor_table.size(); i++) { if (editor_table[i] == main_plugin && !main_editor_buttons[i]->is_visible()) { - main_plugin = NULL; //if button is not visible, then no plugin active + main_plugin = nullptr; //if button is not visible, then no plugin active } } @@ -1970,11 +1987,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } play_button->set_pressed(false); - play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); String main_scene; String run_filename; @@ -2057,14 +2074,14 @@ void EditorNode::_run(bool p_current, const String &p_custom) { emit_signal("play_pressed"); if (p_current) { play_scene_button->set_pressed(true); - play_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); } else if (p_custom != "") { run_custom_filename = p_custom; play_custom_scene_button->set_pressed(true); - play_custom_scene_button->set_icon(gui_base->get_icon("Reload", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); } else { play_button->set_pressed(true); - play_button->set_icon(gui_base->get_icon("Reload", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon("Reload", "EditorIcons")); } stop_button->set_disabled(false); @@ -2085,7 +2102,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_NEW_INHERITED_SCENE: case FILE_OPEN_SCENE: { - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); @@ -2158,7 +2175,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename(); save_confirmation->get_ok()->set_text(TTR("Save & Close")); save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene")); - save_confirmation->popup_centered_minsize(); + save_confirmation->popup_centered(); break; } } else if (p_option == FILE_CLOSE) { @@ -2212,7 +2229,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { break; } - file->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); List<String> extensions; Ref<PackedScene> sd = memnew(PackedScene); @@ -2227,7 +2244,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { file->set_current_path(scene->get_filename()); if (extensions.size()) { String ext = scene->get_filename().get_extension().to_lower(); - if (extensions.find(ext) == NULL) { + if (extensions.find(ext) == nullptr) { file->set_current_path(scene->get_filename().replacen("." + ext, "." + extensions.front()->get())); } } @@ -2254,7 +2271,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { confirmation->get_cancel()->set_text(TTR("No")); confirmation->get_ok()->set_text(TTR("Yes")); confirmation->set_text(TTR("This scene has never been saved. Save before running?")); - confirmation->popup_centered_minsize(); + confirmation->popup_centered(); break; } @@ -2326,7 +2343,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { confirmation->get_ok()->set_text(TTR("Open")); confirmation->set_text(TTR("Current scene not saved. Open anyway?")); - confirmation->popup_centered_minsize(); + confirmation->popup_centered(); break; } @@ -2341,7 +2358,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case EDIT_UNDO: { - if (Input::get_singleton()->get_mouse_button_mask() & 0x7) { + if (InputFilter::get_singleton()->get_mouse_button_mask() & 0x7) { log->add_message("Can't undo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR); } else { String action = editor_data.get_undo_redo().get_current_action_name(); @@ -2355,7 +2372,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case EDIT_REDO: { - if (Input::get_singleton()->get_mouse_button_mask() & 0x7) { + if (InputFilter::get_singleton()->get_mouse_button_mask() & 0x7) { log->add_message("Can't redo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR); } else { if (!editor_data.get_undo_redo().redo()) { @@ -2384,7 +2401,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (unsaved_cache && !p_confirmed) { confirmation->get_ok()->set_text(TTR("Revert")); confirmation->set_text(TTR("This action cannot be undone. Revert anyway?")); - confirmation->popup_centered_minsize(); + confirmation->popup_centered(); break; } @@ -2424,11 +2441,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { editor_run.stop(); run_custom_filename.clear(); play_button->set_pressed(false); - play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); play_scene_button->set_pressed(false); - play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); play_custom_scene_button->set_pressed(false); - play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); stop_button->set_disabled(true); if (bool(EDITOR_GET("run/output/always_close_output_on_stop"))) { @@ -2487,11 +2504,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { export_template_manager->install_android_template(); } else { if (DirAccess::exists("res://android/build")) { - remove_android_build_template->popup_centered_minsize(); + remove_android_build_template->popup_centered(); } else if (export_template_manager->can_install_android_template()) { - install_android_build_template->popup_centered_minsize(); + install_android_build_template->popup_centered(); } else { - custom_build_manage_templates->popup_centered_minsize(); + custom_build_manage_templates->popup_centered(); } } } break; @@ -2513,7 +2530,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { confirmation->get_ok()->set_text(p_option == FILE_QUIT ? TTR("Quit") : TTR("Yes")); confirmation->set_text(p_option == FILE_QUIT ? TTR("Exit the editor?") : TTR("Open Project Manager?")); - confirmation->popup_centered_minsize(); + confirmation->popup_centered(); } else { _discard_changes(); break; @@ -2534,11 +2551,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { save_confirmation->get_ok()->set_text(TTR("Save & Quit")); save_confirmation->set_text((p_option == FILE_QUIT ? TTR("Save changes to the following scene(s) before quitting?") : TTR("Save changes the following scene(s) before opening Project Manager?")) + unsaved_scenes); - save_confirmation->popup_centered_minsize(); + save_confirmation->popup_centered(); } } - OS::get_singleton()->request_attention(); + DisplayServer::get_singleton()->window_request_attention(); break; } @@ -2586,13 +2603,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SETTINGS_TOGGLE_FULLSCREEN: { - OS::get_singleton()->set_window_fullscreen(!OS::get_singleton()->is_window_fullscreen()); + DisplayServer::get_singleton()->window_set_mode(DisplayServer::get_singleton()->window_get_mode() == DisplayServer::WINDOW_MODE_FULLSCREEN ? DisplayServer::WINDOW_MODE_WINDOWED : DisplayServer::WINDOW_MODE_FULLSCREEN); } break; case SETTINGS_TOGGLE_CONSOLE: { - bool was_visible = OS::get_singleton()->is_console_visible(); - OS::get_singleton()->set_console_visible(!was_visible); + bool was_visible = DisplayServer::get_singleton()->is_console_visible(); + DisplayServer::get_singleton()->console_set_visible(!was_visible); EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", was_visible); } break; case EDITOR_SCREENSHOT: { @@ -2601,7 +2618,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SETTINGS_PICK_MAIN_SCENE: { - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); @@ -2627,14 +2644,17 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_QA: { OS::get_singleton()->shell_open("https://godotengine.org/qa/"); } break; - case HELP_ISSUES: { + case HELP_REPORT_A_BUG: { OS::get_singleton()->shell_open("https://github.com/godotengine/godot/issues"); } break; + case HELP_SEND_DOCS_FEEDBACK: { + OS::get_singleton()->shell_open("https://github.com/godotengine/godot-docs/issues"); + } break; case HELP_COMMUNITY: { OS::get_singleton()->shell_open("https://godotengine.org/community"); } break; case HELP_ABOUT: { - about->popup_centered_minsize(Size2(780, 500) * EDSCALE); + about->popup_centered(Size2(780, 500) * EDSCALE); } break; case SET_VIDEO_DRIVER_SAVE_AND_RESTART: { @@ -2663,10 +2683,10 @@ void EditorNode::_screenshot(bool p_use_utc) { void EditorNode::_save_screenshot(NodePath p_path) { - Viewport *viewport = EditorInterface::get_singleton()->get_editor_viewport()->get_viewport(); - viewport->set_clear_mode(Viewport::CLEAR_MODE_ONLY_NEXT_FRAME); + SubViewport *viewport = Object::cast_to<SubViewport>(EditorInterface::get_singleton()->get_editor_viewport()->get_viewport()); + viewport->set_clear_mode(SubViewport::CLEAR_MODE_ONLY_NEXT_FRAME); Ref<Image> img = viewport->get_texture()->get_data(); - viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS); + viewport->set_clear_mode(SubViewport::CLEAR_MODE_ALWAYS); Error error = img->save_png(p_path); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'."); } @@ -2737,7 +2757,7 @@ void EditorNode::_discard_changes(const String &p_str) { case SCENE_TAB_CLOSE: { Node *scene = editor_data.get_edited_scene_root(tab_closing); - if (scene != NULL) { + if (scene != nullptr) { String scene_filename = scene->get_filename(); if (scene_filename != "") { previous_scenes.push_back(scene_filename); @@ -2884,8 +2904,8 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed if (icon.is_valid()) { tb->set_icon(icon); - } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) { - tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + } else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), "EditorIcons")) { + tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), "EditorIcons")); } tb->set_name(p_editor->get_name()); @@ -3117,7 +3137,7 @@ Dictionary EditorNode::_get_main_scene_state() { void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { - if (get_edited_scene() != p_for_scene && p_for_scene != NULL) + if (get_edited_scene() != p_for_scene && p_for_scene != nullptr) return; //not for this scene changing_scene = false; @@ -3269,7 +3289,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (!p_force_open_imported && FileAccess::exists(p_scene + ".import")) { open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."), p_scene.get_file())); - open_imported->popup_centered_minsize(); + open_imported->popup_centered(); new_inherited_button->grab_focus(); open_import_request = p_scene; return OK; @@ -3333,7 +3353,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b dependency_errors.erase(lpath); //at least not self path - for (Map<String, Set<String> >::Element *E = dependency_errors.front(); E; E = E->next()) { + for (Map<String, Set<String>>::Element *E = dependency_errors.front(); E; E = E->next()) { String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E->key()) + "\n"; for (Set<String>::Element *F = E->get().front(); F; F = F->next()) { @@ -3412,7 +3432,7 @@ void EditorNode::open_request(const String &p_path) { if (!opening_prev) { List<String>::Element *prev_scene = previous_scenes.find(p_path); - if (prev_scene != NULL) { + if (prev_scene != nullptr) { prev_scene->erase(); } } @@ -3553,7 +3573,7 @@ void EditorNode::add_io_error(const String &p_error) { void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { EditorNode *en = (EditorNode *)p_ud; - en->load_errors->add_image(en->gui_base->get_icon("Error", "EditorIcons")); + en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons")); en->load_errors->add_text(p_text + "\n"); en->load_error_dialog->popup_centered_ratio(0.5); } @@ -3593,8 +3613,8 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorSelection>(); ClassDB::register_class<EditorFileDialog>(); ClassDB::register_virtual_class<EditorSettings>(); - ClassDB::register_class<EditorSpatialGizmo>(); - ClassDB::register_class<EditorSpatialGizmoPlugin>(); + ClassDB::register_class<EditorNode3DGizmo>(); + ClassDB::register_class<EditorNode3DGizmoPlugin>(); ClassDB::register_virtual_class<EditorResourcePreview>(); ClassDB::register_class<EditorResourcePreviewGenerator>(); ClassDB::register_virtual_class<EditorFileSystem>(); @@ -3612,6 +3632,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class<ScriptCreateDialog>(); ClassDB::register_class<EditorFeatureProfile>(); ClassDB::register_class<EditorSpinSlider>(); + ClassDB::register_virtual_class<FileSystemDock>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? ClassDB::register_class<EditorScenePostImport>(); @@ -3633,7 +3654,7 @@ void EditorNode::stop_child_process(OS::ProcessID p_pid) { } Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) const { - ERR_FAIL_COND_V(!p_object, NULL); + ERR_FAIL_COND_V(!p_object, nullptr); Ref<Script> script = p_object->get_script(); @@ -3660,7 +3681,7 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons } } - return NULL; + return nullptr; } StringName EditorNode::get_object_custom_type_name(const Object *p_object) const { @@ -3706,11 +3727,11 @@ Ref<ImageTexture> EditorNode::_load_custom_class_icon(const String &p_path) cons return icon; } } - return NULL; + return nullptr; } Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String &p_fallback) const { - ERR_FAIL_COND_V(!p_object || !gui_base, NULL); + ERR_FAIL_COND_V(!p_object || !gui_base, nullptr); Ref<Script> script = p_object->get_script(); if (script.is_null() && p_object->is_class("Script")) { @@ -3745,20 +3766,20 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String if (p_object->has_meta("_editor_icon")) return p_object->get_meta("_editor_icon"); - if (gui_base->has_icon(p_object->get_class(), "EditorIcons")) - return gui_base->get_icon(p_object->get_class(), "EditorIcons"); + if (gui_base->has_theme_icon(p_object->get_class(), "EditorIcons")) + return gui_base->get_theme_icon(p_object->get_class(), "EditorIcons"); if (p_fallback.length()) - return gui_base->get_icon(p_fallback, "EditorIcons"); + return gui_base->get_theme_icon(p_fallback, "EditorIcons"); - return NULL; + return nullptr; } Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p_fallback) const { - ERR_FAIL_COND_V_MSG(p_class.empty(), NULL, "Class name cannot be empty."); + ERR_FAIL_COND_V_MSG(p_class.empty(), nullptr, "Class name cannot be empty."); - if (gui_base->has_icon(p_class, "EditorIcons")) { - return gui_base->get_icon(p_class, "EditorIcons"); + if (gui_base->has_theme_icon(p_class, "EditorIcons")) { + return gui_base->get_theme_icon(p_class, "EditorIcons"); } if (ScriptServer::is_global_class(p_class)) { @@ -3772,7 +3793,7 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p while (script.is_valid()) { String current_icon_path; - script->get_language()->get_global_class_name(script->get_path(), NULL, ¤t_icon_path); + script->get_language()->get_global_class_name(script->get_path(), nullptr, ¤t_icon_path); icon = _load_custom_class_icon(current_icon_path); if (icon.is_valid()) { return icon; @@ -3781,14 +3802,14 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } if (icon.is_null()) { - icon = gui_base->get_icon(ScriptServer::get_global_class_base(p_class), "EditorIcons"); + icon = gui_base->get_theme_icon(ScriptServer::get_global_class_base(p_class), "EditorIcons"); } return icon; } - const Map<String, Vector<EditorData::CustomType> > &p_map = EditorNode::get_editor_data().get_custom_types(); - for (const Map<String, Vector<EditorData::CustomType> >::Element *E = p_map.front(); E; E = E->next()) { + const Map<String, Vector<EditorData::CustomType>> &p_map = EditorNode::get_editor_data().get_custom_types(); + for (const Map<String, Vector<EditorData::CustomType>>::Element *E = p_map.front(); E; E = E->next()) { const Vector<EditorData::CustomType> &ct = E->value(); for (int i = 0; i < ct.size(); ++i) { if (ct[i].name == p_class) { @@ -3799,10 +3820,10 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } } - if (p_fallback.length() && gui_base->has_icon(p_fallback, "EditorIcons")) - return gui_base->get_icon(p_fallback, "EditorIcons"); + if (p_fallback.length() && gui_base->has_theme_icon(p_fallback, "EditorIcons")) + return gui_base->get_theme_icon(p_fallback, "EditorIcons"); - return NULL; + return nullptr; } void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { @@ -3921,7 +3942,7 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) { current_option = -1; accept->get_ok()->set_text(p_title); accept->set_text(p_text); - accept->popup_centered_minsize(); + accept->popup_centered(); } void EditorNode::show_warning(const String &p_text, const String &p_title) { @@ -3929,7 +3950,7 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { if (warning->is_inside_tree()) { warning->set_text(p_text); warning->set_title(p_title); - warning->popup_centered_minsize(); + warning->popup_centered(); } else { WARN_PRINT(p_title + " " + p_text); } @@ -3937,7 +3958,91 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { void EditorNode::_copy_warning(const String &p_str) { - OS::get_singleton()->set_clipboard(warning->get_text()); + DisplayServer::get_singleton()->clipboard_set(warning->get_text()); +} + +void EditorNode::_dock_floating_close_request(Control *p_control) { + // Through the MarginContainer to the Window. + Window *window = (Window *)p_control->get_parent()->get_parent(); + int window_slot = window->get_meta("dock_slot"); + + p_control->get_parent()->remove_child(p_control); + dock_slot[window_slot]->add_child(p_control); + dock_slot[window_slot]->move_child(p_control, MIN((int)window->get_meta("dock_index"), dock_slot[window_slot]->get_child_count())); + dock_slot[window_slot]->set_current_tab(window->get_meta("dock_index")); + + window->queue_delete(); + + _update_dock_containers(); + + floating_docks.erase(p_control); +} + +void EditorNode::_dock_make_float() { + Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control(); + ERR_FAIL_COND(!dock); + + const Size2i borders = Size2i(4, 4) * EDSCALE; + Size2 dock_size = dock->get_size() + borders * 2; //remember size + Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders; + + print_line("dock pos: " + dock->get_global_position() + " window pos: " + get_tree()->get_root()->get_position()); + int dock_index = dock->get_index(); + dock_slot[dock_popup_selected]->remove_child(dock); + + Window *window = memnew(Window); + window->set_title(dock->get_name()); + Panel *p = memnew(Panel); + p->set_mode(Panel::MODE_FOREGROUND); + p->set_anchors_and_margins_preset(Control::PRESET_WIDE); + window->add_child(p); + MarginContainer *margin = memnew(MarginContainer); + margin->set_anchors_and_margins_preset(Control::PRESET_WIDE); + margin->add_theme_constant_override("margin_right", borders.width); + margin->add_theme_constant_override("margin_top", borders.height); + margin->add_theme_constant_override("margin_left", borders.width); + margin->add_theme_constant_override("margin_bottom", borders.height); + window->add_child(margin); + dock->set_anchors_and_margins_preset(Control::PRESET_WIDE); + margin->add_child(dock); + window->set_wrap_controls(true); + window->set_size(dock_size); + window->set_position(dock_screen_pos); + window->set_transient(true); + window->connect("close_requested", callable_mp(this, &EditorNode::_dock_floating_close_request), varray(dock)); + window->set_meta("dock_slot", dock_popup_selected); + window->set_meta("dock_index", dock_index); + gui_base->add_child(window); + + dock_select_popup->hide(); + + _update_dock_containers(); + + floating_docks.push_back(dock); +} + +void EditorNode::_update_dock_containers() { + + for (int i = 0; i < DOCK_SLOT_MAX; i++) { + if (dock_slot[i]->get_tab_count() == 0 && dock_slot[i]->is_visible()) { + dock_slot[i]->hide(); + } + if (dock_slot[i]->get_tab_count() > 0 && !dock_slot[i]->is_visible()) { + dock_slot[i]->show(); + } + } + for (int i = 0; i < vsplits.size(); i++) { + bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count(); + if (in_use) + vsplits[i]->show(); + else + vsplits[i]->hide(); + } + + if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) + right_hsplit->show(); + else + right_hsplit->hide(); } void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { @@ -3985,18 +4090,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { dock_slot[nrect]->show(); dock_select->update(); - for (int i = 0; i < vsplits.size(); i++) { - bool in_use = dock_slot[i * 2 + 0]->get_tab_count() || dock_slot[i * 2 + 1]->get_tab_count(); - if (in_use) - vsplits[i]->show(); - else - vsplits[i]->hide(); - } - - if (right_l_vsplit->is_visible() || right_r_vsplit->is_visible()) - right_hsplit->show(); - else - right_hsplit->hide(); + _update_dock_containers(); _edit_current(); _save_docks(); @@ -4050,7 +4144,7 @@ void EditorNode::_dock_select_draw() { Color used = Color(0.6, 0.6, 0.6, 0.8); Color used_selected = Color(0.8, 0.8, 0.8, 0.8); - Color tab_selected = theme_base->get_color("mono_color", "Editor"); + Color tab_selected = theme_base->get_theme_color("mono_color", "Editor"); Color unused = used; unused.a = 0.4; Color unusable = unused; @@ -4328,7 +4422,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String String name = names[j]; //find it, in a horribly inefficient way int atidx = -1; - Control *node = NULL; + Control *node = nullptr; for (int k = 0; k < DOCK_SLOT_MAX; k++) { if (!dock_slot[k]->has_node(name)) continue; @@ -4453,7 +4547,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { current_option = -1; pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); - pick_main_scene->popup_centered_minsize(); + pick_main_scene->popup_centered(); return false; } @@ -4461,7 +4555,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { current_option = -1; pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); - pick_main_scene->popup_centered_minsize(); + pick_main_scene->popup_centered(); return false; } @@ -4469,7 +4563,7 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { current_option = -1; pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); - pick_main_scene->popup_centered_minsize(); + pick_main_scene->popup_centered(); return false; } @@ -4589,7 +4683,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) { if (unsaved) { save_confirmation->get_ok()->set_text(TTR("Save & Close")); save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene")); - save_confirmation->popup_centered_minsize(); + save_confirmation->popup_centered(); } else { _discard_changes(); } @@ -4813,9 +4907,9 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_items[i].control->set_visible(i == p_idx); } if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller - bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); } else { - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); } center_split->set_dragger_visibility(SplitContainer::DRAGGER_VISIBLE); center_split->set_collapsed(false); @@ -4825,7 +4919,7 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_raise->show(); } else { - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); bottom_panel_items[p_idx].button->set_pressed(false); bottom_panel_items[p_idx].control->set_visible(false); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -4894,7 +4988,7 @@ void EditorNode::add_control_to_dock(DockSlot p_slot, Control *p_control) { void EditorNode::remove_control_from_dock(Control *p_control) { - Control *dock = NULL; + Control *dock = nullptr; for (int i = 0; i < DOCK_SLOT_MAX; i++) { if (p_control->get_parent() == dock_slot[i]) { dock = dock_slot[i]; @@ -4918,7 +5012,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { //todo make proper previews - Ref<ImageTexture> pic = gui_base->get_icon("FileBigThumb", "EditorIcons"); + Ref<ImageTexture> pic = gui_base->get_theme_icon("FileBigThumb", "EditorIcons"); Ref<Image> img = pic->get_data(); img = img->duplicate(); img->resize(48, 48); //meh @@ -4970,10 +5064,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * if (p_paths[i].ends_with("/")) { label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); - icon->set_texture(gui_base->get_icon("Folder", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon("Folder", "EditorIcons")); } else { label->set_text(p_paths[i].get_file()); - icon->set_texture(gui_base->get_icon("File", "EditorIcons")); + icon->set_texture(gui_base->get_theme_icon("File", "EditorIcons")); } icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); icon->set_size(Size2(16, 16)); @@ -5017,7 +5111,7 @@ void EditorNode::add_tool_menu_item(const String &p_name, Object *p_handler, con void EditorNode::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) { ERR_FAIL_NULL(p_submenu); - ERR_FAIL_COND(p_submenu->get_parent() != NULL); + ERR_FAIL_COND(p_submenu->get_parent() != nullptr); tool_menu->add_child(p_submenu); tool_menu->add_submenu_item(p_name, p_submenu->get_name(), TOOLS_CUSTOM); @@ -5041,21 +5135,19 @@ void EditorNode::remove_tool_menu_item(const String &p_name) { } } -void EditorNode::_global_menu_action(const Variant &p_id, const Variant &p_meta) { +void EditorNode::_global_menu_scene(const Variant &p_tag) { + int idx = (int)p_tag; + scene_tabs->set_current_tab(idx); +} - int id = (int)p_id; - if (id == GLOBAL_NEW_WINDOW) { - if (OS::get_singleton()->get_main_loop()) { - List<String> args; - args.push_back("-e"); - String exec = OS::get_singleton()->get_executable_path(); +void EditorNode::_global_menu_new_window(const Variant &p_tag) { + if (OS::get_singleton()->get_main_loop()) { + List<String> args; + args.push_back("-p"); + String exec = OS::get_singleton()->get_executable_path(); - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } - } else if (id == GLOBAL_SCENE) { - int idx = (int)p_meta; - scene_tabs->set_current_tab(idx); + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); } } @@ -5120,10 +5212,10 @@ void EditorNode::reload_scene(const String &p_path) { //first of all, reload internal textures, materials, meshes, etc. as they might have changed on disk - List<Ref<Resource> > cached; + List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - List<Ref<Resource> > to_clear; //clear internal resources from previous scene from being used - for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) { + List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used + for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene to_clear.push_back(E->get()); @@ -5254,9 +5346,9 @@ void EditorNode::remove_resource_conversion_plugin(const Ref<EditorResourceConve resource_conversion_plugins.erase(p_plugin); } -Vector<Ref<EditorResourceConversionPlugin> > EditorNode::find_resource_conversion_plugin(const Ref<Resource> &p_for_resource) { +Vector<Ref<EditorResourceConversionPlugin>> EditorNode::find_resource_conversion_plugin(const Ref<Resource> &p_for_resource) { - Vector<Ref<EditorResourceConversionPlugin> > ret; + Vector<Ref<EditorResourceConversionPlugin>> ret; for (int i = 0; i < resource_conversion_plugins.size(); i++) { if (resource_conversion_plugins[i].is_valid() && resource_conversion_plugins[i]->handles(p_for_resource)) { @@ -5276,9 +5368,9 @@ void EditorNode::_update_video_driver_color() { // TODO: Probably should de-hardcode this and add to editor settings. if (video_driver->get_text() == "GLES2") { - video_driver->add_color_override("font_color", Color::hex(0x5586a4ff)); + video_driver->add_theme_color_override("font_color", Color::hex(0x5586a4ff)); } else if (video_driver->get_text() == "Vulkan") { - video_driver->add_color_override("font_color", theme_base->get_color("vulkan_color", "Editor")); + video_driver->add_theme_color_override("font_color", theme_base->get_theme_color("vulkan_color", "Editor")); } } @@ -5286,14 +5378,14 @@ void EditorNode::_video_driver_selected(int p_which) { String driver = video_driver->get_item_metadata(p_which); - String current = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); + String current = ""; //OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); if (driver == current) { return; } video_driver_request = driver; - video_restart_dialog->popup_centered_minsize(); + video_restart_dialog->popup_centered(); video_driver->select(video_driver_current); _update_video_driver_color(); } @@ -5375,6 +5467,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes); ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history); + ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); @@ -5405,7 +5498,7 @@ void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_err static void _execute_thread(void *p_ud) { EditorNode::ExecuteThreadArgs *eta = (EditorNode::ExecuteThreadArgs *)p_ud; - Error err = OS::get_singleton()->execute(eta->path, eta->args, true, NULL, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex); + Error err = OS::get_singleton()->execute(eta->path, eta->args, true, nullptr, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex); print_verbose("Thread exit status: " + itos(eta->exitcode)); if (err != OK) { eta->exitcode = err; @@ -5465,15 +5558,15 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p EditorNode::EditorNode() { - Input::get_singleton()->set_use_accumulated_input(true); + InputFilter::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; - VisualServer::get_singleton()->set_debug_generate_wireframes(true); + RenderingServer::get_singleton()->set_debug_generate_wireframes(true); - NavigationServer::get_singleton()->set_active(false); // no nav by default if editor + NavigationServer3D::get_singleton()->set_active(false); // no nav by default if editor - PhysicsServer::get_singleton()->set_active(false); // no physics by default if editor - Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor + PhysicsServer3D::get_singleton()->set_active(false); // no physics by default if editor + PhysicsServer2D::get_singleton()->set_active(false); // no physics by default if editor ScriptServer::set_scripting_enabled(false); // no scripting by default if editor EditorHelp::generate_doc(); //before any editor classes are created @@ -5481,15 +5574,22 @@ EditorNode::EditorNode() { ResourceLoader::clear_translation_remaps(); //no remaps using during editor ResourceLoader::clear_path_remaps(); - InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton()); + InputFilter *id = InputFilter::get_singleton(); if (id) { - if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) { + bool found_touchscreen = false; + for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { + if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) { + found_touchscreen = true; + } + } + + if (!found_touchscreen && InputFilter::get_singleton()) { //only if no touchscreen ui hint, set emulation id->set_emulate_touch_from_mouse(false); //just disable just in case } - id->set_custom_mouse_cursor(RES()); + DisplayServer::get_singleton()->cursor_set_custom_image(RES()); } singleton = this; @@ -5518,8 +5618,12 @@ EditorNode::EditorNode() { switch (display_scale) { case 0: { // Try applying a suitable display scale automatically - const int screen = OS::get_singleton()->get_current_screen(); - editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0); + const int screen = DisplayServer::get_singleton()->window_get_current_screen(); +#ifdef OSX_ENABLED + editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen)); +#else + editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); +#endif } break; case 1: { @@ -5553,7 +5657,7 @@ EditorNode::EditorNode() { } // Define a minimum window size to prevent UI elements from overlapping or being cut off - OS::get_singleton()->set_min_window_size(Size2(1024, 600) * EDSCALE); + DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE); ResourceLoader::set_abort_on_missing_resources(false); FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files")); @@ -5712,7 +5816,7 @@ EditorNode::EditorNode() { theme_base->set_theme(theme); gui_base->set_theme(theme); - gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); resource_preview = memnew(EditorResourcePreview); add_child(resource_preview); @@ -5727,7 +5831,7 @@ EditorNode::EditorNode() { main_vbox = memnew(VBoxContainer); gui_base->add_child(main_vbox); main_vbox->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 8); - main_vbox->add_constant_override("separation", 8 * EDSCALE); + main_vbox->add_theme_constant_override("separation", 8 * EDSCALE); menu_hb = memnew(HBoxContainer); main_vbox->add_child(menu_hb); @@ -5831,6 +5935,14 @@ EditorNode::EditorNode() { dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_vb->add_child(dock_select); + dock_float = memnew(Button); + dock_float->set_text(TTR("Make Floating")); + dock_float->set_focus_mode(Control::FOCUS_NONE); + dock_float->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + dock_float->connect("pressed", callable_mp(this, &EditorNode::_dock_make_float)); + + dock_vb->add_child(dock_float); + dock_select_popup->set_as_minsize(); dock_select_rect_over = -1; dock_popup_selected = -1; @@ -5860,7 +5972,7 @@ EditorNode::EditorNode() { VBoxContainer *srt = memnew(VBoxContainer); srt->set_v_size_flags(Control::SIZE_EXPAND_FILL); top_split->add_child(srt); - srt->add_constant_override("separation", 0); + srt->add_theme_constant_override("separation", 0); tab_preview_panel = memnew(Panel); tab_preview_panel->set_size(Size2(100, 100) * EDSCALE); @@ -5875,8 +5987,8 @@ EditorNode::EditorNode() { tab_preview_panel->add_child(tab_preview); scene_tabs = memnew(Tabs); - scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles")); + scene_tabs->add_theme_style_override("tab_fg", gui_base->get_theme_stylebox("SceneTabFG", "EditorStyles")); + scene_tabs->add_theme_style_override("tab_bg", gui_base->get_theme_stylebox("SceneTabBG", "EditorStyles")); scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_align(Tabs::ALIGN_LEFT); @@ -5898,7 +6010,6 @@ EditorNode::EditorNode() { scene_tabs_context_menu = memnew(PopupMenu); tabbar_container->add_child(scene_tabs_context_menu); scene_tabs_context_menu->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); - scene_tabs_context_menu->set_hide_on_window_lose_focus(true); srt->add_child(tabbar_container); tabbar_container->add_child(scene_tabs); @@ -5910,34 +6021,34 @@ EditorNode::EditorNode() { #endif distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", callable_mp(this, &EditorNode::_toggle_distraction_free_mode)); - distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); + distraction_free->set_icon(gui_base->get_theme_icon("DistractionFree", "EditorIcons")); distraction_free->set_toggle_mode(true); scene_tab_add = memnew(ToolButton); tabbar_container->add_child(scene_tab_add); tabbar_container->add_child(distraction_free); scene_tab_add->set_tooltip(TTR("Add a new scene.")); - scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); - scene_tab_add->add_color_override("icon_color_normal", Color(0.6f, 0.6f, 0.6f, 0.8f)); + scene_tab_add->set_icon(gui_base->get_theme_icon("Add", "EditorIcons")); + scene_tab_add->add_theme_color_override("icon_color_normal", Color(0.6f, 0.6f, 0.6f, 0.8f)); scene_tab_add->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_NEW_SCENE)); scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); - scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox("Content", "EditorStyles")); scene_root_parent->set_draw_behind_parent(true); srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); - scene_root = memnew(Viewport); + scene_root = memnew(SubViewport); //scene_root->set_usage(Viewport::USAGE_2D); canvas BG mode prevents usage of this as 2D - VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); + RenderingServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); viewport = memnew(VBoxContainer); viewport->set_v_size_flags(Control::SIZE_EXPAND_FILL); - viewport->add_constant_override("separation", 0); + viewport->add_theme_constant_override("separation", 0); scene_root_parent->add_child(viewport); HBoxContainer *left_menu_hb = memnew(HBoxContainer); @@ -5947,11 +6058,11 @@ EditorNode::EditorNode() { file_menu->set_flat(false); file_menu->set_switch_on_hover(true); file_menu->set_text(TTR("Scene")); - file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); left_menu_hb->add_child(file_menu); prev_scene = memnew(ToolButton); - prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); + prev_scene->set_icon(gui_base->get_theme_icon("PrevScene", "EditorIcons")); prev_scene->set_tooltip(TTR("Go to previously opened scene.")); prev_scene->set_disabled(true); prev_scene->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(FILE_OPEN_PREV)); @@ -6003,7 +6114,7 @@ EditorNode::EditorNode() { file_menu->set_tooltip(TTR("Operations with scene files.")); p = file_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); + p->add_shortcut(ED_SHORTCUT("editor/new_scene", TTR("New Scene")), FILE_NEW_SCENE); p->add_shortcut(ED_SHORTCUT("editor/new_inherited_scene", TTR("New Inherited Scene...")), FILE_NEW_INHERITED_SCENE); p->add_shortcut(ED_SHORTCUT("editor/open_scene", TTR("Open Scene..."), KEY_MASK_CMD + KEY_O), FILE_OPEN_SCENE); @@ -6051,11 +6162,11 @@ EditorNode::EditorNode() { project_menu->set_switch_on_hover(true); project_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools.")); project_menu->set_text(TTR("Project")); - project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); left_menu_hb->add_child(project_menu); p = project_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); + p->add_shortcut(ED_SHORTCUT("editor/project_settings", TTR("Project Settings...")), RUN_SETTINGS); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); @@ -6101,19 +6212,20 @@ EditorNode::EditorNode() { debug_menu->set_flat(false); debug_menu->set_switch_on_hover(true); debug_menu->set_text(TTR("Debug")); - debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); left_menu_hb->add_child(debug_menu); + menu_hb->add_spacer(); settings_menu = memnew(MenuButton); settings_menu->set_flat(false); settings_menu->set_switch_on_hover(true); settings_menu->set_text(TTR("Editor")); - settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); left_menu_hb->add_child(settings_menu); p = settings_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); + p->add_shortcut(ED_SHORTCUT("editor/editor_settings", TTR("Editor Settings...")), SETTINGS_PREFERENCES); p->add_separator(); @@ -6157,20 +6269,20 @@ EditorNode::EditorNode() { help_menu->set_flat(false); help_menu->set_switch_on_hover(true); help_menu->set_text(TTR("Help")); - help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox("MenuHover", "EditorStyles")); left_menu_hb->add_child(help_menu); p = help_menu->get_popup(); - p->set_hide_on_window_lose_focus(true); p->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); - p->add_icon_shortcut(gui_base->get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search"), KEY_MASK_SHIFT | KEY_F1), HELP_SEARCH); + p->add_icon_shortcut(gui_base->get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("editor/editor_help", TTR("Search"), KEY_MASK_SHIFT | KEY_F1), HELP_SEARCH); p->add_separator(); - p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Docs")), HELP_DOCS); - p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Q&A")), HELP_QA); - p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/issue_tracker", TTR("Issue Tracker")), HELP_ISSUES); - p->add_icon_shortcut(gui_base->get_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/online_docs", TTR("Online Docs")), HELP_DOCS); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/q&a", TTR("Q&A")), HELP_QA); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/report_a_bug", TTR("Report a Bug")), HELP_REPORT_A_BUG); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/send_docs_feedback", TTR("Send Docs Feedback")), HELP_SEND_DOCS_FEEDBACK); + p->add_icon_shortcut(gui_base->get_theme_icon("Instance", "EditorIcons"), ED_SHORTCUT("editor/community", TTR("Community")), HELP_COMMUNITY); p->add_separator(); - p->add_icon_shortcut(gui_base->get_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About")), HELP_ABOUT); + p->add_icon_shortcut(gui_base->get_theme_icon("Godot", "EditorIcons"), ED_SHORTCUT("editor/about", TTR("About")), HELP_ABOUT); HBoxContainer *play_hb = memnew(HBoxContainer); menu_hb->add_child(play_hb); @@ -6178,7 +6290,7 @@ EditorNode::EditorNode() { play_button = memnew(ToolButton); play_hb->add_child(play_button); play_button->set_toggle_mode(true); - play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); + play_button->set_icon(gui_base->get_theme_icon("MainPlay", "EditorIcons")); play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY)); play_button->set_tooltip(TTR("Play the project.")); @@ -6190,7 +6302,7 @@ EditorNode::EditorNode() { pause_button = memnew(ToolButton); pause_button->set_toggle_mode(true); - pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); + pause_button->set_icon(gui_base->get_theme_icon("Pause", "EditorIcons")); pause_button->set_focus_mode(Control::FOCUS_NONE); pause_button->set_tooltip(TTR("Pause the scene execution for debugging.")); pause_button->set_disabled(true); @@ -6204,7 +6316,7 @@ EditorNode::EditorNode() { stop_button = memnew(ToolButton); play_hb->add_child(stop_button); stop_button->set_focus_mode(Control::FOCUS_NONE); - stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); + stop_button->set_icon(gui_base->get_theme_icon("Stop", "EditorIcons")); stop_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); stop_button->set_disabled(true); @@ -6222,7 +6334,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_scene_button); play_scene_button->set_toggle_mode(true); play_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_theme_icon("PlayScene", "EditorIcons")); play_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_SCENE)); play_scene_button->set_tooltip(TTR("Play the edited scene.")); #ifdef OSX_ENABLED @@ -6235,7 +6347,7 @@ EditorNode::EditorNode() { play_hb->add_child(play_custom_scene_button); play_custom_scene_button->set_toggle_mode(true); play_custom_scene_button->set_focus_mode(Control::FOCUS_NONE); - play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_theme_icon("PlayCustom", "EditorIcons")); play_custom_scene_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_PLAY_CUSTOM_SCENE)); play_custom_scene_button->set_tooltip(TTR("Play custom scene")); #ifdef OSX_ENABLED @@ -6252,11 +6364,15 @@ EditorNode::EditorNode() { video_driver->set_flat(true); video_driver->set_focus_mode(Control::FOCUS_NONE); video_driver->connect("item_selected", callable_mp(this, &EditorNode::_video_driver_selected)); - video_driver->add_font_override("font", gui_base->get_font("bold", "EditorFonts")); + video_driver->add_theme_font_override("font", gui_base->get_theme_font("bold", "EditorFonts")); // TODO re-enable when GLES2 is ported video_driver->set_disabled(true); right_menu_hb->add_child(video_driver); +#ifndef _MSC_VER +#warning neeeds to be reimplemented +#endif +#if 0 String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string; String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); video_driver_current = 0; @@ -6272,7 +6388,7 @@ EditorNode::EditorNode() { } _update_video_driver_color(); - +#endif video_restart_dialog = memnew(ConfirmationDialog); video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor.")); video_restart_dialog->get_ok()->set_text(TTR("Save & Restart")); @@ -6290,7 +6406,7 @@ EditorNode::EditorNode() { update_spinner = memnew(MenuButton); update_spinner->set_tooltip(TTR("Spins when the editor window redraws.")); right_menu_hb->add_child(update_spinner); - update_spinner->set_icon(gui_base->get_icon("Progress1", "EditorIcons")); + update_spinner->set_icon(gui_base->get_theme_icon("Progress1", "EditorIcons")); update_spinner->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); p = update_spinner->get_popup(); p->add_radio_check_item(TTR("Update Continuously"), SETTINGS_UPDATE_CONTINUOUSLY); @@ -6366,7 +6482,7 @@ EditorNode::EditorNode() { // Bottom panels bottom_panel = memnew(PanelContainer); - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("panel", "TabContainer")); center_split->add_child(bottom_panel); center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN); @@ -6388,7 +6504,7 @@ EditorNode::EditorNode() { bottom_panel_hb->add_child(version_label); bottom_panel_raise = memnew(ToolButton); - bottom_panel_raise->set_icon(gui_base->get_icon("ExpandBottomDock", "EditorIcons")); + bottom_panel_raise->set_icon(gui_base->get_theme_icon("ExpandBottomDock", "EditorIcons")); bottom_panel_raise->set_shortcut(ED_SHORTCUT("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KEY_MASK_SHIFT | KEY_F12)); @@ -6413,7 +6529,7 @@ EditorNode::EditorNode() { confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); save_confirmation = memnew(ConfirmationDialog); - save_confirmation->add_button(TTR("Don't Save"), OS::get_singleton()->get_swap_ok_cancel(), "discard"); + save_confirmation->add_button(TTR("Don't Save"), DisplayServer::get_singleton()->get_swap_ok_cancel(), "discard"); gui_base->add_child(save_confirmation); save_confirmation->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); save_confirmation->connect("custom_action", callable_mp(this, &EditorNode::_discard_changes)); @@ -6440,7 +6556,7 @@ EditorNode::EditorNode() { file_templates->set_title(TTR("Import Templates From ZIP File")); gui_base->add_child(file_templates); - file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_templates->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); file_templates->add_filter("*.tpz ; " + TTR("Template Package")); @@ -6451,7 +6567,7 @@ EditorNode::EditorNode() { file_export_lib = memnew(EditorFileDialog); file_export_lib->set_title(TTR("Export Library")); - file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_export_lib->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_export_lib->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); file_export_lib_merge = memnew(CheckBox); file_export_lib_merge->set_text(TTR("Merge With Existing")); @@ -6462,7 +6578,7 @@ EditorNode::EditorNode() { file_script = memnew(EditorFileDialog); file_script->set_title(TTR("Open & Run a Script")); file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_script->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); for (List<String>::Element *E = sexts.front(); E; E = E->next()) { @@ -6472,7 +6588,7 @@ EditorNode::EditorNode() { file_script->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); file_menu->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); - file_menu->connect("about_to_show", callable_mp(this, &EditorNode::_update_file_menu_opened)); + file_menu->connect("about_to_popup", callable_mp(this, &EditorNode::_update_file_menu_opened)); file_menu->get_popup()->connect("popup_hide", callable_mp(this, &EditorNode::_update_file_menu_closed)); settings_menu->get_popup()->connect("id_pressed", callable_mp(this, &EditorNode::_menu_option)); @@ -6487,7 +6603,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(DebuggerEditorPlugin(this, debug_menu))); add_editor_plugin(memnew(AnimationPlayerEditorPlugin(this))); add_editor_plugin(memnew(CanvasItemEditorPlugin(this))); - add_editor_plugin(memnew(SpatialEditorPlugin(this))); + add_editor_plugin(memnew(Node3DEditorPlugin(this))); add_editor_plugin(memnew(ScriptEditorPlugin(this))); EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor(); @@ -6513,18 +6629,19 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(ShaderEditorPlugin(this))); add_editor_plugin(memnew(VisualShaderEditorPlugin(this))); - add_editor_plugin(memnew(CameraEditorPlugin(this))); + add_editor_plugin(memnew(Camera3DEditorPlugin(this))); add_editor_plugin(memnew(ThemeEditorPlugin(this))); add_editor_plugin(memnew(MultiMeshEditorPlugin(this))); - add_editor_plugin(memnew(MeshInstanceEditorPlugin(this))); + add_editor_plugin(memnew(MeshInstance3DEditorPlugin(this))); add_editor_plugin(memnew(AnimationTreeEditorPlugin(this))); add_editor_plugin(memnew(MeshLibraryEditorPlugin(this))); add_editor_plugin(memnew(StyleBoxEditorPlugin(this))); - add_editor_plugin(memnew(SpriteEditorPlugin(this))); + add_editor_plugin(memnew(Sprite2DEditorPlugin(this))); add_editor_plugin(memnew(Skeleton2DEditorPlugin(this))); - add_editor_plugin(memnew(ParticlesEditorPlugin(this))); + add_editor_plugin(memnew(GPUParticles2DEditorPlugin(this))); + add_editor_plugin(memnew(GPUParticles3DEditorPlugin(this))); add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this))); - add_editor_plugin(memnew(CPUParticlesEditorPlugin(this))); + add_editor_plugin(memnew(CPUParticles3DEditorPlugin(this))); add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this))); add_editor_plugin(memnew(ItemListEditorPlugin(this))); add_editor_plugin(memnew(Polygon3DEditorPlugin(this))); @@ -6533,11 +6650,10 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(TileMapEditorPlugin(this))); add_editor_plugin(memnew(SpriteFramesEditorPlugin(this))); add_editor_plugin(memnew(TextureRegionEditorPlugin(this))); - add_editor_plugin(memnew(Particles2DEditorPlugin(this))); add_editor_plugin(memnew(GIProbeEditorPlugin(this))); - // add_editor_plugin(memnew(BakedLightmapEditorPlugin(this))); + //add_editor_plugin(memnew(BakedLightmapEditorPlugin(this))); add_editor_plugin(memnew(Path2DEditorPlugin(this))); - add_editor_plugin(memnew(PathEditorPlugin(this))); + add_editor_plugin(memnew(Path3DEditorPlugin(this))); add_editor_plugin(memnew(Line2DEditorPlugin(this))); add_editor_plugin(memnew(Polygon2DEditorPlugin(this))); add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this))); @@ -6548,9 +6664,9 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(TextureEditorPlugin(this))); add_editor_plugin(memnew(AudioStreamEditorPlugin(this))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); - add_editor_plugin(memnew(SkeletonEditorPlugin(this))); - add_editor_plugin(memnew(SkeletonIKEditorPlugin(this))); - add_editor_plugin(memnew(PhysicalBonePlugin(this))); + add_editor_plugin(memnew(Skeleton3DEditorPlugin(this))); + add_editor_plugin(memnew(SkeletonIK3DEditorPlugin(this))); + add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this))); add_editor_plugin(memnew(MeshEditorPlugin(this))); add_editor_plugin(memnew(MaterialEditorPlugin(this))); @@ -6583,6 +6699,18 @@ EditorNode::EditorNode() { particles_mat_convert.instance(); resource_conversion_plugins.push_back(particles_mat_convert); + Ref<ProceduralSkyMaterialConversionPlugin> procedural_sky_mat_convert; + procedural_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(procedural_sky_mat_convert); + + Ref<PanoramaSkyMaterialConversionPlugin> panorama_sky_mat_convert; + panorama_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(panorama_sky_mat_convert); + + Ref<PhysicalSkyMaterialConversionPlugin> physical_sky_mat_convert; + physical_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(physical_sky_mat_convert); + Ref<VisualShaderConversionPlugin> vshader_convert; vshader_convert.instance(); resource_conversion_plugins.push_back(vshader_convert); @@ -6591,7 +6719,7 @@ EditorNode::EditorNode() { update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn(); update_spinner_step = 0; - editor_plugin_screen = NULL; + editor_plugin_screen = nullptr; editor_plugins_over = memnew(EditorPluginList); editor_plugins_force_over = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList); @@ -6602,7 +6730,7 @@ EditorNode::EditorNode() { EditorExport::get_singleton()->add_export_plugin(export_text_to_binary_plugin); _edit_current(); - current = NULL; + current = nullptr; saving_resource = Ref<Resource>(); reference_resource_mem = true; @@ -6612,14 +6740,14 @@ EditorNode::EditorNode() { open_imported = memnew(ConfirmationDialog); open_imported->get_ok()->set_text(TTR("Open Anyway")); - new_inherited_button = open_imported->add_button(TTR("New Inherited"), !OS::get_singleton()->get_swap_ok_cancel(), "inherit"); + new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "inherit"); open_imported->connect("confirmed", callable_mp(this, &EditorNode::_open_imported)); open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported)); gui_base->add_child(open_imported); saved_version = 1; unsaved_cache = true; - _last_instanced_scene = NULL; + _last_instanced_scene = nullptr; quick_open = memnew(EditorQuickOpen); gui_base->add_child(quick_open); @@ -6704,6 +6832,9 @@ EditorNode::EditorNode() { screenshot_timer->connect("timeout", callable_mp(this, &EditorNode::_request_screenshot)); add_child(screenshot_timer); screenshot_timer->set_owner(get_owner()); + + String exec = OS::get_singleton()->get_executable_path(); + EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "executable_path", exec); // Save editor executable path for third-party tools } EditorNode::~EditorNode() { @@ -6752,7 +6883,7 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) { return discard; } -bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) { +bool EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) { bool discard = false; for (int i = 0; i < plugins_list.size(); i++) { diff --git a/editor/editor_node.h b/editor/editor_node.h index e2badff88d..c6f04b0749 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -84,6 +84,8 @@ class Tabs; class TextureProgress; class ToolButton; class VSplitContainer; +class Window; +class SubViewport; class EditorNode : public Node { @@ -192,7 +194,8 @@ private: HELP_SEARCH, HELP_DOCS, HELP_QA, - HELP_ISSUES, + HELP_REPORT_A_BUG, + HELP_SEND_DOCS_FEEDBACK, HELP_COMMUNITY, HELP_ABOUT, @@ -206,7 +209,7 @@ private: TOOL_MENU_BASE = 1000 }; - Viewport *scene_root; //root of the scene being edited + SubViewport *scene_root; //root of the scene being edited PanelContainer *scene_root_parent; Control *theme_base; @@ -348,11 +351,14 @@ private: Button *new_inherited_button; String open_import_request; + Vector<Control *> floating_docks; + TabContainer *dock_slot[DOCK_SLOT_MAX]; Rect2 dock_select_rect[DOCK_SLOT_MAX]; int dock_select_rect_over; PopupPanel *dock_select_popup; Control *dock_select; + Button *dock_float; ToolButton *dock_tab_move_left; ToolButton *dock_tab_move_right; int dock_popup_selected; @@ -493,7 +499,8 @@ private: void _add_to_recent_scenes(const String &p_scene); void _update_recent_scenes(); void _open_recent_scene(int p_idx); - void _global_menu_action(const Variant &p_id, const Variant &p_meta); + void _global_menu_scene(const Variant &p_tag); + void _global_menu_new_window(const Variant &p_tag); void _dropped_files(const Vector<String> &p_files, int p_screen); void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path); String _recent_scene; @@ -513,7 +520,7 @@ private: Set<FileDialog *> file_dialogs; Set<EditorFileDialog *> editor_file_dialogs; - Map<String, Ref<Texture2D> > icon_type_cache; + Map<String, Ref<Texture2D>> icon_type_cache; void _build_icon_type_cache(); bool _initializing_addons; @@ -536,7 +543,7 @@ private: void _find_node_types(Node *p_node, int &count_2d, int &count_3d); void _save_scene_with_preview(String p_file, int p_idx = -1); - Map<String, Set<String> > dependency_errors; + Map<String, Set<String>> dependency_errors; static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) { EditorNode *en = (EditorNode *)ud; @@ -560,6 +567,8 @@ private: bool _find_scene_in_use(Node *p_node, const String &p_path) const; + void _update_dock_containers(); + void _dock_select_input(const Ref<InputEvent> &p_input); void _dock_move_left(); void _dock_move_right(); @@ -567,6 +576,8 @@ private: void _dock_pre_popup(int p_which); void _dock_split_dragged(int ofs); void _dock_popup_exit(); + void _dock_floating_close_request(Control *p_control); + void _dock_make_float(); void _scene_tab_changed(int p_tab); void _scene_tab_closed(int p_tab, int option = SCENE_TAB_CLOSE); void _scene_tab_hover(int p_tab); @@ -622,7 +633,7 @@ private: void _update_update_spinner(); - Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins; + Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins; PrintHandlerList print_handler; static void _print_handler(void *p_this, const String &p_string, bool p_error); @@ -724,7 +735,7 @@ public: Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } - Viewport *get_scene_root() { return scene_root; } //root of the scene being edited + SubViewport *get_scene_root() { return scene_root; } //root of the scene being edited void fix_dependencies(const String &p_for_file); void clear_scene() { _cleanup_scene(); } @@ -844,7 +855,7 @@ public: void add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin); void remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin); - Vector<Ref<EditorResourceConversionPlugin> > find_resource_conversion_plugin(const Ref<Resource> &p_for_resource); + Vector<Ref<EditorResourceConversionPlugin>> find_resource_conversion_plugin(const Ref<Resource> &p_for_resource); static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); } static void add_build_callback(EditorBuildCallback p_callback); @@ -884,7 +895,7 @@ public: bool forward_gui_input(const Ref<InputEvent> &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); void forward_canvas_force_draw_over_viewport(Control *p_overlay); - bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled); + bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled); void forward_spatial_draw_over_viewport(Control *p_overlay); void forward_spatial_force_draw_over_viewport(Control *p_overlay); void add_plugin(EditorPlugin *p_plugin); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 305dc03568..804ad62bbb 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -149,6 +149,6 @@ EditorPath::EditorPath(EditorHistory *p_history) { history = p_history; set_clip_text(true); set_text_align(ALIGN_LEFT); - get_popup()->connect("about_to_show", callable_mp(this, &EditorPath::_about_to_show)); + get_popup()->connect("about_to_popup", callable_mp(this, &EditorPath::_about_to_show)); get_popup()->connect("id_pressed", callable_mp(this, &EditorPath::_id_pressed)); } diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 10ecdb19c0..746ebc8292 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -38,20 +38,20 @@ #include "editor_resource_preview.h" #include "main/main.h" #include "plugins/canvas_item_editor_plugin.h" -#include "plugins/spatial_editor_plugin.h" -#include "scene/3d/camera.h" +#include "plugins/node_3d_editor_plugin.h" +#include "scene/3d/camera_3d.h" #include "scene/gui/popup_menu.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) { - Vector<Ref<Mesh> > meshes; + Vector<Ref<Mesh>> meshes; for (int i = 0; i < p_meshes.size(); i++) { meshes.push_back(p_meshes[i]); } - Vector<Ref<Texture2D> > textures = make_mesh_previews(meshes, NULL, p_preview_size); + Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size); Array ret; for (int i = 0; i < textures.size(); i++) { ret.push_back(textures[i]); @@ -60,33 +60,33 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ return ret; } -Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { +Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { int size = p_preview_size; - RID scenario = VS::get_singleton()->scenario_create(); + RID scenario = RS::get_singleton()->scenario_create(); - RID viewport = VS::get_singleton()->viewport_create(); - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS); - VS::get_singleton()->viewport_set_scenario(viewport, scenario); - VS::get_singleton()->viewport_set_size(viewport, size, size); - VS::get_singleton()->viewport_set_transparent_background(viewport, true); - VS::get_singleton()->viewport_set_active(viewport, true); - RID viewport_texture = VS::get_singleton()->viewport_get_texture(viewport); + RID viewport = RS::get_singleton()->viewport_create(); + RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS); + RS::get_singleton()->viewport_set_scenario(viewport, scenario); + RS::get_singleton()->viewport_set_size(viewport, size, size); + RS::get_singleton()->viewport_set_transparent_background(viewport, true); + RS::get_singleton()->viewport_set_active(viewport, true); + RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport); - RID camera = VS::get_singleton()->camera_create(); - VS::get_singleton()->viewport_attach_camera(viewport, camera); + RID camera = RS::get_singleton()->camera_create(); + RS::get_singleton()->viewport_attach_camera(viewport, camera); - RID light = VS::get_singleton()->directional_light_create(); - RID light_instance = VS::get_singleton()->instance_create2(light, scenario); + RID light = RS::get_singleton()->directional_light_create(); + RID light_instance = RS::get_singleton()->instance_create2(light, scenario); - RID light2 = VS::get_singleton()->directional_light_create(); - VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); - RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); + RID light2 = RS::get_singleton()->directional_light_create(); + RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); + RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size()); - Vector<Ref<Texture2D> > textures; + Vector<Ref<Texture2D>> textures; for (int i = 0; i < p_meshes.size(); i++) { @@ -97,12 +97,12 @@ Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mes } Transform mesh_xform; - if (p_transforms != NULL) { + if (p_transforms != nullptr) { mesh_xform = (*p_transforms)[i]; } - RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario); - VS::get_singleton()->instance_set_transform(inst, mesh_xform); + RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario); + RS::get_singleton()->instance_set_transform(inst, mesh_xform); AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; @@ -121,32 +121,32 @@ Vector<Ref<Texture2D> > EditorInterface::make_mesh_previews(const Vector<Ref<Mes xform.invert(); xform = mesh_xform * xform; - VS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); - VS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); + RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); - VS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); - VS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); ep.step(TTR("Thumbnail..."), i); Main::iteration(); Main::iteration(); - Ref<Image> img = VS::get_singleton()->texture_2d_get(viewport_texture); + Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture); ERR_CONTINUE(!img.is_valid() || img->empty()); Ref<ImageTexture> it(memnew(ImageTexture)); it->create_from_image(img); - VS::get_singleton()->free(inst); + RS::get_singleton()->free(inst); textures.push_back(it); } - 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(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); return textures; } @@ -194,7 +194,7 @@ Array EditorInterface::get_open_scenes() const { int scns_amount = scenes.size(); for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) { - if (scenes[idx_scn].root == NULL) + if (scenes[idx_scn].root == nullptr) continue; ret.push_back(scenes[idx_scn].root->get_filename()); } @@ -226,6 +226,10 @@ EditorFileSystem *EditorInterface::get_resource_file_system() { return EditorFileSystem::get_singleton(); } +FileSystemDock *EditorInterface::get_file_system_dock() { + return EditorNode::get_singleton()->get_filesystem_dock(); +} + EditorSelection *EditorInterface::get_selection() { return EditorNode::get_singleton()->get_editor_selection(); } @@ -274,7 +278,7 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) { EditorNode::get_singleton()->set_distraction_free_mode(p_enter); } -EditorInterface *EditorInterface::singleton = NULL; +EditorInterface *EditorInterface::singleton = nullptr; void EditorInterface::_bind_methods() { @@ -295,6 +299,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file); ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path); ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path); + ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock); ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled); ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled); @@ -332,7 +337,7 @@ void EditorPlugin::remove_autoload_singleton(const String &p_name) { } ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) { - ERR_FAIL_NULL_V(p_control, NULL); + ERR_FAIL_NULL_V(p_control, nullptr); return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control); } @@ -366,24 +371,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C case CONTAINER_SPATIAL_EDITOR_MENU: { - SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control); + Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: { - SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); - SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); + Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { - SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control); - SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); + Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { - SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control); + Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { @@ -440,18 +445,18 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati case CONTAINER_SPATIAL_EDITOR_MENU: { - SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control); + Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { - SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control); + Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { - SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control); + Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { @@ -557,10 +562,10 @@ void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) { // Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport. int EditorPlugin::update_overlays() const { - if (SpatialEditor::get_singleton()->is_visible()) { + if (Node3DEditor::get_singleton()->is_visible()) { int count = 0; - for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) { - SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i); + for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) { + Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i); if (vp->is_visible()) { vp->update_surface(); count++; @@ -574,7 +579,7 @@ int EditorPlugin::update_overlays() const { } } -bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { +bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) { return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event); @@ -719,12 +724,12 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte EditorExport::get_singleton()->remove_export_plugin(p_exporter); } -void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) { - SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin); +void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) { + Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin); } -void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) { - SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin); +void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) { + Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin); } void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { @@ -860,7 +865,7 @@ void EditorPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "get_plugin_icon")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen")); @@ -909,7 +914,7 @@ void EditorPlugin::_bind_methods() { } EditorPlugin::EditorPlugin() : - undo_redo(NULL), + undo_redo(nullptr), input_event_forwarding_always_enabled(false), force_draw_over_forwarding_enabled(false), last_main_screen_name("") { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index dee63e4322..2ca96ceed2 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -42,17 +42,18 @@ #include "scene/resources/texture.h" class EditorNode; -class Spatial; -class Camera; +class Node3D; +class Camera3D; class EditorSelection; class EditorExport; class EditorSettings; class EditorImportPlugin; class EditorExportPlugin; -class EditorSpatialGizmoPlugin; +class EditorNode3DGizmoPlugin; class EditorResourcePreview; class EditorFileSystem; class EditorToolAddons; +class FileSystemDock; class ScriptEditor; class EditorInterface : public Node { @@ -88,6 +89,8 @@ public: EditorResourcePreview *get_resource_previewer(); EditorFileSystem *get_resource_file_system(); + FileSystemDock *get_file_system_dock(); + Control *get_base_control(); void set_plugin_enabled(const String &p_plugin, bool p_enabled); @@ -98,7 +101,7 @@ public: Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); - Vector<Ref<Texture2D> > make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); + Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); void set_main_screen_editor(const String &p_name); void set_distraction_free_mode(bool p_enter); @@ -182,7 +185,7 @@ public: virtual void forward_canvas_draw_over_viewport(Control *p_overlay); virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay); - 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); virtual void forward_spatial_draw_over_viewport(Control *p_overlay); virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay); @@ -224,8 +227,8 @@ public: void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter); void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter); - void add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin); - void remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin); + void add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin); + void remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin); void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin); void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin); @@ -265,7 +268,7 @@ class EditorPlugins { public: static int get_plugin_count() { return creation_func_count; } static EditorPlugin *create(int p_idx, EditorNode *p_editor) { - ERR_FAIL_INDEX_V(p_idx, creation_func_count, NULL); + ERR_FAIL_INDEX_V(p_idx, creation_func_count, nullptr); return creation_funcs[p_idx](p_editor); } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 76dbadf67e..62a76786ae 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -40,7 +40,7 @@ void EditorPluginSettings::_notification(int p_what) { - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + if (p_what == NOTIFICATION_WM_FOCUS_IN) { update_plugins(); } else if (p_what == Node::NOTIFICATION_READY) { plugin_config_dialog->connect_compat("plugin_ready", EditorNode::get_singleton(), "_on_plugin_ready"); @@ -137,19 +137,12 @@ void EditorPluginSettings::update_plugins() { item->set_metadata(1, script); item->set_text(2, author); item->set_metadata(2, description); - item->set_cell_mode(3, TreeItem::CELL_MODE_RANGE); - item->set_range_config(3, 0, 1, 1); - item->set_text(3, "Inactive,Active"); + item->set_cell_mode(3, TreeItem::CELL_MODE_CHECK); + item->set_text(3, TTR("Enable")); + bool is_active = EditorNode::get_singleton()->is_addon_plugin_enabled(d2); + item->set_checked(3, is_active); item->set_editable(3, true); - item->add_button(4, get_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); - - if (EditorNode::get_singleton()->is_addon_plugin_enabled(d2)) { - item->set_custom_color(3, get_color("success_color", "Editor")); - item->set_range(3, 1); - } else { - item->set_custom_color(3, get_color("disabled_font_color", "Editor")); - item->set_range(3, 0); - } + item->add_button(4, get_theme_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin")); } } } @@ -164,7 +157,7 @@ void EditorPluginSettings::_plugin_activity_changed() { TreeItem *ti = plugin_list->get_edited(); ERR_FAIL_COND(!ti); - bool active = ti->get_range(3); + bool active = ti->is_checked(3); String name = ti->get_metadata(0); EditorNode::get_singleton()->set_addon_plugin_enabled(name, active, true); @@ -173,14 +166,9 @@ void EditorPluginSettings::_plugin_activity_changed() { if (is_active != active) { updating = true; - ti->set_range(3, is_active ? 1 : 0); + ti->set_checked(3, is_active); updating = false; } - - if (is_active) - ti->set_custom_color(3, get_color("success_color", "Editor")); - else - ti->set_custom_color(3, get_color("disabled_font_color", "Editor")); } void EditorPluginSettings::_create_clicked() { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9ff34f8fb4..cf478f20e5 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -35,7 +35,7 @@ #include "editor_node.h" #include "editor_properties_array_dict.h" #include "editor_scale.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" ///////////////////// NULL ///////////////////////// @@ -140,9 +140,9 @@ void EditorPropertyMultilineText::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { - Ref<Texture2D> df = get_icon("DistractionFree", "EditorIcons"); + Ref<Texture2D> df = get_theme_icon("DistractionFree", "EditorIcons"); open_big_text->set_icon(df); - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); text->set_custom_minimum_size(Vector2(0, font->get_height() * 6)); } break; @@ -165,8 +165,8 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() { open_big_text = memnew(ToolButton); open_big_text->connect("pressed", callable_mp(this, &EditorPropertyMultilineText::_open_big_text)); hb->add_child(open_big_text); - big_text_dialog = NULL; - big_text = NULL; + big_text_dialog = nullptr; + big_text = nullptr; } ///////////////////// TEXT ENUM ///////////////////////// @@ -240,10 +240,10 @@ void EditorPropertyPath::_path_pressed() { } if (folder) { - dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR); + dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); dialog->set_current_dir(full_path); } else { - dialog->set_mode(save_mode ? EditorFileDialog::MODE_SAVE_FILE : EditorFileDialog::MODE_OPEN_FILE); + dialog->set_file_mode(save_mode ? EditorFileDialog::FILE_MODE_SAVE_FILE : EditorFileDialog::FILE_MODE_OPEN_FILE); for (int i = 0; i < extensions.size(); i++) { String e = extensions[i].strip_edges(); if (e != String()) { @@ -278,7 +278,7 @@ void EditorPropertyPath::set_save_mode() { void EditorPropertyPath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - path_edit->set_icon(get_icon("Folder", "EditorIcons")); + path_edit->set_icon(get_theme_icon("Folder", "EditorIcons")); } } @@ -303,7 +303,7 @@ EditorPropertyPath::EditorPropertyPath() { path_edit->set_clip_text(true); path_hb->add_child(path_edit); add_focusable(path); - dialog = NULL; + dialog = nullptr; path_edit->connect("pressed", callable_mp(this, &EditorPropertyPath::_path_pressed)); folder = false; global = false; @@ -448,7 +448,7 @@ void EditorPropertyMember::_bind_methods() { } EditorPropertyMember::EditorPropertyMember() { - selector = NULL; + selector = nullptr; property = memnew(Button); property->set_clip_text(true); add_child(property); @@ -604,7 +604,7 @@ public: Vector<String> tooltips; virtual Size2 get_minimum_size() const { - Ref<Font> font = get_font("font", "Label"); + Ref<Font> font = get_theme_font("font", "Label"); return Vector2(0, font->get_height() * 2); } @@ -646,7 +646,7 @@ public: int h = bsize * 2 + 1; int vofs = (rect.size.height - h) / 2; - Color color = get_color("highlight_color", "Editor"); + Color color = get_theme_color("highlight_color", "Editor"); for (int i = 0; i < 2; i++) { Point2 ofs(4, vofs); @@ -749,10 +749,10 @@ void EditorPropertyLayers::_button_pressed() { layers->set_item_checked(idx, grid->value & (1 << i)); } - Rect2 gp = button->get_global_rect(); + Rect2 gp = button->get_screen_rect(); layers->set_as_minsize(); - Vector2 popup_pos = gp.position - Vector2(layers->get_combined_minimum_size().x, 0); - layers->set_global_position(popup_pos); + Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0); + layers->set_position(popup_pos); layers->popup(); } @@ -920,7 +920,7 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { } if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { - preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position())); + preset->set_position(easing_draw->get_screen_transform().xform(mb->get_position())); preset->popup(); // Ensure the easing doesn't appear as being dragged @@ -976,13 +976,13 @@ void EditorPropertyEasing::_draw_easing() { float prev = 1.0; const float exp = get_edited_object()->get(get_edited_property()); - const Ref<Font> f = get_font("font", "Label"); - const Color font_color = get_color("font_color", "Label"); + const Ref<Font> f = get_theme_font("font", "Label"); + const Color font_color = get_theme_color("font_color", "Label"); Color line_color; if (dragging) { - line_color = get_color("accent_color", "Editor"); + line_color = get_theme_color("accent_color", "Editor"); } else { - line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9); + line_color = get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.9); } Vector<Point2> lines; @@ -1058,15 +1058,15 @@ void EditorPropertyEasing::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { preset->clear(); - preset->add_icon_item(get_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO); - preset->add_icon_item(get_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR); - preset->add_icon_item(get_icon("CurveIn", "EditorIcons"), "In", EASING_IN); - preset->add_icon_item(get_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT); + preset->add_icon_item(get_theme_icon("CurveConstant", "EditorIcons"), "Zero", EASING_ZERO); + preset->add_icon_item(get_theme_icon("CurveLinear", "EditorIcons"), "Linear", EASING_LINEAR); + preset->add_icon_item(get_theme_icon("CurveIn", "EditorIcons"), "In", EASING_IN); + preset->add_icon_item(get_theme_icon("CurveOut", "EditorIcons"), "Out", EASING_OUT); if (full) { - preset->add_icon_item(get_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT); - preset->add_icon_item(get_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN); + preset->add_icon_item(get_theme_icon("CurveInOut", "EditorIcons"), "In-Out", EASING_IN_OUT); + preset->add_icon_item(get_theme_icon("CurveOutIn", "EditorIcons"), "Out-In", EASING_OUT_IN); } - easing_draw->set_custom_minimum_size(Size2(0, get_font("font", "Label")->get_height() * 2)); + easing_draw->set_custom_minimum_size(Size2(0, get_theme_font("font", "Label")->get_height() * 2)); } break; } } @@ -1126,7 +1126,7 @@ void EditorPropertyVector2::update_property() { void EditorPropertyVector2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 2; i++) { Color c = base; @@ -1208,7 +1208,7 @@ void EditorPropertyRect2::update_property() { } void EditorPropertyRect2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 4; i++) { Color c = base; @@ -1288,7 +1288,7 @@ void EditorPropertyVector3::update_property() { } void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { Color c = base; @@ -1368,7 +1368,7 @@ void EditorPropertyPlane::update_property() { } void EditorPropertyPlane::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { Color c = base; @@ -1450,7 +1450,7 @@ void EditorPropertyQuat::update_property() { } void EditorPropertyQuat::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { Color c = base; @@ -1537,7 +1537,7 @@ void EditorPropertyAABB::update_property() { } void EditorPropertyAABB::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 6; i++) { Color c = base; @@ -1611,7 +1611,7 @@ void EditorPropertyTransform2D::update_property() { } void EditorPropertyTransform2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 6; i++) { Color c = base; @@ -1690,7 +1690,7 @@ void EditorPropertyBasis::update_property() { } void EditorPropertyBasis::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 9; i++) { Color c = base; @@ -1775,7 +1775,7 @@ void EditorPropertyTransform::update_property() { } void EditorPropertyTransform::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Color base = get_color("accent_color", "Editor"); + Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 12; i++) { Color c = base; @@ -1882,7 +1882,7 @@ EditorPropertyColor::EditorPropertyColor() { void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { NodePath path = p_path; - Node *base_node = NULL; + Node *base_node = nullptr; if (!use_path_from_scene_root) { base_node = Object::cast_to<Node>(get_edited_object()); @@ -1945,7 +1945,7 @@ void EditorPropertyNodePath::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); @@ -1983,7 +1983,7 @@ void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringNam void EditorPropertyNodePath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_icon("Clear", "EditorIcons"); + Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); clear->set_icon(t); } } @@ -2008,7 +2008,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() { hbc->add_child(clear); use_path_from_scene_root = false; - scene_tree = NULL; //do not allocate unnecessarily + scene_tree = nullptr; //do not allocate unnecessarily } ///////////////////// RID ///////////////////////// @@ -2074,7 +2074,7 @@ void EditorPropertyResource::_menu_option(int p_which) { file->connect("file_selected", callable_mp(this, &EditorPropertyResource::_file_selected)); add_child(file); } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); String type = base_type; List<String> extensions; @@ -2121,7 +2121,7 @@ void EditorPropertyResource::_menu_option(int p_which) { List<PropertyInfo> property_list; res_orig->get_property_list(&property_list); - List<Pair<String, Variant> > propvalues; + List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { @@ -2144,7 +2144,7 @@ void EditorPropertyResource::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) { + for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); @@ -2196,7 +2196,7 @@ void EditorPropertyResource::_menu_option(int p_which) { file_system_dock->navigate_to_path(res->get_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; default: { @@ -2206,7 +2206,7 @@ void EditorPropertyResource::_menu_option(int p_which) { int to_type = p_which - CONVERT_BASE_ID; - Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); + Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); ERR_FAIL_INDEX(to_type, conversions.size()); @@ -2248,7 +2248,7 @@ void EditorPropertyResource::_menu_option(int p_which) { return; } - Object *obj = NULL; + Object *obj = nullptr; if (ScriptServer::is_global_class(intype)) { obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype)); @@ -2294,7 +2294,7 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T } if (p_preview.is_valid()) { - preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_constant("hseparation", "Button")); + preview->set_margin(MARGIN_LEFT, assign->get_icon()->get_width() + assign->get_theme_stylebox("normal")->get_default_margin(MARGIN_LEFT) + get_theme_constant("hseparation", "Button")); if (type == "GradientTexture") { preview->set_stretch_mode(TextureRect::STRETCH_SCALE); assign->set_custom_minimum_size(Size2(1, 1)); @@ -2318,8 +2318,8 @@ void EditorPropertyResource::_update_menu_items() { menu->clear(); if (get_edited_property() == "script" && base_type == "Script" && Object::cast_to<Node>(get_edited_object())) { - menu->add_icon_item(get_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); - menu->add_icon_item(get_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + menu->add_icon_item(get_theme_icon("ScriptCreate", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); + menu->add_icon_item(get_theme_icon("ScriptExtend", "EditorIcons"), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); menu->add_separator(); } else if (base_type != "") { int idx = 0; @@ -2381,7 +2381,7 @@ void EditorPropertyResource::_update_menu_items() { inheritors_array.push_back(t); if (!icon.is_valid()) - icon = get_icon(has_icon(t, "EditorIcons") ? t : "Object", "EditorIcons"); + icon = get_theme_icon(has_theme_icon(t, "EditorIcons") ? t : "Object", "EditorIcons"); int id = TYPE_BASE_ID + idx; menu->add_icon_item(icon, vformat(TTR("New %s"), t), id); @@ -2394,14 +2394,14 @@ void EditorPropertyResource::_update_menu_items() { menu->add_separator(); } - menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); + menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); if (!res.is_null()) { - menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); - menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); - menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); - menu->add_icon_item(get_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE); + menu->add_icon_item(get_theme_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); + menu->add_icon_item(get_theme_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); + menu->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + menu->add_icon_item(get_theme_icon("Save", "EditorIcons"), TTR("Save"), OBJ_MENU_SAVE); RES r = res; if (r.is_valid() && r->get_path().is_resource_file()) { menu->add_separator(); @@ -2438,19 +2438,19 @@ void EditorPropertyResource::_update_menu_items() { if (!res.is_null()) { - Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); + Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); if (conversions.size()) { menu->add_separator(); } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); Ref<Texture2D> icon; - if (has_icon(what, "EditorIcons")) { + if (has_theme_icon(what, "EditorIcons")) { - icon = get_icon(what, "EditorIcons"); + icon = get_theme_icon(what, "EditorIcons"); } else { - icon = get_icon(what, "Resource"); + icon = get_theme_icon(what, "Resource"); } menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i); @@ -2462,11 +2462,11 @@ void EditorPropertyResource::_update_menu() { _update_menu_items(); - Rect2 gt = edit->get_global_rect(); + Rect2 gt = edit->get_screen_rect(); menu->set_as_minsize(); - int ms = menu->get_combined_minimum_size().width; + int ms = menu->get_contents_minimum_size().width; Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0); - menu->set_global_position(popup_pos); + menu->set_position(popup_pos); menu->popup(); } @@ -2490,10 +2490,10 @@ void EditorPropertyResource::_button_input(const Ref<InputEvent> &p_event) { if (mb.is_valid()) { if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { _update_menu_items(); - Vector2 pos = mb->get_global_position(); + Vector2 pos = get_screen_position() + mb->get_position(); //pos = assign->get_global_transform().xform(pos); menu->set_as_minsize(); - menu->set_global_position(pos); + menu->set_position(pos); menu->popup(); } } @@ -2598,10 +2598,10 @@ void EditorPropertyResource::update_property() { sub_inspector->refresh(); } else { if (sub_inspector) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(sub_inspector_vbox); - sub_inspector = NULL; - sub_inspector_vbox = NULL; + sub_inspector = nullptr; + sub_inspector_vbox = nullptr; if (opened_editor) { EditorNode::get_singleton()->hide_top_editors(); opened_editor = false; @@ -2663,7 +2663,7 @@ void EditorPropertyResource::setup(const String &p_base_type) { void EditorPropertyResource::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - Ref<Texture2D> t = get_icon("select_arrow", "Tree"); + Ref<Texture2D> t = get_theme_icon("select_arrow", "Tree"); edit->set_icon(t); } @@ -2718,7 +2718,7 @@ void EditorPropertyResource::expand_all_folding() { void EditorPropertyResource::_button_draw() { if (dropping) { - Color color = get_color("accent_color", "Editor"); + Color color = get_theme_color("accent_color", "Editor"); assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false); } } @@ -2823,8 +2823,8 @@ void EditorPropertyResource::_bind_methods() { EditorPropertyResource::EditorPropertyResource() { opened_editor = false; - sub_inspector = NULL; - sub_inspector_vbox = NULL; + sub_inspector = nullptr; + sub_inspector_vbox = nullptr; use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector")); HBoxContainer *hbc = memnew(HBoxContainer); @@ -2860,8 +2860,8 @@ EditorPropertyResource::EditorPropertyResource() { edit->connect("gui_input", callable_mp(this, &EditorPropertyResource::_button_input)); add_focusable(edit); - file = NULL; - scene_tree = NULL; + file = nullptr; + scene_tree = nullptr; dropping = false; add_to_group("_editor_resource_properties"); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index c2a6aeb582..b4ce60171b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -184,9 +184,9 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) { Button *button = Object::cast_to<Button>(p_button); changing_type_idx = p_index; - Rect2 rect = button->get_global_rect(); + Rect2 rect = button->get_screen_rect(); change_type->set_as_minsize(); - change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0)); + change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0)); change_type->popup(); } @@ -199,7 +199,7 @@ void EditorPropertyArray::_change_type_menu(int p_index) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); Variant array = object->get_array(); array.set(changing_type_idx, value); @@ -263,9 +263,9 @@ void EditorPropertyArray::update_property() { edit->set_text(String("(Nil) ") + arrtype); edit->set_pressed(false); if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } return; } @@ -340,7 +340,7 @@ void EditorPropertyArray::update_property() { for (int i = 0; i < amount; i++) { String prop_name = "indices/" + itos(i + offset); - EditorProperty *prop = NULL; + EditorProperty *prop = nullptr; Variant value = array.get(i + offset); Variant::Type value_type = value.get_type(); @@ -353,7 +353,7 @@ void EditorPropertyArray::update_property() { editor->setup("Object"); prop = editor; } else { - prop = EditorInspector::instantiate_property_editor(NULL, value_type, "", subtype_hint, subtype_hint_string, 0); + prop = EditorInspector::instantiate_property_editor(nullptr, value_type, "", subtype_hint, subtype_hint_string, 0); } prop->set_object_and_property(object.ptr(), prop_name); @@ -373,13 +373,13 @@ void EditorPropertyArray::update_property() { if (is_untyped_array) { Button *edit = memnew(Button); - edit->set_icon(get_icon("Edit", "EditorIcons")); + edit->set_icon(get_theme_icon("Edit", "EditorIcons")); hb->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type), varray(edit, i + offset)); } else { Button *remove = memnew(Button); - remove->set_icon(get_icon("Remove", "EditorIcons")); + remove->set_icon(get_theme_icon("Remove", "EditorIcons")); remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset)); hb->add_child(remove); } @@ -391,9 +391,9 @@ void EditorPropertyArray::update_property() { } else { if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } } } @@ -419,7 +419,7 @@ void EditorPropertyArray::_edit_pressed() { Variant array = get_edited_object()->get(get_edited_property()); if (!array.is_array()) { Callable::CallError ce; - array = Variant::construct(array_type, NULL, 0, ce); + array = Variant::construct(array_type, nullptr, 0, ce); get_edited_object()->set(get_edited_property(), array); } @@ -450,7 +450,7 @@ void EditorPropertyArray::_length_changed(double p_page) { for (int i = previous_size; i < size; i++) { if (array.get(i).get_type() == Variant::NIL) { Callable::CallError ce; - array.set(i, Variant::construct(subtype, NULL, 0, ce)); + array.set(i, Variant::construct(subtype, nullptr, 0, ce)); } } } @@ -460,7 +460,7 @@ void EditorPropertyArray::_length_changed(double p_page) { // Pool*Array don't initialize their elements, have to do it manually for (int i = previous_size; i < size; i++) { Callable::CallError ce; - array.set(i, Variant::construct(array.get(i).get_type(), NULL, 0, ce)); + array.set(i, Variant::construct(array.get(i).get_type(), nullptr, 0, ce)); } } @@ -505,9 +505,9 @@ EditorPropertyArray::EditorPropertyArray() { edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); - vbox = NULL; - page = NULL; - length = NULL; + vbox = nullptr; + page = nullptr; + length = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); @@ -553,9 +553,9 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) { Button *button = Object::cast_to<Button>(p_button); - Rect2 rect = button->get_global_rect(); + Rect2 rect = button->get_screen_rect(); change_type->set_as_minsize(); - change_type->set_global_position(rect.position + rect.size - Vector2(change_type->get_combined_minimum_size().x, 0)); + change_type->set_position(rect.position + rect.size - Vector2(change_type->get_contents_minimum_size().x, 0)); change_type->popup(); changing_type_idx = p_index; } @@ -585,7 +585,7 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { if (changing_type_idx < 0) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); if (changing_type_idx == -1) { object->set_new_item_key(value); } else { @@ -601,7 +601,7 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { Variant value; Callable::CallError ce; - value = Variant::construct(Variant::Type(p_index), NULL, 0, ce); + value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); Variant key = dict.get_key_at_index(changing_type_idx); dict[key] = value; } else { @@ -624,9 +624,9 @@ void EditorPropertyDictionary::update_property() { edit->set_text("Dictionary (Nil)"); //This provides symmetry with the array property. edit->set_pressed(false); if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } return; } @@ -683,7 +683,7 @@ void EditorPropertyDictionary::update_property() { dict = dict.duplicate(); object->set_dict(dict); - VBoxContainer *add_vbox = NULL; + VBoxContainer *add_vbox = nullptr; for (int i = 0; i < amount + 2; i++) { String prop_name; @@ -702,7 +702,7 @@ void EditorPropertyDictionary::update_property() { value = object->get_new_item_value(); } - EditorProperty *prop = NULL; + EditorProperty *prop = nullptr; switch (value.get_type()) { case Variant::NIL: { @@ -909,9 +909,9 @@ void EditorPropertyDictionary::update_property() { for (int j = 0; j < 4; j++) { flat->set_default_margin(Margin(j), 2 * EDSCALE); } - flat->set_bg_color(get_color("prop_subsection", "Editor")); + flat->set_bg_color(get_theme_color("prop_subsection", "Editor")); - pc->add_style_override("panel", flat); + pc->add_theme_style_override("panel", flat); add_vbox = memnew(VBoxContainer); pc->add_child(add_vbox); } @@ -944,7 +944,7 @@ void EditorPropertyDictionary::update_property() { hb->add_child(prop); prop->set_h_size_flags(SIZE_EXPAND_FILL); Button *edit = memnew(Button); - edit->set_icon(get_icon("Edit", "EditorIcons")); + edit->set_icon(get_theme_icon("Edit", "EditorIcons")); hb->add_child(edit); edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type), varray(edit, change_index)); @@ -962,9 +962,9 @@ void EditorPropertyDictionary::update_property() { } else { if (vbox) { - set_bottom_editor(NULL); + set_bottom_editor(nullptr); memdelete(vbox); - vbox = NULL; + vbox = nullptr; } } } @@ -981,7 +981,7 @@ void EditorPropertyDictionary::_edit_pressed() { Variant prop_val = get_edited_object()->get(get_edited_property()); if (prop_val.get_type() == Variant::NIL) { Callable::CallError ce; - prop_val = Variant::construct(Variant::DICTIONARY, NULL, 0, ce); + prop_val = Variant::construct(Variant::DICTIONARY, nullptr, 0, ce); get_edited_object()->set(get_edited_property(), prop_val); } @@ -1012,8 +1012,8 @@ EditorPropertyDictionary::EditorPropertyDictionary() { edit->set_toggle_mode(true); add_child(edit); add_focusable(edit); - vbox = NULL; - page = NULL; + vbox = nullptr; + page = nullptr; updating = false; change_type = memnew(PopupMenu); add_child(change_type); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 98bc544478..2a4300f833 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -99,7 +99,7 @@ void EditorResourcePreviewGenerator::_bind_methods() { EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() { } -EditorResourcePreview *EditorResourcePreview::singleton = NULL; +EditorResourcePreview *EditorResourcePreview::singleton = nullptr; void EditorResourcePreview::_thread_func(void *ud) { @@ -168,7 +168,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } r_texture = generated; - int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size + int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_theme_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size small_thumbnail_size *= EDSCALE; if (preview_generators[i]->can_generate_small_preview()) { @@ -465,16 +465,16 @@ void EditorResourcePreview::stop() { preview_sem.post(); while (!exited) { OS::get_singleton()->delay_usec(10000); - VisualServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server + RenderingServer::get_singleton()->sync(); //sync pending stuff, as thread may be blocked on visual server } Thread::wait_to_finish(thread); memdelete(thread); - thread = NULL; + thread = nullptr; } } EditorResourcePreview::EditorResourcePreview() { - thread = NULL; + thread = nullptr; singleton = this; order = 0; exit = false; diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 0e1684963c..dc5a3b9c93 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -94,7 +94,7 @@ class EditorResourcePreview : public Node { static void _thread_func(void *ud); void _thread(); - Vector<Ref<EditorResourcePreviewGenerator> > preview_generators; + Vector<Ref<EditorResourcePreviewGenerator>> preview_generators; protected: static void _bind_methods(); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 9f0e1f2349..b4ddb7ebfa 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -32,6 +32,7 @@ #include "core/project_settings.h" #include "editor_settings.h" +#include "servers/display_server.h" EditorRun::Status EditorRun::get_status() const { @@ -70,19 +71,19 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L int screen = EditorSettings::get_singleton()->get("run/window_placement/screen"); if (screen == 0) { // Same as editor - screen = OS::get_singleton()->get_current_screen(); + screen = DisplayServer::get_singleton()->window_get_current_screen(); } else if (screen == 1) { // Previous monitor (wrap to the other end if needed) screen = Math::wrapi( - OS::get_singleton()->get_current_screen() - 1, + DisplayServer::get_singleton()->window_get_current_screen() - 1, 0, - OS::get_singleton()->get_screen_count()); + DisplayServer::get_singleton()->get_screen_count()); } else if (screen == 2) { // Next monitor (wrap to the other end if needed) screen = Math::wrapi( - OS::get_singleton()->get_current_screen() + 1, + DisplayServer::get_singleton()->window_get_current_screen() + 1, 0, - OS::get_singleton()->get_screen_count()); + DisplayServer::get_singleton()->get_screen_count()); } else { // Fixed monitor ID // There are 3 special options, so decrement the option ID by 3 to get the monitor ID @@ -94,8 +95,8 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } Rect2 screen_rect; - screen_rect.position = OS::get_singleton()->get_screen_position(screen); - screen_rect.size = OS::get_singleton()->get_screen_size(screen); + screen_rect.position = DisplayServer::get_singleton()->screen_get_position(screen); + screen_rect.size = DisplayServer::get_singleton()->screen_get_size(screen); Size2 desired_size; desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/width"); @@ -120,7 +121,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L case 1: { // centered int display_scale = 1; #ifdef OSX_ENABLED - if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000) { + display_scale = DisplayServer::get_singleton()->screen_get_scale(screen); +#else + if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000) { display_scale = 2; } #endif diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp index 628055cac6..c03fd4f6f5 100644 --- a/editor/editor_run_script.cpp +++ b/editor/editor_run_script.cpp @@ -56,7 +56,7 @@ Node *EditorScript::get_scene() { if (!editor) { EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method.")); - return NULL; + return nullptr; } return editor->get_edited_scene(); @@ -73,7 +73,7 @@ void EditorScript::_run() { Callable::CallError ce; ce.error = Callable::CallError::CALL_OK; - get_script_instance()->call("_run", NULL, 0, ce); + get_script_instance()->call("_run", nullptr, 0, ce); if (ce.error != Callable::CallError::CALL_OK) { EditorNode::add_io_error(TTR("Couldn't run script:") + "\n " + s->get_path() + "\n" + TTR("Did you forget the '_run' method?")); @@ -95,5 +95,5 @@ void EditorScript::_bind_methods() { EditorScript::EditorScript() { - editor = NULL; + editor = nullptr; } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index fe28efedeb..bccc38ca1b 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -127,7 +127,7 @@ public: } SectionedInspectorFilter() { - edited = NULL; + edited = nullptr; } }; @@ -142,7 +142,7 @@ void SectionedInspector::_section_selected() { return; selected_category = sections->get_selected()->get_metadata(0); - filter->set_section(selected_category, sections->get_selected()->get_children() == NULL); + filter->set_section(selected_category, sections->get_selected()->get_children() == nullptr); inspector->set_property_prefix(selected_category + "/"); } @@ -177,8 +177,8 @@ void SectionedInspector::edit(Object *p_object) { obj = ObjectID(); sections->clear(); - filter->set_edited(NULL); - inspector->edit(NULL); + filter->set_edited(nullptr); + inspector->edit(nullptr); return; } @@ -257,7 +257,7 @@ void SectionedInspector::update_category_list() { for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; - parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); + parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); if (i > 0) { metasection += "/" + sectionarr[i]; @@ -308,8 +308,8 @@ SectionedInspector::SectionedInspector() : sections(memnew(Tree)), filter(memnew(SectionedInspectorFilter)), inspector(memnew(EditorInspector)), - search_box(NULL) { - add_constant_override("autohide", 1); // Fixes the dragger always showing up + search_box(nullptr) { + add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up VBoxContainer *left_vb = memnew(VBoxContainer); left_vb->set_custom_minimum_size(Size2(190, 0) * EDSCALE); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index ae16a50279..5d5bb1242d 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -44,15 +44,16 @@ #include "core/os/os.h" #include "core/project_settings.h" #include "core/version.h" +#include "editor/doc_translations.gen.h" #include "editor/editor_node.h" -#include "editor/translations.gen.h" +#include "editor/editor_translations.gen.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" // PRIVATE METHODS -Ref<EditorSettings> EditorSettings::singleton = NULL; +Ref<EditorSettings> EditorSettings::singleton = nullptr; // Properties @@ -125,7 +126,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { if (p_name.operator String() == "shortcuts") { Array arr; - for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) { + for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) { Ref<ShortCut> sc = E->get(); @@ -176,7 +177,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { _THREAD_SAFE_METHOD_ - const String *k = NULL; + const String *k = nullptr; Set<_EVCSort> vclist; while ((k = props.next(k))) { @@ -340,6 +341,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::FLOAT, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/separate_distraction_mode", false); _initial_set("interface/editor/automatically_open_screenshots", true); + _initial_set("interface/editor/single_window_mode", false); + hints["interface/editor/single_window_mode"] = PropertyInfo(Variant::BOOL, "interface/editor/single_window_mode", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); _initial_set("interface/editor/hide_console_window", false); _initial_set("interface/editor/save_each_scene_on_quit", true); // Regression _initial_set("interface/editor/quit_confirmation", true); @@ -598,7 +601,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("run/window_placement/rect", 1); hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen"); String screen_hints = "Same as Editor,Previous Monitor,Next Monitor"; - for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) { + for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { screen_hints += ",Monitor " + itos(i + 1); } _initial_set("run/window_placement/rect_custom_position", Vector2()); @@ -777,7 +780,7 @@ void EditorSettings::create() { if (singleton.ptr()) return; //pointless - DirAccess *dir = NULL; + DirAccess *dir = nullptr; String data_path; String data_dir; @@ -982,14 +985,12 @@ void EditorSettings::setup_language() { String lang = get("interface/editor/editor_language"); if (lang == "en") - return; //none to do + return; // Default, nothing to do. + // Load editor translation for configured/detected locale. EditorTranslationList *etl = _editor_translations; - while (etl->data) { - if (etl->lang == lang) { - Vector<uint8_t> data; data.resize(etl->uncomp_size); Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); @@ -997,7 +998,7 @@ void EditorSettings::setup_language() { FileAccessMemory *fa = memnew(FileAccessMemory); fa->open_custom(data.ptr(), data.size()); - Ref<Translation> tr = TranslationLoaderPO::load_translation(fa, NULL, "translation_" + String(etl->lang)); + Ref<Translation> tr = TranslationLoaderPO::load_translation(fa); if (tr.is_valid()) { tr->set_locale(etl->lang); @@ -1008,6 +1009,29 @@ void EditorSettings::setup_language() { etl++; } + + // Load class reference translation. + DocTranslationList *dtl = _doc_translations; + while (dtl->data) { + if (dtl->lang == lang) { + Vector<uint8_t> data; + data.resize(dtl->uncomp_size); + Compression::decompress(data.ptrw(), dtl->uncomp_size, dtl->data, dtl->comp_size, Compression::MODE_DEFLATE); + + FileAccessMemory *fa = memnew(FileAccessMemory); + fa->open_custom(data.ptr(), data.size()); + + Ref<Translation> tr = TranslationLoaderPO::load_translation(fa); + + if (tr.is_valid()) { + tr->set_locale(dtl->lang); + TranslationServer::get_singleton()->set_doc_translation(tr); + break; + } + } + + dtl++; + } } void EditorSettings::setup_network() { @@ -1476,7 +1500,7 @@ void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcu bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const { - const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name); + const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name); ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + "."); return E->get()->is_shortcut(p_event); @@ -1484,7 +1508,7 @@ bool EditorSettings::is_shortcut(const String &p_name, const Ref<InputEvent> &p_ Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const { - const Map<String, Ref<ShortCut> >::Element *E = shortcuts.find(p_name); + const Map<String, Ref<ShortCut>>::Element *E = shortcuts.find(p_name); if (!E) return Ref<ShortCut>(); @@ -1493,7 +1517,7 @@ Ref<ShortCut> EditorSettings::get_shortcut(const String &p_name) const { void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) { - for (const Map<String, Ref<ShortCut> >::Element *E = shortcuts.front(); E; E = E->next()) { + for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) { r_shortcuts->push_back(E->key()); } @@ -1502,7 +1526,7 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) { Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) { if (!EditorSettings::get_singleton()) { - return NULL; + return nullptr; } Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index d4dd19ee10..29b89ef1a8 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -95,7 +95,7 @@ private: int last_order; Ref<Resource> clipboard; - Map<String, Ref<ShortCut> > shortcuts; + Map<String, Ref<ShortCut>> shortcuts; String resource_path; String settings_dir; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 0ede0a3b7a..4eefe844d2 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -29,8 +29,9 @@ /*************************************************************************/ #include "editor_spin_slider.h" + +#include "core/input/input_filter.h" #include "core/math/expression.h" -#include "core/os/input.h" #include "editor_node.h" #include "editor_scale.h" @@ -67,7 +68,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { grabbing_spinner_dist_cache = 0; pre_grab_value = get_value(); grabbing_spinner = false; - grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position(); + grabbing_spinner_mouse_pos = InputFilter::get_singleton()->get_mouse_position(); } } else { @@ -75,8 +76,8 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { if (grabbing_spinner) { - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); - Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos); + InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE); + InputFilter::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos); update(); } else { _focus_entered(); @@ -105,7 +106,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { grabbing_spinner_dist_cache += diff_x; if (!grabbing_spinner && ABS(grabbing_spinner_dist_cache) > 4 * EDSCALE) { - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED); + InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_CAPTURED); grabbing_spinner = true; } @@ -176,11 +177,11 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { void EditorSpinSlider::_notification(int p_what) { - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT || - p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN || + if (p_what == NOTIFICATION_WM_FOCUS_OUT || + p_what == NOTIFICATION_WM_FOCUS_IN || p_what == NOTIFICATION_EXIT_TREE) { if (grabbing_spinner) { - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); + InputFilter::get_singleton()->set_mouse_mode(InputFilter::MOUSE_MODE_VISIBLE); grabbing_spinner = false; grabbing_spinner_attempt = false; } @@ -191,30 +192,30 @@ void EditorSpinSlider::_notification(int p_what) { // when it's edited. The LineEdit "focus" stylebox uses the "normal" stylebox's // default margins. Ref<StyleBoxFlat> stylebox = - EditorNode::get_singleton()->get_theme_base()->get_stylebox("normal", "LineEdit")->duplicate(); + EditorNode::get_singleton()->get_theme_base()->get_theme_stylebox("normal", "LineEdit")->duplicate(); // EditorSpinSliders with a label have more space on the left, so add an // higher margin to match the location where the text begins. // The margin values below were determined by empirical testing. stylebox->set_default_margin(MARGIN_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE); - value_input->add_style_override("normal", stylebox); + value_input->add_theme_style_override("normal", stylebox); } if (p_what == NOTIFICATION_DRAW) { updown_offset = -1; - Ref<StyleBox> sb = get_stylebox("normal", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); if (!flat) { draw_style_box(sb, Rect2(Vector2(), get_size())); } - Ref<Font> font = get_font("font", "LineEdit"); + Ref<Font> font = get_theme_font("font", "LineEdit"); int sep_base = 4 * EDSCALE; int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better int string_width = font->get_string_size(label).width; int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep; - Ref<Texture2D> updown = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox"); if (get_step() == 1) { number_width -= updown->get_width(); @@ -224,7 +225,7 @@ void EditorSpinSlider::_notification(int p_what) { int vofs = (get_size().height - font->get_height()) / 2 + font->get_ascent(); - Color fc = get_color("font_color", "LineEdit"); + Color fc = get_theme_color("font_color", "LineEdit"); Color lc; if (use_custom_label_color) { lc = custom_label_color; @@ -233,12 +234,12 @@ void EditorSpinSlider::_notification(int p_what) { } if (flat && label != String()) { - Color label_bg_color = get_color("dark_color_3", "Editor"); + Color label_bg_color = get_theme_color("dark_color_3", "Editor"); draw_rect(Rect2(Vector2(), Vector2(sb->get_offset().x * 2 + string_width, get_size().height)), label_bg_color); } if (has_focus()) { - Ref<StyleBox> focus = get_stylebox("focus", "LineEdit"); + Ref<StyleBox> focus = get_theme_stylebox("focus", "LineEdit"); draw_style_box(focus, Rect2(Vector2(), get_size())); } @@ -247,7 +248,7 @@ void EditorSpinSlider::_notification(int p_what) { draw_string(font, Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs), numstr, fc, number_width); if (get_step() == 1) { - Ref<Texture2D> updown2 = get_icon("updown", "SpinBox"); + Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox"); int updown_vofs = (get_size().height - updown2->get_height()) / 2; updown_offset = get_size().width - sb->get_margin(MARGIN_RIGHT) - updown2->get_width(); Color c(1, 1, 1); @@ -272,7 +273,7 @@ void EditorSpinSlider::_notification(int p_what) { Rect2 grabber_rect = Rect2(ofs + gofs, svofs + 1, grabber_w, 2 * EDSCALE); draw_rect(grabber_rect, c); - bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input->is_visible(); + bool display_grabber = (mouse_over_spin || mouse_over_grabber) && !grabbing_spinner && !value_input_popup->is_visible(); if (grabber->is_visible() != display_grabber) { if (display_grabber) { grabber->show(); @@ -284,9 +285,9 @@ void EditorSpinSlider::_notification(int p_what) { if (display_grabber) { Ref<Texture2D> grabber_tex; if (mouse_over_grabber) { - grabber_tex = get_icon("grabber_highlight", "HSlider"); + grabber_tex = get_theme_icon("grabber_highlight", "HSlider"); } else { - grabber_tex = get_icon("grabber", "HSlider"); + grabber_tex = get_theme_icon("grabber", "HSlider"); } if (grabber->get_texture() != grabber_tex) { @@ -297,7 +298,7 @@ void EditorSpinSlider::_notification(int p_what) { grabber->set_position(get_global_position() + grabber_rect.position + grabber_rect.size * 0.5 - grabber->get_size() * 0.5); if (mousewheel_over_grabber) { - Input::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size); + InputFilter::get_singleton()->warp_mouse_position(grabber->get_position() + grabber_rect.size); } grabber_range = width; @@ -316,12 +317,7 @@ void EditorSpinSlider::_notification(int p_what) { update(); } if (p_what == NOTIFICATION_FOCUS_ENTER) { - /* Sorry, I don't like this, it makes navigating the different fields with arrows more difficult. - * Just press enter to edit. - * if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) { - _focus_entered(); - }*/ - if ((Input::get_singleton()->is_action_pressed("ui_focus_next") || Input::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) { + if ((InputFilter::get_singleton()->is_action_pressed("ui_focus_next") || InputFilter::get_singleton()->is_action_pressed("ui_focus_prev")) && !value_input_just_closed) { _focus_entered(); } value_input_just_closed = false; @@ -330,8 +326,8 @@ void EditorSpinSlider::_notification(int p_what) { Size2 EditorSpinSlider::get_minimum_size() const { - Ref<StyleBox> sb = get_stylebox("normal", "LineEdit"); - Ref<Font> font = get_font("font", "LineEdit"); + Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); + Ref<Font> font = get_theme_font("font", "LineEdit"); Size2 ms = sb->get_minimum_size(); ms.height += font->get_height(); @@ -366,7 +362,7 @@ void EditorSpinSlider::_evaluate_input_text() { return; } - Variant v = expr->execute(Array(), NULL, false); + Variant v = expr->execute(Array(), nullptr, false); if (v.get_type() == Variant::NIL) return; set_value(v); @@ -375,7 +371,7 @@ void EditorSpinSlider::_evaluate_input_text() { //text_entered signal void EditorSpinSlider::_value_input_entered(const String &p_text) { value_input_just_closed = true; - value_input->hide(); + value_input_popup->hide(); } //modal_closed signal @@ -398,7 +394,7 @@ void EditorSpinSlider::_value_focus_exited() { // -> modal_close was not called // -> need to close/hide manually if (!value_input_just_closed) { //value_input_just_closed should do the same - value_input->hide(); + value_input_popup->hide(); //tab was pressed } else { //enter, click, esc @@ -441,11 +437,11 @@ void EditorSpinSlider::set_custom_label_color(bool p_use_custom_label_color, Col } void EditorSpinSlider::_focus_entered() { - Rect2 gr = get_global_rect(); + Rect2 gr = get_screen_rect(); value_input->set_text(get_text_value()); - value_input->set_position(gr.position); - value_input->set_size(gr.size); - value_input->call_deferred("show_modal"); + value_input_popup->set_position(gr.position); + value_input_popup->set_size(gr.size); + value_input_popup->call_deferred("popup"); value_input->call_deferred("grab_focus"); value_input->call_deferred("select_all"); value_input->set_focus_next(find_next_valid_focus()->get_path()); @@ -492,11 +488,13 @@ EditorSpinSlider::EditorSpinSlider() { mousewheel_over_grabber = false; grabbing_grabber = false; grabber_range = 1; + value_input_popup = memnew(Popup); + add_child(value_input_popup); value_input = memnew(LineEdit); - add_child(value_input); - value_input->set_as_toplevel(true); - value_input->hide(); - value_input->connect("modal_closed", callable_mp(this, &EditorSpinSlider::_value_input_closed)); + value_input_popup->add_child(value_input); + value_input_popup->set_wrap_controls(true); + value_input->set_anchors_and_margins_preset(PRESET_WIDE); + value_input_popup->connect("popup_hide", callable_mp(this, &EditorSpinSlider::_value_input_closed)); value_input->connect("text_entered", callable_mp(this, &EditorSpinSlider::_value_input_entered)); value_input->connect("focus_exited", callable_mp(this, &EditorSpinSlider::_value_focus_exited)); value_input_just_closed = false; diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 81a7b981cc..db74f5fb70 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -62,6 +62,7 @@ class EditorSpinSlider : public Range { Vector2 grabbing_spinner_mouse_pos; double pre_grab_value; + Popup *value_input_popup; LineEdit *value_input; bool value_input_just_closed; diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index 3ebd8f0475..1205e0b37c 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -46,7 +46,7 @@ void EditorSubScene::_path_changed(const String &p_path) { if (scene) { memdelete(scene); - scene = NULL; + scene = nullptr; } if (p_path == "") @@ -61,7 +61,7 @@ void EditorSubScene::_path_changed(const String &p_path) { if (!scene) return; - _fill_tree(scene, NULL); + _fill_tree(scene, nullptr); } void EditorSubScene::_path_browse() { @@ -70,11 +70,11 @@ void EditorSubScene::_path_browse() { } void EditorSubScene::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible() && scene == NULL) + if (is_visible() && scene == nullptr) { _path_browse(); + } } } @@ -209,7 +209,7 @@ void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { if (!is_root) { memdelete(scene); } - scene = NULL; + scene = nullptr; //return selnode; } @@ -226,7 +226,7 @@ void EditorSubScene::_bind_methods() { EditorSubScene::EditorSubScene() { - scene = NULL; + scene = nullptr; is_root = false; set_title(TTR("Select Node(s) to Import")); @@ -240,7 +240,7 @@ EditorSubScene::EditorSubScene() { path = memnew(LineEdit); path->connect("text_entered", callable_mp(this, &EditorSubScene::_path_changed)); hb->add_child(path); - path->set_h_size_flags(SIZE_EXPAND_FILL); + path->set_h_size_flags(Control::SIZE_EXPAND_FILL); Button *b = memnew(Button); b->set_text(TTR("Browse")); hb->add_child(b); @@ -248,7 +248,7 @@ EditorSubScene::EditorSubScene() { vb->add_margin_child(TTR("Scene Path:"), hb); tree = memnew(Tree); - tree->set_v_size_flags(SIZE_EXPAND_FILL); + tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); vb->add_margin_child(TTR("Import From Node:"), tree, true); tree->set_select_mode(Tree::SELECT_MULTI); tree->connect("multi_selected", callable_mp(this, &EditorSubScene::_item_multi_selected)); @@ -266,7 +266,7 @@ EditorSubScene::EditorSubScene() { file_dialog->add_filter("*." + E->get()); } - file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorSubScene::_path_selected)); } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 39d4b70a6a..576ee436de 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -187,8 +187,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = exceptions.insert("EditorHandle"); exceptions.insert("Editor3DHandle"); exceptions.insert("Godot"); - exceptions.insert("PanoramaSky"); - exceptions.insert("ProceduralSky"); + exceptions.insert("Sky"); exceptions.insert("EditorControlAnchor"); exceptions.insert("DefaultProjectIcon"); exceptions.insert("GuiCloseCustomizable"); @@ -249,7 +248,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = } } - ImageLoaderSVG::set_convert_colors(NULL); + ImageLoaderSVG::set_convert_colors(nullptr); #else WARN_PRINT("SVG support disabled, editor icons won't be rendered."); #endif @@ -419,7 +418,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { //Register icons + font // the resolution and the icon color (dark_theme bool) has not changed, so we do not regenerate the icons - if (p_theme != NULL && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) { + if (p_theme != nullptr && fabs(p_theme->get_constant("scale", "Editor") - EDSCALE) < 0.00001 && (bool)p_theme->get_constant("dark_theme", "Editor") == dark_theme) { // register already generated icons for (int i = 0; i < editor_icons_count; i++) { theme->set_icon(editor_icons_names[i], "EditorIcons", p_theme->get_icon(editor_icons_names[i], "EditorIcons")); @@ -428,7 +427,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { editor_register_and_generate_icons(theme, dark_theme, thumb_size); } // thumbnail size has changed, so we regenerate the medium sizes - if (p_theme != NULL && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { + if (p_theme != nullptr && fabs((double)p_theme->get_constant("thumb_size", "Editor") - thumb_size) > 0.00001) { editor_register_and_generate_icons(p_theme, dark_theme, thumb_size, true); } @@ -911,14 +910,17 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_window->set_border_color(tab_color); style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE); style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE); - theme->set_stylebox("panel", "WindowDialog", style_window); - theme->set_color("title_color", "WindowDialog", font_color); - theme->set_icon("close", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons")); - theme->set_icon("close_highlight", "WindowDialog", theme->get_icon("GuiClose", "EditorIcons")); - theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE); - theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE); - theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE); - theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts")); + + theme->set_stylebox("panel", "Window", style_default); + theme->set_stylebox("panel_window", "Window", style_window); + theme->set_color("title_color", "Window", font_color); + theme->set_icon("close", "Window", theme->get_icon("GuiClose", "EditorIcons")); + theme->set_icon("close_highlight", "Window", theme->get_icon("GuiClose", "EditorIcons")); + theme->set_constant("close_h_ofs", "Window", 22 * EDSCALE); + theme->set_constant("close_v_ofs", "Window", 20 * EDSCALE); + theme->set_constant("title_height", "Window", 24 * EDSCALE); + theme->set_constant("resize_margin", "Window", 4 * EDSCALE); + theme->set_font("title_font", "Window", theme->get_font("title", "EditorFonts")); // complex window, for now only Editor settings and Project settings Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); @@ -959,12 +961,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2)); theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); + theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); // VSlider theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0)); theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); + theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); //RichTextLabel theme->set_color("default_color", "RichTextLabel", font_color); @@ -979,6 +983,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Panel theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4)); + theme->set_stylebox("panel_fg", "Panel", style_default); // Label theme->set_stylebox("normal", "Label", style_empty); @@ -992,6 +997,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // LinkButton theme->set_stylebox("focus", "LinkButton", style_empty); theme->set_color("font_color", "LinkButton", font_color); + theme->set_color("font_color_hover", "LinkButton", font_color_hl); + theme->set_color("font_color_pressed", "LinkButton", accent_color); + theme->set_color("font_color_disabled", "LinkButton", font_color_disabled); // TooltipPanel Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate(); diff --git a/editor/editor_themes.h b/editor/editor_themes.h index 6e9630804f..4d9bfc56c8 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -33,8 +33,8 @@ #include "scene/resources/theme.h" -Ref<Theme> create_editor_theme(Ref<Theme> p_theme = NULL); +Ref<Theme> create_editor_theme(Ref<Theme> p_theme = nullptr); -Ref<Theme> create_custom_theme(Ref<Theme> p_theme = NULL); +Ref<Theme> create_custom_theme(Ref<Theme> p_theme = nullptr); #endif diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index c420cf44e7..6f3a8d9ea7 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -30,7 +30,7 @@ #include "editor_vcs_interface.h" -EditorVCSInterface *EditorVCSInterface::singleton = NULL; +EditorVCSInterface *EditorVCSInterface::singleton = nullptr; void EditorVCSInterface::_bind_methods() { diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 9328a5e04d..7cb18432a7 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -30,10 +30,10 @@ #include "export_template_manager.h" +#include "core/input/input_filter.h" #include "core/io/json.h" #include "core/io/zip_io.h" #include "core/os/dir_access.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor_node.h" @@ -82,11 +82,11 @@ void ExportTemplateManager::_update_template_list() { String(VERSION_STATUS) != String("rc"); Label *current = memnew(Label); - current->set_h_size_flags(SIZE_EXPAND_FILL); + current->set_h_size_flags(Control::SIZE_EXPAND_FILL); current_hb->add_child(current); if (templates.has(current_version)) { - current->add_color_override("font_color", get_color("success_color", "Editor")); + current->add_theme_color_override("font_color", current->get_theme_color("success_color", "Editor")); // Only display a redownload button if it can be downloaded in the first place if (downloads_available) { @@ -103,7 +103,7 @@ void ExportTemplateManager::_update_template_list() { uninstall->connect("pressed", callable_mp(this, &ExportTemplateManager::_uninstall_template), varray(current_version)); } else { - current->add_color_override("font_color", get_color("error_color", "Editor")); + current->add_theme_color_override("font_color", current->get_theme_color("error_color", "Editor")); Button *redownload = memnew(Button); redownload->set_text(TTR("Download")); @@ -121,13 +121,13 @@ void ExportTemplateManager::_update_template_list() { HBoxContainer *hbc = memnew(HBoxContainer); Label *version = memnew(Label); - version->set_modulate(get_color("disabled_font_color", "Editor")); + version->set_modulate(current->get_theme_color("disabled_font_color", "Editor")); String text = E->get(); if (text == current_version) { text += " " + TTR("(Current)"); } version->set_text(text); - version->set_h_size_flags(SIZE_EXPAND_FILL); + version->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->add_child(version); Button *uninstall = memnew(Button); @@ -145,7 +145,7 @@ void ExportTemplateManager::_download_template(const String &p_version) { while (template_list->get_child_count()) { memdelete(template_list->get_child(0)); } - template_downloader->popup_centered_minsize(); + template_downloader->popup_centered(); template_list_state->set_text(TTR("Retrieving mirrors, please wait...")); template_download_progress->set_max(100); template_download_progress->set_value(0); @@ -157,7 +157,7 @@ void ExportTemplateManager::_download_template(const String &p_version) { void ExportTemplateManager::_uninstall_template(const String &p_version) { remove_confirm->set_text(vformat(TTR("Remove template version '%s'?"), p_version)); - remove_confirm->popup_centered_minsize(); + remove_confirm->popup_centered(); to_remove = p_version; } @@ -184,7 +184,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ // unzClose() will take care of closing the file stored in the unzFile, // so we don't need to `memdelete(fa)` in this method. - FileAccess *fa = NULL; + FileAccess *fa = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&fa); unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); @@ -203,7 +203,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String file = fname; @@ -258,7 +258,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ ret = unzGoToFirstFile(pkg); - EditorProgress *p = NULL; + EditorProgress *p = nullptr; if (p_use_progress) { p = memnew(EditorProgress("ltask", TTR("Extracting Export Templates"), fc)); } @@ -270,7 +270,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ //get filename unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String file_path(String(fname).simplify_path()); @@ -342,7 +342,7 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ void ExportTemplateManager::popup_manager() { _update_template_list(); - popup_centered_minsize(Size2(400, 400) * EDSCALE); + popup_centered(Size2(400, 400) * EDSCALE); } void ExportTemplateManager::ok_pressed() { @@ -446,7 +446,7 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int void ExportTemplateManager::_begin_template_download(const String &p_url) { - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { OS::get_singleton()->shell_open(p_url); return; } @@ -483,6 +483,11 @@ void ExportTemplateManager::_window_template_downloader_closed() { void ExportTemplateManager::_notification(int p_what) { + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (!is_visible()) { + set_process(false); + } + } if (p_what == NOTIFICATION_PROCESS) { update_countdown -= get_process_delta_time(); @@ -536,12 +541,6 @@ void ExportTemplateManager::_notification(int p_what) { set_process(false); } } - - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (!is_visible_in_tree()) { - set_process(false); - } - } } bool ExportTemplateManager::can_install_android_template() { @@ -588,7 +587,7 @@ Error ExportTemplateManager::install_android_template() { const String &source_zip = templates_path.plus_file("android_source.zip"); ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN); - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io); @@ -612,7 +611,7 @@ Error ExportTemplateManager::install_android_template() { // Get file path. unz_file_info info; char fpath[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0); String path = fpath; String base_dir = path.get_base_dir(); @@ -674,7 +673,7 @@ ExportTemplateManager::ExportTemplateManager() { installed_scroll->add_child(installed_vb); installed_scroll->set_enable_v_scroll(true); installed_scroll->set_enable_h_scroll(false); - installed_vb->set_h_size_flags(SIZE_EXPAND_FILL); + installed_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); get_cancel()->set_text(TTR("Close")); get_ok()->set_text(TTR("Install From File")); @@ -688,7 +687,7 @@ ExportTemplateManager::ExportTemplateManager() { template_open->set_title(TTR("Select Template File")); template_open->add_filter("*.tpz ; " + TTR("Godot Export Templates")); template_open->set_access(FileDialog::ACCESS_FILESYSTEM); - template_open->set_mode(FileDialog::MODE_OPEN_FILE); + template_open->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); template_open->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_from_file), varray(true)); add_child(template_open); @@ -708,7 +707,7 @@ ExportTemplateManager::ExportTemplateManager() { template_downloader->get_ok()->set_text(TTR("Close")); template_downloader->set_exclusive(true); add_child(template_downloader); - template_downloader->connect("popup_hide", callable_mp(this, &ExportTemplateManager::_window_template_downloader_closed)); + template_downloader->connect("cancelled", callable_mp(this, &ExportTemplateManager::_window_template_downloader_closed)); VBoxContainer *vbc = memnew(VBoxContainer); template_downloader->add_child(vbc); diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp deleted file mode 100644 index 52ab80cc48..0000000000 --- a/editor/file_type_cache.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************/ -/* file_type_cache.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "file_type_cache.h" - -#include "core/os/file_access.h" -#include "core/project_settings.h" - -FileTypeCache *FileTypeCache::singleton = NULL; - -bool FileTypeCache::has_file(const String &p_path) const { - - GLOBAL_LOCK_FUNCTION - return file_type_map.has(p_path); -} - -String FileTypeCache::get_file_type(const String &p_path) const { - - GLOBAL_LOCK_FUNCTION - ERR_FAIL_COND_V(!file_type_map.has(p_path), ""); - return file_type_map[p_path]; -} -void FileTypeCache::set_file_type(const String &p_path, const String &p_type) { - - GLOBAL_LOCK_FUNCTION - file_type_map[p_path] = p_type; -} - -void FileTypeCache::load() { - - GLOBAL_LOCK_FUNCTION - String project = ProjectSettings::get_singleton()->get_resource_path(); - FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ); - - if (!f) { - - WARN_PRINT("Can't open file_type_cache.cch."); - return; - } - - file_type_map.clear(); - while (!f->eof_reached()) { - - String path = f->get_line(); - if (f->eof_reached()) - break; - String type = f->get_line(); - set_file_type(path, type); - } - - memdelete(f); -} - -void FileTypeCache::save() { - - GLOBAL_LOCK_FUNCTION - String project = ProjectSettings::get_singleton()->get_resource_path(); - FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE); - - ERR_FAIL_COND_MSG(!f, "Can't open file_type_cache.cch for writing, not saving file type cache!"); - - const String *K = NULL; - - while ((K = file_type_map.next(K))) { - - f->store_line(*K); - f->store_line(file_type_map[*K]); - } - - memdelete(f); -} - -FileTypeCache::FileTypeCache() { - - ERR_FAIL_COND_MSG(singleton, "FileTypeCache singleton already exist."); - singleton = this; -} diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h deleted file mode 100644 index 216effea00..0000000000 --- a/editor/file_type_cache.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************/ -/* file_type_cache.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef FILE_TYPE_CACHE_H -#define FILE_TYPE_CACHE_H - -#include "core/object.h" - -class FileTypeCache : Object { - - GDCLASS(FileTypeCache, Object); - - HashMap<String, String> file_type_map; - - static FileTypeCache *singleton; - -public: - static FileTypeCache *get_singleton() { return singleton; } - - bool has_file(const String &p_path) const; - String get_file_type(const String &p_path) const; - void set_file_type(const String &p_path, const String &p_type); - - void load(); - void save(); - - FileTypeCache(); -}; - -#endif // FILE_TYPE_CACHE_H diff --git a/editor/fileserver/SCsub b/editor/fileserver/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/fileserver/SCsub +++ b/editor/fileserver/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/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 6c69f46941..236ae16ccf 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -42,16 +42,17 @@ #include "editor_scale.h" #include "editor_settings.h" #include "import_dock.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" +#include "servers/display_server.h" Ref<Texture2D> FileSystemDock::_get_tree_item_icon(EditorFileSystemDirectory *p_dir, int p_idx) { Ref<Texture2D> file_icon; if (!p_dir->get_file_import_is_valid(p_idx)) { - file_icon = get_icon("ImportFail", "EditorIcons"); + file_icon = get_theme_icon("ImportFail", "EditorIcons"); } else { String file_type = p_dir->get_file_type(p_idx); - file_icon = (has_icon(file_type, "EditorIcons")) ? get_icon(file_type, "EditorIcons") : get_icon("File", "EditorIcons"); + file_icon = (has_theme_icon(file_type, "EditorIcons")) ? get_theme_icon(file_type, "EditorIcons") : get_theme_icon("File", "EditorIcons"); } return file_icon; } @@ -66,8 +67,8 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory dname = "res://"; subdirectory_item->set_text(0, dname); - subdirectory_item->set_icon(0, get_icon("Folder", "EditorIcons")); - subdirectory_item->set_icon_modulate(0, get_color("folder_icon_modulate", "FileDialog")); + subdirectory_item->set_icon(0, get_theme_icon("Folder", "EditorIcons")); + subdirectory_item->set_icon_modulate(0, get_theme_color("folder_icon_modulate", "FileDialog")); subdirectory_item->set_selectable(0, true); String lpath = p_dir->get_path(); subdirectory_item->set_metadata(0, lpath); @@ -121,7 +122,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory file_item->set_as_cursor(0); } if (main_scene == file_metadata) { - file_item->set_custom_color(0, get_color("accent_color", "Editor")); + file_item->set_custom_color(0, get_theme_color("accent_color", "Editor")); } Array udata; udata.push_back(tree_update_id); @@ -187,7 +188,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo // Handles the favorites. TreeItem *favorites = tree->create_item(root); - favorites->set_icon(0, get_icon("Favorites", "EditorIcons")); + favorites->set_icon(0, get_theme_icon("Favorites", "EditorIcons")); favorites->set_text(0, TTR("Favorites:")); favorites->set_metadata(0, "Favorites"); favorites->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); @@ -198,8 +199,8 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (!fave.begins_with("res://")) continue; - Ref<Texture2D> folder_icon = get_icon("Folder", "EditorIcons"); - const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = get_theme_icon("Folder", "EditorIcons"); + const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); String text; Ref<Texture2D> icon; @@ -219,7 +220,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo if (dir) { icon = _get_tree_item_icon(dir, index); } else { - icon = get_icon("File", "EditorIcons"); + icon = get_theme_icon("File", "EditorIcons"); } color = Color(1, 1, 1); } @@ -306,20 +307,21 @@ void FileSystemDock::_notification(int p_what) { EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated)); String ei = "EditorIcons"; - button_reload->set_icon(get_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_icon("Panels2", ei)); + + button_reload->set_icon(get_theme_icon("Reload", ei)); + button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display)); files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file)); button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history)); button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history)); - tree_search_box->set_right_icon(get_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon("Search", ei)); tree_search_box->set_clear_button_enabled(true); - file_list_search_box->set_right_icon(get_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); file_list_search_box->set_clear_button_enabled(true); - button_hist_next->set_icon(get_icon("Forward", ei)); - button_hist_prev->set_icon(get_icon("Back", ei)); + button_hist_next->set_icon(get_theme_icon("Forward", ei)); + button_hist_prev->set_icon(get_theme_icon("Back", ei)); file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option)); tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); @@ -369,19 +371,19 @@ void FileSystemDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons. String ei = "EditorIcons"; - button_reload->set_icon(get_icon("Reload", ei)); - button_toggle_display_mode->set_icon(get_icon("Panels2", ei)); - button_hist_next->set_icon(get_icon("Forward", ei)); - button_hist_prev->set_icon(get_icon("Back", ei)); + button_reload->set_icon(get_theme_icon("Reload", ei)); + button_toggle_display_mode->set_icon(get_theme_icon("Panels2", ei)); + button_hist_next->set_icon(get_theme_icon("Forward", ei)); + button_hist_prev->set_icon(get_theme_icon("Back", ei)); if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) { - button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); } else { - button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); } - tree_search_box->set_right_icon(get_icon("Search", ei)); + tree_search_box->set_right_icon(get_theme_icon("Search", ei)); tree_search_box->set_clear_button_enabled(true); - file_list_search_box->set_right_icon(get_icon("Search", ei)); + file_list_search_box->set_right_icon(get_theme_icon("Search", ei)); file_list_search_box->set_clear_button_enabled(true); // Update always show folders. @@ -532,11 +534,11 @@ void FileSystemDock::_toggle_file_display() { void FileSystemDock::_set_file_display(bool p_active) { if (p_active) { file_list_display_mode = FILE_LIST_DISPLAY_LIST; - button_file_list_display_mode->set_icon(get_icon("FileThumbnail", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon("FileThumbnail", "EditorIcons")); button_file_list_display_mode->set_tooltip(TTR("View items as a grid of thumbnails.")); } else { file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; - button_file_list_display_mode->set_icon(get_icon("FileList", "EditorIcons")); + button_file_list_display_mode->set_icon(get_theme_icon("FileList", "EditorIcons")); button_file_list_display_mode->set_tooltip(TTR("View items as a list.")); } @@ -628,13 +630,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_icon("FolderMediumThumb", ei); - file_thumbnail = get_icon("FileMediumThumb", ei); - file_thumbnail_broken = get_icon("FileDeadMediumThumb", ei); + folder_thumbnail = get_theme_icon("FolderMediumThumb", ei); + file_thumbnail = get_theme_icon("FileMediumThumb", ei); + file_thumbnail_broken = get_theme_icon("FileDeadMediumThumb", ei); } else { - folder_thumbnail = get_icon("FolderBigThumb", ei); - file_thumbnail = get_icon("FileBigThumb", ei); - file_thumbnail_broken = get_icon("FileDeadBigThumb", ei); + folder_thumbnail = get_theme_icon("FolderBigThumb", ei); + file_thumbnail = get_theme_icon("FileBigThumb", ei); + file_thumbnail_broken = get_theme_icon("FileDeadBigThumb", ei); } } else { // No thumbnails. @@ -645,8 +647,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2()); } - Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_icon("folder", "FileDialog"); - const Color folder_color = get_color("folder_icon_modulate", "FileDialog"); + Ref<Texture2D> folder_icon = (use_thumbnails) ? folder_thumbnail : get_theme_icon("folder", "FileDialog"); + const Color folder_color = get_theme_color("folder_icon_modulate", "FileDialog"); // Build the FileInfo list. List<FileInfo> filelist; @@ -766,10 +768,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Select the icons. if (!finfo->import_broken) { - type_icon = (has_icon(ftype, ei)) ? get_icon(ftype, ei) : get_icon(oi, ei); + type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei); big_icon = file_thumbnail; } else { - type_icon = get_icon("ImportFail", ei); + type_icon = get_theme_icon("ImportFail", ei); big_icon = file_thumbnail_broken; tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually."); } @@ -789,7 +791,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { } if (fpath == main_scene) { - files->set_item_custom_fg_color(item_index, get_color("accent_color", "Editor")); + files->set_item_custom_fg_color(item_index, get_theme_color("accent_color", "Editor")); } // Generate the preview. @@ -841,7 +843,7 @@ void FileSystemDock::_tree_activate_file() { if (selected) { String path = selected->get_metadata(0); TreeItem *parent = selected->get_parent(); - bool is_favorite = parent != NULL && parent->get_metadata(0) == "Favorites"; + bool is_favorite = parent != nullptr && parent->get_metadata(0) == "Favorites"; if ((!is_favorite && path.ends_with("/")) || path == "Favorites") { bool collapsed = selected->is_collapsed(); @@ -953,7 +955,7 @@ void FileSystemDock::_push_to_history() { } void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const { - if (efsd == NULL) + if (efsd == nullptr) return; for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -1085,10 +1087,10 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const { // Rename all resources loaded, be it subresources or actual resources. - List<Ref<Resource> > cached; + List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); - for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) { + for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { Ref<Resource> r = E->get(); String base_path = r->get_path(); @@ -1287,12 +1289,12 @@ void FileSystemDock::_make_scene_confirm() { editor->get_editor_data().set_scene_path(idx, scene_name); } -void FileSystemDock::_file_deleted(String p_file) { - emit_signal("file_deleted", p_file); +void FileSystemDock::_file_removed(String p_file) { + emit_signal("file_removed", p_file); } -void FileSystemDock::_folder_deleted(String p_folder) { - emit_signal("folder_deleted", p_folder); +void FileSystemDock::_folder_removed(String p_folder) { + emit_signal("folder_removed", p_folder); } void FileSystemDock::_rename_operation_confirm() { @@ -1412,7 +1414,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove bool can_move = _check_existing(); if (!can_move) { // Ask to do something. - overwrite_dialog->popup_centered_minsize(); + overwrite_dialog->popup_centered(); return; } } @@ -1676,7 +1678,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected rename_dialog_text->set_text(name); rename_dialog_text->select(0, name.length()); } - rename_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE); + rename_dialog->popup_centered(Size2(250, 80) * EDSCALE); rename_dialog_text->grab_focus(); } } @@ -1720,7 +1722,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected duplicate_dialog_text->set_text(name); duplicate_dialog_text->select(0, name.length()); } - duplicate_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE); + duplicate_dialog->popup_centered(Size2(250, 80) * EDSCALE); duplicate_dialog_text->grab_focus(); } } break; @@ -1742,14 +1744,14 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_NEW_FOLDER: { make_dir_dialog_text->set_text("new folder"); make_dir_dialog_text->select_all(); - make_dir_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE); + make_dir_dialog->popup_centered(Size2(250, 80) * EDSCALE); make_dir_dialog_text->grab_focus(); } break; case FILE_NEW_SCENE: { make_scene_dialog_text->set_text("new scene"); make_scene_dialog_text->select_all(); - make_scene_dialog->popup_centered_minsize(Size2(250, 80) * EDSCALE); + make_scene_dialog->popup_centered(Size2(250, 80) * EDSCALE); make_scene_dialog_text->grab_focus(); } break; @@ -1765,7 +1767,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_COPY_PATH: { if (!p_selected.empty()) { String fpath = p_selected[0]; - OS::get_singleton()->set_clipboard(fpath); + DisplayServer::get_singleton()->clipboard_set(fpath); } } break; @@ -1869,7 +1871,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) return Variant(); } - bool is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent(); + bool is_favorite = selected->get_parent() != nullptr && tree->get_root()->get_children() == selected->get_parent(); all_favorites &= is_favorite; all_not_favorites &= !is_favorite; selected = tree->get_next_selected(selected); @@ -2178,28 +2180,28 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (all_files) { if (all_files_scenes) { if (filenames.size() == 1) { - p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN); - p_popup->add_icon_item(get_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT); + p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scene"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), TTR("New Inherited Scene"), FILE_INHERIT); if (ProjectSettings::get_singleton()->get("application/run/main_scene") != filenames[0]) { - p_popup->add_icon_item(get_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE); + p_popup->add_icon_item(get_theme_icon("PlayScene", "EditorIcons"), TTR("Set As Main Scene"), FILE_MAIN_SCENE); } } else { - p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open Scenes"), FILE_OPEN); } - p_popup->add_icon_item(get_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE); + p_popup->add_icon_item(get_theme_icon("Instance", "EditorIcons"), TTR("Instance"), FILE_INSTANCE); p_popup->add_separator(); } else if (filenames.size() == 1) { - p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } } if (p_paths.size() >= 1) { if (!all_favorites) { - p_popup->add_icon_item(get_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE); + p_popup->add_icon_item(get_theme_icon("Favorites", "EditorIcons"), TTR("Add to Favorites"), FILE_ADD_FAVORITE); } if (!all_not_favorites) { - p_popup->add_icon_item(get_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); + p_popup->add_icon_item(get_theme_icon("NonFavorite", "EditorIcons"), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE); } p_popup->add_separator(); } @@ -2212,36 +2214,36 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } } else if (all_folders && foldernames.size() > 0) { - p_popup->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); + p_popup->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open"), FILE_OPEN); p_popup->add_separator(); } if (p_paths.size() == 1) { - p_popup->add_icon_item(get_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH); + p_popup->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH); if (p_paths[0] != "res://") { - p_popup->add_icon_item(get_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME); - p_popup->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE); + p_popup->add_icon_item(get_theme_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME); + p_popup->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE); } } if (p_paths.size() > 1 || p_paths[0] != "res://") { - p_popup->add_icon_item(get_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE); - p_popup->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete"), FILE_REMOVE); + p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE); + p_popup->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Delete"), FILE_REMOVE); } if (p_paths.size() == 1) { p_popup->add_separator(); if (p_display_path_dependent_options) { - p_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - p_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - p_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - p_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + p_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); + p_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); + p_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); + p_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); p_popup->add_separator(); } String fpath = p_paths[0]; String item_text = fpath.ends_with("/") ? TTR("Open in File Manager") : TTR("Show in File Manager"); - p_popup->add_icon_item(get_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER); + p_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), item_text, FILE_SHOW_IN_EXPLORER); } } @@ -2251,8 +2253,8 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { if (paths.size() == 1) { if (paths[0].ends_with("/")) { - tree_popup->add_icon_item(get_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL); - tree_popup->add_icon_item(get_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); + tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowDown", "EditorIcons"), TTR("Expand All"), FOLDER_EXPAND_ALL); + tree_popup->add_icon_item(get_theme_icon("GuiTreeArrowRight", "EditorIcons"), TTR("Collapse All"), FOLDER_COLLAPSE_ALL); tree_popup->add_separator(); } } @@ -2272,10 +2274,10 @@ void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) { path = "res://"; tree_popup->clear(); tree_popup->set_size(Size2(1, 1)); - tree_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - tree_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - tree_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - tree_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + tree_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); + tree_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); + tree_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); + tree_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); tree_popup->set_position(tree->get_global_position() + p_pos); tree_popup->popup(); } @@ -2315,12 +2317,12 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) { file_list_popup->clear(); file_list_popup->set_size(Size2(1, 1)); - file_list_popup->add_icon_item(get_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); - file_list_popup->add_icon_item(get_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); - file_list_popup->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); - file_list_popup->add_icon_item(get_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); + file_list_popup->add_icon_item(get_theme_icon("Folder", "EditorIcons"), TTR("New Folder..."), FILE_NEW_FOLDER); + file_list_popup->add_icon_item(get_theme_icon("PackedScene", "EditorIcons"), TTR("New Scene..."), FILE_NEW_SCENE); + file_list_popup->add_icon_item(get_theme_icon("Script", "EditorIcons"), TTR("New Script..."), FILE_NEW_SCRIPT); + file_list_popup->add_icon_item(get_theme_icon("Object", "EditorIcons"), TTR("New Resource..."), FILE_NEW_RESOURCE); file_list_popup->add_separator(); - file_list_popup->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); + file_list_popup->add_icon_item(get_theme_icon("Filesystem", "EditorIcons"), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); file_list_popup->set_position(files->get_global_position() + p_pos); file_list_popup->popup(); } @@ -2348,8 +2350,6 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { } void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { - if (get_viewport()->get_modal_stack_top()) - return; // Ignore because of modal window. Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed() && !key->is_echo()) { @@ -2366,8 +2366,6 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { } void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { - if (get_viewport()->get_modal_stack_top()) - return; // Ignore because of modal window. Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed() && !key->is_echo()) { @@ -2492,7 +2490,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { add_child(top_vbc); HBoxContainer *toolbar_hbc = memnew(HBoxContainer); - toolbar_hbc->add_constant_override("separation", 0); + toolbar_hbc->add_theme_constant_override("separation", 0); top_vbc->add_child(toolbar_hbc); button_hist_prev = memnew(ToolButton); @@ -2529,7 +2527,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { toolbar_hbc->add_child(button_toggle_display_mode); HBoxContainer *toolbar2_hbc = memnew(HBoxContainer); - toolbar2_hbc->add_constant_override("separation", 0); + toolbar2_hbc->add_theme_constant_override("separation", 0); top_vbc->add_child(toolbar2_hbc); tree_search_box = memnew(LineEdit); @@ -2539,11 +2537,11 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { toolbar2_hbc->add_child(tree_search_box); file_list_popup = memnew(PopupMenu); - file_list_popup->set_hide_on_window_lose_focus(true); + add_child(file_list_popup); tree_popup = memnew(PopupMenu); - tree_popup->set_hide_on_window_lose_focus(true); + add_child(tree_popup); split_box = memnew(VSplitContainer); @@ -2613,8 +2611,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { add_child(owners_editor); remove_dialog = memnew(DependencyRemoveDialog); - remove_dialog->connect("file_removed", callable_mp(this, &FileSystemDock::_file_deleted)); - remove_dialog->connect("folder_removed", callable_mp(this, &FileSystemDock::_folder_deleted)); + remove_dialog->connect("file_removed", callable_mp(this, &FileSystemDock::_file_removed)); + remove_dialog->connect("folder_removed", callable_mp(this, &FileSystemDock::_folder_removed)); add_child(remove_dialog); move_dialog = memnew(EditorDirDialog); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 00f8cd9d50..6d2d8510d1 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -210,8 +210,8 @@ private: void _update_favorites_list_after_move(const Map<String, String> &p_files_renames, const Map<String, String> &p_folders_renames) const; void _update_project_settings_after_move(const Map<String, String> &p_renames) const; - void _file_deleted(String p_file); - void _folder_deleted(String p_folder); + void _file_removed(String p_file); + void _folder_removed(String p_folder); void _files_moved(String p_old_file, String p_new_file); void _folder_moved(String p_old_folder, String p_new_folder); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 5a7d4cede7..d73180c831 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -299,14 +299,14 @@ const char *FindInFilesDialog::SIGNAL_REPLACE_REQUESTED = "replace_requested"; FindInFilesDialog::FindInFilesDialog() { - set_custom_minimum_size(Size2(500 * EDSCALE, 0)); + set_min_size(Size2(500 * EDSCALE, 0)); set_title(TTR("Find in Files")); 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); GridContainer *gc = memnew(GridContainer); @@ -318,7 +318,7 @@ FindInFilesDialog::FindInFilesDialog() { gc->add_child(find_label); _search_text_line_edit = memnew(LineEdit); - _search_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL); + _search_text_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); _search_text_line_edit->connect("text_changed", callable_mp(this, &FindInFilesDialog::_on_search_text_modified)); _search_text_line_edit->connect("text_entered", callable_mp(this, &FindInFilesDialog::_on_search_text_entered)); gc->add_child(_search_text_line_edit); @@ -329,7 +329,7 @@ FindInFilesDialog::FindInFilesDialog() { gc->add_child(_replace_label); _replace_text_line_edit = memnew(LineEdit); - _replace_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL); + _replace_text_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); _replace_text_line_edit->connect("text_entered", callable_mp(this, &FindInFilesDialog::_on_replace_text_entered)); _replace_text_line_edit->hide(); gc->add_child(_replace_text_line_edit); @@ -362,7 +362,7 @@ FindInFilesDialog::FindInFilesDialog() { hbc->add_child(prefix_label); _folder_line_edit = memnew(LineEdit); - _folder_line_edit->set_h_size_flags(SIZE_EXPAND_FILL); + _folder_line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->add_child(_folder_line_edit); Button *folder_button = memnew(Button); @@ -371,7 +371,7 @@ FindInFilesDialog::FindInFilesDialog() { hbc->add_child(folder_button); _folder_dialog = memnew(FileDialog); - _folder_dialog->set_mode(FileDialog::MODE_OPEN_DIR); + _folder_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); _folder_dialog->connect("dir_selected", callable_mp(this, &FindInFilesDialog::_on_folder_selected)); add_child(_folder_dialog); @@ -464,6 +464,7 @@ Set<String> FindInFilesDialog::get_filter() const { void FindInFilesDialog::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (is_visible()) { // Doesn't work more than once if not deferred... _search_text_line_edit->call_deferred("grab_focus"); @@ -576,7 +577,7 @@ FindInFilesPanel::FindInFilesPanel() { hbc->add_child(find_label); _search_text_label = memnew(Label); - _search_text_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts")); + _search_text_label->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); hbc->add_child(_search_text_label); _progress_bar = memnew(ProgressBar); @@ -604,7 +605,7 @@ FindInFilesPanel::FindInFilesPanel() { } _results_display = memnew(Tree); - _results_display->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("source", "EditorFonts")); + _results_display->add_theme_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); _results_display->set_v_size_flags(SIZE_EXPAND_FILL); _results_display->connect("item_selected", callable_mp(this, &FindInFilesPanel::_on_result_selected)); _results_display->connect("item_edited", callable_mp(this, &FindInFilesPanel::_on_item_edited)); @@ -707,7 +708,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin TreeItem *file_item; Map<String, TreeItem *>::Element *E = _file_items.find(fpath); - if (E == NULL) { + if (E == nullptr) { file_item = _results_display->create_item(); file_item->set_text(0, fpath); file_item->set_metadata(0, fpath); @@ -734,7 +735,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin item->set_text(text_index, item_text); item->set_custom_draw(text_index, this, "_draw_result_text"); - Ref<Font> font = _results_display->get_font("font"); + Ref<Font> font = _results_display->get_theme_font("font"); float raw_text_width = font->get_string_size(text).x; float item_text_width = font->get_string_size(item_text).x; @@ -780,11 +781,11 @@ void FindInFilesPanel::_on_item_edited() { TreeItem *item = _results_display->get_selected(); if (item->is_checked(0)) { - item->set_custom_color(1, _results_display->get_color("font_color")); + item->set_custom_color(1, _results_display->get_theme_color("font_color")); } else { // Grey out - Color color = _results_display->get_color("font_color"); + Color color = _results_display->get_theme_color("font_color"); color.a /= 2.0; item->set_custom_color(1, color); } @@ -812,7 +813,7 @@ void FindInFilesPanel::_on_result_selected() { TreeItem *item = _results_display->get_selected(); Map<TreeItem *, Result>::Element *E = _result_items.find(item); - if (E == NULL) + if (E == nullptr) return; Result r = E->value(); @@ -844,7 +845,7 @@ void FindInFilesPanel::_on_replace_all_clicked() { continue; Map<TreeItem *, Result>::Element *F = _result_items.find(item); - ERR_FAIL_COND(F == NULL); + ERR_FAIL_COND(F == nullptr); locations.push_back(F->value()); } diff --git a/editor/find_in_files.h b/editor/find_in_files.h index 7002f750b7..41adb156b6 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -120,10 +120,11 @@ public: Set<String> get_filter() const; protected: - static void _bind_methods(); - void _notification(int p_what); + + void _visibility_changed(); void custom_action(const String &p_action); + static void _bind_methods(); private: void _on_folder_button_pressed(); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index b4c9a01f2a..7e5d2e87d6 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -68,7 +68,7 @@ void GroupDialog::_load_nodes(Node *p_current) { keep = false; } - TreeItem *node = NULL; + TreeItem *node = nullptr; NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current); if (keep && p_current->is_in_group(selected_group)) { if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) { @@ -94,7 +94,7 @@ void GroupDialog::_load_nodes(Node *p_current) { if (!_can_edit(p_current, selected_group)) { node->set_selectable(0, false); - node->set_custom_color(0, get_color("disabled_font_color", "Editor")); + node->set_custom_color(0, groups->get_theme_color("disabled_font_color", "Editor")); } } @@ -122,7 +122,7 @@ bool GroupDialog::_can_edit(Node *p_node, String p_group) { } void GroupDialog::_add_pressed() { - TreeItem *selected = nodes_to_add->get_next_selected(NULL); + TreeItem *selected = nodes_to_add->get_next_selected(nullptr); if (!selected) { return; @@ -151,7 +151,7 @@ void GroupDialog::_add_pressed() { } void GroupDialog::_removed_pressed() { - TreeItem *selected = nodes_to_remove->get_next_selected(NULL); + TreeItem *selected = nodes_to_remove->get_next_selected(nullptr); if (!selected) { return; @@ -204,7 +204,7 @@ void GroupDialog::_add_group(String p_name) { TreeItem *new_group = groups->create_item(groups_root); new_group->set_text(0, name); - new_group->add_button(0, get_icon("Remove", "EditorIcons"), 0); + new_group->add_button(0, groups->get_theme_icon("Remove", "EditorIcons"), 0); new_group->set_editable(0, true); new_group->select(0); groups->ensure_cursor_is_visible(); @@ -361,12 +361,12 @@ void GroupDialog::_delete_group_item(const String &p_name) { void GroupDialog::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - add_button->set_icon(get_icon("Forward", "EditorIcons")); - remove_button->set_icon(get_icon("Back", "EditorIcons")); + add_button->set_icon(groups->get_theme_icon("Forward", "EditorIcons")); + remove_button->set_icon(groups->get_theme_icon("Back", "EditorIcons")); - add_filter->set_right_icon(get_icon("Search", "EditorIcons")); + add_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); add_filter->set_clear_button_enabled(true); - remove_filter->set_right_icon(get_icon("Search", "EditorIcons")); + remove_filter->set_right_icon(groups->get_theme_icon("Search", "EditorIcons")); remove_filter->set_clear_button_enabled(true); } break; } @@ -399,21 +399,21 @@ void GroupDialog::_bind_methods() { } GroupDialog::GroupDialog() { - set_custom_minimum_size(Size2(600, 400) * EDSCALE); + set_min_size(Size2(600, 400) * EDSCALE); scene_tree = SceneTree::get_singleton(); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); - vbc->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + vbc->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); HBoxContainer *hbc = memnew(HBoxContainer); vbc->add_child(hbc); - hbc->set_v_size_flags(SIZE_EXPAND_FILL); + hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL); VBoxContainer *vbc_left = memnew(VBoxContainer); hbc->add_child(vbc_left); - vbc_left->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL); Label *group_title = memnew(Label); group_title->set_text(TTR("Groups")); @@ -425,19 +425,19 @@ GroupDialog::GroupDialog() { groups->set_select_mode(Tree::SELECT_SINGLE); groups->set_allow_reselect(true); groups->set_allow_rmb_select(true); - groups->set_v_size_flags(SIZE_EXPAND_FILL); - groups->add_constant_override("draw_guides", 1); + groups->set_v_size_flags(Control::SIZE_EXPAND_FILL); + groups->add_theme_constant_override("draw_guides", 1); groups->connect("item_selected", callable_mp(this, &GroupDialog::_group_selected)); groups->connect("button_pressed", callable_mp(this, &GroupDialog::_delete_group_pressed)); groups->connect("item_edited", callable_mp(this, &GroupDialog::_group_renamed)); HBoxContainer *chbc = memnew(HBoxContainer); vbc_left->add_child(chbc); - chbc->set_h_size_flags(SIZE_EXPAND_FILL); + chbc->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_group_text = memnew(LineEdit); chbc->add_child(add_group_text); - add_group_text->set_h_size_flags(SIZE_EXPAND_FILL); + add_group_text->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_group_text->connect("text_entered", callable_mp(this, &GroupDialog::_add_group_pressed)); Button *add_group_button = memnew(Button); @@ -447,7 +447,7 @@ GroupDialog::GroupDialog() { VBoxContainer *vbc_add = memnew(VBoxContainer); hbc->add_child(vbc_add); - vbc_add->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_add->set_h_size_flags(Control::SIZE_EXPAND_FILL); Label *out_of_group_title = memnew(Label); out_of_group_title->set_text(TTR("Nodes Not in Group")); @@ -458,23 +458,23 @@ GroupDialog::GroupDialog() { nodes_to_add->set_hide_root(true); nodes_to_add->set_hide_folding(true); nodes_to_add->set_select_mode(Tree::SELECT_MULTI); - nodes_to_add->set_v_size_flags(SIZE_EXPAND_FILL); - nodes_to_add->add_constant_override("draw_guides", 1); + nodes_to_add->set_v_size_flags(Control::SIZE_EXPAND_FILL); + nodes_to_add->add_theme_constant_override("draw_guides", 1); HBoxContainer *add_filter_hbc = memnew(HBoxContainer); - add_filter_hbc->add_constant_override("separate", 0); + add_filter_hbc->add_theme_constant_override("separate", 0); vbc_add->add_child(add_filter_hbc); add_filter = memnew(LineEdit); - add_filter->set_h_size_flags(SIZE_EXPAND_FILL); + add_filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_filter->set_placeholder(TTR("Filter nodes")); add_filter_hbc->add_child(add_filter); add_filter->connect("text_changed", callable_mp(this, &GroupDialog::_add_filter_changed)); VBoxContainer *vbc_buttons = memnew(VBoxContainer); hbc->add_child(vbc_buttons); - vbc_buttons->set_h_size_flags(SIZE_SHRINK_CENTER); - vbc_buttons->set_v_size_flags(SIZE_SHRINK_CENTER); + vbc_buttons->set_h_size_flags(Control::SIZE_SHRINK_CENTER); + vbc_buttons->set_v_size_flags(Control::SIZE_SHRINK_CENTER); add_button = memnew(ToolButton); add_button->set_text(TTR("Add")); @@ -493,7 +493,7 @@ GroupDialog::GroupDialog() { VBoxContainer *vbc_remove = memnew(VBoxContainer); hbc->add_child(vbc_remove); - vbc_remove->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_remove->set_h_size_flags(Control::SIZE_EXPAND_FILL); Label *in_group_title = memnew(Label); in_group_title->set_text(TTR("Nodes in Group")); @@ -501,18 +501,18 @@ GroupDialog::GroupDialog() { nodes_to_remove = memnew(Tree); vbc_remove->add_child(nodes_to_remove); - nodes_to_remove->set_v_size_flags(SIZE_EXPAND_FILL); + nodes_to_remove->set_v_size_flags(Control::SIZE_EXPAND_FILL); nodes_to_remove->set_hide_root(true); nodes_to_remove->set_hide_folding(true); nodes_to_remove->set_select_mode(Tree::SELECT_MULTI); - nodes_to_remove->add_constant_override("draw_guides", 1); + nodes_to_remove->add_theme_constant_override("draw_guides", 1); HBoxContainer *remove_filter_hbc = memnew(HBoxContainer); - remove_filter_hbc->add_constant_override("separate", 0); + remove_filter_hbc->add_theme_constant_override("separate", 0); vbc_remove->add_child(remove_filter_hbc); remove_filter = memnew(LineEdit); - remove_filter->set_h_size_flags(SIZE_EXPAND_FILL); + remove_filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); remove_filter->set_placeholder(TTR("Filter nodes")); remove_filter_hbc->add_child(remove_filter); remove_filter->connect("text_changed", callable_mp(this, &GroupDialog::_remove_filter_changed)); @@ -524,11 +524,9 @@ GroupDialog::GroupDialog() { group_empty->set_autowrap(true); group_empty->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); nodes_to_remove->add_child(group_empty); - group_empty->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); + group_empty->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_KEEP_SIZE, 8 * EDSCALE); set_title(TTR("Group Editor")); - set_as_toplevel(true); - set_resizable(true); error = memnew(ConfirmationDialog); add_child(error); @@ -639,7 +637,7 @@ void GroupsEditor::update_tree() { TreeItem *item = tree->create_item(root); item->set_text(0, gi.name); if (can_be_deleted) { - item->add_button(0, get_icon("Remove", "EditorIcons"), 0); + item->add_button(0, get_theme_icon("Remove", "EditorIcons"), 0); } else { item->set_selectable(0, false); } @@ -664,12 +662,12 @@ void GroupsEditor::_bind_methods() { GroupsEditor::GroupsEditor() { - node = NULL; + node = nullptr; VBoxContainer *vbc = this; group_dialog = memnew(GroupDialog); - group_dialog->set_as_toplevel(true); + add_child(group_dialog); group_dialog->connect("group_edited", callable_mp(this, &GroupsEditor::update_tree)); @@ -682,7 +680,7 @@ GroupsEditor::GroupsEditor() { vbc->add_child(hbc); group_name = memnew(LineEdit); - group_name->set_h_size_flags(SIZE_EXPAND_FILL); + group_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->add_child(group_name); group_name->connect("text_entered", callable_mp(this, &GroupsEditor::_add_group)); @@ -693,11 +691,11 @@ GroupsEditor::GroupsEditor() { tree = memnew(Tree); tree->set_hide_root(true); - tree->set_v_size_flags(SIZE_EXPAND_FILL); + tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(tree); tree->connect("button_pressed", callable_mp(this, &GroupsEditor::_remove_group)); - tree->add_constant_override("draw_guides", 1); - add_constant_override("separation", 3 * EDSCALE); + tree->add_theme_constant_override("draw_guides", 1); + add_theme_constant_override("separation", 3 * EDSCALE); } GroupsEditor::~GroupsEditor() { diff --git a/editor/groups_editor.h b/editor/groups_editor.h index 84c653bdea..40c7b3c75a 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -41,9 +41,9 @@ #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" -class GroupDialog : public WindowDialog { +class GroupDialog : public AcceptDialog { - GDCLASS(GroupDialog, WindowDialog); + GDCLASS(GroupDialog, AcceptDialog); ConfirmationDialog *error; diff --git a/editor/icons/AcceptDialog.svg b/editor/icons/AcceptDialog.svg index e0bf7b8336..07e54d722f 100644 --- a/editor/icons/AcceptDialog.svg +++ b/editor/icons/AcceptDialog.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm9.4746 1.6367 1.4141 1.4141-4.9492 4.9492-2.8281-2.8281 1.4141-1.4141 1.4141 1.4141z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm9.4746 1.6367 1.4141 1.4141-4.9492 4.9492-2.8281-2.8281 1.4141-1.4141 1.4141 1.4141z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/AnimatedSprite.svg b/editor/icons/AnimatedSprite2D.svg index 411ddda015..411ddda015 100644 --- a/editor/icons/AnimatedSprite.svg +++ b/editor/icons/AnimatedSprite2D.svg diff --git a/editor/icons/Area.svg b/editor/icons/Area3D.svg index 21ebe3c251..21ebe3c251 100644 --- a/editor/icons/Area.svg +++ b/editor/icons/Area3D.svg diff --git a/editor/icons/BoneAttachment.svg b/editor/icons/BoneAttachment3D.svg index 0b7dede0b6..0b7dede0b6 100644 --- a/editor/icons/BoneAttachment.svg +++ b/editor/icons/BoneAttachment3D.svg diff --git a/editor/icons/BoxShape.svg b/editor/icons/BoxShape3D.svg index 171e95f4fa..171e95f4fa 100644 --- a/editor/icons/BoxShape.svg +++ b/editor/icons/BoxShape3D.svg diff --git a/editor/icons/CPUParticles.svg b/editor/icons/CPUParticles3D.svg index af4115c93f..af4115c93f 100644 --- a/editor/icons/CPUParticles.svg +++ b/editor/icons/CPUParticles3D.svg diff --git a/editor/icons/Camera.svg b/editor/icons/Camera3D.svg index af1cb8a2e9..af1cb8a2e9 100644 --- a/editor/icons/Camera.svg +++ b/editor/icons/Camera3D.svg diff --git a/editor/icons/CapsuleShape.svg b/editor/icons/CapsuleShape3D.svg index ba035ca196..ba035ca196 100644 --- a/editor/icons/CapsuleShape.svg +++ b/editor/icons/CapsuleShape3D.svg diff --git a/editor/icons/ClippedCamera.svg b/editor/icons/ClippedCamera3D.svg index 8c80c04e27..8c80c04e27 100644 --- a/editor/icons/ClippedCamera.svg +++ b/editor/icons/ClippedCamera3D.svg diff --git a/editor/icons/CollisionPolygon.svg b/editor/icons/CollisionPolygon3D.svg index 5e849ae4e3..5e849ae4e3 100644 --- a/editor/icons/CollisionPolygon.svg +++ b/editor/icons/CollisionPolygon3D.svg diff --git a/editor/icons/CollisionShape.svg b/editor/icons/CollisionShape3D.svg index 8f14996a97..8f14996a97 100644 --- a/editor/icons/CollisionShape.svg +++ b/editor/icons/CollisionShape3D.svg diff --git a/editor/icons/ConcavePolygonShape.svg b/editor/icons/ConcavePolygonShape3D.svg index 001ab82826..001ab82826 100644 --- a/editor/icons/ConcavePolygonShape.svg +++ b/editor/icons/ConcavePolygonShape3D.svg diff --git a/editor/icons/ConeTwistJoint.svg b/editor/icons/ConeTwistJoint3D.svg index 0e5e98a17b..0e5e98a17b 100644 --- a/editor/icons/ConeTwistJoint.svg +++ b/editor/icons/ConeTwistJoint3D.svg diff --git a/editor/icons/ConfirmationDialog.svg b/editor/icons/ConfirmationDialog.svg index d1f13fbb3b..2d6e45b51f 100644 --- a/editor/icons/ConfirmationDialog.svg +++ b/editor/icons/ConfirmationDialog.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm6.9863 1.002c.34689-.0022844.6986.055762 1.0391.17969 1.3618.4956 2.1813 1.9126 1.9297 3.3398-.19105 1.0835-.96172 1.9461-1.9551 2.3008v.17773h-1-1v-.8418a1.0001 1.0001 0 0 1 1-1.1582c.49193 0 .89895-.34177.98438-.82617.085424-.4845-.18031-.94508-.64258-1.1133-.46227-.1683-.96106.013453-1.207.43945a1.0002 1.0002 0 0 1 -1.7324-1c.54346-.94148 1.5433-1.4912 2.584-1.498zm-.98633 6.998h2v1h-2z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm6.9863 1.002c.34689-.0022844.6986.055762 1.0391.17969 1.3618.4956 2.1813 1.9126 1.9297 3.3398-.19105 1.0835-.96172 1.9461-1.9551 2.3008v.17773h-1-1v-.8418a1.0001 1.0001 0 0 1 1-1.1582c.49193 0 .89895-.34177.98438-.82617.085424-.4845-.18031-.94508-.64258-1.1133-.46227-.1683-.96106.013453-1.207.43945a1.0002 1.0002 0 0 1 -1.7324-1c.54346-.94148 1.5433-1.4912 2.584-1.498zm-.98633 6.998h2v1h-2z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/ConvexPolygonShape.svg b/editor/icons/ConvexPolygonShape3D.svg index bfb9230586..bfb9230586 100644 --- a/editor/icons/ConvexPolygonShape.svg +++ b/editor/icons/ConvexPolygonShape3D.svg diff --git a/editor/icons/CylinderShape.svg b/editor/icons/CylinderShape3D.svg index f0aa5833d2..f0aa5833d2 100644 --- a/editor/icons/CylinderShape.svg +++ b/editor/icons/CylinderShape3D.svg diff --git a/editor/icons/DirectionalLight.svg b/editor/icons/DirectionalLight3D.svg index faac2be134..faac2be134 100644 --- a/editor/icons/DirectionalLight.svg +++ b/editor/icons/DirectionalLight3D.svg diff --git a/editor/icons/PopupDialog.svg b/editor/icons/EditorFileDialog.svg index d871e56a63..95906234ab 100644 --- a/editor/icons/PopupDialog.svg +++ b/editor/icons/EditorFileDialog.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm6 1h2v5h-2zm0 6h2v2h-2z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm3 2h3c1 0 1 2 2 2h3v4h-8z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/FileDialog.svg b/editor/icons/FileDialog.svg index 7708659c21..95906234ab 100644 --- a/editor/icons/FileDialog.svg +++ b/editor/icons/FileDialog.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm3 2h3c1 0 1 2 2 2h3v4h-8z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm3 2h3c1 0 1 2 2 2h3v4h-8z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/Particles2D.svg b/editor/icons/GPUParticles2D.svg index 7151194e36..7151194e36 100644 --- a/editor/icons/Particles2D.svg +++ b/editor/icons/GPUParticles2D.svg diff --git a/editor/icons/Particles.svg b/editor/icons/GPUParticles3D.svg index f1378e3f8c..f1378e3f8c 100644 --- a/editor/icons/Particles.svg +++ b/editor/icons/GPUParticles3D.svg diff --git a/editor/icons/Generic6DOFJoint.svg b/editor/icons/Generic6DOFJoint3D.svg index 30d892e7a1..30d892e7a1 100644 --- a/editor/icons/Generic6DOFJoint.svg +++ b/editor/icons/Generic6DOFJoint3D.svg diff --git a/editor/icons/GizmoSpatialSamplePlayer.svg b/editor/icons/Gizmo3DSamplePlayer.svg index ee471124dc..ee471124dc 100644 --- a/editor/icons/GizmoSpatialSamplePlayer.svg +++ b/editor/icons/Gizmo3DSamplePlayer.svg diff --git a/editor/icons/GizmoCPUParticles.svg b/editor/icons/GizmoCPUParticles3D.svg index d4e86d9c42..d4e86d9c42 100644 --- a/editor/icons/GizmoCPUParticles.svg +++ b/editor/icons/GizmoCPUParticles3D.svg diff --git a/editor/icons/GizmoParticles.svg b/editor/icons/GizmoGPUParticles3D.svg index 1c5d8c5f2d..1c5d8c5f2d 100644 --- a/editor/icons/GizmoParticles.svg +++ b/editor/icons/GizmoGPUParticles3D.svg diff --git a/editor/icons/HeightMapShape.svg b/editor/icons/HeightMapShape3D.svg index 2e0bf53565..2e0bf53565 100644 --- a/editor/icons/HeightMapShape.svg +++ b/editor/icons/HeightMapShape3D.svg diff --git a/editor/icons/HingeJoint.svg b/editor/icons/HingeJoint3D.svg index 21b3e29cb5..21b3e29cb5 100644 --- a/editor/icons/HingeJoint.svg +++ b/editor/icons/HingeJoint3D.svg diff --git a/editor/icons/ImmediateGeometry.svg b/editor/icons/ImmediateGeometry3D.svg index 5679d5906f..5679d5906f 100644 --- a/editor/icons/ImmediateGeometry.svg +++ b/editor/icons/ImmediateGeometry3D.svg diff --git a/editor/icons/KinematicBody.svg b/editor/icons/KinematicBody3D.svg index 16078fbdec..16078fbdec 100644 --- a/editor/icons/KinematicBody.svg +++ b/editor/icons/KinematicBody3D.svg diff --git a/editor/icons/Listener.svg b/editor/icons/Listener3D.svg index 96eaeaffa9..96eaeaffa9 100644 --- a/editor/icons/Listener.svg +++ b/editor/icons/Listener3D.svg diff --git a/editor/icons/MeshInstance.svg b/editor/icons/MeshInstance3D.svg index 68344b7dbd..68344b7dbd 100644 --- a/editor/icons/MeshInstance.svg +++ b/editor/icons/MeshInstance3D.svg diff --git a/editor/icons/MultiMeshInstance.svg b/editor/icons/MultiMeshInstance3D.svg index c114a725db..c114a725db 100644 --- a/editor/icons/MultiMeshInstance.svg +++ b/editor/icons/MultiMeshInstance3D.svg diff --git a/editor/icons/Navigation.svg b/editor/icons/Navigation3D.svg index d5a8f8618b..d5a8f8618b 100644 --- a/editor/icons/Navigation.svg +++ b/editor/icons/Navigation3D.svg diff --git a/editor/icons/NavigationAgent.svg b/editor/icons/NavigationAgent3D.svg index 44c991d44c..44c991d44c 100644 --- a/editor/icons/NavigationAgent.svg +++ b/editor/icons/NavigationAgent3D.svg diff --git a/editor/icons/NavigationObstacle.svg b/editor/icons/NavigationObstacle3D.svg index 42481a6067..42481a6067 100644 --- a/editor/icons/NavigationObstacle.svg +++ b/editor/icons/NavigationObstacle3D.svg diff --git a/editor/icons/NavigationRegion.svg b/editor/icons/NavigationRegion3D.svg index 61f43497b4..61f43497b4 100644 --- a/editor/icons/NavigationRegion.svg +++ b/editor/icons/NavigationRegion3D.svg diff --git a/editor/icons/Spatial.svg b/editor/icons/Node3D.svg index 6a469dde13..6a469dde13 100644 --- a/editor/icons/Spatial.svg +++ b/editor/icons/Node3D.svg diff --git a/editor/icons/OmniLight.svg b/editor/icons/OmniLight3D.svg index 6fa0454e8c..6fa0454e8c 100644 --- a/editor/icons/OmniLight.svg +++ b/editor/icons/OmniLight3D.svg diff --git a/editor/icons/Path.svg b/editor/icons/Path3D.svg index cde9a06903..cde9a06903 100644 --- a/editor/icons/Path.svg +++ b/editor/icons/Path3D.svg diff --git a/editor/icons/PathFollow.svg b/editor/icons/PathFollow3D.svg index 8e904ab5a5..8e904ab5a5 100644 --- a/editor/icons/PathFollow.svg +++ b/editor/icons/PathFollow3D.svg diff --git a/editor/icons/PhysicalBone.svg b/editor/icons/PhysicalBone3D.svg index 0a34eb6e48..0a34eb6e48 100644 --- a/editor/icons/PhysicalBone.svg +++ b/editor/icons/PhysicalBone3D.svg diff --git a/editor/icons/PinJoint.svg b/editor/icons/PinJoint3D.svg index 147553d316..147553d316 100644 --- a/editor/icons/PinJoint.svg +++ b/editor/icons/PinJoint3D.svg diff --git a/editor/icons/Popup.svg b/editor/icons/Popup.svg index 93f7e5000d..a497b7a7fc 100644 --- a/editor/icons/Popup.svg +++ b/editor/icons/Popup.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .89543-2 2v10c0 1.1046.89543 2 2 2h10c1.1046 0 2-.89543 2-2v-10c0-1.1046-.89543-2-2-2zm4 2h2v6h-2zm0 8h2v2h-2z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .89543-2 2v10c0 1.1046.89543 2 2 2h10c1.1046 0 2-.89543 2-2v-10c0-1.1046-.89543-2-2-2zm4 2h2v6h-2zm0 8h2v2h-2z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/PopupMenu.svg b/editor/icons/PopupMenu.svg index dd7b2bb0fd..ebf62208e0 100644 --- a/editor/icons/PopupMenu.svg +++ b/editor/icons/PopupMenu.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v4h6v-4zm1 1h4l-2 2zm0 4a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7a1 1 0 0 0 -1-1zm1 2h10v2h-10zm0 3h10v2h-10z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v4h6v-4zm1 1h4l-2 2zm0 4a1 1 0 0 0 -1 1v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7a1 1 0 0 0 -1-1zm1 2h10v2h-10zm0 3h10v2h-10z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/PopupPanel.svg b/editor/icons/PopupPanel.svg index 47a5448f5b..b45a3c9c3c 100644 --- a/editor/icons/PopupPanel.svg +++ b/editor/icons/PopupPanel.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v4h6v-4zm1 1h4l-2 2zm0 4c-.55228 0-1 .44772-1 1v7c0 .55228.44772 1 1 1h12c.55228 0 1-.44772 1-1v-7c0-.55228-.44772-1-1-1z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v4h6v-4zm1 1h4l-2 2zm0 4c-.55228 0-1 .44772-1 1v7c0 .55228.44772 1 1 1h12c.55228 0 1-.44772 1-1v-7c0-.55228-.44772-1-1-1z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/ProximityGroup.svg b/editor/icons/ProximityGroup3D.svg index 7df1cc9093..7df1cc9093 100644 --- a/editor/icons/ProximityGroup.svg +++ b/editor/icons/ProximityGroup3D.svg diff --git a/editor/icons/RayCast.svg b/editor/icons/RayCast3D.svg index e782b27e9f..e782b27e9f 100644 --- a/editor/icons/RayCast.svg +++ b/editor/icons/RayCast3D.svg diff --git a/editor/icons/RayShape.svg b/editor/icons/RayShape3D.svg index 37c2206740..37c2206740 100644 --- a/editor/icons/RayShape.svg +++ b/editor/icons/RayShape3D.svg diff --git a/editor/icons/RemoteTransform.svg b/editor/icons/RemoteTransform3D.svg index 2bdf8cd858..2bdf8cd858 100644 --- a/editor/icons/RemoteTransform.svg +++ b/editor/icons/RemoteTransform3D.svg diff --git a/editor/icons/RigidBody.svg b/editor/icons/RigidBody3D.svg index 5d766f7c3d..5d766f7c3d 100644 --- a/editor/icons/RigidBody.svg +++ b/editor/icons/RigidBody3D.svg diff --git a/editor/icons/SCsub b/editor/icons/SCsub index b39c74c66a..f0d51999f0 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -1,21 +1,21 @@ #!/usr/bin/env python -Import('env') +Import("env") from platform_methods import run_in_subprocess import editor_icons_builders -make_editor_icons_builder = Builder(action=run_in_subprocess(editor_icons_builders.make_editor_icons_action), - suffix='.h', - src_suffix='.svg') +make_editor_icons_builder = Builder( + action=run_in_subprocess(editor_icons_builders.make_editor_icons_action), suffix=".h", src_suffix=".svg" +) -env['BUILDERS']['MakeEditorIconsBuilder'] = make_editor_icons_builder +env["BUILDERS"]["MakeEditorIconsBuilder"] = make_editor_icons_builder # Editor's own icons icon_sources = Glob("*.svg") # Module icons for module_icons in env.module_icons_paths: - icon_sources += Glob('#' + module_icons + "/*.svg") + icon_sources += Glob("#" + module_icons + "/*.svg") -env.Alias('editor_icons', [env.MakeEditorIconsBuilder('#editor/editor_icons.gen.h', icon_sources)]) +env.Alias("editor_icons", [env.MakeEditorIconsBuilder("#editor/editor_icons.gen.h", icon_sources)]) diff --git a/editor/icons/ScriptCreateDialog.svg b/editor/icons/ScriptCreateDialog.svg index 751b799ba9..78a69c5e59 100644 --- a/editor/icons/ScriptCreateDialog.svg +++ b/editor/icons/ScriptCreateDialog.svg @@ -1 +1 @@ -<svg height="17.067" viewBox="0 0 16 16" width="17.067" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 -1036.4)"><path d="m6 1v1c-.55228 0-1 .44772-1 1v10h-1v-2h-2v2c.0002826.35698.19084.68674.5.86523.15194.088045.32439.13452.5.13477v1h6v-5l3-2v-3h3v-2c0-1.1046-.89543-2-2-2z" fill="#a5efac" transform="translate(0 1036.4)"/><path d="m6 1c-1.1046 0-2 .89543-2 2v7h-3v3c0 1.1046.89543 2 2 2s2-.89543 2-2v-10c0-.55228.44772-1 1-1s1 .44772 1 1v3h5v-1h-4v-2c0-1.1046-.89543-2-2-2zm-4 10h2v2c0 .55228-.44772 1-1 1s-1-.44772-1-1z" fill="#87e29f" transform="translate(0 1036.4)"/><circle cx="3" cy="1048.4" fill="#e0e0e0" r="0"/><g fill="#87e29f"><ellipse cx="12" cy="1048.4" rx=".5" ry="3"/><ellipse cx="913.91" cy="513.79" rx=".5" ry="3" transform="matrix(.5 .8660254 -.8660254 .5 0 0)"/><ellipse cx="901.91" cy="-534.57" rx=".5" ry="3" transform="matrix(-.5 .8660254 -.8660254 -.5 0 0)"/></g></g></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8zm5.5722656 1h3.9980464a1.1426143 1.1426143 0 0 1 1.142579 1.1425781v1.1425781h-1.712891-2.2851562v-.5703124-.5722657c0-.6310659-.5115295-1.1425781-1.1425782-1.1425781zm0 .5722656c.3155215 0 .5703125.254791.5703125.5703125v.5722657.5703124.5722657h.5722657 2.2851562v3.9980471a1.1426143 1.1426143 0 0 1 -1.1425781 1.142578h-4c.6310487 0 1.1425781-.511529 1.1425781-1.142578v-5.7128909c0-.0785019.01823-.1545692.046875-.2226562v-.0019531c.02868-.0672829.0683226-.1266374.1191406-.1777344.00097-.00096.0029352-.0010048.0039063-.0019532.0513303-.0508898.1121075-.0944618.1796875-.1230468.0683505-.028909.1437752-.0429688.2226562-.0429688zm-2.2851562 5.1406254h1.1425781v1.142578c0 .315522-.2567441.572265-.5722656.572265-.0776611 0-.15125-.016852-.21875-.044922-.00206-.000799-.0038594-.003049-.0058594-.003906-.0656506-.028192-.1236101-.067817-.1738281-.117187a.57130715.57130715 0 0 1 -.0097656-.009766c-.0490902-.050487-.0893425-.107988-.1171876-.173828-.028908-.06835-.0449218-.143776-.0449218-.222656z"/><circle cx="-23.915255" cy="3.118624" r="0"/></g></svg>
\ No newline at end of file diff --git a/editor/icons/Skeleton.svg b/editor/icons/Skeleton3D.svg index 015c842125..015c842125 100644 --- a/editor/icons/Skeleton.svg +++ b/editor/icons/Skeleton3D.svg diff --git a/editor/icons/SkeletonIK.svg b/editor/icons/SkeletonIK3D.svg index e69f6e8bf3..e69f6e8bf3 100644 --- a/editor/icons/SkeletonIK.svg +++ b/editor/icons/SkeletonIK3D.svg diff --git a/editor/icons/Sky.svg b/editor/icons/Sky.svg new file mode 100644 index 0000000000..356a966fe9 --- /dev/null +++ b/editor/icons/Sky.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="8" x2="8" y1="1040.4" y2="1050.4"><stop offset="0" stop-color="#1ec3ff"/><stop offset="1" stop-color="#b2e1ff"/></linearGradient><g transform="translate(0 -1037.4)"><path d="m8 1040.4a7 7 0 0 0 -7 7 7 7 0 0 0 .68555 3h12.631a7 7 0 0 0 .68359-3 7 7 0 0 0 -7-7z" fill="url(#a)"/><path d="m10 7c-.554 0-1 .446-1 1h-1c-.554 0-1 .446-1 1s.446 1 1 1h2c.554 0 1-.446 1-1h1c.554 0 1-.446 1-1s-.446-1-1-1zm-7 3c-.554 0-1 .446-1 1s.446 1 1 1h1c.554 0 1-.446 1-1s-.446-1-1-1z" fill="#fff" transform="translate(0 1037.4)"/></g></svg>
\ No newline at end of file diff --git a/editor/icons/SliderJoint.svg b/editor/icons/SliderJoint3D.svg index fdd7487bbf..fdd7487bbf 100644 --- a/editor/icons/SliderJoint.svg +++ b/editor/icons/SliderJoint3D.svg diff --git a/editor/icons/SoftBody.svg b/editor/icons/SoftBody3D.svg index 2c907df847..2c907df847 100644 --- a/editor/icons/SoftBody.svg +++ b/editor/icons/SoftBody3D.svg diff --git a/editor/icons/SpatialMaterial.svg b/editor/icons/SpatialMaterial.svg deleted file mode 100644 index cfd994a0fe..0000000000 --- a/editor/icons/SpatialMaterial.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.9629 1.002a1.0001 1.0001 0 0 0 -.41016.10352l-3.7891 1.8945h8.4727l-3.7891-1.8945a1.0001 1.0001 0 0 0 -.48438-.10352z" fill="#ff7070"/><path d="m3.7637 3-2.2109 1.1055a1.0001 1.0001 0 0 0 -.55273.89453h3.2363l3.7637-1.8809 3.7637 1.8809h3.2363a1.0001 1.0001 0 0 0 -.55273-.89453l-2.2109-1.1055h-8.4727z" fill="#ffeb70"/><path d="m1 5v2h2v-.38086l.76172.38086h8.4766l.76172-.38086v.38086h2v-2h-3.2363l-3.7637 1.8828-3.7637-1.8828h-3.2363z" fill="#9dff70"/><path d="m1 7v2h2v-2zm2.7617 0 3.2383 1.6191v.38086h2v-.38086l3.2383-1.6191zm9.2383 0v2h2v-2z" fill="#70ffb9"/><path d="m1 9v2h3.2344l-1.2344-.61719v-1.3828h-2zm6 0v2h2v-2zm6 0v1.3828l-1.2344.61719h3.2344v-2h-2z" fill="#70deff"/><path d="m3.7637 13 3.7891 1.8945a1.0001 1.0001 0 0 0 .48438.10547 1.0001 1.0001 0 0 0 .41016-.10547l3.7891-1.8945h-8.4727z" fill="#ff70ac"/><path d="m1 11a1.0001 1.0001 0 0 0 .55273.89453l2.2109 1.1055h8.4727l2.2109-1.1055a1.0001 1.0001 0 0 0 .55273-.89453h-3.2344l-2.7656 1.3828v-1.3828h-2v1.3828l-2.7656-1.3828h-3.2344z" fill="#9f70ff"/></svg>
\ No newline at end of file diff --git a/editor/icons/SphereShape.svg b/editor/icons/SphereShape3D.svg index 4da18a1a38..4da18a1a38 100644 --- a/editor/icons/SphereShape.svg +++ b/editor/icons/SphereShape3D.svg diff --git a/editor/icons/SpotLight.svg b/editor/icons/SpotLight3D.svg index 6a35ee3890..6a35ee3890 100644 --- a/editor/icons/SpotLight.svg +++ b/editor/icons/SpotLight3D.svg diff --git a/editor/icons/SpringArm.svg b/editor/icons/SpringArm3D.svg index eb0c1ebd7d..eb0c1ebd7d 100644 --- a/editor/icons/SpringArm.svg +++ b/editor/icons/SpringArm3D.svg diff --git a/editor/icons/Sprite.svg b/editor/icons/Sprite2D.svg index 26a10625fc..26a10625fc 100644 --- a/editor/icons/Sprite.svg +++ b/editor/icons/Sprite2D.svg diff --git a/editor/icons/StaticBody.svg b/editor/icons/StaticBody3D.svg index de819bd76b..de819bd76b 100644 --- a/editor/icons/StaticBody.svg +++ b/editor/icons/StaticBody3D.svg diff --git a/editor/icons/SubViewport.svg b/editor/icons/SubViewport.svg new file mode 100644 index 0000000000..103b1006ad --- /dev/null +++ b/editor/icons/SubViewport.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 2c-.5304.0000801-1.0390625.2108475-1.4140625.5859375-.37509.37501-.5858575.8836225-.5859375 1.4140625v8c.0000803.5304.2108475 1.039063.5859375 1.414062.37501.375091.8836225.585858 1.4140625.585938h10c1.1046 0 2-.89543 2-2v-8c0-1.1046-.89543-2-2-2zm0 1h10c.55228.0000096.99999.44772 1 1v8c-.00001.55228-.44772.99999-1 1h-10c-.55228-.00001-.99999-.44772-1-1v-8c.0000096-.55228.44772-.99999 1-1zm3 1c-.5304.0001-1.0390625.2108375-1.4140625.5859375-.37509.375-.5858575.8836225-.5859375 1.4140625v4c.00008.5304.2108475 1.039062.5859375 1.414062.37501.3751.8836225.585838 1.4140625.585938h4c1.1046 0 2-.8954 2-2v-4c0-1.1046-.89543-2-2-2zm0 1h4c.55228 0 .99999.4477 1 1v4c-.00001.5523-.44772 1-1 1h-4c-.55228 0-.99999-.4477-1-1v-4c.00001-.5523.44772-1 1-1z" fill="#e0e0e0" fill-opacity=".996078"/></svg>
\ No newline at end of file diff --git a/editor/icons/ViewportContainer.svg b/editor/icons/SubViewportContainer.svg index 18dcddc15f..18dcddc15f 100644 --- a/editor/icons/ViewportContainer.svg +++ b/editor/icons/SubViewportContainer.svg diff --git a/editor/icons/VehicleBody.svg b/editor/icons/VehicleBody3D.svg index a509730602..a509730602 100644 --- a/editor/icons/VehicleBody.svg +++ b/editor/icons/VehicleBody3D.svg diff --git a/editor/icons/VehicleWheel.svg b/editor/icons/VehicleWheel3D.svg index bd870c0118..bd870c0118 100644 --- a/editor/icons/VehicleWheel.svg +++ b/editor/icons/VehicleWheel3D.svg diff --git a/editor/icons/VisibilityEnabler.svg b/editor/icons/VisibilityEnabler3D.svg index 70e4f081c2..70e4f081c2 100644 --- a/editor/icons/VisibilityEnabler.svg +++ b/editor/icons/VisibilityEnabler3D.svg diff --git a/editor/icons/VisibilityNotifier.svg b/editor/icons/VisibilityNotifier3D.svg index c908d5c99d..c908d5c99d 100644 --- a/editor/icons/VisibilityNotifier.svg +++ b/editor/icons/VisibilityNotifier3D.svg diff --git a/editor/icons/WindowDialog.svg b/editor/icons/Window.svg index 3c7be2a58d..a02a86d56a 100644 --- a/editor/icons/WindowDialog.svg +++ b/editor/icons/Window.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8z" fill="#a5efac"/></svg>
\ No newline at end of file +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1c-1.1046 0-2 .8954-2 2v1h14v-1c0-1.1046-.89543-2-2-2zm9 1h1v1h-1zm-11 3v8c0 1.1046.89543 2 2 2h10c1.1046 0 2-.8954 2-2v-8z" fill="#e0e0e0"/></svg>
\ No newline at end of file diff --git a/editor/icons/World.svg b/editor/icons/World3D.svg index 3db96a75a6..3db96a75a6 100644 --- a/editor/icons/World.svg +++ b/editor/icons/World3D.svg diff --git a/editor/icons/WorldMarginShape.svg b/editor/icons/WorldMarginShape.svg deleted file mode 100644 index 2c90cf6d53..0000000000 --- a/editor/icons/WorldMarginShape.svg +++ /dev/null @@ -1 +0,0 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1044.4 7 3 7-3-7-3z" fill="#a2d2ff" fill-rule="evenodd" transform="translate(0 -1036.4)"/></svg>
\ No newline at end of file diff --git a/editor/icons/PlaneShape.svg b/editor/icons/WorldMarginShape3D.svg index 2c90cf6d53..2c90cf6d53 100644 --- a/editor/icons/PlaneShape.svg +++ b/editor/icons/WorldMarginShape3D.svg diff --git a/editor/icons/ARVRAnchor.svg b/editor/icons/XRAnchor3D.svg index f1571b3fcc..f1571b3fcc 100644 --- a/editor/icons/ARVRAnchor.svg +++ b/editor/icons/XRAnchor3D.svg diff --git a/editor/icons/ARVRCamera.svg b/editor/icons/XRCamera3D.svg index f59a8c8b4a..f59a8c8b4a 100644 --- a/editor/icons/ARVRCamera.svg +++ b/editor/icons/XRCamera3D.svg diff --git a/editor/icons/ARVRController.svg b/editor/icons/XRController3D.svg index 40e5b8dce1..40e5b8dce1 100644 --- a/editor/icons/ARVRController.svg +++ b/editor/icons/XRController3D.svg diff --git a/editor/icons/ARVROrigin.svg b/editor/icons/XROrigin3D.svg index dbb93ba7a5..dbb93ba7a5 100644 --- a/editor/icons/ARVROrigin.svg +++ b/editor/icons/XROrigin3D.svg diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py index ea2c2e57d1..d7145abe50 100644 --- a/editor/icons/editor_icons_builders.py +++ b/editor/icons/editor_icons_builders.py @@ -3,9 +3,10 @@ All such functions are invoked in a subprocess on Windows to prevent build flakiness. """ + import os +from io import StringIO from platform_methods import subprocess_main -from compat import StringIO def make_editor_icons_action(target, source, env): @@ -21,16 +22,16 @@ def make_editor_icons_action(target, source, env): icons_string.write('\t"') - with open(fname, 'rb') as svgf: + with open(fname, "rb") as svgf: b = svgf.read(1) - while(len(b) == 1): + while len(b) == 1: icons_string.write("\\" + str(hex(ord(b)))[1:]) b = svgf.read(1) icons_string.write('"') if fname != svg_icons[-1]: icons_string.write(",") - icons_string.write('\n') + icons_string.write("\n") s = StringIO() s.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") @@ -39,7 +40,7 @@ def make_editor_icons_action(target, source, env): s.write("static const int editor_icons_count = {};\n".format(len(svg_icons))) s.write("static const char *editor_icons_sources[] = {\n") s.write(icons_string.getvalue()) - s.write('};\n\n') + s.write("};\n\n") s.write("static const char *editor_icons_names[] = {\n") # this is used to store the indices of thumbnail icons @@ -62,11 +63,11 @@ def make_editor_icons_action(target, source, env): if fname != svg_icons[-1]: s.write(",") - s.write('\n') + s.write("\n") index += 1 - s.write('};\n') + s.write("};\n") if thumb_medium_indices: s.write("\n\n") @@ -90,5 +91,5 @@ def make_editor_icons_action(target, source, env): icons_string.close() -if __name__ == '__main__': +if __name__ == "__main__": subprocess_main(globals()) diff --git a/editor/import/SCsub b/editor/import/SCsub index 2b1e889fb0..359d04e5df 100644 --- a/editor/import/SCsub +++ b/editor/import/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/collada/collada.cpp b/editor/import/collada.cpp index cf39abdc53..9e49fa9066 100644 --- a/editor/collada/collada.cpp +++ b/editor/import/collada.cpp @@ -1540,7 +1540,7 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { } if (parser.is_empty()) //nothing else to parse... - return NULL; + return nullptr; while (parser.read() == OK) { @@ -1548,7 +1548,7 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { break; } - return NULL; + return nullptr; } Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { @@ -1572,7 +1572,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { String empty_draw_type = ""; - Node *node = NULL; + Node *node = nullptr; name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id"); if (name == "") { @@ -1773,12 +1773,12 @@ void Collada::_parse_animation(XMLParser &parser) { return; } - Map<String, Vector<float> > float_sources; - Map<String, Vector<String> > string_sources; + Map<String, Vector<float>> float_sources; + Map<String, Vector<String>> string_sources; Map<String, int> source_strides; - Map<String, Map<String, String> > samplers; - Map<String, Vector<String> > source_param_names; - Map<String, Vector<String> > source_param_types; + Map<String, Map<String, String>> samplers; + Map<String, Vector<String>> source_param_names; + Map<String, Vector<String>> source_param_types; String id = ""; if (parser.has_attribute("id")) @@ -2140,7 +2140,7 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton NodeJoint *nj = static_cast<NodeJoint *>(node); nj->owner = p_skeleton; } else { - p_skeleton = NULL; + p_skeleton = nullptr; } for (int i = 0; i < node->children.size(); i++) { @@ -2240,7 +2240,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { SkinControllerData &cd = E->get(); - NodeSkeleton *skeleton = NULL; + NodeSkeleton *skeleton = nullptr; for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { @@ -2257,7 +2257,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { Node *node = state.scene_map[name]; ERR_CONTINUE(node->type != Node::TYPE_JOINT); - NodeSkeleton *sk = NULL; + NodeSkeleton *sk = nullptr; while (node && !sk) { diff --git a/editor/collada/collada.h b/editor/import/collada.h index 10ed42260b..b74332fb22 100644 --- a/editor/collada/collada.h +++ b/editor/import/collada.h @@ -404,7 +404,7 @@ public: Node() { noname = false; type = TYPE_NODE; - parent = NULL; + parent = nullptr; ignore_anim = false; } virtual ~Node() { @@ -424,7 +424,7 @@ public: String sid; NodeJoint() { type = TYPE_JOINT; - owner = NULL; + owner = nullptr; } }; @@ -570,8 +570,8 @@ public: Vector<AnimationClip> animation_clips; Vector<AnimationTrack> animation_tracks; - Map<String, Vector<int> > referenced_tracks; - Map<String, Vector<int> > by_id_tracks; + Map<String, Vector<int>> referenced_tracks; + Map<String, Vector<int>> by_id_tracks; float animation_length; @@ -631,7 +631,7 @@ private: // private stuff String _read_empty_draw_type(XMLParser &parser); void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner); - void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = NULL); + void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = nullptr); void _find_morph_nodes(VisualScene *p_vscene, Node *p_node); bool _remove_node(Node *p_parent, Node *p_node); void _remove_node(VisualScene *p_vscene, Node *p_node); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 2f97f4aa31..697ddfba96 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -31,14 +31,14 @@ #include "editor_import_collada.h" #include "core/os/os.h" -#include "editor/collada/collada.h" #include "editor/editor_node.h" -#include "scene/3d/camera.h" -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/path.h" -#include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" +#include "editor/import/collada.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/path_3d.h" +#include "scene/3d/skeleton_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" #include "scene/resources/packed_scene.h" @@ -47,18 +47,18 @@ struct ColladaImport { Collada collada; - Spatial *scene; + Node3D *scene; - Vector<Ref<Animation> > animations; + Vector<Ref<Animation>> animations; struct NodeMap { //String path; - Spatial *node; + Node3D *node; int bone; List<int> anim_tracks; NodeMap() { - node = NULL; + node = nullptr; bone = -1; } }; @@ -73,23 +73,23 @@ struct ColladaImport { Map<String, NodeMap> node_map; //map from collada node to engine node Map<String, String> node_name_map; //map from collada node to engine node - Map<String, Ref<ArrayMesh> > mesh_cache; - Map<String, Ref<Curve3D> > curve_cache; - Map<String, Ref<Material> > material_cache; - Map<Collada::Node *, Skeleton *> skeleton_map; + Map<String, Ref<ArrayMesh>> mesh_cache; + Map<String, Ref<Curve3D>> curve_cache; + Map<String, Ref<Material>> material_cache; + Map<Collada::Node *, Skeleton3D *> skeleton_map; - Map<Skeleton *, Map<String, int> > skeleton_bone_map; + Map<Skeleton3D *, Map<String, int>> skeleton_bone_map; Set<String> valid_animated_nodes; Vector<int> valid_animated_properties; Map<String, bool> bones_with_animation; - Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent); + Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent); Error _create_scene_skeletons(Collada::Node *p_node); - Error _create_scene(Collada::Node *p_node, Spatial *p_parent); + Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); - Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes = Vector<Ref<ArrayMesh> >(), bool p_use_compression = false, bool p_use_mesh_material = false); + Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes = Vector<Ref<ArrayMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false); void _fix_param_animation_tracks(); void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks); @@ -110,7 +110,7 @@ struct ColladaImport { } }; -Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) { +Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) { if (p_node->type != Collada::Node::TYPE_JOINT) return OK; @@ -174,7 +174,7 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { if (p_node->type == Collada::Node::TYPE_SKELETON) { - Skeleton *sk = memnew(Skeleton); + Skeleton3D *sk = memnew(Skeleton3D); int bone = 0; for (int i = 0; i < p_node->children.size(); i++) { @@ -193,15 +193,15 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { return OK; } -Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { +Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { - Spatial *node = NULL; + Node3D *node = nullptr; switch (p_node->type) { case Collada::Node::TYPE_NODE: { - node = memnew(Spatial); + node = memnew(Node3D); } break; case Collada::Node::TYPE_JOINT: { @@ -223,7 +223,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (!bool(GLOBAL_DEF("collada/use_ambient", false))) return OK; //well, it's an ambient light.. - Light *l = memnew(DirectionalLight); + Light3D *l = memnew(DirectionalLight3D); //l->set_color(Light::COLOR_AMBIENT,ld.color); //l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0)); //l->set_color(Light::COLOR_SPECULAR,Color(0,0,0)); @@ -232,7 +232,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) { //well, it's an ambient light.. - Light *l = memnew(DirectionalLight); + Light3D *l = memnew(DirectionalLight3D); /* if (found_ambient) //use it here l->set_color(Light::COLOR_AMBIENT,ambient); @@ -243,12 +243,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { node = l; } else { - Light *l; + Light3D *l; if (ld.mode == Collada::LightData::MODE_OMNI) - l = memnew(OmniLight); + l = memnew(OmniLight3D); else { - l = memnew(SpotLight); + l = memnew(SpotLight3D); //l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle); //l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp); } @@ -262,13 +262,13 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else { - node = memnew(Spatial); + node = memnew(Node3D); } } break; case Collada::Node::TYPE_CAMERA: { Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node); - Camera *camera = memnew(Camera); + Camera3D *camera = memnew(Camera3D); if (collada.state.camera_data_map.has(cam->camera)) { @@ -280,12 +280,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (cd.orthogonal.y_mag) { - camera->set_keep_aspect_mode(Camera::KEEP_HEIGHT); + camera->set_keep_aspect_mode(Camera3D::KEEP_HEIGHT); camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far); } else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) { - camera->set_keep_aspect_mode(Camera::KEEP_WIDTH); + camera->set_keep_aspect_mode(Camera3D::KEEP_WIDTH); camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far); } @@ -314,17 +314,17 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (collada.state.curve_data_map.has(ng->source)) { - node = memnew(Path); + node = memnew(Path3D); } else { //mesh since nothing else - node = memnew(MeshInstance); - //Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + node = memnew(MeshInstance3D); + //Object::cast_to<MeshInstance3D>(node)->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE); - Skeleton *sk = skeleton_map[p_node]; + Skeleton3D *sk = skeleton_map[p_node]; node = sk; } break; } @@ -489,7 +489,7 @@ Error ColladaImport::_create_material(const String &p_target) { return OK; } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { bool local_xform_mirror = p_local_xform.basis.determinant() < 0; @@ -536,7 +536,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me /* NORMAL SOURCE */ - const Collada::MeshData::Source *normal_src = NULL; + const Collada::MeshData::Source *normal_src = nullptr; int normal_ofs = 0; if (p.sources.has("NORMAL")) { @@ -547,7 +547,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me normal_src = &meshdata.sources[normal_source_id]; } - const Collada::MeshData::Source *binormal_src = NULL; + const Collada::MeshData::Source *binormal_src = nullptr; int binormal_ofs = 0; if (p.sources.has("TEXBINORMAL")) { @@ -558,7 +558,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me binormal_src = &meshdata.sources[binormal_source_id]; } - const Collada::MeshData::Source *tangent_src = NULL; + const Collada::MeshData::Source *tangent_src = nullptr; int tangent_ofs = 0; if (p.sources.has("TEXTANGENT")) { @@ -569,7 +569,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me tangent_src = &meshdata.sources[tangent_source_id]; } - const Collada::MeshData::Source *uv_src = NULL; + const Collada::MeshData::Source *uv_src = nullptr; int uv_ofs = 0; if (p.sources.has("TEXCOORD0")) { @@ -580,7 +580,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me uv_src = &meshdata.sources[uv_source_id]; } - const Collada::MeshData::Source *uv2_src = NULL; + const Collada::MeshData::Source *uv2_src = nullptr; int uv2_ofs = 0; if (p.sources.has("TEXCOORD1")) { @@ -591,7 +591,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me uv2_src = &meshdata.sources[uv2_source_id]; } - const Collada::MeshData::Source *color_src = NULL; + const Collada::MeshData::Source *color_src = nullptr; int color_ofs = 0; if (p.sources.has("COLOR")) { @@ -608,13 +608,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me /* ADD WEIGHTS IF EXIST */ /************************/ - Map<int, Vector<Collada::Vertex::Weight> > pre_weights; + Map<int, Vector<Collada::Vertex::Weight>> pre_weights; bool has_weights = false; if (p_skin_controller) { - const Collada::SkinControllerData::Source *weight_src = NULL; + const Collada::SkinControllerData::Source *weight_src = nullptr; int weight_ofs = 0; if (p_skin_controller->weights.sources.has("WEIGHT")) { @@ -922,10 +922,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me if (has_weights) { Vector<float> weights; Vector<int> bones; - weights.resize(VS::ARRAY_WEIGHTS_SIZE); - bones.resize(VS::ARRAY_WEIGHTS_SIZE); + weights.resize(RS::ARRAY_WEIGHTS_SIZE); + bones.resize(RS::ARRAY_WEIGHTS_SIZE); //float sum=0.0; - for (int l = 0; l < VS::ARRAY_WEIGHTS_SIZE; l++) { + for (int l = 0; l < RS::ARRAY_WEIGHTS_SIZE; l++) { if (l < vertex_array[k].weights.size()) { weights.write[l] = vertex_array[k].weights[l].weight; bones.write[l] = vertex_array[k].weights[l].bone_idx; @@ -963,7 +963,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me //////////////////////////// Array d = surftool->commit_to_arrays(); - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); Array mr; @@ -1010,12 +1010,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) { - Spatial *node = node_map[p_node->id].node; + Node3D *node = node_map[p_node->id].node; Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); - if (Object::cast_to<Path>(node)) { + if (Object::cast_to<Path3D>(node)) { - Path *path = Object::cast_to<Path>(node); + Path3D *path = Object::cast_to<Path3D>(node); if (curve_cache.has(ng->source)) { @@ -1047,7 +1047,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres const Collada::CurveData::Source &interps = cd.sources[cd.control_vertices["INTERPOLATION"]]; ERR_FAIL_COND_V(interps.stride != 1, ERR_INVALID_DATA); - const Collada::CurveData::Source *tilts = NULL; + const Collada::CurveData::Source *tilts = nullptr; if (cd.control_vertices.has("TILT") && cd.sources.has(cd.control_vertices["TILT"])) tilts = &cd.sources[cd.control_vertices["TILT"]]; @@ -1083,20 +1083,20 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } } - if (Object::cast_to<MeshInstance>(node)) { + if (Object::cast_to<MeshInstance3D>(node)) { Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node); - MeshInstance *mi = Object::cast_to<MeshInstance>(node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node); ERR_FAIL_COND_V(!mi, ERR_BUG); - Collada::SkinControllerData *skin = NULL; - Collada::MorphControllerData *morph = NULL; + Collada::SkinControllerData *skin = nullptr; + Collada::MorphControllerData *morph = nullptr; String meshid; Transform apply_xform; Vector<int> bone_remap; - Vector<Ref<ArrayMesh> > morphs; + Vector<Ref<ArrayMesh>> morphs; if (ng2->controller) { @@ -1114,7 +1114,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres String skname = skeletons[0]; ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA); NodeMap nmsk = node_map[skname]; - Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node); + Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node); ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA); ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA); Map<String, int> &bone_remap_map = skeleton_bone_map[sk]; @@ -1173,7 +1173,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2]; mesh->set_name(meshdata.name); - Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false); + Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, nullptr, Vector<Ref<ArrayMesh>>(), false); ERR_FAIL_COND_V(err, err); morphs.push_back(mesh); @@ -1265,7 +1265,7 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA); Collada::VisualScene &vs = collada.state.visual_scene_map[collada.state.root_visual_scene]; - scene = memnew(Spatial); // root + scene = memnew(Node3D); // root //determine what's going on with the lights for (int i = 0; i < vs.root_nodes.size(); i++) { @@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones String path = scene->get_path_to(nm.node); if (nm.bone >= 0) { - Skeleton *sk = static_cast<Skeleton *>(nm.node); + Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node); String name = sk->get_bone_name(nm.bone); path = path + ":" + name; } @@ -1621,7 +1621,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (nm.bone >= 0) { //make bone transform relative to rest (in case of skeleton) - Skeleton *sk = Object::cast_to<Skeleton>(nm.node); + Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node); if (sk) { xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; @@ -1662,7 +1662,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones NodeMap &nm = node_map[E->key()]; String path = scene->get_path_to(nm.node); ERR_CONTINUE(nm.bone < 0); - Skeleton *sk = static_cast<Skeleton *>(nm.node); + Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node); String name = sk->get_bone_name(nm.bone); path = path + ":" + name; @@ -1777,7 +1777,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & EditorSceneImporter::IMPORT_USE_COMPRESSION); - ERR_FAIL_COND_V_MSG(err != OK, NULL, "Cannot load scene from file '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Cannot load scene from file '" + p_path + "'."); if (state.missing_textures.size()) { diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 822a6450be..932a064e76 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -40,7 +40,7 @@ class EditorSceneImporterCollada : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporterCollada(); diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 4383b1b084..be4679b6d3 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -52,7 +52,7 @@ public: virtual int get_import_order() const; virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr); }; #endif //EDITOR_IMPORT_PLUGIN_H diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 731d094745..6ad2aa4142 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -37,9 +37,9 @@ #include "core/os/file_access.h" #include "core/os/os.h" #include "modules/regex/regex.h" -#include "scene/3d/bone_attachment.h" -#include "scene/3d/camera.h" -#include "scene/3d/mesh_instance.h" +#include "scene/3d/bone_attachment_3d.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/surface_tool.h" @@ -1266,7 +1266,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } Vector<uint8_t> data; - const uint8_t *data_ptr = NULL; + const uint8_t *data_ptr = nullptr; int data_size = 0; if (d.has("uri")) { @@ -1307,7 +1307,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("png") != -1) { //is a png - ERR_FAIL_COND_V(Image::_png_mem_loader_func == NULL, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(Image::_png_mem_loader_func == nullptr, ERR_UNAVAILABLE); const Ref<Image> img = Image::_png_mem_loader_func(data_ptr, data_size); @@ -1323,7 +1323,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("jpeg") != -1) { //is a jpg - ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == NULL, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(Image::_jpg_mem_loader_func == nullptr, ERR_UNAVAILABLE); const Ref<Image> img = Image::_jpg_mem_loader_func(data_ptr, data_size); @@ -1838,7 +1838,7 @@ Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) { skeleton_sets.get_representatives(groups_representatives); Vector<GLTFNodeIndex> highest_group_members; - Vector<Vector<GLTFNodeIndex> > groups; + Vector<Vector<GLTFNodeIndex>> groups; for (int i = 0; i < groups_representatives.size(); ++i) { Vector<GLTFNodeIndex> group; skeleton_sets.get_members(group, groups_representatives[i]); @@ -2108,7 +2108,7 @@ Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) { GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i]; - Skeleton *skeleton = memnew(Skeleton); + Skeleton3D *skeleton = memnew(Skeleton3D); gltf_skeleton.godot_skeleton = skeleton; // Make a unique name, no gltf node represents this skeleton @@ -2485,12 +2485,12 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { } } -BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index) { +BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; const GLTFNode *bone_node = state.nodes[gltf_node->parent]; - BoneAttachment *bone_attachment = memnew(BoneAttachment); + BoneAttachment3D *bone_attachment = memnew(BoneAttachment3D); print_verbose("glTF: Creating bone attachment for: " + gltf_node->name); ERR_FAIL_COND_V(!bone_node->joint, nullptr); @@ -2500,12 +2500,12 @@ BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &st return bone_attachment; } -MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr); - MeshInstance *mi = memnew(MeshInstance); + MeshInstance3D *mi = memnew(MeshInstance3D); print_verbose("glTF: Creating mesh for: " + gltf_node->name); GLTFMesh &mesh = state.meshes.write[gltf_node->mesh]; @@ -2522,12 +2522,12 @@ MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, return mi; } -Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +Camera3D *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; ERR_FAIL_INDEX_V(gltf_node->camera, state.cameras.size(), nullptr); - Camera *camera = memnew(Camera); + Camera3D *camera = memnew(Camera3D); print_verbose("glTF: Creating camera for: " + gltf_node->name); const GLTFCamera &c = state.cameras[gltf_node->camera]; @@ -2540,26 +2540,26 @@ Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_ return camera; } -Spatial *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; - Spatial *spatial = memnew(Spatial); + Node3D *spatial = memnew(Node3D); print_verbose("glTF: Creating spatial for: " + gltf_node->name); return spatial; } -void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index) { +void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; - Spatial *current_node = nullptr; + Node3D *current_node = nullptr; // Is our parent a skeleton - Skeleton *active_skeleton = Object::cast_to<Skeleton>(scene_parent); + Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(scene_parent); if (gltf_node->skeleton >= 0) { - Skeleton *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton; + Skeleton3D *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton; if (active_skeleton != skeleton) { ERR_FAIL_COND_MSG(active_skeleton != nullptr, "glTF: Generating scene detected direct parented Skeletons"); @@ -2577,7 +2577,7 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene // If we have an active skeleton, and the node is node skinned, we need to create a bone attachment if (current_node == nullptr && active_skeleton != nullptr && gltf_node->skin < 0) { - BoneAttachment *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index); + BoneAttachment3D *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index); scene_parent->add_child(bone_attachment); bone_attachment->set_owner(scene_root); @@ -2776,7 +2776,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye const GLTFNode *node = state.nodes[E->key()]; if (node->skeleton >= 0) { - const Skeleton *sk = Object::cast_to<Skeleton>(state.scene_nodes.find(node_index)->get()); + const Skeleton3D *sk = Object::cast_to<Skeleton3D>(state.scene_nodes.find(node_index)->get()); ERR_FAIL_COND(sk == nullptr); const String path = ap->get_parent()->get_path_to(sk); @@ -2853,7 +2853,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye xform.basis.set_quat_scale(rot, scale); xform.origin = pos; - const Skeleton *skeleton = state.skeletons[node->skeleton].godot_skeleton; + const Skeleton3D *skeleton = state.skeletons[node->skeleton].godot_skeleton; const int bone_idx = skeleton->find_bone(node->name); xform = skeleton->get_bone_rest(bone_idx).affine_inverse() * xform; @@ -2922,7 +2922,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye ap->add_animation(name, animation); } -void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial *scene_root) { +void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D *scene_root) { for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) { const GLTFNode *node = state.nodes[node_i]; @@ -2930,12 +2930,12 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial const GLTFSkinIndex skin_i = node->skin; Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i); - MeshInstance *mi = Object::cast_to<MeshInstance>(mi_element->get()); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get()); ERR_FAIL_COND(mi == nullptr); const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton; const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i]; - Skeleton *skeleton = gltf_skeleton.godot_skeleton; + Skeleton3D *skeleton = gltf_skeleton.godot_skeleton; ERR_FAIL_COND(skeleton == nullptr); mi->get_parent()->remove_child(mi); @@ -2949,9 +2949,9 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial } } -Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { +Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { - Spatial *root = memnew(Spatial); + Node3D *root = memnew(Node3D); // scene_name is already unique root->set_name(state.scene_name); @@ -2985,19 +2985,19 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla //text file Error err = _parse_glb(p_path, state); if (err) - return NULL; + return nullptr; } else { //text file Error err = _parse_json(p_path, state); if (err) - return NULL; + return nullptr; } - ERR_FAIL_COND_V(!state.json.has("asset"), NULL); + ERR_FAIL_COND_V(!state.json.has("asset"), nullptr); Dictionary asset = state.json["asset"]; - ERR_FAIL_COND_V(!asset.has("version"), NULL); + ERR_FAIL_COND_V(!asset.has("version"), nullptr); String version = asset["version"]; @@ -3008,83 +3008,83 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla /* STEP 0 PARSE SCENE */ Error err = _parse_scenes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 1 PARSE NODES */ err = _parse_nodes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 2 PARSE BUFFERS */ err = _parse_buffers(state, p_path.get_base_dir()); if (err != OK) - return NULL; + return nullptr; /* STEP 3 PARSE BUFFER VIEWS */ err = _parse_buffer_views(state); if (err != OK) - return NULL; + return nullptr; /* STEP 4 PARSE ACCESSORS */ err = _parse_accessors(state); if (err != OK) - return NULL; + return nullptr; /* STEP 5 PARSE IMAGES */ err = _parse_images(state, p_path.get_base_dir()); if (err != OK) - return NULL; + return nullptr; /* STEP 6 PARSE TEXTURES */ err = _parse_textures(state); if (err != OK) - return NULL; + return nullptr; /* STEP 7 PARSE TEXTURES */ err = _parse_materials(state); if (err != OK) - return NULL; + return nullptr; /* STEP 9 PARSE SKINS */ err = _parse_skins(state); if (err != OK) - return NULL; + return nullptr; /* STEP 10 DETERMINE SKELETONS */ err = _determine_skeletons(state); if (err != OK) - return NULL; + return nullptr; /* STEP 11 CREATE SKELETONS */ err = _create_skeletons(state); if (err != OK) - return NULL; + return nullptr; /* STEP 12 CREATE SKINS */ err = _create_skins(state); if (err != OK) - return NULL; + return nullptr; /* STEP 13 PARSE MESHES (we have enough info now) */ err = _parse_meshes(state); if (err != OK) - return NULL; + return nullptr; /* STEP 14 PARSE CAMERAS */ err = _parse_cameras(state); if (err != OK) - return NULL; + return nullptr; /* STEP 15 PARSE ANIMATIONS */ err = _parse_animations(state); if (err != OK) - return NULL; + return nullptr; /* STEP 16 ASSIGN SCENE NAMES */ _assign_scene_names(state); /* STEP 17 MAKE SCENE! */ - Spatial *scene = _generate_scene(state, p_bake_fps); + Node3D *scene = _generate_scene(state, p_bake_fps); return scene; } diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 5d2711483b..d127a87782 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -32,12 +32,12 @@ #define EDITOR_SCENE_IMPORTER_GLTF_H #include "editor/import/resource_importer_scene.h" -#include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/skeleton_3d.h" class AnimationPlayer; -class BoneAttachment; -class MeshInstance; +class BoneAttachment3D; +class MeshInstance3D; class EditorSceneImporterGLTF : public EditorSceneImporter { @@ -192,7 +192,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Vector<GLTFNodeIndex> roots; // The created Skeleton for the scene - Skeleton *godot_skeleton; + Skeleton3D *godot_skeleton; // Set of unique bone names for the skeleton Set<String> unique_names; @@ -284,7 +284,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Channel<Vector3> translation_track; Channel<Quat> rotation_track; Channel<Vector3> scale_track; - Vector<Channel<float> > weight_tracks; + Vector<Channel<float>> weight_tracks; }; String name; @@ -302,18 +302,18 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { bool use_named_skin_binds; Vector<GLTFNode *> nodes; - Vector<Vector<uint8_t> > buffers; + Vector<Vector<uint8_t>> buffers; Vector<GLTFBufferView> buffer_views; Vector<GLTFAccessor> accessors; Vector<GLTFMesh> meshes; //meshes are loaded directly, no reason not to. - Vector<Ref<Material> > materials; + Vector<Ref<Material>> materials; String scene_name; Vector<int> root_nodes; Vector<GLTFTexture> textures; - Vector<Ref<Texture2D> > images; + Vector<Ref<Texture2D>> images; Vector<GLTFSkin> skins; Vector<GLTFCamera> cameras; @@ -395,15 +395,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Error _parse_animations(GLTFState &state); - BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index); - MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index); + MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index); - Spatial *_generate_scene(GLTFState &state, const int p_bake_fps); + void _generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index); + Node3D *_generate_scene(GLTFState &state, const int p_bake_fps); - void _process_mesh_instances(GLTFState &state, Spatial *scene_root); + void _process_mesh_instances(GLTFState &state, Node3D *scene_root); void _assign_scene_names(GLTFState &state); @@ -415,7 +415,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporterGLTF(); diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index dd95cb687a..927fac566e 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -51,7 +51,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterBitMap(); ~ResourceImporterBitMap(); diff --git a/editor/import/resource_importer_csv.h b/editor/import/resource_importer_csv.h index 2030dd1f99..7aa48f68de 100644 --- a/editor/import/resource_importer_csv.h +++ b/editor/import/resource_importer_csv.h @@ -49,7 +49,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterCSV(); }; diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 3119fb088b..1d7bed3975 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -96,7 +96,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR); Vector<String> locales; - Vector<Ref<Translation> > translations; + Vector<Ref<Translation>> translations; for (int i = 1; i < line.size(); i++) { diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index ec33d6aa16..742f6b8f60 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -49,7 +49,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterCSVTranslation(); }; diff --git a/editor/import/resource_importer_image.h b/editor/import/resource_importer_image.h index 6ad77eec1b..abb74d0665 100644 --- a/editor/import/resource_importer_image.h +++ b/editor/import/resource_importer_image.h @@ -50,7 +50,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterImage(); }; diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index d472070808..a4cbc81b26 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -259,7 +259,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const Ref<Image> image; image.instance(); - Error err = ImageLoader::load_image(p_source_file, image, NULL, false, 1.0); + Error err = ImageLoader::load_image(p_source_file, image, nullptr, false, 1.0); if (err != OK) return err; @@ -383,7 +383,7 @@ const char *ResourceImporterLayeredTexture::compression_formats[] = { "etc", "etc2", "pvrtc", - NULL + nullptr }; String ResourceImporterLayeredTexture::get_import_settings_string() const { @@ -438,7 +438,7 @@ bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_p return valid; } -ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = NULL; +ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = nullptr; ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 6a6bc89a81..40e5c9023e 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -114,7 +114,7 @@ public: void _save_tex(const Vector<Ref<Image> > &p_images, const String &p_to_path, int p_compress_mode, Image::CompressMode p_vram_compression, bool p_mipmaps); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); void update_imports(); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 7fd3bcc478..6a6eadfa5c 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -32,8 +32,8 @@ #include "core/io/resource_saver.h" #include "core/os/file_access.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/spatial.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/node_3d.h" #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" @@ -42,7 +42,7 @@ uint32_t EditorOBJImporter::get_import_flags() const { return IMPORT_SCENE; } -static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D> > &material_map, List<String> *r_missing_deps) { +static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path)); @@ -203,7 +203,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand return OK; } -static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) { +static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path)); @@ -221,7 +221,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p Vector<Vector2> uvs; String name; - Map<String, Map<String, Ref<StandardMaterial3D> > > material_map; + Map<String, Map<String, Ref<StandardMaterial3D>>> material_map; Ref<SurfaceTool> surf_tool = memnew(SurfaceTool); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -397,7 +397,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p current_material_library = l.replace("mtllib", "").strip_edges(); if (!material_map.has(current_material_library)) { - Map<String, Ref<StandardMaterial3D> > lib; + Map<String, Ref<StandardMaterial3D>> lib; Error err = _parse_material_library(current_material_library, lib, r_missing_deps); if (err == ERR_CANT_OPEN) { String dir = p_path.get_base_dir(); @@ -420,7 +420,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - List<Ref<Mesh> > meshes; + List<Ref<Mesh>> meshes; Error err = _parse_obj(p_path, meshes, false, p_flags & IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & IMPORT_USE_COMPRESSION, Vector3(1, 1, 1), Vector3(0, 0, 0), r_missing_deps); @@ -428,14 +428,14 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in if (r_err) { *r_err = err; } - return NULL; + return nullptr; } - Spatial *scene = memnew(Spatial); + Node3D *scene = memnew(Node3D); - for (List<Ref<Mesh> >::Element *E = meshes.front(); E; E = E->next()) { + for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { - MeshInstance *mi = memnew(MeshInstance); + MeshInstance3D *mi = memnew(MeshInstance3D); mi->set_mesh(E->get()); mi->set_name(E->get()->get_name()); scene->add_child(mi); @@ -500,9 +500,9 @@ bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Ma Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { - List<Ref<Mesh> > meshes; + List<Ref<Mesh>> meshes; - Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], NULL); + Error err = _parse_obj(p_source_file, meshes, true, p_options["generate_tangents"], p_options["optimize_mesh"], p_options["scale_mesh"], p_options["offset_mesh"], nullptr); ERR_FAIL_COND_V(err != OK, err); ERR_FAIL_COND_V(meshes.size() != 1, ERR_BUG); diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 678be45106..7485e60f7b 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -40,7 +40,7 @@ class EditorOBJImporter : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorOBJImporter(); @@ -62,7 +62,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterOBJ(); }; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 5651197fa3..b5766a48a0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -32,19 +32,19 @@ #include "core/io/resource_saver.h" #include "editor/editor_node.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation.h" -#include "scene/3d/physics_body.h" -#include "scene/3d/vehicle_body.h" +#include "scene/3d/collision_shape_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/navigation_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/3d/vehicle_body_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" -#include "scene/resources/box_shape.h" +#include "scene/resources/box_shape_3d.h" #include "scene/resources/packed_scene.h" -#include "scene/resources/ray_shape.h" +#include "scene/resources/ray_shape_3d.h" #include "scene/resources/resource_format_text.h" -#include "scene/resources/sphere_shape.h" -#include "scene/resources/world_margin_shape.h" +#include "scene/resources/sphere_shape_3d.h" +#include "scene/resources/world_margin_shape_3d.h" uint32_t EditorSceneImporter::get_import_flags() const { @@ -72,7 +72,7 @@ Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, return get_script_instance()->call("_import_scene", p_path, p_flags, p_bake_fps); } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { @@ -81,7 +81,7 @@ Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint3 return get_script_instance()->call("_import_animation", p_path, p_flags); } - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } //for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf), @@ -170,7 +170,7 @@ String ResourceImporterScene::get_visible_name() const { void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const { - for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { E->get()->get_extensions(p_extensions); } } @@ -276,15 +276,15 @@ static String _fixstr(const String &p_what, const String &p_str) { return what; } -static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape> > &r_shape_list, bool p_convex) { +static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) { if (!p_convex) { - Ref<Shape> shape = mesh->create_trimesh_shape(); + Ref<Shape3D> shape = mesh->create_trimesh_shape(); r_shape_list.push_back(shape); } else { - Vector<Ref<Shape> > cd = mesh->convex_decompose(); + Vector<Ref<Shape3D>> cd = mesh->convex_decompose(); if (cd.size()) { for (int i = 0; i < cd.size(); i++) { r_shape_list.push_back(cd[i]); @@ -293,7 +293,7 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape> > &r_shape_li } } -Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape> > > &collision_map, LightBakeMode p_light_bake_mode) { +Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode) { // children first for (int i = 0; i < p_node->get_child_count(); i++) { @@ -311,12 +311,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (!isroot && _teststr(name, "noimp")) { memdelete(p_node); - return NULL; + return nullptr; } - if (Object::cast_to<MeshInstance>(p_node)) { + if (Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> m = mi->get_mesh(); @@ -344,7 +344,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (p_light_bake_mode != LIGHT_BAKE_DISABLED) { - mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + mi->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); } } @@ -377,12 +377,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); if (mi) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape> > shapes; + List<Ref<Shape3D>> shapes; String fixed_name; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; @@ -400,11 +400,11 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> fixed_name = _fixstr(name, "convcolonly"); } - ERR_FAIL_COND_V(fixed_name == String(), NULL); + ERR_FAIL_COND_V(fixed_name == String(), nullptr); if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_transform(mi->get_transform()); col->set_name(fixed_name); p_node->replace_by(col); @@ -412,9 +412,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = col; int idx = 0; - for (List<Ref<Shape> >::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -427,55 +427,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); - StaticBody *sb = memnew(StaticBody); + StaticBody3D *sb = memnew(StaticBody3D); sb->set_name(_fixstr(name, "colonly")); - Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform()); + Object::cast_to<Node3D>(sb)->set_transform(Object::cast_to<Node3D>(p_node)->get_transform()); p_node->replace_by(sb); memdelete(p_node); - p_node = NULL; - CollisionShape *colshape = memnew(CollisionShape); + p_node = nullptr; + CollisionShape3D *colshape = memnew(CollisionShape3D); if (empty_draw_type == "CUBE") { - BoxShape *boxShape = memnew(BoxShape); + BoxShape3D *boxShape = memnew(BoxShape3D); boxShape->set_extents(Vector3(1, 1, 1)); colshape->set_shape(boxShape); - colshape->set_name("BoxShape"); + colshape->set_name("BoxShape3D"); } else if (empty_draw_type == "SINGLE_ARROW") { - RayShape *rayShape = memnew(RayShape); + RayShape3D *rayShape = memnew(RayShape3D); rayShape->set_length(1); colshape->set_shape(rayShape); - colshape->set_name("RayShape"); - Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2); + colshape->set_name("RayShape3D"); + Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2); } else if (empty_draw_type == "IMAGE") { - WorldMarginShape *world_margin_shape = memnew(WorldMarginShape); + WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D); colshape->set_shape(world_margin_shape); - colshape->set_name("WorldMarginShape"); + colshape->set_name("WorldMarginShape3D"); } else { - SphereShape *sphereShape = memnew(SphereShape); + SphereShape3D *sphereShape = memnew(SphereShape3D); sphereShape->set_radius(1); colshape->set_shape(sphereShape); - colshape->set_name("SphereShape"); + colshape->set_name("SphereShape3D"); } sb->add_child(colshape); colshape->set_owner(sb->get_owner()); } - } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) { + } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape> > shapes; + List<Ref<Shape3D>> shapes; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; } else { _gen_shape_list(mesh, shapes, true); } - RigidBody *rigid_body = memnew(RigidBody); + RigidBody3D *rigid_body = memnew(RigidBody3D); rigid_body->set_name(_fixstr(name, "rigid")); p_node->replace_by(rigid_body); rigid_body->set_transform(mi->get_transform()); @@ -486,9 +486,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> mi->set_owner(rigid_body->get_owner()); int idx = 0; - for (List<Ref<Shape> >::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); rigid_body->add_child(cshape); @@ -498,14 +498,14 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } - } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) { + } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape> > shapes; + List<Ref<Shape3D>> shapes; String fixed_name; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; @@ -530,15 +530,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_name("static_collision"); mi->add_child(col); col->set_owner(mi->get_owner()); int idx = 0; - for (List<Ref<Shape> >::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -550,22 +550,22 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } - } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) { + } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); - ERR_FAIL_COND_V(mesh.is_null(), NULL); - NavigationRegion *nmi = memnew(NavigationRegion); + ERR_FAIL_COND_V(mesh.is_null(), nullptr); + NavigationRegion3D *nmi = memnew(NavigationRegion3D); nmi->set_name(_fixstr(name, "navmesh")); Ref<NavigationMesh> nmesh = memnew(NavigationMesh); nmesh->create_from_mesh(mesh); nmi->set_navigation_mesh(nmesh); - Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform()); + Object::cast_to<Node3D>(nmi)->set_transform(mi->get_transform()); p_node->replace_by(nmi); memdelete(p_node); p_node = nmi; @@ -575,8 +575,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> return p_node; Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleBody *bv = memnew(VehicleBody); + Node3D *s = Object::cast_to<Node3D>(p_node); + VehicleBody3D *bv = memnew(VehicleBody3D); String n = _fixstr(p_node->get_name(), "vehicle"); bv->set_name(n); p_node->replace_by(bv); @@ -595,8 +595,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> return p_node; Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleWheel *bv = memnew(VehicleWheel); + Node3D *s = Object::cast_to<Node3D>(p_node); + VehicleWheel3D *bv = memnew(VehicleWheel3D); String n = _fixstr(p_node->get_name(), "wheel"); bv->set_name(n); p_node->replace_by(bv); @@ -609,16 +609,16 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = bv; - } else if (Object::cast_to<MeshInstance>(p_node)) { + } else if (Object::cast_to<MeshInstance3D>(p_node)) { //last attempt, maybe collision inside the mesh data - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_null()) { - List<Ref<Shape> > shapes; + List<Ref<Shape3D>> shapes; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; } else if (_teststr(mesh->get_name(), "col")) { @@ -632,15 +632,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_name("static_collision"); p_node->add_child(col); col->set_owner(p_node->get_owner()); int idx = 0; - for (List<Ref<Shape> >::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -934,14 +934,14 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans List<PropertyInfo> pi; p_node->get_property_list(&pi); - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); if (mi) { Ref<ArrayMesh> mesh = mi->get_mesh(); if (mesh.is_valid() && !meshes.has(mesh)) { - Spatial *s = mi; + Node3D *s = mi; Transform transform; while (s) { transform = transform * s->get_transform(); @@ -957,7 +957,7 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans } } -void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) { +void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes) { List<PropertyInfo> pi; @@ -1141,7 +1141,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Spatial")); + r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D")); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root")); List<String> script_extentions; @@ -1209,7 +1209,7 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte Ref<EditorSceneImporter> importer; String ext = p_path.get_extension().to_lower(); - for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { if (E->get().ptr() == p_exception) continue; @@ -1229,7 +1229,7 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte break; } - ERR_FAIL_COND_V(!importer.is_valid(), NULL); + ERR_FAIL_COND_V(!importer.is_valid(), nullptr); List<String> missing; Error err; @@ -1241,7 +1241,7 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito Ref<EditorSceneImporter> importer; String ext = p_path.get_extension().to_lower(); - for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { if (E->get().ptr() == p_exception) continue; @@ -1261,7 +1261,7 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito break; } - ERR_FAIL_COND_V(!importer.is_valid(), NULL); + ERR_FAIL_COND_V(!importer.is_valid(), nullptr); return importer->import_animation(p_path, p_flags, p_bake_fps); } @@ -1276,7 +1276,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p EditorProgress progress("import", TTR("Import Scene"), 104); progress.step(TTR("Importing Scene..."), 0); - for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { List<String> extensions; E->get()->get_extensions(&extensions); @@ -1327,13 +1327,13 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p String root_type = p_options["nodes/root_type"]; root_type = root_type.split(" ")[0]; // full root_type is "ClassName (filename.gd)" for a script global class. - Ref<Script> root_script = NULL; + Ref<Script> root_script = nullptr; if (ScriptServer::is_global_class(root_type)) { root_script = ResourceLoader::load(ScriptServer::get_global_class_path(root_type)); root_type = ScriptServer::get_global_class_base(root_type); } - if (root_type != "Spatial") { + if (root_type != "Node3D") { Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type)); if (base_node) { @@ -1348,9 +1348,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p scene->set_script(Variant(root_script)); } - if (Object::cast_to<Spatial>(scene)) { + if (Object::cast_to<Node3D>(scene)) { float root_scale = p_options["nodes/root_scale"]; - Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); + Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); } if (p_options["nodes/root_name"] != "Scene Root") @@ -1368,7 +1368,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"]; int light_bake_mode = p_options["meshes/light_baking"]; - Map<Ref<Mesh>, List<Ref<Shape> > > collision_map; + Map<Ref<Mesh>, List<Ref<Shape3D>>> collision_map; scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode)); @@ -1456,9 +1456,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p } if (external_animations || external_materials || external_meshes) { - Map<Ref<Animation>, Ref<Animation> > anim_map; - Map<Ref<Material>, Ref<Material> > mat_map; - Map<Ref<ArrayMesh>, Ref<ArrayMesh> > mesh_map; + Map<Ref<Animation>, Ref<Animation>> anim_map; + Map<Ref<Material>, Ref<Material>> mat_map; + Map<Ref<ArrayMesh>, Ref<ArrayMesh>> mesh_map; bool keep_materials = bool(p_options["materials/keep_on_reimport"]); @@ -1533,7 +1533,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p return OK; } -ResourceImporterScene *ResourceImporterScene::singleton = NULL; +ResourceImporterScene *ResourceImporterScene::singleton = nullptr; ResourceImporterScene::ResourceImporterScene() { singleton = this; @@ -1550,10 +1550,10 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla Error error; Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); - ERR_FAIL_COND_V_MSG(!ps.is_valid(), NULL, "Cannot load scene as text resource from path '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'."); Node *scene = ps->instance(); - ERR_FAIL_COND_V(!scene, NULL); + ERR_FAIL_COND_V(!scene, nullptr); return scene; } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 20e7af15b5..f48f181951 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -34,7 +34,7 @@ #include "core/io/resource_importer.h" #include "scene/resources/animation.h" #include "scene/resources/mesh.h" -#include "scene/resources/shape.h" +#include "scene/resources/shape_3d.h" class Material; @@ -66,7 +66,7 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); EditorSceneImporter() {} @@ -93,7 +93,7 @@ public: class ResourceImporterScene : public ResourceImporter { GDCLASS(ResourceImporterScene, ResourceImporter); - Set<Ref<EditorSceneImporter> > importers; + Set<Ref<EditorSceneImporter>> importers; static ResourceImporterScene *singleton; @@ -125,7 +125,7 @@ class ResourceImporterScene : public ResourceImporter { public: static ResourceImporterScene *get_singleton() { return singleton; } - const Set<Ref<EditorSceneImporter> > &get_importers() const { return importers; } + const Set<Ref<EditorSceneImporter>> &get_importers() const { return importers; } void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); } void remove_importer(Ref<EditorSceneImporter> p_importer) { importers.erase(p_importer); } @@ -145,16 +145,16 @@ public: void _find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Transform> &meshes); - void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); + void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes); - Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape> > > &collision_map, LightBakeMode p_light_bake_mode); + Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode); void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all); void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep); void _filter_tracks(Node *scene, const String &p_text); void _optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); Node *import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); Ref<Animation> import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps); @@ -168,7 +168,7 @@ class EditorSceneImporterESCN : public EditorSceneImporter { public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr); virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps); }; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 0090d30b9c..f8ed9304b6 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -36,7 +36,7 @@ #include "editor/editor_file_system.h" #include "editor/editor_node.h" -void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_channel) { +void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) { MutexLock lock(singleton->mutex); @@ -424,7 +424,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String String normal_map = p_options["roughness/src_normal"]; Ref<Image> normal_image; - Image::RoughnessChannel roughness_channel; + Image::RoughnessChannel roughness_channel = Image::ROUGHNESS_CHANNEL_R; if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) { normal_image.instance(); @@ -434,7 +434,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } Ref<Image> image; image.instance(); - Error err = ImageLoader::load_image(p_source_file, image, NULL, hdr_as_srgb, scale); + Error err = ImageLoader::load_image(p_source_file, image, nullptr, hdr_as_srgb, scale); if (err != OK) return err; @@ -575,7 +575,7 @@ const char *ResourceImporterTexture::compression_formats[] = { "etc", "etc2", "pvrtc", - NULL + nullptr }; String ResourceImporterTexture::get_import_settings_string() const { @@ -630,7 +630,7 @@ bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) co return valid; } -ResourceImporterTexture *ResourceImporterTexture::singleton = NULL; +ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr; ResourceImporterTexture::ResourceImporterTexture() { diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index ed0fe1be89..e1c71ff1b8 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -35,7 +35,7 @@ #include "core/io/resource_importer.h" #include "core/os/file_access.h" #include "scene/resources/texture.h" -#include "servers/visual_server.h" +#include "servers/rendering_server.h" class StreamTexture; @@ -63,16 +63,16 @@ protected: int flags; String normal_path_for_roughness; - VS::TextureDetectRoughnessChannel channel_for_roughness; + RS::TextureDetectRoughnessChannel channel_for_roughness; MakeInfo() { flags = 0; - channel_for_roughness = VS::TEXTURE_DETECT_ROUGNHESS_R; + channel_for_roughness = RS::TEXTURE_DETECT_ROUGNHESS_R; } }; Map<StringName, MakeInfo> make_flags; - static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, VisualServer::TextureDetectRoughnessChannel p_channel); + static void _texture_reimport_roughness(const Ref<StreamTexture> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel); static void _texture_reimport_3d(const Ref<StreamTexture> &p_tex); static void _texture_reimport_normal(const Ref<StreamTexture> &p_tex); @@ -104,7 +104,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); void update_imports(); diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 3172cc7279..2765bb7fae 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -192,7 +192,7 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr } } -Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant> > &p_source_file_options, const Map<String, String> &p_base_paths) { +Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) { ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen @@ -202,7 +202,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file pack_data_files.resize(p_source_file_options.size()); int idx = 0; - for (const Map<String, Map<StringName, Variant> >::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { + for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { PackData &pack_data = pack_data_files.write[idx]; const String &source = E->key(); @@ -251,7 +251,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file Ref<BitMap> bit_map; bit_map.instance(); bit_map->create_from_image_alpha(image); - Vector<Vector<Vector2> > polygons = bit_map->clip_opaque_to_polygons(Rect2(0, 0, image->get_width(), image->get_height())); + Vector<Vector<Vector2>> polygons = bit_map->clip_opaque_to_polygons(Rect2(0, 0, image->get_width(), image->get_height())); for (int j = 0; j < polygons.size(); j++) { @@ -323,7 +323,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file //save the images idx = 0; - for (const Map<String, Map<StringName, Variant> >::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { + for (const Map<String, Map<StringName, Variant>>::Element *E = p_source_file_options.front(); E; E = E->next(), idx++) { PackData &pack_data = pack_data_files.write[idx]; diff --git a/editor/import/resource_importer_texture_atlas.h b/editor/import/resource_importer_texture_atlas.h index e455a157cf..c61fa5c040 100644 --- a/editor/import/resource_importer_texture_atlas.h +++ b/editor/import/resource_importer_texture_atlas.h @@ -40,7 +40,7 @@ class ResourceImporterTextureAtlas : public ResourceImporter { Rect2 region; bool is_mesh; Vector<int> chart_pieces; //one for region, many for mesh - Vector<Vector<Vector2> > chart_vertices; //for mesh + Vector<Vector<Vector2>> chart_vertices; //for mesh Ref<Image> image; }; @@ -63,8 +63,8 @@ public: virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; virtual String get_option_group_file() const; - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); - virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant> > &p_source_file_options, const Map<String, String> &p_base_paths); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); + virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths); ResourceImporterTextureAtlas(); }; diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 6df5b88b13..bc2f023e6b 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -162,7 +162,7 @@ public: } } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL); + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr); ResourceImporterWAV(); }; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 3ef88105fe..22f6aedeaa 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -112,19 +112,19 @@ void ImportDock::set_edit_path(const String &p_path) { _update_options(config); - List<Ref<ResourceImporter> > importers; + List<Ref<ResourceImporter>> importers; ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers); - List<Pair<String, String> > importer_names; + List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); } - importer_names.sort_custom<PairSort<String, String> >(); + importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String> >::Element *E = importer_names.front(); E; E = E->next()) { + for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { import_as->add_item(E->get().first); import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); if (E->get().second == params->importer->get_importer_name()) { @@ -240,19 +240,19 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { params->update(); - List<Ref<ResourceImporter> > importers; + List<Ref<ResourceImporter>> importers; ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_paths[0].get_extension(), &importers); - List<Pair<String, String> > importer_names; + List<Pair<String, String>> importer_names; - for (List<Ref<ResourceImporter> >::Element *E = importers.front(); E; E = E->next()) { + for (List<Ref<ResourceImporter>>::Element *E = importers.front(); E; E = E->next()) { importer_names.push_back(Pair<String, String>(E->get()->get_visible_name(), E->get()->get_importer_name())); } - importer_names.sort_custom<PairSort<String, String> >(); + importer_names.sort_custom<PairSort<String, String>>(); import_as->clear(); - for (List<Pair<String, String> >::Element *E = importer_names.front(); E; E = E->next()) { + for (List<Pair<String, String>>::Element *E = importer_names.front(); E; E = E->next()) { import_as->add_item(E->get().first); import_as->set_item_metadata(import_as->get_item_count() - 1, E->get().second); if (E->get().second == params->importer->get_importer_name()) { @@ -424,7 +424,7 @@ void ImportDock::_reimport_attempt() { if (need_restart) { label_warning->set_visible(used_in_resources); - reimport_confirm->popup_centered_minsize(); + reimport_confirm->popup_centered(); return; } @@ -450,8 +450,8 @@ void ImportDock::_reimport() { String importer_name = params->importer->get_importer_name(); - if (params->checking) { - //update only what edited (checkboxes) + if (params->checking && config->get_value("remap", "importer") == params->importer->get_importer_name()) { + //update only what is edited (checkboxes) if the importer is the same for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { if (params->checked.has(E->get().name)) { config->set_value("params", E->get().name, params->values[E->get().name]); @@ -492,13 +492,13 @@ void ImportDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - imported->add_style_override("normal", get_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit")); } break; case NOTIFICATION_ENTER_TREE: { import_opts->edit(params); - label_warning->add_color_override("font_color", get_color("warning_color", "Editor")); + label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); } break; } } @@ -526,7 +526,7 @@ ImportDock::ImportDock() { set_name("Import"); imported = memnew(Label); - imported->add_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "LineEdit")); + imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); imported->set_clip_text(true); add_child(imported); HBoxContainer *hb = memnew(HBoxContainer); @@ -558,7 +558,7 @@ ImportDock::ImportDock() { hb->add_spacer(); reimport_confirm = memnew(ConfirmationDialog); - reimport_confirm->get_ok()->set_text(TTR("Save scenes, re-import and restart")); + reimport_confirm->get_ok()->set_text(TTR("Save Scenes, Re-Import, and Restart")); add_child(reimport_confirm); reimport_confirm->connect("confirmed", callable_mp(this, &ImportDock::_reimport_and_restart)); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 2729d9ecb5..3715547bdc 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -112,7 +112,7 @@ void InspectorDock::_menu_option(int p_option) { editor_data->get_undo_redo().clear_history(); - editor->get_editor_plugins_over()->edit(NULL); + editor->get_editor_plugins_over()->edit(nullptr); editor->get_editor_plugins_over()->edit(current); } break; @@ -140,7 +140,7 @@ void InspectorDock::_new_resource() { } void InspectorDock::_load_resource(const String &p_type) { - load_resource_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + load_resource_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type(p_type, &extensions); @@ -166,7 +166,7 @@ void InspectorDock::_resource_file_selected(String p_file) { void InspectorDock::_save_resource(bool save_as) const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -180,7 +180,7 @@ void InspectorDock::_save_resource(bool save_as) const { void InspectorDock::_unref_resource() const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -191,7 +191,7 @@ void InspectorDock::_unref_resource() const { void InspectorDock::_copy_resource() const { ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); - Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : NULL; + Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -214,7 +214,7 @@ void InspectorDock::_prepare_history() { history_menu->get_popup()->clear(); - Ref<Texture2D> base_icon = get_icon("Object", "EditorIcons"); + Ref<Texture2D> base_icon = get_theme_icon("Object", "EditorIcons"); Set<ObjectID> already; for (int i = editor_history->get_history_len() - 1; i >= history_to; i--) { @@ -310,14 +310,14 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu } void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) { - Spatial *s = Object::cast_to<Spatial>(sp); + Node3D *s = Object::cast_to<Node3D>(sp); if (!s) return; AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(s, p_sub, p_key); } void InspectorDock::_warning_pressed() { - warning_dialog->popup_centered_minsize(); + warning_dialog->popup_centered(); } Container *InspectorDock::get_addon_area() { @@ -328,15 +328,15 @@ void InspectorDock::_notification(int p_what) { switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { set_theme(editor->get_gui_base()->get_theme()); - resource_new_button->set_icon(get_icon("New", "EditorIcons")); - resource_load_button->set_icon(get_icon("Load", "EditorIcons")); - resource_save_button->set_icon(get_icon("Save", "EditorIcons")); - backward_button->set_icon(get_icon("Back", "EditorIcons")); - forward_button->set_icon(get_icon("Forward", "EditorIcons")); - history_menu->set_icon(get_icon("History", "EditorIcons")); - object_menu->set_icon(get_icon("Tools", "EditorIcons")); - warning->set_icon(get_icon("NodeWarning", "EditorIcons")); - warning->add_color_override("font_color", get_color("warning_color", "Editor")); + resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); + resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); + resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); + backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); + forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); + history_menu->set_icon(get_theme_icon("History", "EditorIcons")); + object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); + warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); } break; } } @@ -397,7 +397,7 @@ void InspectorDock::update(Object *p_object) { editor_path->set_disabled(true); editor_path->set_text(""); editor_path->set_tooltip(""); - editor_path->set_icon(NULL); + editor_path->set_icon(nullptr); return; } @@ -435,7 +435,7 @@ void InspectorDock::update(Object *p_object) { p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES); p->add_separator(); - p->add_icon_shortcut(get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); + p->add_icon_shortcut(get_theme_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); } List<MethodInfo> methods; @@ -496,21 +496,21 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { resource_new_button = memnew(ToolButton); resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it.")); - resource_new_button->set_icon(get_icon("New", "EditorIcons")); + resource_new_button->set_icon(get_theme_icon("New", "EditorIcons")); general_options_hb->add_child(resource_new_button); resource_new_button->connect("pressed", callable_mp(this, &InspectorDock::_new_resource)); resource_new_button->set_focus_mode(Control::FOCUS_NONE); resource_load_button = memnew(ToolButton); resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it.")); - resource_load_button->set_icon(get_icon("Load", "EditorIcons")); + resource_load_button->set_icon(get_theme_icon("Load", "EditorIcons")); general_options_hb->add_child(resource_load_button); resource_load_button->connect("pressed", callable_mp(this, &InspectorDock::_open_resource_selector)); resource_load_button->set_focus_mode(Control::FOCUS_NONE); resource_save_button = memnew(MenuButton); resource_save_button->set_tooltip(TTR("Save the currently edited resource.")); - resource_save_button->set_icon(get_icon("Save", "EditorIcons")); + resource_save_button->set_icon(get_theme_icon("Save", "EditorIcons")); general_options_hb->add_child(resource_save_button); resource_save_button->get_popup()->add_item(TTR("Save"), RESOURCE_SAVE); resource_save_button->get_popup()->add_item(TTR("Save As..."), RESOURCE_SAVE_AS); @@ -522,7 +522,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { backward_button = memnew(ToolButton); general_options_hb->add_child(backward_button); - backward_button->set_icon(get_icon("Back", "EditorIcons")); + backward_button->set_icon(get_theme_icon("Back", "EditorIcons")); backward_button->set_flat(true); backward_button->set_tooltip(TTR("Go to the previous edited object in history.")); backward_button->set_disabled(true); @@ -530,7 +530,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { forward_button = memnew(ToolButton); general_options_hb->add_child(forward_button); - forward_button->set_icon(get_icon("Forward", "EditorIcons")); + forward_button->set_icon(get_theme_icon("Forward", "EditorIcons")); forward_button->set_flat(true); forward_button->set_tooltip(TTR("Go to the next edited object in history.")); forward_button->set_disabled(true); @@ -538,9 +538,9 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { history_menu = memnew(MenuButton); history_menu->set_tooltip(TTR("History of recently edited objects.")); - history_menu->set_icon(get_icon("History", "EditorIcons")); + history_menu->set_icon(get_theme_icon("History", "EditorIcons")); general_options_hb->add_child(history_menu); - history_menu->connect("about_to_show", callable_mp(this, &InspectorDock::_prepare_history)); + history_menu->connect("about_to_popup", callable_mp(this, &InspectorDock::_prepare_history)); history_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_select_history)); HBoxContainer *node_info_hb = memnew(HBoxContainer); @@ -551,7 +551,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { node_info_hb->add_child(editor_path); object_menu = memnew(MenuButton); - object_menu->set_icon(get_icon("Tools", "EditorIcons")); + object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); node_info_hb->add_child(object_menu); object_menu->set_tooltip(TTR("Object properties.")); object_menu->get_popup()->connect("id_pressed", callable_mp(this, &InspectorDock::_menu_option)); @@ -564,15 +564,15 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { search = memnew(LineEdit); search->set_h_size_flags(Control::SIZE_EXPAND_FILL); search->set_placeholder(TTR("Filter properties")); - search->set_right_icon(get_icon("Search", "EditorIcons")); + search->set_right_icon(get_theme_icon("Search", "EditorIcons")); search->set_clear_button_enabled(true); add_child(search); warning = memnew(Button); add_child(warning); warning->set_text(TTR("Changes may be lost!")); - warning->set_icon(get_icon("NodeWarning", "EditorIcons")); - warning->add_color_override("font_color", get_color("warning_color", "Editor")); + warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); + warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); warning->set_clip_text(true); warning->hide(); warning->connect("pressed", callable_mp(this, &InspectorDock::_warning_pressed)); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index d6e443ec14..724782ac44 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* spatial_editor_gizmos.cpp */ +/* node_3d_editor_gizmos.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,45 +28,46 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "spatial_editor_gizmos.h" +#include "node_3d_editor_gizmos.h" #include "core/math/geometry.h" #include "core/math/quick_hull.h" #include "scene/3d/audio_stream_player_3d.h" #include "scene/3d/baked_lightmap.h" -#include "scene/3d/collision_polygon.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/cpu_particles.h" +#include "scene/3d/collision_polygon_3d.h" +#include "scene/3d/collision_shape_3d.h" +#include "scene/3d/cpu_particles_3d.h" +#include "scene/3d/decal.h" #include "scene/3d/gi_probe.h" -#include "scene/3d/light.h" -#include "scene/3d/listener.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation_region.h" -#include "scene/3d/particles.h" -#include "scene/3d/physics_joint.h" +#include "scene/3d/gpu_particles_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/listener_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/navigation_region_3d.h" +#include "scene/3d/physics_joint_3d.h" #include "scene/3d/position_3d.h" -#include "scene/3d/ray_cast.h" +#include "scene/3d/ray_cast_3d.h" #include "scene/3d/reflection_probe.h" -#include "scene/3d/soft_body.h" -#include "scene/3d/spring_arm.h" +#include "scene/3d/soft_body_3d.h" +#include "scene/3d/spring_arm_3d.h" #include "scene/3d/sprite_3d.h" -#include "scene/3d/vehicle_body.h" -#include "scene/3d/visibility_notifier.h" -#include "scene/resources/box_shape.h" -#include "scene/resources/capsule_shape.h" -#include "scene/resources/concave_polygon_shape.h" -#include "scene/resources/convex_polygon_shape.h" -#include "scene/resources/cylinder_shape.h" -#include "scene/resources/height_map_shape.h" +#include "scene/3d/vehicle_body_3d.h" +#include "scene/3d/visibility_notifier_3d.h" +#include "scene/resources/box_shape_3d.h" +#include "scene/resources/capsule_shape_3d.h" +#include "scene/resources/concave_polygon_shape_3d.h" +#include "scene/resources/convex_polygon_shape_3d.h" +#include "scene/resources/cylinder_shape_3d.h" +#include "scene/resources/height_map_shape_3d.h" #include "scene/resources/primitive_meshes.h" -#include "scene/resources/ray_shape.h" -#include "scene/resources/sphere_shape.h" +#include "scene/resources/ray_shape_3d.h" +#include "scene/resources/sphere_shape_3d.h" #include "scene/resources/surface_tool.h" -#include "scene/resources/world_margin_shape.h" +#include "scene/resources/world_margin_shape_3d.h" #define HANDLE_HALF_SIZE 9.5 -bool EditorSpatialGizmo::is_editable() const { +bool EditorNode3DGizmo::is_editable() const { ERR_FAIL_COND_V(!spatial_node, false); Node *edited_root = spatial_node->get_tree()->get_edited_scene_root(); @@ -81,12 +82,12 @@ bool EditorSpatialGizmo::is_editable() const { return false; } -void EditorSpatialGizmo::clear() { +void EditorNode3DGizmo::clear() { for (int i = 0; i < instances.size(); i++) { if (instances[i].instance.is_valid()) - VS::get_singleton()->free(instances[i].instance); + RS::get_singleton()->free(instances[i].instance); } billboard_handle = false; @@ -97,7 +98,7 @@ void EditorSpatialGizmo::clear() { secondary_handles.clear(); } -void EditorSpatialGizmo::redraw() { +void EditorNode3DGizmo::redraw() { if (get_script_instance() && get_script_instance()->has_method("redraw")) { get_script_instance()->call("redraw"); @@ -108,7 +109,7 @@ void EditorSpatialGizmo::redraw() { gizmo_plugin->redraw(this); } -String EditorSpatialGizmo::get_handle_name(int p_idx) const { +String EditorNode3DGizmo::get_handle_name(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_idx); @@ -118,7 +119,7 @@ String EditorSpatialGizmo::get_handle_name(int p_idx) const { return gizmo_plugin->get_handle_name(this, p_idx); } -bool EditorSpatialGizmo::is_handle_highlighted(int p_idx) const { +bool EditorNode3DGizmo::is_handle_highlighted(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_idx); @@ -128,7 +129,7 @@ bool EditorSpatialGizmo::is_handle_highlighted(int p_idx) const { return gizmo_plugin->is_handle_highlighted(this, p_idx); } -Variant EditorSpatialGizmo::get_handle_value(int p_idx) { +Variant EditorNode3DGizmo::get_handle_value(int p_idx) { if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) { return get_script_instance()->call("get_handle_value", p_idx); @@ -138,7 +139,7 @@ Variant EditorSpatialGizmo::get_handle_value(int p_idx) { return gizmo_plugin->get_handle_value(this, p_idx); } -void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { +void EditorNode3DGizmo::set_handle(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_idx, p_camera, p_point); @@ -149,7 +150,7 @@ void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); } -void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { +void EditorNode3DGizmo::commit_handle(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_idx, p_restore, p_cancel); @@ -160,27 +161,27 @@ void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); } -void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) { +void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) { ERR_FAIL_NULL(p_node); spatial_node = p_node; } -void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidden) { +void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) { - instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); - VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); + instance = RS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); + RS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); if (skin_reference.is_valid()) { - VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); + RS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); } if (extra_margin) - VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); - VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF); - int layer = p_hidden ? 0 : 1 << SpatialEditorViewport::GIZMO_EDIT_LAYER; - VS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26 + RS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); + RS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, RS::SHADOW_CASTING_SETTING_OFF); + int layer = p_hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER; + RS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26 } -void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { +void EditorNode3DGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { ERR_FAIL_COND(!spatial_node); Instance ins; @@ -191,16 +192,16 @@ void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard ins.material = p_material; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); if (ins.material.is_valid()) { - VS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); + RS::get_singleton()->instance_geometry_set_material_override(ins.instance, p_material->get_rid()); } } instances.push_back(ins); } -void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) { +void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard, const Color &p_modulate) { if (p_lines.empty()) { return; } @@ -246,13 +247,13 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat ins.mesh = mesh; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); } -void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) { +void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) { ERR_FAIL_COND(!spatial_node); Instance ins; @@ -310,7 +311,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, ins.billboard = true; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } selectable_icon_size = p_scale; @@ -318,11 +319,11 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, instances.push_back(ins); } -void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh) { +void EditorNode3DGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh) { collision_mesh = p_tmesh; } -void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) { +void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) { int from = collision_segments.size(); collision_segments.resize(from + p_lines.size()); @@ -332,7 +333,7 @@ void EditorSpatialGizmo::add_collision_segments(const Vector<Vector3> &p_lines) } } -void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) { +void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) { billboard_handle = p_billboard; @@ -346,8 +347,8 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref Ref<ArrayMesh> mesh = memnew(ArrayMesh); Array a; - a.resize(VS::ARRAY_MAX); - a[VS::ARRAY_VERTEX] = p_handles; + a.resize(RS::ARRAY_MAX); + a[RS::ARRAY_VERTEX] = p_handles; Vector<Color> colors; { colors.resize(p_handles.size()); @@ -358,13 +359,13 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref if (is_handle_highlighted(i)) col = Color(0, 0, 1, 0.9); - if (SpatialEditor::get_singleton()->get_over_gizmo_handle() != i) + if (Node3DEditor::get_singleton()->get_over_gizmo_handle() != i) col.a = 0.8; w[i] = col; } } - a[VS::ARRAY_COLOR] = colors; + a[RS::ARRAY_COLOR] = colors; mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a); mesh->surface_set_material(0, p_material); @@ -384,7 +385,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref ins.extra_margin = true; if (valid) { ins.create_instance(spatial_node, hidden); - VS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(ins.instance, spatial_node->get_global_transform()); } instances.push_back(ins); if (!p_secondary) { @@ -403,21 +404,21 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref } } -void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) { +void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position) { ERR_FAIL_COND(!spatial_node); CubeMesh cubem; cubem.set_size(p_size); Array arrays = cubem.surface_get_arrays(0); - PackedVector3Array vertex = arrays[VS::ARRAY_VERTEX]; + PackedVector3Array vertex = arrays[RS::ARRAY_VERTEX]; Vector3 *w = vertex.ptrw(); for (int i = 0; i < vertex.size(); ++i) { w[i] += p_position; } - arrays[VS::ARRAY_VERTEX] = vertex; + arrays[RS::ARRAY_VERTEX] = vertex; Ref<ArrayMesh> m = memnew(ArrayMesh); m->add_surface_from_arrays(cubem.surface_get_primitive_type(0), arrays); @@ -425,7 +426,7 @@ void EditorSpatialGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size add_mesh(m); } -bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum) { +bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector<Plane> &p_frustum) { ERR_FAIL_COND_V(!spatial_node, false); ERR_FAIL_COND_V(!valid, false); @@ -497,7 +498,7 @@ bool EditorSpatialGizmo::intersect_frustum(const Camera *p_camera, const Vector< return false; } -bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) { +bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) { ERR_FAIL_COND_V(!spatial_node, false); ERR_FAIL_COND_V(!valid, false); @@ -574,7 +575,7 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, float scale = t.origin.distance_to(p_camera->get_camera_transform().origin); - if (p_camera->get_projection() == Camera::PROJECTION_ORTHOGONAL) { + if (p_camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) { float aspect = p_camera->get_viewport()->get_visible_rect().size.aspect(); float size = p_camera->get_size(); scale = size / aspect; @@ -689,7 +690,7 @@ bool EditorSpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, return false; } -void EditorSpatialGizmo::create() { +void EditorNode3DGizmo::create() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(valid); @@ -703,16 +704,16 @@ void EditorSpatialGizmo::create() { transform(); } -void EditorSpatialGizmo::transform() { +void EditorNode3DGizmo::transform() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { - VS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); + RS::get_singleton()->instance_set_transform(instances[i].instance, spatial_node->get_global_transform()); } } -void EditorSpatialGizmo::free() { +void EditorNode3DGizmo::free() { ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); @@ -720,7 +721,7 @@ void EditorSpatialGizmo::free() { for (int i = 0; i < instances.size(); i++) { if (instances[i].instance.is_valid()) - VS::get_singleton()->free(instances[i].instance); + RS::get_singleton()->free(instances[i].instance); instances.write[i].instance = RID(); } @@ -729,31 +730,31 @@ void EditorSpatialGizmo::free() { valid = false; } -void EditorSpatialGizmo::set_hidden(bool p_hidden) { +void EditorNode3DGizmo::set_hidden(bool p_hidden) { hidden = p_hidden; - int layer = hidden ? 0 : 1 << SpatialEditorViewport::GIZMO_EDIT_LAYER; + int layer = hidden ? 0 : 1 << Node3DEditorViewport::GIZMO_EDIT_LAYER; for (int i = 0; i < instances.size(); ++i) { - VS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer); + RS::get_singleton()->instance_set_layer_mask(instances[i].instance, layer); } } -void EditorSpatialGizmo::set_plugin(EditorSpatialGizmoPlugin *p_plugin) { +void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) { gizmo_plugin = p_plugin; } -void EditorSpatialGizmo::_bind_methods() { +void EditorNode3DGizmo::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorSpatialGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments); - ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorSpatialGizmo::add_collision_triangles); - ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorSpatialGizmo::add_handles, DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorSpatialGizmo::_set_spatial_node); - ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorSpatialGizmo::get_spatial_node); - ClassDB::bind_method(D_METHOD("get_plugin"), &EditorSpatialGizmo::get_plugin); - ClassDB::bind_method(D_METHOD("clear"), &EditorSpatialGizmo::clear); - ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorSpatialGizmo::set_hidden); + ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments); + ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorNode3DGizmo::add_collision_triangles); + ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorNode3DGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorNode3DGizmo::add_handles, DEFVAL(false), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorNode3DGizmo::_set_spatial_node); + ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorNode3DGizmo::get_spatial_node); + ClassDB::bind_method(D_METHOD("get_plugin"), &EditorNode3DGizmo::get_plugin); + ClassDB::bind_method(D_METHOD("clear"), &EditorNode3DGizmo::clear); + ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorNode3DGizmo::set_hidden); BIND_VMETHOD(MethodInfo("redraw")); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "index"))); @@ -763,31 +764,31 @@ void EditorSpatialGizmo::_bind_methods() { hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; BIND_VMETHOD(hvget); - BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo("set_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::VECTOR2, "point"))); MethodInfo cm = MethodInfo("commit_handle", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "restore"), PropertyInfo(Variant::BOOL, "cancel")); cm.default_arguments.push_back(false); BIND_VMETHOD(cm); } -EditorSpatialGizmo::EditorSpatialGizmo() { +EditorNode3DGizmo::EditorNode3DGizmo() { valid = false; billboard_handle = false; hidden = false; - base = NULL; + base = nullptr; selected = false; instanced = false; - spatial_node = NULL; - gizmo_plugin = NULL; + spatial_node = nullptr; + gizmo_plugin = nullptr; selectable_icon_size = -1.0f; } -EditorSpatialGizmo::~EditorSpatialGizmo() { +EditorNode3DGizmo::~EditorNode3DGizmo() { - if (gizmo_plugin != NULL) gizmo_plugin->unregister_gizmo(this); + if (gizmo_plugin != nullptr) gizmo_plugin->unregister_gizmo(this); clear(); } -Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const { +Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3()); @@ -796,34 +797,34 @@ Vector3 EditorSpatialGizmo::get_handle_pos(int p_idx) const { //// light gizmo -LightSpatialGizmoPlugin::LightSpatialGizmoPlugin() { +Light3DGizmoPlugin::Light3DGizmoPlugin() { // Enable vertex colors for the materials below as the gizmo color depends on the light color. create_material("lines_primary", Color(1, 1, 1), false, false, true); create_material("lines_secondary", Color(1, 1, 1, 0.35), false, false, true); create_material("lines_billboard", Color(1, 1, 1), true, false, true); - create_icon_material("light_directional_icon", SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight", "EditorIcons")); - create_icon_material("light_omni_icon", SpatialEditor::get_singleton()->get_icon("GizmoLight", "EditorIcons")); - create_icon_material("light_spot_icon", SpatialEditor::get_singleton()->get_icon("GizmoSpotLight", "EditorIcons")); + create_icon_material("light_directional_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoDirectionalLight", "EditorIcons")); + create_icon_material("light_omni_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoLight", "EditorIcons")); + create_icon_material("light_spot_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoSpotLight", "EditorIcons")); create_handle_material("handles"); create_handle_material("handles_billboard", true); } -bool LightSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Light>(p_spatial) != NULL; +bool Light3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Light3D>(p_spatial) != nullptr; } -String LightSpatialGizmoPlugin::get_name() const { - return "Lights"; +String Light3DGizmoPlugin::get_name() const { + return "Light3D"; } -int LightSpatialGizmoPlugin::get_priority() const { +int Light3DGizmoPlugin::get_priority() const { return -1; } -String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { if (p_idx == 0) return "Radius"; @@ -831,13 +832,13 @@ String LightSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizm return "Aperture"; } -Variant LightSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); + Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_idx == 0) - return light->get_param(Light::PARAM_RANGE); + return light->get_param(Light3D::PARAM_RANGE); if (p_idx == 1) - return light->get_param(Light::PARAM_SPOT_ANGLE); + return light->get_param(Light3D::PARAM_SPOT_ANGLE); return Variant(); } @@ -871,9 +872,9 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec return a * 180.0 / Math_PI; } -void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); + Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Transform gt = light->get_global_transform(); Transform gi = gt.affine_inverse(); @@ -883,20 +884,20 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; if (p_idx == 0) { - if (Object::cast_to<SpotLight>(light)) { + if (Object::cast_to<SpotLight3D>(light)) { Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, -4096), s[0], s[1], ra, rb); float d = -ra.z; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d <= 0) // Equal is here for negative zero. d = 0; - light->set_param(Light::PARAM_RANGE, d); - } else if (Object::cast_to<OmniLight>(light)) { + light->set_param(Light3D::PARAM_RANGE, d); + } else if (Object::cast_to<OmniLight3D>(light)) { Plane cp = Plane(gt.origin, p_camera->get_transform().basis.get_axis(2)); @@ -904,48 +905,48 @@ void LightSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, if (cp.intersects_ray(ray_from, ray_dir, &inters)) { float r = inters.distance_to(gt.origin); - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - r = Math::stepify(r, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + r = Math::stepify(r, Node3DEditor::get_singleton()->get_translate_snap()); } - light->set_param(Light::PARAM_RANGE, r); + light->set_param(Light3D::PARAM_RANGE, r); } } } else if (p_idx == 1) { - float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light::PARAM_RANGE), gt); - light->set_param(Light::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99)); + float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt); + light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99)); } } -void LightSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); + Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_cancel) { - light->set_param(p_idx == 0 ? Light::PARAM_RANGE : Light::PARAM_SPOT_ANGLE, p_restore); + light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); } else if (p_idx == 0) { - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); - ur->add_do_method(light, "set_param", Light::PARAM_RANGE, light->get_param(Light::PARAM_RANGE)); - ur->add_undo_method(light, "set_param", Light::PARAM_RANGE, p_restore); + ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE)); + ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore); ur->commit_action(); } else if (p_idx == 1) { - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); - ur->add_do_method(light, "set_param", Light::PARAM_SPOT_ANGLE, light->get_param(Light::PARAM_SPOT_ANGLE)); - ur->add_undo_method(light, "set_param", Light::PARAM_SPOT_ANGLE, p_restore); + ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE)); + ur->add_undo_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, p_restore); ur->commit_action(); } } -void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Light *light = Object::cast_to<Light>(p_gizmo->get_spatial_node()); + Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Color color = light->get_color(); // Make the gizmo color as bright as possible for better visibility @@ -953,7 +954,7 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->clear(); - if (Object::cast_to<DirectionalLight>(light)) { + if (Object::cast_to<DirectionalLight3D>(light)) { Ref<Material> material = get_material("lines_primary", p_gizmo); Ref<Material> icon = get_material("light_directional_icon", p_gizmo); @@ -991,15 +992,15 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_unscaled_billboard(icon, 0.05, color); } - if (Object::cast_to<OmniLight>(light)) { + if (Object::cast_to<OmniLight3D>(light)) { // Use both a billboard circle and 3 non-billboard circles for a better sphere-like representation const Ref<Material> lines_material = get_material("lines_secondary", p_gizmo); const Ref<Material> lines_billboard_material = get_material("lines_billboard", p_gizmo); const Ref<Material> icon = get_material("light_omni_icon", p_gizmo); - OmniLight *on = Object::cast_to<OmniLight>(light); - const float r = on->get_param(Light::PARAM_RANGE); + OmniLight3D *on = Object::cast_to<OmniLight3D>(light); + const float r = on->get_param(Light3D::PARAM_RANGE); Vector<Vector3> points; Vector<Vector3> points_billboard; @@ -1033,7 +1034,7 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, get_material("handles_billboard"), true); } - if (Object::cast_to<SpotLight>(light)) { + if (Object::cast_to<SpotLight3D>(light)) { const Ref<Material> material_primary = get_material("lines_primary", p_gizmo); const Ref<Material> material_secondary = get_material("lines_secondary", p_gizmo); @@ -1041,11 +1042,11 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Vector<Vector3> points_primary; Vector<Vector3> points_secondary; - SpotLight *sl = Object::cast_to<SpotLight>(light); + SpotLight3D *sl = Object::cast_to<SpotLight3D>(light); - float r = sl->get_param(Light::PARAM_RANGE); - float w = r * Math::sin(Math::deg2rad(sl->get_param(Light::PARAM_SPOT_ANGLE))); - float d = r * Math::cos(Math::deg2rad(sl->get_param(Light::PARAM_SPOT_ANGLE))); + float r = sl->get_param(Light3D::PARAM_RANGE); + float w = r * Math::sin(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE))); + float d = r * Math::cos(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE))); for (int i = 0; i < 120; i++) { @@ -1086,39 +1087,39 @@ void LightSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ////// //// player gizmo -AudioStreamPlayer3DSpatialGizmoPlugin::AudioStreamPlayer3DSpatialGizmoPlugin() { +AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); - create_icon_material("stream_player_3d_icon", SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons")); + create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons")); create_material("stream_player_3d_material_primary", gizmo_color); create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35)); create_handle_material("handles"); } -bool AudioStreamPlayer3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<AudioStreamPlayer3D>(p_spatial) != NULL; +bool AudioStreamPlayer3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<AudioStreamPlayer3D>(p_spatial) != nullptr; } -String AudioStreamPlayer3DSpatialGizmoPlugin::get_name() const { +String AudioStreamPlayer3DGizmoPlugin::get_name() const { return "AudioStreamPlayer3D"; } -int AudioStreamPlayer3DSpatialGizmoPlugin::get_priority() const { +int AudioStreamPlayer3DGizmoPlugin::get_priority() const { return -1; } -String AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { return "Emission Radius"; } -Variant AudioStreamPlayer3DSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); return player->get_emission_angle(); } -void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); @@ -1157,7 +1158,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_giz } } -void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); @@ -1167,7 +1168,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_ } else { - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change AudioStreamPlayer3D Emission Angle")); ur->add_do_method(player, "set_emission_angle", player->get_emission_angle()); ur->add_undo_method(player, "set_emission_angle", p_restore); @@ -1175,7 +1176,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_ } } -void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); @@ -1233,7 +1234,7 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) ////// -CameraSpatialGizmoPlugin::CameraSpatialGizmoPlugin() { +Camera3DGizmoPlugin::Camera3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8)); @@ -1241,34 +1242,34 @@ CameraSpatialGizmoPlugin::CameraSpatialGizmoPlugin() { create_handle_material("handles"); } -bool CameraSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Camera>(p_spatial) != NULL; +bool Camera3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Camera3D>(p_spatial) != nullptr; } -String CameraSpatialGizmoPlugin::get_name() const { - return "Camera"; +String Camera3DGizmoPlugin::get_name() const { + return "Camera3D"; } -int CameraSpatialGizmoPlugin::get_priority() const { +int Camera3DGizmoPlugin::get_priority() const { return -1; } -String CameraSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); + Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); - if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { + if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { return "FOV"; } else { return "Size"; } } -Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); + Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); - if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { + if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { return camera->get_fov(); } else { @@ -1276,9 +1277,9 @@ Variant CameraSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, } } -void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); + Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); Transform gt = camera->get_global_transform(); Transform gi = gt.affine_inverse(); @@ -1288,7 +1289,7 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { + if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { Transform gt2 = camera->get_global_transform(); float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2); camera->set("fov", CLAMP(a * 2.0, 1, 179)); @@ -1297,8 +1298,8 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(0, 0, -1), Vector3(4096, 0, -1), s[0], s[1], ra, rb); float d = ra.x * 2.0; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } d = CLAMP(d, 0.1, 16384); @@ -1307,17 +1308,17 @@ void CameraSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx } } -void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); + Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); - if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { + if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { if (p_cancel) { camera->set("fov", p_restore); } else { - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Camera FOV")); ur->add_do_property(camera, "fov", camera->get_fov()); ur->add_undo_property(camera, "fov", p_restore); @@ -1330,7 +1331,7 @@ void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_ camera->set("size", p_restore); } else { - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Camera Size")); ur->add_do_property(camera, "size", camera->get_size()); ur->add_undo_property(camera, "size", p_restore); @@ -1339,9 +1340,9 @@ void CameraSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_ } } -void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Camera *camera = Object::cast_to<Camera>(p_gizmo->get_spatial_node()); + Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1374,7 +1375,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { switch (camera->get_projection()) { - case Camera::PROJECTION_PERSPECTIVE: { + case Camera3D::PROJECTION_PERSPECTIVE: { // The real FOV is halved for accurate representation float fov = camera->get_fov() / 2.0; @@ -1396,7 +1397,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ADD_TRIANGLE(tup, side + up, nside + up); } break; - case Camera::PROJECTION_ORTHOGONAL: { + case Camera3D::PROJECTION_ORTHOGONAL: { float size = camera->get_size(); @@ -1418,7 +1419,7 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ADD_TRIANGLE(tup, right + up + back, -right + up + back); } break; - case Camera::PROJECTION_FRUSTUM: { + case Camera3D::PROJECTION_FRUSTUM: { float hsize = camera->get_size() / 2.0; Vector3 side = Vector3(hsize, 0, -camera->get_znear()).normalized(); @@ -1445,9 +1446,9 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(lines, material); p_gizmo->add_handles(handles, get_material("handles")); - ClippedCamera *clipcam = Object::cast_to<ClippedCamera>(camera); + ClippedCamera3D *clipcam = Object::cast_to<ClippedCamera3D>(camera); if (clipcam) { - Spatial *parent = Object::cast_to<Spatial>(camera->get_parent()); + Node3D *parent = Object::cast_to<Node3D>(camera->get_parent()); if (!parent) { return; } @@ -1489,28 +1490,28 @@ void CameraSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ////// -MeshInstanceSpatialGizmoPlugin::MeshInstanceSpatialGizmoPlugin() { +MeshInstance3DGizmoPlugin::MeshInstance3DGizmoPlugin() { } -bool MeshInstanceSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<MeshInstance>(p_spatial) != NULL && Object::cast_to<SoftBody>(p_spatial) == NULL; +bool MeshInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<MeshInstance3D>(p_spatial) != nullptr && Object::cast_to<SoftBody3D>(p_spatial) == nullptr; } -String MeshInstanceSpatialGizmoPlugin::get_name() const { - return "MeshInstance"; +String MeshInstance3DGizmoPlugin::get_name() const { + return "MeshInstance3D"; } -int MeshInstanceSpatialGizmoPlugin::get_priority() const { +int MeshInstance3DGizmoPlugin::get_priority() const { return -1; } -bool MeshInstanceSpatialGizmoPlugin::can_be_hidden() const { +bool MeshInstance3DGizmoPlugin::can_be_hidden() const { return false; } -void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - MeshInstance *mesh = Object::cast_to<MeshInstance>(p_gizmo->get_spatial_node()); + MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1526,26 +1527,26 @@ void MeshInstanceSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } ///// -Sprite3DSpatialGizmoPlugin::Sprite3DSpatialGizmoPlugin() { +Sprite3DGizmoPlugin::Sprite3DGizmoPlugin() { } -bool Sprite3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Sprite3D>(p_spatial) != NULL; +bool Sprite3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Sprite3D>(p_spatial) != nullptr; } -String Sprite3DSpatialGizmoPlugin::get_name() const { +String Sprite3DGizmoPlugin::get_name() const { return "Sprite3D"; } -int Sprite3DSpatialGizmoPlugin::get_priority() const { +int Sprite3DGizmoPlugin::get_priority() const { return -1; } -bool Sprite3DSpatialGizmoPlugin::can_be_hidden() const { +bool Sprite3DGizmoPlugin::can_be_hidden() const { return false; } -void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node()); @@ -1559,7 +1560,7 @@ void Sprite3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { /// -Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { +Position3DGizmoPlugin::Position3DGizmoPlugin() { pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); cursor_points = Vector<Vector3>(); @@ -1571,12 +1572,12 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { cursor_points.push_back(Vector3(0, -cs, 0)); cursor_points.push_back(Vector3(0, 0, +cs)); cursor_points.push_back(Vector3(0, 0, -cs)); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_x_color", "Editor")); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_x_color", "Editor")); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_y_color", "Editor")); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_y_color", "Editor")); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); - cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_x_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_y_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor")); + cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_theme_color("axis_z_color", "Editor")); Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); @@ -1585,26 +1586,26 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); Array d; - d.resize(VS::ARRAY_MAX); + d.resize(RS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX] = cursor_points; d[Mesh::ARRAY_COLOR] = cursor_colors; pos3d_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, d); pos3d_mesh->surface_set_material(0, mat); } -bool Position3DSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Position3D>(p_spatial) != NULL; +bool Position3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Position3D>(p_spatial) != nullptr; } -String Position3DSpatialGizmoPlugin::get_name() const { +String Position3DGizmoPlugin::get_name() const { return "Position3D"; } -int Position3DSpatialGizmoPlugin::get_priority() const { +int Position3DGizmoPlugin::get_priority() const { return -1; } -void Position3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); p_gizmo->add_mesh(pos3d_mesh); @@ -1613,27 +1614,27 @@ void Position3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ///// -SkeletonSpatialGizmoPlugin::SkeletonSpatialGizmoPlugin() { +Skeleton3DGizmoPlugin::Skeleton3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/skeleton", Color(1, 0.8, 0.4)); create_material("skeleton_material", gizmo_color); } -bool SkeletonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Skeleton>(p_spatial) != NULL; +bool Skeleton3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Skeleton3D>(p_spatial) != nullptr; } -String SkeletonSpatialGizmoPlugin::get_name() const { - return "Skeleton"; +String Skeleton3DGizmoPlugin::get_name() const { + return "Skeleton3D"; } -int SkeletonSpatialGizmoPlugin::get_priority() const { +int Skeleton3DGizmoPlugin::get_priority() const { return -1; } -void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Skeleton *skel = Object::cast_to<Skeleton>(p_gizmo->get_spatial_node()); + Skeleton3D *skel = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1822,54 +1823,54 @@ void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { //// -PhysicalBoneSpatialGizmoPlugin::PhysicalBoneSpatialGizmoPlugin() { +PhysicalBone3DGizmoPlugin::PhysicalBone3DGizmoPlugin() { create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1))); } -bool PhysicalBoneSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<PhysicalBone>(p_spatial) != NULL; +bool PhysicalBone3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<PhysicalBone3D>(p_spatial) != nullptr; } -String PhysicalBoneSpatialGizmoPlugin::get_name() const { - return "PhysicalBones"; +String PhysicalBone3DGizmoPlugin::get_name() const { + return "PhysicalBone3D"; } -int PhysicalBoneSpatialGizmoPlugin::get_priority() const { +int PhysicalBone3DGizmoPlugin::get_priority() const { return -1; } -void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); - PhysicalBone *physical_bone = Object::cast_to<PhysicalBone>(p_gizmo->get_spatial_node()); + PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_spatial_node()); if (!physical_bone) return; - Skeleton *sk(physical_bone->find_skeleton_parent()); + Skeleton3D *sk(physical_bone->find_skeleton_parent()); if (!sk) return; - PhysicalBone *pb(sk->get_physical_bone(physical_bone->get_bone_id())); + PhysicalBone3D *pb(sk->get_physical_bone(physical_bone->get_bone_id())); if (!pb) return; - PhysicalBone *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id())); + PhysicalBone3D *pbp(sk->get_physical_bone_parent(physical_bone->get_bone_id())); if (!pbp) return; Vector<Vector3> points; switch (physical_bone->get_joint_type()) { - case PhysicalBone::JOINT_TYPE_PIN: { + case PhysicalBone3D::JOINT_TYPE_PIN: { - JointSpatialGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points); + Joint3DGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points); } break; - case PhysicalBone::JOINT_TYPE_CONE: { + case PhysicalBone3D::JOINT_TYPE_CONE: { - const PhysicalBone::ConeJointData *cjd(static_cast<const PhysicalBone::ConeJointData *>(physical_bone->get_joint_data())); - JointSpatialGizmoPlugin::CreateConeTwistJointGizmo( + const PhysicalBone3D::ConeJointData *cjd(static_cast<const PhysicalBone3D::ConeJointData *>(physical_bone->get_joint_data())); + Joint3DGizmoPlugin::CreateConeTwistJointGizmo( physical_bone->get_joint_offset(), physical_bone->get_global_transform() * physical_bone->get_joint_offset(), pb->get_global_transform(), @@ -1879,10 +1880,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { &points, &points); } break; - case PhysicalBone::JOINT_TYPE_HINGE: { + case PhysicalBone3D::JOINT_TYPE_HINGE: { - const PhysicalBone::HingeJointData *hjd(static_cast<const PhysicalBone::HingeJointData *>(physical_bone->get_joint_data())); - JointSpatialGizmoPlugin::CreateHingeJointGizmo( + const PhysicalBone3D::HingeJointData *hjd(static_cast<const PhysicalBone3D::HingeJointData *>(physical_bone->get_joint_data())); + Joint3DGizmoPlugin::CreateHingeJointGizmo( physical_bone->get_joint_offset(), physical_bone->get_global_transform() * physical_bone->get_joint_offset(), pb->get_global_transform(), @@ -1894,10 +1895,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { &points, &points); } break; - case PhysicalBone::JOINT_TYPE_SLIDER: { + case PhysicalBone3D::JOINT_TYPE_SLIDER: { - const PhysicalBone::SliderJointData *sjd(static_cast<const PhysicalBone::SliderJointData *>(physical_bone->get_joint_data())); - JointSpatialGizmoPlugin::CreateSliderJointGizmo( + const PhysicalBone3D::SliderJointData *sjd(static_cast<const PhysicalBone3D::SliderJointData *>(physical_bone->get_joint_data())); + Joint3DGizmoPlugin::CreateSliderJointGizmo( physical_bone->get_joint_offset(), physical_bone->get_global_transform() * physical_bone->get_joint_offset(), pb->get_global_transform(), @@ -1910,10 +1911,10 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { &points, &points); } break; - case PhysicalBone::JOINT_TYPE_6DOF: { + case PhysicalBone3D::JOINT_TYPE_6DOF: { - const PhysicalBone::SixDOFJointData *sdofjd(static_cast<const PhysicalBone::SixDOFJointData *>(physical_bone->get_joint_data())); - JointSpatialGizmoPlugin::CreateGeneric6DOFJointGizmo( + const PhysicalBone3D::SixDOFJointData *sdofjd(static_cast<const PhysicalBone3D::SixDOFJointData *>(physical_bone->get_joint_data())); + Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( physical_bone->get_joint_offset(), physical_bone->get_global_transform() * physical_bone->get_joint_offset(), @@ -1957,7 +1958,7 @@ void PhysicalBoneSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ///// -RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() { +RayCast3DGizmoPlugin::RayCast3DGizmoPlugin() { const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); @@ -1966,21 +1967,21 @@ RayCastSpatialGizmoPlugin::RayCastSpatialGizmoPlugin() { create_material("shape_material_disabled", gizmo_color_disabled); } -bool RayCastSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<RayCast>(p_spatial) != NULL; +bool RayCast3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<RayCast3D>(p_spatial) != nullptr; } -String RayCastSpatialGizmoPlugin::get_name() const { - return "RayCast"; +String RayCast3DGizmoPlugin::get_name() const { + return "RayCast3D"; } -int RayCastSpatialGizmoPlugin::get_priority() const { +int RayCast3DGizmoPlugin::get_priority() const { return -1; } -void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - RayCast *raycast = Object::cast_to<RayCast>(p_gizmo->get_spatial_node()); + RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1998,9 +1999,9 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ///// -void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - SpringArm *spring_arm = Object::cast_to<SpringArm>(p_gizmo->get_spatial_node()); + SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2015,46 +2016,46 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_collision_segments(lines); } -SpringArmSpatialGizmoPlugin::SpringArmSpatialGizmoPlugin() { +SpringArm3DGizmoPlugin::SpringArm3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); } -bool SpringArmSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<SpringArm>(p_spatial) != NULL; +bool SpringArm3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<SpringArm3D>(p_spatial) != nullptr; } -String SpringArmSpatialGizmoPlugin::get_name() const { - return "SpringArm"; +String SpringArm3DGizmoPlugin::get_name() const { + return "SpringArm3D"; } -int SpringArmSpatialGizmoPlugin::get_priority() const { +int SpringArm3DGizmoPlugin::get_priority() const { return -1; } ///// -VehicleWheelSpatialGizmoPlugin::VehicleWheelSpatialGizmoPlugin() { +VehicleWheel3DGizmoPlugin::VehicleWheel3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); } -bool VehicleWheelSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<VehicleWheel>(p_spatial) != NULL; +bool VehicleWheel3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<VehicleWheel3D>(p_spatial) != nullptr; } -String VehicleWheelSpatialGizmoPlugin::get_name() const { - return "VehicleWheel"; +String VehicleWheel3DGizmoPlugin::get_name() const { + return "VehicleWheel3D"; } -int VehicleWheelSpatialGizmoPlugin::get_priority() const { +int VehicleWheel3DGizmoPlugin::get_priority() const { return -1; } -void VehicleWheelSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - VehicleWheel *car_wheel = Object::cast_to<VehicleWheel>(p_gizmo->get_spatial_node()); + VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2108,30 +2109,30 @@ void VehicleWheelSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { /////////// -SoftBodySpatialGizmoPlugin::SoftBodySpatialGizmoPlugin() { +SoftBody3DGizmoPlugin::SoftBody3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); create_handle_material("handles"); } -bool SoftBodySpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<SoftBody>(p_spatial) != NULL; +bool SoftBody3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<SoftBody3D>(p_spatial) != nullptr; } -String SoftBodySpatialGizmoPlugin::get_name() const { - return "SoftBody"; +String SoftBody3DGizmoPlugin::get_name() const { + return "SoftBody3D"; } -int SoftBodySpatialGizmoPlugin::get_priority() const { +int SoftBody3DGizmoPlugin::get_priority() const { return -1; } -bool SoftBodySpatialGizmoPlugin::is_selectable_when_hidden() const { +bool SoftBody3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node()); +void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2161,28 +2162,28 @@ void SoftBodySpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_collision_triangles(tm); } -String SoftBodySpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { - return "SoftBody pin point"; +String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { + return "SoftBody3D pin point"; } -Variant SoftBodySpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { - SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node()); +Variant SoftBody3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { + SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); return Variant(soft_body->is_point_pinned(p_idx)); } -void SoftBodySpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node()); +void SoftBody3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { + SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); soft_body->pin_point_toggle(p_idx); } -bool SoftBodySpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const { - SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node()); +bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const { + SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node()); return soft_body->is_point_pinned(idx); } /////////// -VisibilityNotifierGizmoPlugin::VisibilityNotifierGizmoPlugin() { +VisibilityNotifier3DGizmoPlugin::VisibilityNotifier3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/visibility_notifier", Color(0.8, 0.5, 0.7)); create_material("visibility_notifier_material", gizmo_color); gizmo_color.a = 0.1; @@ -2190,19 +2191,19 @@ VisibilityNotifierGizmoPlugin::VisibilityNotifierGizmoPlugin() { create_handle_material("handles"); } -bool VisibilityNotifierGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<VisibilityNotifier>(p_spatial) != NULL; +bool VisibilityNotifier3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<VisibilityNotifier3D>(p_spatial) != nullptr; } -String VisibilityNotifierGizmoPlugin::get_name() const { - return "VisibilityNotifier"; +String VisibilityNotifier3DGizmoPlugin::get_name() const { + return "VisibilityNotifier3D"; } -int VisibilityNotifierGizmoPlugin::get_priority() const { +int VisibilityNotifier3DGizmoPlugin::get_priority() const { return -1; } -String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Size X"; @@ -2216,14 +2217,14 @@ String VisibilityNotifierGizmoPlugin::get_handle_name(const EditorSpatialGizmo * return ""; } -Variant VisibilityNotifierGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node()); + VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); return notifier->get_aabb(); } -void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node()); + VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); Transform gt = notifier->get_global_transform(); @@ -2249,8 +2250,8 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; @@ -2261,8 +2262,8 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx] - ofs[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -2274,25 +2275,25 @@ void VisibilityNotifierGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int } } -void VisibilityNotifierGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node()); + VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); if (p_cancel) { notifier->set_aabb(p_restore); return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Notifier AABB")); ur->add_do_method(notifier, "set_aabb", notifier->get_aabb()); ur->add_undo_method(notifier, "set_aabb", p_restore); ur->commit_action(); } -void VisibilityNotifierGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - VisibilityNotifier *notifier = Object::cast_to<VisibilityNotifier>(p_gizmo->get_spatial_node()); + VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2342,59 +2343,59 @@ void VisibilityNotifierGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { //// -CPUParticlesGizmoPlugin::CPUParticlesGizmoPlugin() { - create_icon_material("particles_icon", SpatialEditor::get_singleton()->get_icon("GizmoCPUParticles", "EditorIcons")); +CPUParticles3DGizmoPlugin::CPUParticles3DGizmoPlugin() { + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoCPUParticles3D", "EditorIcons")); } -bool CPUParticlesGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<CPUParticles>(p_spatial) != NULL; +bool CPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<CPUParticles3D>(p_spatial) != nullptr; } -String CPUParticlesGizmoPlugin::get_name() const { - return "CPUParticles"; +String CPUParticles3DGizmoPlugin::get_name() const { + return "CPUParticles3D"; } -int CPUParticlesGizmoPlugin::get_priority() const { +int CPUParticles3DGizmoPlugin::get_priority() const { return -1; } -bool CPUParticlesGizmoPlugin::is_selectable_when_hidden() const { +bool CPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -void CPUParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void CPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> icon = get_material("particles_icon", p_gizmo); p_gizmo->add_unscaled_billboard(icon, 0.05); } //// -ParticlesGizmoPlugin::ParticlesGizmoPlugin() { +GPUParticles3DGizmoPlugin::GPUParticles3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/particles", Color(0.8, 0.7, 0.4)); create_material("particles_material", gizmo_color); gizmo_color.a = 0.1; create_material("particles_solid_material", gizmo_color); - create_icon_material("particles_icon", SpatialEditor::get_singleton()->get_icon("GizmoParticles", "EditorIcons")); + create_icon_material("particles_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGPUParticles3D", "EditorIcons")); create_handle_material("handles"); } -bool ParticlesGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Particles>(p_spatial) != NULL; +bool GPUParticles3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<GPUParticles3D>(p_spatial) != nullptr; } -String ParticlesGizmoPlugin::get_name() const { - return "Particles"; +String GPUParticles3DGizmoPlugin::get_name() const { + return "GPUParticles3D"; } -int ParticlesGizmoPlugin::get_priority() const { +int GPUParticles3DGizmoPlugin::get_priority() const { return -1; } -bool ParticlesGizmoPlugin::is_selectable_when_hidden() const { +bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { return true; } -String ParticlesGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Size X"; @@ -2407,14 +2408,14 @@ String ParticlesGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, return ""; } -Variant ParticlesGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node()); + GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); return particles->get_visibility_aabb(); } -void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node()); + GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); Transform gt = particles->get_global_transform(); Transform gi = gt.affine_inverse(); @@ -2439,8 +2440,8 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } aabb.position[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; @@ -2451,8 +2452,8 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx] - ofs[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -2464,25 +2465,25 @@ void ParticlesGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Ca } } -void ParticlesGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node()); + GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); if (p_cancel) { particles->set_visibility_aabb(p_restore); return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Particles AABB")); ur->add_do_method(particles, "set_visibility_aabb", particles->get_visibility_aabb()); ur->add_undo_method(particles, "set_visibility_aabb", p_restore); ur->commit_action(); } -void ParticlesGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Particles *particles = Object::cast_to<Particles>(p_gizmo->get_spatial_node()); + GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2543,12 +2544,12 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() { gizmo_color.a = 0.1; create_material("reflection_probe_solid_material", gizmo_color); - create_icon_material("reflection_probe_icon", SpatialEditor::get_singleton()->get_icon("GizmoReflectionProbe", "EditorIcons")); + create_icon_material("reflection_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoReflectionProbe", "EditorIcons")); create_handle_material("handles"); } -bool ReflectionProbeGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<ReflectionProbe>(p_spatial) != NULL; +bool ReflectionProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<ReflectionProbe>(p_spatial) != nullptr; } String ReflectionProbeGizmoPlugin::get_name() const { @@ -2559,7 +2560,7 @@ int ReflectionProbeGizmoPlugin::get_priority() const { return -1; } -String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Extents X"; @@ -2572,12 +2573,12 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_g return ""; } -Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); return AABB(probe->get_extents(), probe->get_origin_offset()); } -void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); Transform gt = probe->get_global_transform(); @@ -2598,8 +2599,8 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -2626,8 +2627,8 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i Geometry::get_closest_points_between_segments(origin - axis * 16384, origin + axis * 16384, sg[0], sg[1], ra, rb); // Adjust the actual position to account for the gizmo handle position float d = ra[p_idx] + 0.25; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } origin[p_idx] = d; @@ -2635,7 +2636,7 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i } } -void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); @@ -2647,7 +2648,7 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Probe Extents")); ur->add_do_method(probe, "set_extents", probe->get_extents()); ur->add_do_method(probe, "set_origin_offset", probe->get_origin_offset()); @@ -2656,7 +2657,7 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int ur->commit_action(); } -void ReflectionProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); @@ -2718,7 +2719,143 @@ void ReflectionProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_unscaled_billboard(icon, 0.05); p_gizmo->add_handles(handles, get_material("handles")); } +/////////////////////////////// +//// + +DecalGizmoPlugin::DecalGizmoPlugin() { + Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/decal", Color(0.6, 0.5, 1.0)); + + create_material("decal_material", gizmo_color); + + create_handle_material("handles"); +} + +bool DecalGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Decal>(p_spatial) != nullptr; +} + +String DecalGizmoPlugin::get_name() const { + return "Decal"; +} + +int DecalGizmoPlugin::get_priority() const { + return -1; +} + +String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { + + switch (p_idx) { + case 0: return "Extents X"; + case 1: return "Extents Y"; + case 2: return "Extents Z"; + } + + return ""; +} +Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { + + Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); + return decal->get_extents(); +} +void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { + + Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); + Transform gt = decal->get_global_transform(); + + Transform gi = gt.affine_inverse(); + + Vector3 extents = decal->get_extents(); + + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + + Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 16384) }; + + Vector3 axis; + axis[p_idx] = 1.0; + + Vector3 ra, rb; + Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); + float d = ra[p_idx]; + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); + } + + if (d < 0.001) + d = 0.001; + + extents[p_idx] = d; + decal->set_extents(extents); +} + +void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { + + Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); + + Vector3 restore = p_restore; + + if (p_cancel) { + decal->set_extents(restore); + return; + } + + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Change Decal Extents")); + ur->add_do_method(decal, "set_extents", decal->get_extents()); + ur->add_undo_method(decal, "set_extents", restore); + ur->commit_action(); +} + +void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + + Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); + + p_gizmo->clear(); + + Vector<Vector3> lines; + Vector3 extents = decal->get_extents(); + + AABB aabb; + aabb.position = -extents; + aabb.size = extents * 2; + + for (int i = 0; i < 12; i++) { + Vector3 a, b; + aabb.get_edge(i, a, b); + if (a.y == b.y) { + lines.push_back(a); + lines.push_back(b); + } else { + Vector3 ah = a.linear_interpolate(b, 0.2); + lines.push_back(a); + lines.push_back(ah); + Vector3 bh = b.linear_interpolate(a, 0.2); + lines.push_back(b); + lines.push_back(bh); + } + } + + lines.push_back(Vector3(0, extents.y, 0)); + lines.push_back(Vector3(0, extents.y * 1.2, 0)); + + Vector<Vector3> handles; + + for (int i = 0; i < 3; i++) { + + Vector3 ax; + ax[i] = aabb.position[i] + aabb.size[i]; + handles.push_back(ax); + } + + Ref<Material> material = get_material("decal_material", p_gizmo); + + p_gizmo->add_lines(lines, material); + + p_gizmo->add_handles(handles, get_material("handles")); +} + +/////////////////////////////// GIProbeGizmoPlugin::GIProbeGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/gi_probe", Color(0.5, 1, 0.6)); @@ -2731,12 +2868,12 @@ GIProbeGizmoPlugin::GIProbeGizmoPlugin() { gizmo_color.a = 0.05; create_material("gi_probe_solid_material", gizmo_color); - create_icon_material("gi_probe_icon", SpatialEditor::get_singleton()->get_icon("GizmoGIProbe", "EditorIcons")); + create_icon_material("gi_probe_icon", Node3DEditor::get_singleton()->get_theme_icon("GizmoGIProbe", "EditorIcons")); create_handle_material("handles"); } -bool GIProbeGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<GIProbe>(p_spatial) != NULL; +bool GIProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<GIProbe>(p_spatial) != nullptr; } String GIProbeGizmoPlugin::get_name() const { @@ -2747,7 +2884,7 @@ int GIProbeGizmoPlugin::get_priority() const { return -1; } -String GIProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Extents X"; @@ -2757,12 +2894,12 @@ String GIProbeGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, in return ""; } -Variant GIProbeGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); return probe->get_extents(); } -void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); @@ -2782,8 +2919,8 @@ void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Came Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -2793,7 +2930,7 @@ void GIProbeGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Came probe->set_extents(extents); } -void GIProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); @@ -2804,14 +2941,14 @@ void GIProbeGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, c return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Probe Extents")); ur->add_do_method(probe, "set_extents", probe->get_extents()); ur->add_undo_method(probe, "set_extents", restore); ur->commit_action(); } -void GIProbeGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); @@ -2911,11 +3048,11 @@ BakedIndirectLightGizmoPlugin::BakedIndirectLightGizmoPlugin() { gizmo_color.a = 0.1; create_material("baked_indirect_light_internal_material", gizmo_color); - create_icon_material("baked_indirect_light_icon", SpatialEditor::get_singleton()->get_icon("GizmoBakedLightmap", "EditorIcons")); + create_icon_material("baked_indirect_light_icon", Node3DEditor::get_singleton()->get_icon("GizmoBakedLightmap", "EditorIcons")); create_handle_material("handles"); } -String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Extents X"; @@ -2925,12 +3062,12 @@ String BakedIndirectLightGizmoPlugin::get_handle_name(const EditorSpatialGizmo * return ""; } -Variant BakedIndirectLightGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant BakedIndirectLightGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); return baker->get_extents(); } -void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void BakedIndirectLightGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); @@ -2950,8 +3087,8 @@ void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 16384, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -2961,7 +3098,7 @@ void BakedIndirectLightGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int baker->set_extents(extents); } -void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void BakedIndirectLightGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); @@ -2972,7 +3109,7 @@ void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, i return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Probe Extents")); ur->add_do_method(baker, "set_extents", baker->get_extents()); ur->add_undo_method(baker, "set_extents", restore); @@ -2980,7 +3117,7 @@ void BakedIndirectLightGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, i } bool BakedIndirectLightGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<BakedLightmap>(p_spatial) != NULL; + return Object::cast_to<BakedLightmap>(p_spatial) != nullptr; } String BakedIndirectLightGizmoPlugin::get_name() const { @@ -2991,7 +3128,7 @@ int BakedIndirectLightGizmoPlugin::get_priority() const { return -1; } -void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void BakedIndirectLightGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); @@ -3034,7 +3171,7 @@ void BakedIndirectLightGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { #endif //// -CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() { +CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() { const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); @@ -3043,47 +3180,47 @@ CollisionShapeSpatialGizmoPlugin::CollisionShapeSpatialGizmoPlugin() { create_handle_material("handles"); } -bool CollisionShapeSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<CollisionShape>(p_spatial) != NULL; +bool CollisionShape3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<CollisionShape3D>(p_spatial) != nullptr; } -String CollisionShapeSpatialGizmoPlugin::get_name() const { - return "CollisionShape"; +String CollisionShape3DGizmoPlugin::get_name() const { + return "CollisionShape3D"; } -int CollisionShapeSpatialGizmoPlugin::get_priority() const { +int CollisionShape3DGizmoPlugin::get_priority() const { return -1; } -String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const { +String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - const CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node()); + const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); - Ref<Shape> s = cs->get_shape(); + Ref<Shape3D> s = cs->get_shape(); if (s.is_null()) return ""; - if (Object::cast_to<SphereShape>(*s)) { + if (Object::cast_to<SphereShape3D>(*s)) { return "Radius"; } - if (Object::cast_to<BoxShape>(*s)) { + if (Object::cast_to<BoxShape3D>(*s)) { return "Extents"; } - if (Object::cast_to<CapsuleShape>(*s)) { + if (Object::cast_to<CapsuleShape3D>(*s)) { return p_idx == 0 ? "Radius" : "Height"; } - if (Object::cast_to<CylinderShape>(*s)) { + if (Object::cast_to<CylinderShape3D>(*s)) { return p_idx == 0 ? "Radius" : "Height"; } - if (Object::cast_to<RayShape>(*s)) { + if (Object::cast_to<RayShape3D>(*s)) { return "Length"; } @@ -3091,51 +3228,51 @@ String CollisionShapeSpatialGizmoPlugin::get_handle_name(const EditorSpatialGizm return ""; } -Variant CollisionShapeSpatialGizmoPlugin::get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const { +Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node()); + CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); - Ref<Shape> s = cs->get_shape(); + Ref<Shape3D> s = cs->get_shape(); if (s.is_null()) return Variant(); - if (Object::cast_to<SphereShape>(*s)) { + if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape> ss = s; + Ref<SphereShape3D> ss = s; return ss->get_radius(); } - if (Object::cast_to<BoxShape>(*s)) { + if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape> bs = s; + Ref<BoxShape3D> bs = s; return bs->get_extents(); } - if (Object::cast_to<CapsuleShape>(*s)) { + if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape> cs2 = s; + Ref<CapsuleShape3D> cs2 = s; return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); } - if (Object::cast_to<CylinderShape>(*s)) { + if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape> cs2 = s; + Ref<CylinderShape3D> cs2 = s; return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); } - if (Object::cast_to<RayShape>(*s)) { + if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape> cs2 = s; + Ref<RayShape3D> cs2 = s; return cs2->get_length(); } return Variant(); } -void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point) { +void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node()); + CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); - Ref<Shape> s = cs->get_shape(); + Ref<Shape3D> s = cs->get_shape(); if (s.is_null()) return; @@ -3147,14 +3284,14 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; - if (Object::cast_to<SphereShape>(*s)) { + if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape> ss = s; + Ref<SphereShape3D> ss = s; Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), Vector3(4096, 0, 0), sg[0], sg[1], ra, rb); float d = ra.x; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -3163,14 +3300,14 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i ss->set_radius(d); } - if (Object::cast_to<RayShape>(*s)) { + if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape> rs = s; + Ref<RayShape3D> rs = s; Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), Vector3(0, 0, 4096), sg[0], sg[1], ra, rb); float d = ra.z; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -3179,16 +3316,16 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i rs->set_length(d); } - if (Object::cast_to<BoxShape>(*s)) { + if (Object::cast_to<BoxShape3D>(*s)) { Vector3 axis; axis[p_idx] = 1.0; - Ref<BoxShape> bs = s; + Ref<BoxShape3D> bs = s; Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = ra[p_idx]; - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -3199,19 +3336,19 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i bs->set_extents(he); } - if (Object::cast_to<CapsuleShape>(*s)) { + if (Object::cast_to<CapsuleShape3D>(*s)) { Vector3 axis; axis[p_idx == 0 ? 0 : 2] = 1.0; - Ref<CapsuleShape> cs2 = s; + Ref<CapsuleShape3D> cs2 = s; Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); if (p_idx == 1) d -= cs2->get_radius(); - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -3223,16 +3360,16 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i cs2->set_height(d * 2.0); } - if (Object::cast_to<CylinderShape>(*s)) { + if (Object::cast_to<CylinderShape3D>(*s)) { Vector3 axis; axis[p_idx == 0 ? 0 : 1] = 1.0; - Ref<CylinderShape> cs2 = s; + Ref<CylinderShape3D> cs2 = s; Vector3 ra, rb; Geometry::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb); float d = axis.dot(ra); - if (SpatialEditor::get_singleton()->is_snap_enabled()) { - d = Math::stepify(d, SpatialEditor::get_singleton()->get_translate_snap()); + if (Node3DEditor::get_singleton()->is_snap_enabled()) { + d = Math::stepify(d, Node3DEditor::get_singleton()->get_translate_snap()); } if (d < 0.001) @@ -3244,47 +3381,47 @@ void CollisionShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, i cs2->set_height(d * 2.0); } } -void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { +void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node()); + CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); - Ref<Shape> s = cs->get_shape(); + Ref<Shape3D> s = cs->get_shape(); if (s.is_null()) return; - if (Object::cast_to<SphereShape>(*s)) { + if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape> ss = s; + Ref<SphereShape3D> ss = s; if (p_cancel) { ss->set_radius(p_restore); return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Sphere Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); ur->add_undo_method(ss.ptr(), "set_radius", p_restore); ur->commit_action(); } - if (Object::cast_to<BoxShape>(*s)) { + if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape> ss = s; + Ref<BoxShape3D> ss = s; if (p_cancel) { ss->set_extents(p_restore); return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Box Shape Extents")); ur->add_do_method(ss.ptr(), "set_extents", ss->get_extents()); ur->add_undo_method(ss.ptr(), "set_extents", p_restore); ur->commit_action(); } - if (Object::cast_to<CapsuleShape>(*s)) { + if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape> ss = s; + Ref<CapsuleShape3D> ss = s; if (p_cancel) { if (p_idx == 0) ss->set_radius(p_restore); @@ -3293,7 +3430,7 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); if (p_idx == 0) { ur->create_action(TTR("Change Capsule Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); @@ -3307,9 +3444,9 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo ur->commit_action(); } - if (Object::cast_to<CylinderShape>(*s)) { + if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape> ss = s; + Ref<CylinderShape3D> ss = s; if (p_cancel) { if (p_idx == 0) ss->set_radius(p_restore); @@ -3318,7 +3455,7 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); if (p_idx == 0) { ur->create_action(TTR("Change Cylinder Shape Radius")); ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius()); @@ -3336,28 +3473,28 @@ void CollisionShapeSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo ur->commit_action(); } - if (Object::cast_to<RayShape>(*s)) { + if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape> ss = s; + Ref<RayShape3D> ss = s; if (p_cancel) { ss->set_length(p_restore); return; } - UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Ray Shape Length")); ur->add_do_method(ss.ptr(), "set_length", ss->get_length()); ur->add_undo_method(ss.ptr(), "set_length", p_restore); ur->commit_action(); } } -void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - CollisionShape *cs = Object::cast_to<CollisionShape>(p_gizmo->get_spatial_node()); + CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); - Ref<Shape> s = cs->get_shape(); + Ref<Shape3D> s = cs->get_shape(); if (s.is_null()) return; @@ -3365,9 +3502,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { get_material(!cs->is_disabled() ? "shape_material" : "shape_material_disabled", p_gizmo); Ref<Material> handles_material = get_material("handles"); - if (Object::cast_to<SphereShape>(*s)) { + if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape> sp = s; + Ref<SphereShape3D> sp = s; float r = sp->get_radius(); Vector<Vector3> points; @@ -3411,9 +3548,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<BoxShape>(*s)) { + if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape> bs = s; + Ref<BoxShape3D> bs = s; Vector<Vector3> lines; AABB aabb; aabb.position = -bs->get_extents(); @@ -3440,9 +3577,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<CapsuleShape>(*s)) { + if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape> cs2 = s; + Ref<CapsuleShape3D> cs2 = s; float radius = cs2->get_radius(); float height = cs2->get_height(); @@ -3515,9 +3652,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<CylinderShape>(*s)) { + if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape> cs2 = s; + Ref<CylinderShape3D> cs2 = s; float radius = cs2->get_radius(); float height = cs2->get_height(); @@ -3576,9 +3713,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<WorldMarginShape>(*s)) { + if (Object::cast_to<WorldMarginShape3D>(*s)) { - Ref<WorldMarginShape> ps = s; + Ref<WorldMarginShape3D> ps = s; Plane p = ps->get_plane(); Vector<Vector3> points; @@ -3607,9 +3744,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_collision_segments(points); } - if (Object::cast_to<ConvexPolygonShape>(*s)) { + if (Object::cast_to<ConvexPolygonShape3D>(*s)) { - Vector<Vector3> points = Object::cast_to<ConvexPolygonShape>(*s)->get_points(); + Vector<Vector3> points = Object::cast_to<ConvexPolygonShape3D>(*s)->get_points(); if (points.size() > 3) { @@ -3630,17 +3767,17 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } } - if (Object::cast_to<ConcavePolygonShape>(*s)) { + if (Object::cast_to<ConcavePolygonShape3D>(*s)) { - Ref<ConcavePolygonShape> cs2 = s; + Ref<ConcavePolygonShape3D> cs2 = s; Ref<ArrayMesh> mesh = cs2->get_debug_mesh(); p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); p_gizmo->add_collision_segments(cs2->get_debug_mesh_lines()); } - if (Object::cast_to<RayShape>(*s)) { + if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape> rs = s; + Ref<RayShape3D> rs = s; Vector<Vector3> points; points.push_back(Vector3()); @@ -3652,9 +3789,9 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_handles(handles, handles_material); } - if (Object::cast_to<HeightMapShape>(*s)) { + if (Object::cast_to<HeightMapShape3D>(*s)) { - Ref<HeightMapShape> hms = s; + Ref<HeightMapShape3D> hms = s; Ref<ArrayMesh> mesh = hms->get_debug_mesh(); p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); @@ -3663,7 +3800,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { ///// -CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() { +CollisionPolygon3DGizmoPlugin::CollisionPolygon3DGizmoPlugin() { const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); @@ -3671,21 +3808,21 @@ CollisionPolygonSpatialGizmoPlugin::CollisionPolygonSpatialGizmoPlugin() { create_material("shape_material_disabled", gizmo_color_disabled); } -bool CollisionPolygonSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<CollisionPolygon>(p_spatial) != NULL; +bool CollisionPolygon3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<CollisionPolygon3D>(p_spatial) != nullptr; } -String CollisionPolygonSpatialGizmoPlugin::get_name() const { - return "CollisionPolygon"; +String CollisionPolygon3DGizmoPlugin::get_name() const { + return "CollisionPolygon3D"; } -int CollisionPolygonSpatialGizmoPlugin::get_priority() const { +int CollisionPolygon3DGizmoPlugin::get_priority() const { return -1; } -void CollisionPolygonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - CollisionPolygon *polygon = Object::cast_to<CollisionPolygon>(p_gizmo->get_spatial_node()); + CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -3713,28 +3850,28 @@ void CollisionPolygonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { //// -NavigationMeshSpatialGizmoPlugin::NavigationMeshSpatialGizmoPlugin() { +NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() { create_material("navigation_edge_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge", Color(0.5, 1, 1))); create_material("navigation_edge_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_edge_disabled", Color(0.7, 0.7, 0.7))); create_material("navigation_solid_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid", Color(0.5, 1, 1, 0.4))); create_material("navigation_solid_material_disabled", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/navigation_solid_disabled", Color(0.7, 0.7, 0.7, 0.4))); } -bool NavigationMeshSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<NavigationRegion>(p_spatial) != NULL; +bool NavigationRegion3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<NavigationRegion3D>(p_spatial) != nullptr; } -String NavigationMeshSpatialGizmoPlugin::get_name() const { - return "NavigationRegion"; +String NavigationRegion3DGizmoPlugin::get_name() const { + return "NavigationRegion3D"; } -int NavigationMeshSpatialGizmoPlugin::get_priority() const { +int NavigationRegion3DGizmoPlugin::get_priority() const { return -1; } -void NavigationMeshSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { +void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - NavigationRegion *navmesh = Object::cast_to<NavigationRegion>(p_gizmo->get_spatial_node()); + NavigationRegion3D *navmesh = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node()); Ref<Material> edge_material = get_material("navigation_edge_material", p_gizmo); Ref<Material> edge_material_disabled = get_material("navigation_edge_material_disabled", p_gizmo); @@ -4078,37 +4215,37 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base //// -JointSpatialGizmoPlugin::JointSpatialGizmoPlugin() { +Joint3DGizmoPlugin::Joint3DGizmoPlugin() { create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1))); create_material("joint_body_a_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_a", Color(0.6, 0.8, 1))); create_material("joint_body_b_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_b", Color(0.6, 0.9, 1))); } -bool JointSpatialGizmoPlugin::has_gizmo(Spatial *p_spatial) { - return Object::cast_to<Joint>(p_spatial) != NULL; +bool Joint3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to<Joint3D>(p_spatial) != nullptr; } -String JointSpatialGizmoPlugin::get_name() const { - return "Joints"; +String Joint3DGizmoPlugin::get_name() const { + return "Joint3D"; } -int JointSpatialGizmoPlugin::get_priority() const { +int Joint3DGizmoPlugin::get_priority() const { return -1; } -void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - Joint *joint = Object::cast_to<Joint>(p_gizmo->get_spatial_node()); +void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + Joint3D *joint = Object::cast_to<Joint3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); - Spatial *node_body_a = NULL; + Node3D *node_body_a = nullptr; if (!joint->get_node_a().is_empty()) { - node_body_a = Object::cast_to<Spatial>(joint->get_node(joint->get_node_a())); + node_body_a = Object::cast_to<Node3D>(joint->get_node(joint->get_node_a())); } - Spatial *node_body_b = NULL; + Node3D *node_body_b = nullptr; if (!joint->get_node_b().is_empty()) { - node_body_b = Object::cast_to<Spatial>(joint->get_node(joint->get_node_b())); + node_body_b = Object::cast_to<Node3D>(joint->get_node(joint->get_node_b())); } if (!node_body_a && !node_body_b) { @@ -4123,13 +4260,13 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Vector<Vector3> body_a_points; Vector<Vector3> body_b_points; - if (Object::cast_to<PinJoint>(joint)) { + if (Object::cast_to<PinJoint3D>(joint)) { CreatePinJointGizmo(Transform(), points); p_gizmo->add_collision_segments(points); p_gizmo->add_lines(points, common_material); } - HingeJoint *hinge = Object::cast_to<HingeJoint>(joint); + HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint); if (hinge) { CreateHingeJointGizmo( @@ -4137,12 +4274,12 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { hinge->get_global_transform(), node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform(), - hinge->get_param(HingeJoint::PARAM_LIMIT_LOWER), - hinge->get_param(HingeJoint::PARAM_LIMIT_UPPER), - hinge->get_flag(HingeJoint::FLAG_USE_LIMIT), + hinge->get_param(HingeJoint3D::PARAM_LIMIT_LOWER), + hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER), + hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT), points, - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); @@ -4153,7 +4290,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(body_b_points, body_b_material); } - SliderJoint *slider = Object::cast_to<SliderJoint>(joint); + SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint); if (slider) { CreateSliderJointGizmo( @@ -4161,13 +4298,13 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { slider->get_global_transform(), node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform(), - slider->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_LOWER), - slider->get_param(SliderJoint::PARAM_ANGULAR_LIMIT_UPPER), - slider->get_param(SliderJoint::PARAM_LINEAR_LIMIT_LOWER), - slider->get_param(SliderJoint::PARAM_LINEAR_LIMIT_UPPER), + slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_LOWER), + slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_UPPER), + slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER), + slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_UPPER), points, - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); @@ -4178,7 +4315,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(body_b_points, body_b_material); } - ConeTwistJoint *cone = Object::cast_to<ConeTwistJoint>(joint); + ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint); if (cone) { CreateConeTwistJointGizmo( @@ -4186,10 +4323,10 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { cone->get_global_transform(), node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform(), - cone->get_param(ConeTwistJoint::PARAM_SWING_SPAN), - cone->get_param(ConeTwistJoint::PARAM_TWIST_SPAN), - node_body_a ? &body_a_points : NULL, - node_body_b ? &body_b_points : NULL); + cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN), + cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN), + node_body_a ? &body_a_points : nullptr, + node_body_b ? &body_b_points : nullptr); p_gizmo->add_collision_segments(body_a_points); p_gizmo->add_collision_segments(body_b_points); @@ -4198,7 +4335,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->add_lines(body_b_points, body_b_material); } - Generic6DOFJoint *gen = Object::cast_to<Generic6DOFJoint>(joint); + Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint); if (gen) { CreateGeneric6DOFJointGizmo( @@ -4207,30 +4344,30 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { node_body_a ? node_body_a->get_global_transform() : Transform(), node_body_b ? node_body_b->get_global_transform() : Transform(), - gen->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT), - gen->get_param_x(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT), - gen->get_param_x(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT), - gen->get_param_x(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT), - gen->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT), - gen->get_flag_x(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT), - - gen->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT), - gen->get_param_y(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT), - gen->get_param_y(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT), - gen->get_param_y(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT), - gen->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT), - gen->get_flag_y(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT), - - gen->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_LOWER_LIMIT), - gen->get_param_z(Generic6DOFJoint::PARAM_ANGULAR_UPPER_LIMIT), - gen->get_param_z(Generic6DOFJoint::PARAM_LINEAR_LOWER_LIMIT), - gen->get_param_z(Generic6DOFJoint::PARAM_LINEAR_UPPER_LIMIT), - gen->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_ANGULAR_LIMIT), - gen->get_flag_z(Generic6DOFJoint::FLAG_ENABLE_LINEAR_LIMIT), + gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT), + gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT), + gen->get_param_x(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT), + gen->get_param_x(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT), + gen->get_flag_x(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT), + gen->get_flag_x(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT), + + gen->get_param_y(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT), + gen->get_param_y(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT), + gen->get_param_y(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT), + gen->get_param_y(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT), + gen->get_flag_y(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT), + gen->get_flag_y(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT), + + gen->get_param_z(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT), + gen->get_param_z(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT), + gen->get_param_z(Generic6DOFJoint3D::PARAM_LINEAR_LOWER_LIMIT), + gen->get_param_z(Generic6DOFJoint3D::PARAM_LINEAR_UPPER_LIMIT), + gen->get_flag_z(Generic6DOFJoint3D::FLAG_ENABLE_ANGULAR_LIMIT), + gen->get_flag_z(Generic6DOFJoint3D::FLAG_ENABLE_LINEAR_LIMIT), points, - node_body_a ? &body_a_points : NULL, - node_body_a ? &body_b_points : NULL); + node_body_a ? &body_a_points : nullptr, + node_body_a ? &body_b_points : nullptr); p_gizmo->add_collision_segments(points); p_gizmo->add_collision_segments(body_a_points); @@ -4242,7 +4379,7 @@ void JointSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } } -void JointSpatialGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) { +void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) { float cs = 0.25; r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin); @@ -4253,7 +4390,7 @@ void JointSpatialGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vec r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin); } -void JointSpatialGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin); r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin); @@ -4285,7 +4422,7 @@ void JointSpatialGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, c } } -void JointSpatialGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { p_linear_limit_lower = -p_linear_limit_lower; p_linear_limit_upper = -p_linear_limit_upper; @@ -4345,7 +4482,7 @@ void JointSpatialGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, true); } -void JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { if (r_body_a_points) JointGizmosDrawer::draw_cone( @@ -4364,7 +4501,7 @@ void JointSpatialGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offse *r_body_b_points); } -void JointSpatialGizmoPlugin::CreateGeneric6DOFJointGizmo( +void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h new file mode 100644 index 0000000000..8bc52b6ba9 --- /dev/null +++ b/editor/node_3d_editor_gizmos.h @@ -0,0 +1,452 @@ +/*************************************************************************/ +/* node_3d_editor_gizmos.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef SPATIAL_EDITOR_GIZMOS_H +#define SPATIAL_EDITOR_GIZMOS_H + +#include "editor/plugins/node_3d_editor_plugin.h" +#include "scene/3d/camera_3d.h" + +class Camera3D; + +class Light3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Light3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + void redraw(EditorNode3DGizmo *p_gizmo); + + Light3DGizmoPlugin(); +}; + +class AudioStreamPlayer3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(AudioStreamPlayer3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + void redraw(EditorNode3DGizmo *p_gizmo); + + AudioStreamPlayer3DGizmoPlugin(); +}; + +class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + void redraw(EditorNode3DGizmo *p_gizmo); + + Camera3DGizmoPlugin(); +}; + +class MeshInstance3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(MeshInstance3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + bool can_be_hidden() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + MeshInstance3DGizmoPlugin(); +}; + +class Sprite3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Sprite3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + bool can_be_hidden() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + Sprite3DGizmoPlugin(); +}; + +class Position3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Position3DGizmoPlugin, EditorNode3DGizmoPlugin); + + Ref<ArrayMesh> pos3d_mesh; + Vector<Vector3> cursor_points; + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + Position3DGizmoPlugin(); +}; + +class Skeleton3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Skeleton3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + Skeleton3DGizmoPlugin(); +}; + +class PhysicalBone3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(PhysicalBone3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + PhysicalBone3DGizmoPlugin(); +}; + +class RayCast3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(RayCast3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + RayCast3DGizmoPlugin(); +}; + +class SpringArm3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(SpringArm3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + SpringArm3DGizmoPlugin(); +}; + +class VehicleWheel3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(VehicleWheel3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + VehicleWheel3DGizmoPlugin(); +}; + +class SoftBody3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(SoftBody3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + bool is_selectable_when_hidden() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel); + bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const; + + SoftBody3DGizmoPlugin(); +}; + +class VisibilityNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(VisibilityNotifier3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + VisibilityNotifier3DGizmoPlugin(); +}; + +class CPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(CPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + bool is_selectable_when_hidden() const; + void redraw(EditorNode3DGizmo *p_gizmo); + CPUParticles3DGizmoPlugin(); +}; + +class GPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(GPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + bool is_selectable_when_hidden() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + GPUParticles3DGizmoPlugin(); +}; + +class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(ReflectionProbeGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + ReflectionProbeGizmoPlugin(); +}; + +class DecalGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(DecalGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + DecalGizmoPlugin(); +}; + +class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + GIProbeGizmoPlugin(); +}; + +#if 0 +class BakedIndirectLightGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(BakedIndirectLightGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Spatial *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + BakedIndirectLightGizmoPlugin(); +}; +#endif +class CollisionShape3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(CollisionShape3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const; + Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const; + void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point); + void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); + + CollisionShape3DGizmoPlugin(); +}; + +class CollisionPolygon3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(CollisionPolygon3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + CollisionPolygon3DGizmoPlugin(); +}; + +class NavigationRegion3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(NavigationRegion3DGizmoPlugin, EditorNode3DGizmoPlugin); + + struct _EdgeKey { + + Vector3 from; + Vector3 to; + + bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; } + }; + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + NavigationRegion3DGizmoPlugin(); +}; + +class JointGizmosDrawer { +public: + static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform); + static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform); + static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform); + static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform); + /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis + /// with axis X and Y that are looking toward the body and oriented toward up + static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform); + + // Draw circle around p_axis + static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); + static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); +}; + +class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { + + GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin); + +public: + bool has_gizmo(Node3D *p_spatial); + String get_name() const; + int get_priority() const; + void redraw(EditorNode3DGizmo *p_gizmo); + + static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points); + static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreateGeneric6DOFJointGizmo( + const Transform &p_offset, + const Transform &p_trs_joint, + const Transform &p_trs_body_a, + const Transform &p_trs_body_b, + real_t p_angular_limit_lower_x, + real_t p_angular_limit_upper_x, + real_t p_linear_limit_lower_x, + real_t p_linear_limit_upper_x, + bool p_enable_angular_limit_x, + bool p_enable_linear_limit_x, + real_t p_angular_limit_lower_y, + real_t p_angular_limit_upper_y, + real_t p_linear_limit_lower_y, + real_t p_linear_limit_upper_y, + bool p_enable_angular_limit_y, + bool p_enable_linear_limit_y, + real_t p_angular_limit_lower_z, + real_t p_angular_limit_upper_z, + real_t p_linear_limit_lower_z, + real_t p_linear_limit_upper_z, + bool p_enable_angular_limit_z, + bool p_enable_linear_limit_z, + Vector<Vector3> &r_points, + Vector<Vector3> *r_body_a_points, + Vector<Vector3> *r_body_b_points); + + Joint3DGizmoPlugin(); +}; + +#endif // SPATIAL_EDITOR_GIZMOS_H diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index 3013406152..a076b1eecc 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -55,12 +55,12 @@ void NodeDock::_bind_methods() { void NodeDock::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - connections_button->set_icon(get_icon("Signals", "EditorIcons")); - groups_button->set_icon(get_icon("Groups", "EditorIcons")); + connections_button->set_icon(get_theme_icon("Signals", "EditorIcons")); + groups_button->set_icon(get_theme_icon("Groups", "EditorIcons")); } } -NodeDock *NodeDock::singleton = NULL; +NodeDock *NodeDock::singleton = nullptr; void NodeDock::update_lists() { diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index b143f86ada..ce90fa94dc 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -45,7 +45,7 @@ void PaneDrag::_notification(int p_what) { case NOTIFICATION_DRAW: { - Ref<Texture2D> icon = mouse_over ? get_icon("PaneDragHover", "EditorIcons") : get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = mouse_over ? get_theme_icon("PaneDragHover", "EditorIcons") : get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) icon->draw(get_canvas_item(), Point2(0, 0)); @@ -62,7 +62,7 @@ void PaneDrag::_notification(int p_what) { } Size2 PaneDrag::get_minimum_size() const { - Ref<Texture2D> icon = get_icon("PaneDrag", "EditorIcons"); + Ref<Texture2D> icon = get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) return icon->get_size(); return Size2(); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 1e7c625abb..4317a5e80f 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -131,14 +131,15 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { void PluginConfigDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (is_visible()) { + name_edit->grab_focus(); + } + } break; case NOTIFICATION_READY: { connect("confirmed", callable_mp(this, &PluginConfigDialog::_on_confirmed)); get_cancel()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled)); } break; - - case NOTIFICATION_POST_POPUP: { - name_edit->grab_focus(); - } break; } } 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 5e53adf471..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); } } @@ -536,7 +536,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano updating = true; Set<String> paths; - HashMap<String, Set<String> > types; + HashMap<String, Set<String>> types; { List<StringName> animations; player->get_animation_list(&animations); @@ -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 5629e3854d..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); @@ -2028,10 +2035,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (m.is_valid()) { // Save the ik chain for reapplying before IK solve - Vector<List<Dictionary> > all_bones_ik_states; + 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; @@ -2130,10 +2137,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (drag_selection.size() > 0) { // Save the ik chain for reapplying before IK solve - Vector<List<Dictionary> > all_bones_ik_states; + 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) { @@ -4306,10 +4319,20 @@ void CanvasItemEditor::_zoom_on_position(float p_zoom, Point2 p_position) { float prev_zoom = zoom; zoom = p_zoom; - Point2 ofs = p_position; - ofs = ofs / prev_zoom - ofs / zoom; - view_offset.x = Math::round(view_offset.x + ofs.x); - view_offset.y = Math::round(view_offset.y + ofs.y); + + view_offset += p_position / prev_zoom - p_position / zoom; + + // We want to align in-scene pixels to screen pixels, this prevents blurry rendering + // in small details (texts, lines). + // This correction adds a jitter movement when zooming, so we correct only when the + // zoom factor is an integer. (in the other cases, all pixels won't be aligned anyway) + float closest_zoom_factor = Math::round(zoom); + if (Math::is_zero_approx(zoom - closest_zoom_factor)) { + // make sure scene pixel at view_offset is aligned on a screen pixel + Vector2 view_offset_int = view_offset.floor(); + Vector2 view_offset_frac = view_offset - view_offset_int; + view_offset = view_offset_int + (view_offset_frac * closest_zoom_factor).round() / closest_zoom_factor; + } _update_zoom_label(); update_viewport(); @@ -4901,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; @@ -5410,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); @@ -5435,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)); @@ -5452,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); @@ -5467,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); @@ -5773,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)); @@ -5790,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) { @@ -5808,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); } } @@ -5876,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); @@ -5943,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) { @@ -6039,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; } @@ -6054,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); @@ -6069,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") @@ -6084,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); } @@ -6100,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(); } } @@ -6166,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 { @@ -6181,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; @@ -6199,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; } } @@ -6223,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)); @@ -6237,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; @@ -6261,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); @@ -6283,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 e5b948aad7..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 71976d509b..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()) @@ -170,7 +170,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, if (1) { - Vector<Ref<Mesh> > meshes; + Vector<Ref<Mesh>> meshes; Vector<Transform> transforms; Vector<int> ids = p_library->get_item_list(); for (int i = 0; i < ids.size(); i++) { @@ -182,7 +182,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, } } - Vector<Ref<Texture2D> > textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); + Vector<Ref<Texture2D>> textures = EditorInterface::get_singleton()->make_mesh_previews(meshes, &transforms, EditorSettings::get_singleton()->get("editors/grid_map/preview_size")); int j = 0; for (int i = 0; i < ids.size(); i++) { @@ -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 a71cb50db4..354c951a7c 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,15 +2273,15 @@ 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; @@ -2325,22 +2326,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 +2367,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 +2386,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 +2409,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 +2437,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 +2472,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 +2513,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 +2571,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 +2588,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 +2631,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 +2646,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 +2654,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 +2666,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 +2676,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 +2692,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 +2731,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 +2749,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 +2843,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 +2879,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 +2903,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 +2967,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 +2983,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 +3013,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 +3033,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 +3053,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 +3073,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 +3100,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 +3186,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 +3212,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 +3220,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 +3240,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 +3251,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 +3276,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 +3357,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 +3374,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 +3394,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 +3420,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 +3436,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 +3447,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 +3475,7 @@ void SpatialEditorViewport::reset() { _update_name(); } -void SpatialEditorViewport::focus_selection() { +void Node3DEditorViewport::focus_selection() { if (!get_selected_count()) return; @@ -3445,11 +3486,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 +3505,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 +3527,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 +3542,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 +3568,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 +3589,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 +3600,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 +3626,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 +3637,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 +3652,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 +3676,7 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - if (instanced_scene == NULL) { + if (instanced_scene == nullptr) { return false; } @@ -3646,7 +3687,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 +3702,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 +3713,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 +3728,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 +3745,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 +3806,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 +3825,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 +3846,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 +3871,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 +3885,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 +3929,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 +3953,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 +3970,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 +4009,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 +4030,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 +4076,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 +4095,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 +4109,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 +4160,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 +4193,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 +4203,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 +4289,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 +4308,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 +4408,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 +4439,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 +4459,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 +4470,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 +4505,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 +4514,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 +4570,7 @@ void SpatialEditor::_generate_selection_box() { selection_box = st->commit(); } -Dictionary SpatialEditor::get_state() const { +Dictionary Node3DEditor::get_state() const { Dictionary d; @@ -4570,7 +4621,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 +4695,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 +4706,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 +4720,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 +4737,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 +4746,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 +4784,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 +4809,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 +4838,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 +4846,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 +4862,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 +4875,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 +4891,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 +4925,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 +4937,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 +4949,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 +4961,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 +4973,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 +4985,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 +5000,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 +5015,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 +5037,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 +5061,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 +5085,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 +5108,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 +5128,7 @@ void SpatialEditor::_menu_item_pressed(int p_option) { } } -void SpatialEditor::_init_indicators() { +void Node3DEditor::_init_indicators() { { origin_enabled = true; @@ -5097,13 +5148,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 +5175,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 +5199,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 +5465,7 @@ void SpatialEditor::_init_indicators() { _generate_selection_box(); } -void SpatialEditor::_update_gizmos_menu() { +void Node3DEditor::_update_gizmos_menu() { gizmos_menu->clear(); @@ -5425,39 +5476,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 +5552,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 +5590,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 +5602,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 +5645,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 +5681,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 +5704,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 +5720,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 +5737,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 +5762,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 +5815,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 +5848,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 +5901,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 +5946,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 +5999,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 +6026,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 +6051,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 +6062,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 +6070,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 +6078,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 +6088,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 +6122,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 +6130,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 +6141,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 +6178,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 +6210,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 +6227,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 +6248,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); @@ -6243,6 +6295,10 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500)); 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], &Node3DEditorViewport::_update_camera), varray(0.0)); + } + /* XFORM DIALOG */ xform_dialog = memnew(ConfirmationDialog); @@ -6302,11 +6358,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"); @@ -6320,11 +6376,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) { @@ -6337,31 +6393,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); @@ -6370,9 +6426,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(); @@ -6381,9 +6437,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(); @@ -6392,9 +6448,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(); @@ -6403,19 +6459,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(); } @@ -6425,12 +6481,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); @@ -6440,19 +6496,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); @@ -6460,14 +6516,14 @@ 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)); - Vector<Ref<StandardMaterial3D> > mats; + Vector<Ref<StandardMaterial3D>> mats; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; @@ -6505,11 +6561,11 @@ 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)); - Vector<Ref<StandardMaterial3D> > icons; + Vector<Ref<StandardMaterial3D>> icons; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; @@ -6546,12 +6602,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)); @@ -6564,16 +6620,16 @@ void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool handle_material->set_on_top_of_alpha(); } - materials[p_name] = Vector<Ref<StandardMaterial3D> >(); + materials[p_name] = Vector<Ref<StandardMaterial3D>>(); materials[p_name].push_back(handle_material); } -void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { - materials[p_name] = Vector<Ref<StandardMaterial3D> >(); +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>()); @@ -6592,27 +6648,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; @@ -6624,18 +6680,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")); @@ -6649,7 +6705,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); @@ -6659,103 +6715,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 489bce1e15..2c3b15cfc8 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 { @@ -238,11 +242,16 @@ public: }; 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 +265,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 +293,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 +304,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 +375,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 +427,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 +445,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 +463,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 +472,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 +540,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 +577,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 +587,7 @@ private: ToolMode tool_mode; bool orthogonal; - VisualServer::ScenarioDebugMode scenario_debug; + RenderingServer::ScenarioDebugMode scenario_debug; RID origin; RID origin_instance; @@ -605,7 +618,7 @@ private: Ref<StandardMaterial3D> cursor_material; // Scene drag and drop support - Spatial *preview_node; + Node3D *preview_node; AABB preview_bounds; struct Gizmo { @@ -705,19 +718,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 +744,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 +757,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 +770,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 +789,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 +824,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,13 +837,13 @@ 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; @@ -839,13 +852,13 @@ public: private: int current_state; - List<EditorSpatialGizmo *> current_gizmos; - HashMap<String, Vector<Ref<StandardMaterial3D> > > materials; + 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 +866,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..67e836082d 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); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bb03cad285..0b97ade278 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,16 +961,16 @@ 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; } } Array ScriptEditor::_get_open_scripts() const { Array ret; - Vector<Ref<Script> > scripts = get_open_scripts(); + Vector<Ref<Script>> scripts = get_open_scripts(); int scrits_amount = scripts.size(); for (int idx_script = 0; idx_script < scrits_amount; idx_script++) { ret.push_back(scripts[idx_script]); @@ -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; @@ -1571,7 +1566,7 @@ void ScriptEditor::ensure_select_current() { _update_selected_editor_menu(); } -void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script> > &used) { +void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used) { if (p_current != p_base && p_current->get_owner() != p_base) return; @@ -1704,7 +1699,7 @@ void ScriptEditor::_update_help_overview() { return; } - Vector<Pair<String, int> > sections = se->get_sections(); + Vector<Pair<String, int>> sections = se->get_sections(); for (int i = 0; i < sections.size(); i++) { help_overview->add_item(sections[i].first); help_overview->set_item_metadata(i, sections[i].second); @@ -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++) { @@ -1757,7 +1752,7 @@ void ScriptEditor::_update_script_names() { if (restoring_layout) return; - Set<Ref<Script> > used; + Set<Ref<Script>> used; Node *edited = EditorNode::get_singleton()->get_edited_scene(); if (edited) { _find_scripts(edited, edited, used); @@ -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; @@ -1836,7 +1831,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 +1986,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 +2064,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 +2086,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 +2101,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 +2182,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 +2341,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 +2568,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 +2825,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); } } @@ -2861,9 +2856,9 @@ void ScriptEditor::_history_back() { } } -Vector<Ref<Script> > ScriptEditor::get_open_scripts() const { +Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { - Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >(); + Vector<Ref<Script>> out_scripts = Vector<Ref<Script>>(); for (int i = 0; i < tab_container->get_child_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); @@ -2871,7 +2866,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 +2947,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 +2955,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 +3106,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 +3118,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 +3166,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 +3223,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 +3254,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 +3278,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 +3312,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 +3353,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 b4b4f33fc5..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; @@ -351,7 +349,7 @@ class ScriptEditor : public PanelContainer { void _update_help_overview(); void _help_overview_selected(int p_idx); - void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script> > &used); + void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> &used); void _tree_changed(); @@ -429,7 +427,7 @@ public: void get_window_layout(Ref<ConfigFile> p_layout); void set_scene_root_script(Ref<Script> p_script); - Vector<Ref<Script> > get_open_scripts() const; + Vector<Ref<Script>> get_open_scripts() const; bool script_goto_method(Ref<Script> p_script, const String &p_method); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1489ea1e27..4b8383e1e5 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); } @@ -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,10 +757,10 @@ 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) { +static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_current, Set<Ref<Script>> &r_scripts) { if (p_current->get_owner() != p_base && p_base != p_current) return; @@ -780,14 +781,14 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo ERR_FAIL_COND(!get_tree()); - Set<Ref<Script> > scripts; + Set<Ref<Script>> scripts; Node *base = get_tree()->get_edited_scene_root(); if (base) { _find_changed_scripts_for_external_editor(base, base, scripts); } - for (Set<Ref<Script> >::Element *E = scripts.front(); E; E = E->next()) { + for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) { Ref<Script> script = E->get(); @@ -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..2a36700105 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]); } } @@ -199,7 +200,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(), r_options, calltip); get_text_edit()->set_code_hint(calltip); } @@ -214,7 +215,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()); if (err != OK) { String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text(); @@ -351,7 +352,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 +377,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 +596,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 +615,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 +622,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 +646,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 +666,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 +681,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 +699,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 +716,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/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 135807e88c..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; } @@ -204,7 +204,7 @@ void SpriteEditor::_update_mesh_data() { float epsilon = simplification->get_value(); - Vector<Vector<Vector2> > lines = bm->clip_opaque_to_polygons(rect, epsilon); + Vector<Vector<Vector2>> lines = bm->clip_opaque_to_polygons(rect, epsilon); uv_lines.clear(); @@ -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 13177c9142..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; @@ -60,8 +60,8 @@ class SpriteEditor : public Control { ConfirmationDialog *debug_uv_dialog; Control *debug_uv; Vector<Vector2> uv_lines; - Vector<Vector<Vector2> > outline_lines; - Vector<Vector<Vector2> > computed_outline_lines; + Vector<Vector<Vector2>> outline_lines; + Vector<Vector<Vector2>> computed_outline_lines; Vector<Vector2> computed_vertices; Vector<Vector2> computed_uv; Vector<int> computed_indices; @@ -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 5d615c7553..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; } } @@ -249,7 +249,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ ERR_FAIL_COND(!frames->has_animation(edited_anim)); - List<Ref<Texture2D> > resources; + List<Ref<Texture2D>> resources; for (int i = 0; i < p_path.size(); i++) { @@ -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 } @@ -278,7 +278,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ int count = 0; - for (List<Ref<Texture2D> >::Element *E = resources.front(); E; E = E->next()) { + for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) { undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); @@ -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..fbb6616dea 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) { @@ -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/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 d877cf9436..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; @@ -94,7 +94,7 @@ class TextureRegionEditor : public VBoxContainer { Rect2 rect_prev; float prev_margin; int edited_margin; - Map<RID, List<Rect2> > cache_map; + Map<RID, List<Rect2>> cache_map; List<Rect2> autoslice_cache; bool autoslice_is_dirty; @@ -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 d5b52e9711..b246b611fd 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -120,12 +120,12 @@ struct _TECategory { bool operator<(const Item<T> &p) const { return name < p.name; } }; - Set<RefItem<StyleBox> > stylebox_items; - Set<RefItem<Font> > font_items; - Set<RefItem<Texture2D> > icon_items; + Set<RefItem<StyleBox>> stylebox_items; + Set<RefItem<Font>> font_items; + Set<RefItem<Texture2D>> icon_items; - Set<Item<Color> > color_items; - Set<Item<int> > constant_items; + Set<Item<Color>> color_items; + Set<Item<int>> constant_items; }; void ThemeEditor::_save_template_cbk(String fname) { @@ -275,7 +275,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.stylebox_items.size()) file->store_line("\n; StyleBox Items:\n"); - for (Set<_TECategory::RefItem<StyleBox> >::Element *F = tc.stylebox_items.front(); F; F = F->next()) { + for (Set<_TECategory::RefItem<StyleBox>>::Element *F = tc.stylebox_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -283,7 +283,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.font_items.size()) file->store_line("\n; Font Items:\n"); - for (Set<_TECategory::RefItem<Font> >::Element *F = tc.font_items.front(); F; F = F->next()) { + for (Set<_TECategory::RefItem<Font>>::Element *F = tc.font_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -291,7 +291,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.icon_items.size()) file->store_line("\n; Icon Items:\n"); - for (Set<_TECategory::RefItem<Texture2D> >::Element *F = tc.icon_items.front(); F; F = F->next()) { + for (Set<_TECategory::RefItem<Texture2D>>::Element *F = tc.icon_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -299,7 +299,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.color_items.size()) file->store_line("\n; Color Items:\n"); - for (Set<_TECategory::Item<Color> >::Element *F = tc.color_items.front(); F; F = F->next()) { + for (Set<_TECategory::Item<Color>>::Element *F = tc.color_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -307,7 +307,7 @@ void ThemeEditor::_save_template_cbk(String fname) { if (tc.constant_items.size()) file->store_line("\n; Constant Items:\n"); - for (Set<_TECategory::Item<int> >::Element *F = tc.constant_items.front(); F; F = F->next()) { + for (Set<_TECategory::Item<int>>::Element *F = tc.constant_items.front(); F; F = F->next()) { file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -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..ce421ac0a5 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) { @@ -60,25 +67,30 @@ void TileMapEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - 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")); + get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); + 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")); - 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")); + 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")); - 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 +433,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 +639,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 +906,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 +996,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 +1377,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 +1785,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 +1901,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 +1918,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 +1972,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 +2043,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 +2051,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 +2154,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 d23b037ed4..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 @@ -2350,12 +2350,12 @@ void TileSetEditor::_undo_tile_removal(int p_id) { undo_redo->add_undo_method(tileset.ptr(), "tile_set_light_occluder", p_id, tileset->tile_get_light_occluder(p_id)); undo_redo->add_undo_method(tileset.ptr(), "tile_set_navigation_polygon", p_id, tileset->tile_get_navigation_polygon(p_id)); } else { - Map<Vector2, Ref<OccluderPolygon2D> > oclusion_map = tileset->autotile_get_light_oclusion_map(p_id); - for (Map<Vector2, Ref<OccluderPolygon2D> >::Element *E = oclusion_map.front(); E; E = E->next()) { + Map<Vector2, Ref<OccluderPolygon2D>> oclusion_map = tileset->autotile_get_light_oclusion_map(p_id); + for (Map<Vector2, Ref<OccluderPolygon2D>>::Element *E = oclusion_map.front(); E; E = E->next()) { undo_redo->add_undo_method(tileset.ptr(), "autotile_set_light_occluder", p_id, E->value(), E->key()); } - Map<Vector2, Ref<NavigationPolygon> > navigation_map = tileset->autotile_get_navigation_map(p_id); - for (Map<Vector2, Ref<NavigationPolygon> >::Element *E = navigation_map.front(); E; E = E->next()) { + Map<Vector2, Ref<NavigationPolygon>> navigation_map = tileset->autotile_get_navigation_map(p_id); + for (Map<Vector2, Ref<NavigationPolygon>>::Element *E = navigation_map.front(); E; E = E->next()) { undo_redo->add_undo_method(tileset.ptr(), "autotile_set_navigation_polygon", p_id, E->value(), E->key()); } Map<Vector2, uint32_t> bitmask_map = tileset->autotile_get_bitmask_map(p_id); @@ -2693,8 +2693,8 @@ void TileSetEditor::draw_polygon_shapes() { } } } else { - Map<Vector2, Ref<OccluderPolygon2D> > map = tileset->autotile_get_light_oclusion_map(t_id); - for (Map<Vector2, Ref<OccluderPolygon2D> >::Element *E = map.front(); E; E = E->next()) { + Map<Vector2, Ref<OccluderPolygon2D>> map = tileset->autotile_get_light_oclusion_map(t_id); + for (Map<Vector2, Ref<OccluderPolygon2D>>::Element *E = map.front(); E; E = E->next()) { Vector2 coord = E->key(); Vector2 anchor = tileset->autotile_get_size(t_id); anchor.x += tileset->autotile_get_spacing(t_id); @@ -2781,8 +2781,8 @@ void TileSetEditor::draw_polygon_shapes() { } } } else { - Map<Vector2, Ref<NavigationPolygon> > map = tileset->autotile_get_navigation_map(t_id); - for (Map<Vector2, Ref<NavigationPolygon> >::Element *E = map.front(); E; E = E->next()) { + Map<Vector2, Ref<NavigationPolygon>> map = tileset->autotile_get_navigation_map(t_id); + for (Map<Vector2, Ref<NavigationPolygon>>::Element *E = map.front(); E; E = E->next()) { Vector2 coord = E->key(); Vector2 anchor = tileset->autotile_get_size(t_id); anchor.x += tileset->autotile_get_spacing(t_id); @@ -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 7b49e2ece2..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" @@ -114,7 +114,7 @@ class TileSetEditor : public HSplitContainer { int option; ToolButton *tileset_toolbar_buttons[TOOL_TILESET_MAX]; MenuButton *tileset_toolbar_tools; - Map<RID, Ref<Texture2D> > texture_map; + Map<RID, Ref<Texture2D>> texture_map; bool creating_shape; int dragging_point; @@ -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..294ce2c4cd 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(); @@ -2262,7 +2274,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()); for (int i = 0; i < preview_text->get_line_count(); i++) { preview_text->set_line_as_marked(i, false); @@ -2297,7 +2309,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 +2501,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 +2678,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 +2991,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 +3140,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 +3158,7 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par } if (pinfo.size() == 0) - return NULL; + return nullptr; properties.clear(); @@ -3128,7 +3169,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); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 8756fe9fe9..473c1bb070 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -228,7 +228,7 @@ class VisualShaderEditor : public VBoxContainer { void _copy_nodes(); void _paste_nodes(bool p_use_custom_position = false, const Vector2 &p_custom_position = Vector2()); - Vector<Ref<VisualShaderNodePlugin> > plugins; + Vector<Ref<VisualShaderNodePlugin>> plugins; void _mode_selected(int p_id); void _rebuild(); diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index cdc5255edd..86df069b8b 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -34,6 +34,7 @@ #include "core/os/os.h" #include "editor_scale.h" #include "main/main.h" +#include "servers/display_server.h" void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) { @@ -134,19 +135,9 @@ void BackgroundProgress::end_task(const String &p_task) { //////////////////////////////////////////////// -ProgressDialog *ProgressDialog::singleton = NULL; +ProgressDialog *ProgressDialog::singleton = nullptr; void ProgressDialog::_notification(int p_what) { - - switch (p_what) { - - case NOTIFICATION_DRAW: { - - Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); - draw_style_box(style, Rect2(Point2(), get_size())); - - } break; - } } void ProgressDialog::_popup() { @@ -154,14 +145,14 @@ void ProgressDialog::_popup() { Size2 ms = main->get_combined_minimum_size(); ms.width = MAX(500 * EDSCALE, ms.width); - Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); + Ref<StyleBox> style = main->get_theme_stylebox("panel", "PopupMenu"); ms += style->get_minimum_size(); main->set_margin(MARGIN_LEFT, style->get_margin(MARGIN_LEFT)); main->set_margin(MARGIN_RIGHT, -style->get_margin(MARGIN_RIGHT)); main->set_margin(MARGIN_TOP, style->get_margin(MARGIN_TOP)); main->set_margin(MARGIN_BOTTOM, -style->get_margin(MARGIN_BOTTOM)); - raise(); + //raise(); popup_centered(ms); } @@ -219,7 +210,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int t.state->set_text(p_state); last_progress_tick = OS::get_singleton()->get_ticks_usec(); if (cancel_hb->is_visible()) { - OS::get_singleton()->force_process_input(); + DisplayServer::get_singleton()->process_events(); } Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h index e01c7d802b..82f479ae9d 100644 --- a/editor/progress_dialog.h +++ b/editor/progress_dialog.h @@ -68,9 +68,9 @@ public: BackgroundProgress() {} }; -class ProgressDialog : public Popup { +class ProgressDialog : public PopupPanel { - GDCLASS(ProgressDialog, Popup); + GDCLASS(ProgressDialog, PopupPanel); struct Task { String task; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 37b959c78a..04ec5ae043 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -46,25 +46,28 @@ #include "scene/gui/margin_container.h" #include "scene/gui/scroll_container.h" #include "scene/gui/tab_container.h" - +#include "servers/display_server.h" + +void ProjectExportDialog::_theme_changed() { + duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); + delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); + Control *panel = custom_feature_display->get_parent_control(); + if (panel) + panel->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree")); +} void ProjectExportDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "export", Rect2(get_position(), get_size())); + } + } break; case NOTIFICATION_READY: { - duplicate_preset->set_icon(get_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(get_icon("Remove", "EditorIcons")); + duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons")); + delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons")); connect("confirmed", callable_mp(this, &ProjectExportDialog::_export_pck_zip)); - custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree")); - } break; - case NOTIFICATION_POPUP_HIDE: { - EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "export", get_rect()); - } break; - case NOTIFICATION_THEME_CHANGED: { - duplicate_preset->set_icon(get_icon("Duplicate", "EditorIcons")); - delete_preset->set_icon(get_icon("Remove", "EditorIcons")); - Control *panel = custom_feature_display->get_parent_control(); - if (panel) - panel->add_style_override("panel", get_stylebox("bg", "Tree")); + custom_feature_display->get_parent_control()->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree")); } break; } } @@ -193,7 +196,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { name->set_editable(false); export_path->hide(); runnable->set_disabled(true); - parameters->edit(NULL); + parameters->edit(nullptr); presets->unselect_all(); duplicate_preset->set_disabled(true); delete_preset->set_disabled(true); @@ -247,8 +250,8 @@ void ProjectExportDialog::_edit_preset(int p_index) { patch->set_checked(0, true); patch->set_tooltip(0, patchlist[i]); patch->set_metadata(0, i); - patch->add_button(0, get_icon("Remove", "EditorIcons"), 0); - patch->add_button(0, get_icon("folder", "FileDialog"), 1); + patch->add_button(0, presets->get_theme_icon("Remove", "EditorIcons"), 0); + patch->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1); } TreeItem *patch_add = patches->create_item(patch_root); @@ -258,7 +261,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { else patch_add->set_text(0, TTR("Add previous patches...")); - patch_add->add_button(0, get_icon("folder", "FileDialog"), 1); + patch_add->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1); _fill_resource_tree(); @@ -299,7 +302,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { custom_features->set_text(current->get_custom_features()); _update_feature_list(); _update_export_all(); - minimum_size_changed(); + child_controls_changed(); int script_export_mode = current->get_script_export_mode(); script_mode->select(script_export_mode); @@ -388,7 +391,7 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in Vector<String> patches = current->get_patches(); ERR_FAIL_INDEX(patch_index, patches.size()); patch_erase->set_text(vformat(TTR("Delete patch '%s' from list?"), patches[patch_index].get_file())); - patch_erase->popup_centered_minsize(); + patch_erase->popup_centered(); } else { patch_dialog->popup_centered_ratio(); } @@ -618,7 +621,7 @@ void ProjectExportDialog::_delete_preset() { return; delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name())); - delete_confirm->popup_centered_minsize(); + delete_confirm->popup_centered(); } void ProjectExportDialog::_delete_preset_confirm() { @@ -649,7 +652,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_ label->set_text(presets->get_item_text(pos)); drag->add_child(label); - set_drag_preview(drag); + presets->set_drag_preview(drag); return d; } @@ -666,7 +669,7 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_ Label *label = memnew(Label); label->set_text(item->get_text(0)); - set_drag_preview(label); + patches->set_drag_preview(label); return d; } @@ -816,7 +819,7 @@ void ProjectExportDialog::_fill_resource_tree() { bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> ¤t, bool p_only_scenes) { - p_item->set_icon(0, get_icon("folder", "FileDialog")); + p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog")); p_item->set_text(0, p_dir->get_name() + "/"); bool used = false; @@ -954,7 +957,7 @@ void ProjectExportDialog::_export_project() { export_project->get_line_edit()->connect_compat("text_entered", export_project, "_file_entered"); } - export_project->set_mode(EditorFileDialog::MODE_SAVE_FILE); + export_project->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); export_project->popup_centered_ratio(); } @@ -979,14 +982,14 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) { ERR_PRINT(vformat("Failed to export the project for platform '%s'.", platform->get_name())); error_dialog->show(); - error_dialog->popup_centered_minsize(Size2(300, 80)); + error_dialog->popup_centered(Size2(300, 80)); } } void ProjectExportDialog::_export_all_dialog() { export_all_dialog->show(); - export_all_dialog->popup_centered_minsize(Size2(300, 80)); + export_all_dialog->popup_centered(Size2(300, 80)); } void ProjectExportDialog::_export_all_dialog_action(const String &p_str) { @@ -1017,7 +1020,7 @@ void ProjectExportDialog::_export_all(bool p_debug) { error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name()); } error_dialog->show(); - error_dialog->popup_centered_minsize(Size2(300, 80)); + error_dialog->popup_centered(Size2(300, 80)); ERR_PRINT("Failed to export project"); } } @@ -1039,13 +1042,13 @@ void ProjectExportDialog::_bind_methods() { ProjectExportDialog::ProjectExportDialog() { set_title(TTR("Export")); - set_resizable(true); VBoxContainer *main_vb = memnew(VBoxContainer); + main_vb->connect("theme_changed", callable_mp(this, &ProjectExportDialog::_theme_changed)); add_child(main_vb); HSplitContainer *hbox = memnew(HSplitContainer); main_vb->add_child(hbox); - hbox->set_v_size_flags(SIZE_EXPAND_FILL); + hbox->set_v_size_flags(Control::SIZE_EXPAND_FILL); // Presets list. @@ -1064,9 +1067,12 @@ ProjectExportDialog::ProjectExportDialog() { preset_hb->add_child(add_preset); MarginContainer *mc = memnew(MarginContainer); preset_vb->add_child(mc); - mc->set_v_size_flags(SIZE_EXPAND_FILL); + mc->set_v_size_flags(Control::SIZE_EXPAND_FILL); presets = memnew(ItemList); - presets->set_drag_forwarding(this); +#ifndef _MSC_VER +#warning must reimplement drag forward +#endif + //presets->set_drag_forwarding(this); mc->add_child(presets); presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset)); duplicate_preset = memnew(ToolButton); @@ -1104,14 +1110,14 @@ ProjectExportDialog::ProjectExportDialog() { sections->set_tab_align(TabContainer::ALIGN_LEFT); sections->set_use_hidden_tabs_for_min_size(true); settings_vb->add_child(sections); - sections->set_v_size_flags(SIZE_EXPAND_FILL); + sections->set_v_size_flags(Control::SIZE_EXPAND_FILL); // Main preset parameters. parameters = memnew(EditorInspector); sections->add_child(parameters); parameters->set_name(TTR("Options")); - parameters->set_v_size_flags(SIZE_EXPAND_FILL); + parameters->set_v_size_flags(Control::SIZE_EXPAND_FILL); parameters->connect("property_edited", callable_mp(this, &ProjectExportDialog::_update_parameters)); // Resources export parameters. @@ -1131,7 +1137,7 @@ ProjectExportDialog::ProjectExportDialog() { include_label->set_text(TTR("Resources to export:")); resources_vb->add_child(include_label); include_margin = memnew(MarginContainer); - include_margin->set_v_size_flags(SIZE_EXPAND_FILL); + include_margin->set_v_size_flags(Control::SIZE_EXPAND_FILL); resources_vb->add_child(include_margin); include_files = memnew(Tree); @@ -1163,11 +1169,14 @@ ProjectExportDialog::ProjectExportDialog() { patches = memnew(Tree); patch_vb->add_child(patches); - patches->set_v_size_flags(SIZE_EXPAND_FILL); + patches->set_v_size_flags(Control::SIZE_EXPAND_FILL); patches->set_hide_root(true); patches->connect("button_pressed", callable_mp(this, &ProjectExportDialog::_patch_button_pressed)); patches->connect("item_edited", callable_mp(this, &ProjectExportDialog::_patch_edited)); - patches->set_drag_forwarding(this); +#ifndef _MSC_VER +#warning must reimplement drag forward +#endif + //patches->set_drag_forwarding(this); patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); HBoxContainer *patches_hb = memnew(HBoxContainer); @@ -1180,7 +1189,7 @@ ProjectExportDialog::ProjectExportDialog() { patch_dialog = memnew(EditorFileDialog); patch_dialog->add_filter("*.pck ; " + TTR("Pack File")); - patch_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + patch_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); patch_dialog->connect("file_selected", callable_mp(this, &ProjectExportDialog::_patch_selected)); add_child(patch_dialog); @@ -1196,12 +1205,9 @@ ProjectExportDialog::ProjectExportDialog() { custom_features = memnew(LineEdit); custom_features->connect("text_changed", callable_mp(this, &ProjectExportDialog::_custom_features_changed)); feature_vb->add_margin_child(TTR("Custom (comma-separated):"), custom_features); - Panel *features_panel = memnew(Panel); custom_feature_display = memnew(RichTextLabel); - features_panel->add_child(custom_feature_display); - custom_feature_display->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 10 * EDSCALE); - custom_feature_display->set_v_size_flags(SIZE_EXPAND_FILL); - feature_vb->add_margin_child(TTR("Feature List:"), features_panel, true); + custom_feature_display->set_v_size_flags(Control::SIZE_EXPAND_FILL); + feature_vb->add_margin_child(TTR("Feature List:"), custom_feature_display, true); sections->add_child(feature_vb); // Script export parameters. @@ -1220,7 +1226,7 @@ ProjectExportDialog::ProjectExportDialog() { script_key->connect("text_changed", callable_mp(this, &ProjectExportDialog::_script_encryption_key_changed)); script_key_error = memnew(Label); script_key_error->set_text("- " + TTR("Invalid Encryption Key (must be 64 characters long)")); - script_key_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + script_key_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); script_vb->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"), script_key); script_vb->add_child(script_key_error); sections->add_child(script_vb); @@ -1235,7 +1241,7 @@ ProjectExportDialog::ProjectExportDialog() { delete_preset->set_disabled(true); script_key_error->hide(); sections->hide(); - parameters->edit(NULL); + parameters->edit(nullptr); // Deletion dialog. @@ -1250,7 +1256,7 @@ ProjectExportDialog::ProjectExportDialog() { get_cancel()->set_text(TTR("Close")); get_ok()->set_text(TTR("Export PCK/Zip")); - export_button = add_button(TTR("Export Project"), !OS::get_singleton()->get_swap_ok_cancel(), "export"); + export_button = add_button(TTR("Export Project"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export"); export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project)); // Disable initially before we select a valid preset export_button->set_disabled(true); @@ -1265,7 +1271,7 @@ ProjectExportDialog::ProjectExportDialog() { export_all_dialog->add_button(TTR("Release"), true, "release"); export_all_dialog->connect("custom_action", callable_mp(this, &ProjectExportDialog::_export_all_dialog_action)); - export_all_button = add_button(TTR("Export All"), !OS::get_singleton()->get_swap_ok_cancel(), "export"); + export_all_button = add_button(TTR("Export All"), !DisplayServer::get_singleton()->get_swap_ok_cancel(), "export"); export_all_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_all_dialog)); export_all_button->set_disabled(true); @@ -1273,14 +1279,14 @@ ProjectExportDialog::ProjectExportDialog() { export_pck_zip->add_filter("*.zip ; " + TTR("ZIP File")); export_pck_zip->add_filter("*.pck ; " + TTR("Godot Game Pack")); export_pck_zip->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - export_pck_zip->set_mode(EditorFileDialog::MODE_SAVE_FILE); + export_pck_zip->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); add_child(export_pck_zip); export_pck_zip->connect("file_selected", callable_mp(this, &ProjectExportDialog::_export_pck_zip_selected)); export_error = memnew(Label); main_vb->add_child(export_error); export_error->hide(); - export_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + export_error->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); export_templates_error = memnew(HBoxContainer); main_vb->add_child(export_templates_error); @@ -1288,7 +1294,7 @@ ProjectExportDialog::ProjectExportDialog() { Label *export_error2 = memnew(Label); export_templates_error->add_child(export_error2); - export_error2->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + export_error2->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " "); error_dialog = memnew(AcceptDialog); @@ -1299,7 +1305,7 @@ ProjectExportDialog::ProjectExportDialog() { LinkButton *download_templates = memnew(LinkButton); download_templates->set_text(TTR("Manage Export Templates")); - download_templates->set_v_size_flags(SIZE_SHRINK_CENTER); + download_templates->set_v_size_flags(Control::SIZE_SHRINK_CENTER); export_templates_error->add_child(download_templates); download_templates->connect("pressed", callable_mp(this, &ProjectExportDialog::_open_export_template_manager)); diff --git a/editor/project_export.h b/editor/project_export.h index 00e6dfd6e3..2e311eb3b3 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -167,6 +167,7 @@ private: void _tab_changed(int); protected: + void _theme_changed(); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 94f9bf2767..0ca540a33f 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -51,6 +51,8 @@ #include "scene/gui/separator.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tool_button.h" +#include "scene/main/window.h" +#include "servers/display_server.h" static inline String get_project_key_from_path(const String &dir) { return dir.replace("/", "::"); @@ -115,22 +117,22 @@ private: case MESSAGE_ERROR: { - msg->add_color_override("font_color", get_color("error_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor")); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = get_icon("StatusError", "EditorIcons"); + new_icon = msg->get_theme_icon("StatusError", "EditorIcons"); } break; case MESSAGE_WARNING: { - msg->add_color_override("font_color", get_color("warning_color", "Editor")); + msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor")); msg->set_modulate(Color(1, 1, 1, 1)); - new_icon = get_icon("StatusWarning", "EditorIcons"); + new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons"); } break; case MESSAGE_SUCCESS: { msg->set_modulate(Color(1, 1, 1, 0)); - new_icon = get_icon("StatusSuccess", "EditorIcons"); + new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons"); } break; } @@ -141,7 +143,7 @@ private: install_status_rect->set_texture(new_icon); } - set_size(Size2(500, 0) * EDSCALE); + set_size(Size2i(500, 0) * EDSCALE); } String _test_path() { @@ -189,7 +191,7 @@ private: if (valid_path != "" && !d->file_exists("project.godot")) { if (valid_path.ends_with(".zip")) { - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); @@ -206,7 +208,7 @@ private: while (ret == UNZ_OK) { unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); if (String(fname).ends_with("project.godot")) { break; @@ -377,19 +379,19 @@ private: if (mode == MODE_IMPORT) { - fdialog->set_mode(FileDialog::MODE_OPEN_FILE); + fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); fdialog->clear_filters(); fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project"))); fdialog->add_filter("*.zip ; " + TTR("ZIP File")); } else { - fdialog->set_mode(FileDialog::MODE_OPEN_DIR); + fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); } fdialog->popup_centered_ratio(); } void _browse_install_path() { fdialog_install->set_current_dir(install_path->get_text()); - fdialog_install->set_mode(FileDialog::MODE_OPEN_DIR); + fdialog_install->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); fdialog_install->popup_centered_ratio(); } @@ -416,12 +418,12 @@ private: } else { dialog_error->set_text(TTR("Couldn't create folder.")); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); } } else { dialog_error->set_text(TTR("There is already a folder in this path with the specified name.")); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); } } @@ -498,14 +500,14 @@ private: if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("project.godot"), initial_settings, Vector<String>(), false) != OK) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { - ResourceSaver::save(dir.plus_file("icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); + ResourceSaver::save(dir.plus_file("icon.png"), msg->get_theme_icon("DefaultProjectIcon", "EditorIcons")); FileAccess *f = FileAccess::open(dir.plus_file("default_env.tres"), FileAccess::WRITE); if (!f) { set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); - f->store_line("[sub_resource type=\"ProceduralSky\" id=1]"); + f->store_line("[sub_resource type=\"Sky\" id=1]"); f->store_line("[resource]"); f->store_line("background_mode = 2"); f->store_line("background_sky = SubResource( 1 )"); @@ -520,14 +522,14 @@ private: zip_path = project_path->get_text(); } - FileAccess *src_f = NULL; + FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); if (!pkg) { dialog_error->set_text(TTR("Error opening package file, not in ZIP format.")); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); return; } @@ -541,7 +543,7 @@ private: //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); String path = fname; @@ -605,11 +607,11 @@ private: } dialog_error->set_text(msg); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); } else if (!project_path->get_text().ends_with(".zip")) { dialog_error->set_text(TTR("Package installed successfully!")); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); } } } @@ -647,16 +649,16 @@ private: project_name->clear(); _text_changed(""); - if (status_rect->get_texture() == get_icon("StatusError", "EditorIcons")) + if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) msg->show(); - if (install_status_rect->get_texture() == get_icon("StatusError", "EditorIcons")) + if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) msg->show(); } void _notification(int p_what) { - if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) + if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) _remove_created_folder(); } @@ -786,7 +788,7 @@ public: _test_path(); } - popup_centered_minsize(Size2(500, 0) * EDSCALE); + popup_centered(Size2i(500, 0) * EDSCALE); } ProjectDialog() { @@ -805,7 +807,7 @@ public: name_container->add_child(pnhb); project_name = memnew(LineEdit); - project_name->set_h_size_flags(SIZE_EXPAND_FILL); + project_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); pnhb->add_child(project_name); create_dir = memnew(Button); @@ -824,7 +826,7 @@ public: path_container->add_child(pphb); project_path = memnew(LineEdit); - project_path->set_h_size_flags(SIZE_EXPAND_FILL); + project_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); pphb->add_child(project_path); install_path_container = memnew(VBoxContainer); @@ -838,7 +840,7 @@ public: install_path_container->add_child(iphb); install_path = memnew(LineEdit); - install_path->set_h_size_flags(SIZE_EXPAND_FILL); + install_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); iphb->add_child(install_path); // status icon @@ -876,7 +878,7 @@ public: rasterizer_button_group.instance(); Container *rvb = memnew(VBoxContainer); - rvb->set_h_size_flags(SIZE_EXPAND_FILL); + rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL); rshb->add_child(rvb); Button *rs_button = memnew(CheckBox); rs_button->set_button_group(rasterizer_button_group); @@ -895,7 +897,7 @@ public: TTR("The GLES2 renderer is currently unavailable, as it needs to be reworked for Godot 4.0.\nUse Godot 3.2 if you need GLES2 support."); rvb = memnew(VBoxContainer); - rvb->set_h_size_flags(SIZE_EXPAND_FILL); + rvb->set_h_size_flags(Control::SIZE_EXPAND_FILL); rshb->add_child(rvb); rs_button = memnew(CheckBox); rs_button->set_button_group(rasterizer_button_group); @@ -910,7 +912,7 @@ public: // Also set the tooltip on the label so it appears when hovering either the checkbox or label. l->set_tooltip(gles2_unsupported_tooltip); // Required for the tooltip to show. - l->set_mouse_filter(MOUSE_FILTER_STOP); + l->set_mouse_filter(Control::MOUSE_FILTER_STOP); rvb->add_child(l); l = memnew(Label); @@ -953,8 +955,8 @@ public: bool hover; ProjectListItemControl() { - favorite_button = NULL; - icon = NULL; + favorite_button = nullptr; + icon = nullptr; icon_needs_reload = true; hover = false; } @@ -975,7 +977,7 @@ public: } break; case NOTIFICATION_DRAW: { if (hover) { - draw_style_box(get_stylebox("hover", "Tree"), Rect2(Point2(), get_size() - Size2(10, 0) * EDSCALE)); + draw_style_box(get_theme_stylebox("hover", "Tree"), Rect2(Point2(), get_size() - Size2(10, 0) * EDSCALE)); } } break; } @@ -1034,7 +1036,7 @@ public: grayed = p_grayed; missing = p_missing; version = p_version; - control = NULL; + control = nullptr; } _FORCE_INLINE_ bool operator==(const Item &l) const { @@ -1045,6 +1047,9 @@ public: ProjectList(); ~ProjectList(); + void _global_menu_new_window(const Variant &p_tag); + void _global_menu_open_project(const Variant &p_tag); + void update_dock_menu(); void load_projects(); void set_search_term(String p_search_term); @@ -1116,7 +1121,7 @@ ProjectList::ProjectList() { _order_option = ProjectListFilter::FILTER_EDIT_DATE; _scroll_children = memnew(VBoxContainer); - _scroll_children->set_h_size_flags(SIZE_EXPAND_FILL); + _scroll_children->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_child(_scroll_children); _icon_load_index = 0; @@ -1150,7 +1155,7 @@ void ProjectList::_notification(int p_what) { void ProjectList::load_project_icon(int p_index) { Item &item = _projects.write[p_index]; - Ref<Texture2D> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); + Ref<Texture2D> default_icon = get_theme_icon("DefaultProjectIcon", "EditorIcons"); Ref<Texture2D> icon; if (item.icon != "") { Ref<Image> img; @@ -1231,7 +1236,7 @@ void ProjectList::load_projects() { // Clear whole list for (int i = 0; i < _projects.size(); ++i) { Item &project = _projects.write[i]; - CRASH_COND(project.control == NULL); + CRASH_COND(project.control == nullptr); memdelete(project.control); // Why not queue_free()? } _projects.clear(); @@ -1284,7 +1289,11 @@ void ProjectList::load_projects() { } void ProjectList::update_dock_menu() { - OS::get_singleton()->global_menu_clear("_dock"); + + if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { + return; + } + DisplayServer::get_singleton()->global_menu_clear("_dock"); int favs_added = 0; int total_added = 0; @@ -1294,18 +1303,41 @@ void ProjectList::update_dock_menu() { favs_added++; } else { if (favs_added != 0) { - OS::get_singleton()->global_menu_add_separator("_dock"); + DisplayServer::get_singleton()->global_menu_add_separator("_dock"); } favs_added = 0; } - OS::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot"))); + DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", callable_mp(this, &ProjectList::_global_menu_open_project), i); total_added++; } } if (total_added != 0) { - OS::get_singleton()->global_menu_add_separator("_dock"); + DisplayServer::get_singleton()->global_menu_add_separator("_dock"); + } + DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &ProjectList::_global_menu_new_window)); +} + +void ProjectList::_global_menu_new_window(const Variant &p_tag) { + List<String> args; + args.push_back("-p"); + String exec = OS::get_singleton()->get_executable_path(); + + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); +} + +void ProjectList::_global_menu_open_project(const Variant &p_tag) { + int idx = (int)p_tag; + + if (idx >= 0 && idx < _projects.size()) { + String conf = _projects[idx].path.plus_file("project.godot"); + List<String> args; + args.push_back(conf); + String exec = OS::get_singleton()->get_executable_path(); + + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); } - OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant()); } void ProjectList::create_project_item_control(int p_index) { @@ -1314,15 +1346,15 @@ void ProjectList::create_project_item_control(int p_index) { ERR_FAIL_COND(p_index != _scroll_children->get_child_count()); Item &item = _projects.write[p_index]; - ERR_FAIL_COND(item.control != NULL); // Already created + ERR_FAIL_COND(item.control != nullptr); // Already created - Ref<Texture2D> favorite_icon = get_icon("Favorites", "EditorIcons"); - Color font_color = get_color("font_color", "Tree"); + Ref<Texture2D> favorite_icon = get_theme_icon("Favorites", "EditorIcons"); + Color font_color = get_theme_color("font_color", "Tree"); ProjectListItemControl *hb = memnew(ProjectListItemControl); hb->connect("draw", callable_mp(this, &ProjectList::_panel_draw), varray(hb)); hb->connect("gui_input", callable_mp(this, &ProjectList::_panel_input), varray(hb)); - hb->add_constant_override("separation", 10 * EDSCALE); + hb->add_theme_constant_override("separation", 10 * EDSCALE); hb->set_tooltip(item.description); VBoxContainer *favorite_box = memnew(VBoxContainer); @@ -1342,7 +1374,7 @@ void ProjectList::create_project_item_control(int p_index) { TextureRect *tf = memnew(TextureRect); // The project icon may not be loaded by the time the control is displayed, // so use a loading placeholder. - tf->set_texture(get_icon("ProjectIconLoading", "EditorIcons")); + tf->set_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); tf->set_v_size_flags(SIZE_SHRINK_CENTER); if (item.missing) { tf->set_modulate(Color(1, 1, 1, 0.5)); @@ -1353,25 +1385,25 @@ void ProjectList::create_project_item_control(int p_index) { VBoxContainer *vb = memnew(VBoxContainer); if (item.grayed) vb->set_modulate(Color(1, 1, 1, 0.5)); - vb->set_h_size_flags(SIZE_EXPAND_FILL); + vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(vb); Control *ec = memnew(Control); ec->set_custom_minimum_size(Size2(0, 1)); ec->set_mouse_filter(MOUSE_FILTER_PASS); vb->add_child(ec); Label *title = memnew(Label(!item.missing ? item.project_name : TTR("Missing Project"))); - title->add_font_override("font", get_font("title", "EditorFonts")); - title->add_color_override("font_color", font_color); + title->add_theme_font_override("font", get_theme_font("title", "EditorFonts")); + title->add_theme_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); HBoxContainer *path_hb = memnew(HBoxContainer); - path_hb->set_h_size_flags(SIZE_EXPAND_FILL); + path_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); vb->add_child(path_hb); Button *show = memnew(Button); // Display a folder icon if the project directory can be opened, or a "broken file" icon if it can't - show->set_icon(get_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons")); + show->set_icon(get_theme_icon(!item.missing ? "Load" : "FileBroken", "EditorIcons")); show->set_flat(true); if (!item.grayed) { // Don't make the icon less prominent if the parent is already grayed out @@ -1388,9 +1420,9 @@ void ProjectList::create_project_item_control(int p_index) { Label *fpath = memnew(Label(item.path)); path_hb->add_child(fpath); - fpath->set_h_size_flags(SIZE_EXPAND_FILL); + fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL); fpath->set_modulate(Color(1, 1, 1, 0.5)); - fpath->add_color_override("font_color", font_color); + fpath->add_theme_color_override("font_color", font_color); fpath->set_clip_text(true); _scroll_children->add_child(hb); @@ -1722,12 +1754,12 @@ void ProjectList::erase_selected_projects() { void ProjectList::_panel_draw(Node *p_hb) { Control *hb = Object::cast_to<Control>(p_hb); - hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_color("guide_color", "Tree")); + hb->draw_line(Point2(0, hb->get_size().y + 1), Point2(hb->get_size().x - 10, hb->get_size().y + 1), get_theme_color("guide_color", "Tree")); String key = _projects[p_hb->get_index()].project_key; if (_selected_project_keys.has(key)) { - hb->draw_style_box(get_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE)); + hb->draw_style_box(get_theme_stylebox("selected", "Tree"), Rect2(Point2(), hb->get_size() - Size2(10, 0) * EDSCALE)); } } @@ -1827,13 +1859,13 @@ void ProjectManager::_notification(int p_what) { case NOTIFICATION_RESIZED: { if (open_templates->is_visible()) { - open_templates->popup_centered_minsize(); + open_templates->popup_centered(); } } break; case NOTIFICATION_READY: { if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) - open_templates->popup_centered_minsize(); + open_templates->popup_centered(); if (_project_list->get_project_count() >= 1) { // Focus on the search box immediately to allow the user @@ -1845,7 +1877,7 @@ void ProjectManager::_notification(int p_what) { set_process_unhandled_input(is_visible_in_tree()); } break; - case NOTIFICATION_WM_QUIT_REQUEST: { + case NOTIFICATION_WM_CLOSE_REQUEST: { _dim_window(); } break; @@ -2018,30 +2050,6 @@ void ProjectManager::_confirm_update_settings() { _open_selected_projects(); } -void ProjectManager::_global_menu_action(const Variant &p_id, const Variant &p_meta) { - - int id = (int)p_id; - if (id == ProjectList::GLOBAL_NEW_WINDOW) { - List<String> args; - args.push_back("-p"); - String exec = OS::get_singleton()->get_executable_path(); - - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } else if (id == ProjectList::GLOBAL_OPEN_PROJECT) { - String conf = (String)p_meta; - - if (conf != String()) { - List<String> args; - args.push_back(conf); - String exec = OS::get_singleton()->get_executable_path(); - - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } - } -} - void ProjectManager::_open_selected_projects() { const Set<String> &selected_list = _project_list->get_selected_project_keys(); @@ -2053,7 +2061,7 @@ void ProjectManager::_open_selected_projects() { if (!FileAccess::exists(conf)) { dialog_error->set_text(vformat(TTR("Can't open project at '%s'."), path)); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); return; } @@ -2091,7 +2099,7 @@ void ProjectManager::_open_selected_projects_ask() { if (selected_list.size() > 1) { multi_open_ask->set_text(TTR("Are you sure to open more than one project?")); - multi_open_ask->popup_centered_minsize(); + multi_open_ask->popup_centered(); return; } @@ -2107,19 +2115,19 @@ void ProjectManager::_open_selected_projects_ask() { // Check if the config_version property was empty or 0 if (config_version == 0) { ask_update_settings->set_text(vformat(TTR("The following project settings file does not specify the version of Godot through which it was created.\n\n%s\n\nIf you proceed with opening it, it will be converted to Godot's current configuration file format.\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf)); - ask_update_settings->popup_centered_minsize(); + ask_update_settings->popup_centered(); return; } // Check if we need to convert project settings from an earlier engine version if (config_version < ProjectSettings::CONFIG_VERSION) { ask_update_settings->set_text(vformat(TTR("The following project settings file was generated by an older engine version, and needs to be converted for this version:\n\n%s\n\nDo you want to convert it?\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf)); - ask_update_settings->popup_centered_minsize(); + ask_update_settings->popup_centered(); return; } // Check if the file was generated by a newer, incompatible engine version if (config_version > ProjectSettings::CONFIG_VERSION) { dialog_error->set_text(vformat(TTR("Can't open project at '%s'.") + "\n" + TTR("The project settings were created by a newer engine version, whose settings are not compatible with this version."), project.path)); - dialog_error->popup_centered_minsize(); + dialog_error->popup_centered(); return; } @@ -2179,7 +2187,7 @@ void ProjectManager::_run_project() { if (selected_list.size() > 1) { multi_run_ask->set_text(vformat(TTR("Are you sure to run %d projects at once?"), selected_list.size())); - multi_run_ask->popup_centered_minsize(); + multi_run_ask->popup_centered(); } else { _run_project_confirm(); } @@ -2276,13 +2284,13 @@ void ProjectManager::_erase_project() { } erase_ask->set_text(confirm_message); - erase_ask->popup_centered_minsize(); + erase_ask->popup_centered(); } void ProjectManager::_erase_missing_projects() { erase_missing_ask->set_text(TTR("Remove all missing projects from the list?\nThe project folders' contents won't be modified.")); - erase_missing_ask->popup_centered_minsize(); + erase_missing_ask->popup_centered(); } void ProjectManager::_language_selected(int p_id) { @@ -2290,7 +2298,7 @@ void ProjectManager::_language_selected(int p_id) { String lang = language_btn->get_item_metadata(p_id); EditorSettings::get_singleton()->set("interface/editor/editor_language", lang); language_btn->set_text(lang); - language_btn->set_icon(get_icon("Environment", "EditorIcons")); + language_btn->set_icon(get_theme_icon("Environment", "EditorIcons")); language_restart_ask->set_text(TTR("Language changed.\nThe interface will update after restarting the editor or project manager.")); language_restart_ask->popup_centered(); @@ -2357,7 +2365,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { multi_scan_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders), varray(folders)); multi_scan_ask->set_text( vformat(TTR("Are you sure to scan %s folders for existing Godot projects?\nThis could take a while."), folders.size())); - multi_scan_ask->popup_centered_minsize(); + multi_scan_ask->popup_centered(); } else { _scan_multiple_folders(folders); } @@ -2413,8 +2421,12 @@ ProjectManager::ProjectManager() { switch (display_scale) { case 0: { // Try applying a suitable display scale automatically - const int screen = OS::get_singleton()->get_current_screen(); - editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0); + const int screen = DisplayServer::get_singleton()->window_get_current_screen(); +#ifdef OSX_ENABLED + editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen)); +#else + editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); +#endif } break; case 1: editor_set_scale(0.75); break; @@ -2430,12 +2442,12 @@ ProjectManager::ProjectManager() { } // Define a minimum window size to prevent UI elements from overlapping or being cut off - OS::get_singleton()->set_min_window_size(Size2(750, 420) * EDSCALE); + DisplayServer::get_singleton()->window_set_min_size(Size2(750, 420) * EDSCALE); #ifndef OSX_ENABLED // The macOS platform implementation uses its own hiDPI window resizing code // TODO: Resize windows on hiDPI displays on Windows and Linux and remove the line below - OS::get_singleton()->set_window_size(OS::get_singleton()->get_window_size() * MAX(1, EDSCALE)); + DisplayServer::get_singleton()->window_set_size(DisplayServer::get_singleton()->window_get_size() * MAX(1, EDSCALE)); #endif } @@ -2451,7 +2463,7 @@ ProjectManager::ProjectManager() { Panel *panel = memnew(Panel); gui_base->add_child(panel); panel->set_anchors_and_margins_preset(Control::PRESET_WIDE); - panel->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); + panel->add_theme_style_override("panel", gui_base->get_theme_stylebox("Background", "EditorStyles")); VBoxContainer *vb = memnew(VBoxContainer); panel->add_child(vb); @@ -2459,10 +2471,10 @@ ProjectManager::ProjectManager() { String cp; cp += 0xA9; - OS::get_singleton()->set_window_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors"); + DisplayServer::get_singleton()->window_set_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors"); Control *center_box = memnew(Control); - center_box->set_v_size_flags(SIZE_EXPAND_FILL); + center_box->set_v_size_flags(Control::SIZE_EXPAND_FILL); vb->add_child(center_box); tabs = memnew(TabContainer); @@ -2479,7 +2491,7 @@ ProjectManager::ProjectManager() { VBoxContainer *search_tree_vb = memnew(VBoxContainer); tree_hb->add_child(search_tree_vb); - search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL); + search_tree_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); HBoxContainer *sort_filters = memnew(HBoxContainer); Label *sort_label = memnew(Label); @@ -2511,9 +2523,9 @@ ProjectManager::ProjectManager() { search_tree_vb->add_child(sort_filters); PanelContainer *pc = memnew(PanelContainer); - pc->add_style_override("panel", gui_base->get_stylebox("bg", "Tree")); + pc->add_theme_style_override("panel", gui_base->get_theme_stylebox("bg", "Tree")); search_tree_vb->add_child(pc); - pc->set_v_size_flags(SIZE_EXPAND_FILL); + pc->set_v_size_flags(Control::SIZE_EXPAND_FILL); _project_list = memnew(ProjectList); _project_list->connect(ProjectList::SIGNAL_SELECTION_CHANGED, callable_mp(this, &ProjectManager::_update_project_buttons)); @@ -2547,7 +2559,7 @@ ProjectManager::ProjectManager() { scan_dir = memnew(FileDialog); scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM); - scan_dir->set_mode(FileDialog::MODE_OPEN_DIR); + scan_dir->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR); scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden scan_dir->set_current_dir(EditorSettings::get_singleton()->get("filesystem/directories/default_project_path")); gui_base->add_child(scan_dir); @@ -2631,7 +2643,7 @@ ProjectManager::ProjectManager() { language_btn->set_text(lang); } } - language_btn->set_icon(get_icon("Environment", "EditorIcons")); + language_btn->set_icon(get_theme_icon("Environment", "EditorIcons")); settings_hb->add_child(language_btn); language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected)); @@ -2689,8 +2701,7 @@ ProjectManager::ProjectManager() { _scan_begin(EditorSettings::get_singleton()->get("filesystem/directories/autoscan_project_path")); } - SceneTree::get_singleton()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); - SceneTree::get_singleton()->connect("global_menu_action", callable_mp(this, &ProjectManager::_global_menu_action)); + SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); run_error_diag = memnew(AcceptDialog); gui_base->add_child(run_error_diag); @@ -2748,7 +2759,7 @@ void ProjectListFilter::_filter_option_selected(int p_idx) { void ProjectListFilter::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE && has_search_box) { - 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); } } @@ -2769,7 +2780,7 @@ void ProjectListFilter::add_search_box() { search_box = memnew(LineEdit); search_box->set_placeholder(TTR("Search")); search_box->connect("text_changed", callable_mp(this, &ProjectListFilter::_search_text_changed)); - search_box->set_h_size_flags(SIZE_EXPAND_FILL); + search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); add_child(search_box); has_search_box = true; diff --git a/editor/project_manager.h b/editor/project_manager.h index 8b9c769c59..6385000821 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -97,7 +97,6 @@ class ProjectManager : public Control { void _restart_confirm(); void _exit_dialog(); void _scan_begin(const String &p_base); - void _global_menu_action(const Variant &p_id, const Variant &p_meta); void _confirm_update_settings(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 7d8a4a733d..42493191a8 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -31,7 +31,7 @@ #include "project_settings_editor.h" #include "core/global_constants.h" -#include "core/input_map.h" +#include "core/input/input_map.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "core/translation.h" @@ -41,7 +41,7 @@ #include "scene/gui/margin_container.h" #include "scene/gui/tab_container.h" -ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL; +ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr; static const char *_button_names[JOY_BUTTON_MAX] = { "DualShock Cross, Xbox A, Nintendo B", @@ -80,7 +80,7 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) { const Ref<InputEventKey> k = p_event; - if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { + if (k.is_valid() && k->is_pressed()) { if (k->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { if (search_button->is_pressed()) { @@ -91,7 +91,7 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) { search_button->set_pressed(true); } - accept_event(); + set_input_as_handled(); } } } @@ -99,22 +99,28 @@ void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) { void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", Rect2(get_position(), get_size())); + set_process_unhandled_input(false); + } + } break; case NOTIFICATION_ENTER_TREE: { globals_editor->edit(ProjectSettings::get_singleton()); - search_button->set_icon(get_icon("Search", "EditorIcons")); - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_button->set_icon(input_editor->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(input_editor->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - action_add_error->add_color_override("font_color", get_color("error_color", "Editor")); + action_add_error->add_theme_color_override("font_color", input_editor->get_theme_color("error_color", "Editor")); translation_list->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_translation_delete)); _update_actions(); - popup_add->add_icon_item(get_icon("Keyboard", "EditorIcons"), TTR("Key"), INPUT_KEY); //"Key " - because the word 'key' has already been used as a key animation - popup_add->add_icon_item(get_icon("KeyboardPhysical", "EditorIcons"), TTR("Physical Key"), INPUT_KEY_PHYSICAL); - popup_add->add_icon_item(get_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), INPUT_JOY_BUTTON); - popup_add->add_icon_item(get_icon("JoyAxis", "EditorIcons"), TTR("Joy Axis"), INPUT_JOY_MOTION); - popup_add->add_icon_item(get_icon("Mouse", "EditorIcons"), TTR("Mouse Button"), INPUT_MOUSE_BUTTON); + popup_add->add_icon_item(input_editor->get_theme_icon("Keyboard", "EditorIcons"), TTR("Key"), INPUT_KEY); + popup_add->add_icon_item(input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons"), TTR("Physical Key"), INPUT_KEY_PHYSICAL); + popup_add->add_icon_item(input_editor->get_theme_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), INPUT_JOY_BUTTON); + popup_add->add_icon_item(input_editor->get_theme_icon("JoyAxis", "EditorIcons"), TTR("Joy Axis"), INPUT_JOY_MOTION); + popup_add->add_icon_item(input_editor->get_theme_icon("Mouse", "EditorIcons"), TTR("Mouse Button"), INPUT_MOUSE_BUTTON); List<String> tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); @@ -131,26 +137,22 @@ void ProjectSettingsEditor::_notification(int p_what) { translation_res_option_file_open->add_filter("*." + E->get()); } - restart_close_button->set_icon(get_icon("Close", "EditorIcons")); - restart_container->add_style_override("panel", get_stylebox("bg", "Tree")); - restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons")); - restart_label->add_color_override("font_color", get_color("warning_color", "Editor")); + restart_close_button->set_icon(input_editor->get_theme_icon("Close", "EditorIcons")); + restart_container->add_theme_style_override("panel", input_editor->get_theme_stylebox("bg", "Tree")); + restart_icon->set_texture(input_editor->get_theme_icon("StatusWarning", "EditorIcons")); + restart_label->add_theme_color_override("font_color", input_editor->get_theme_color("warning_color", "Editor")); } break; - case NOTIFICATION_POPUP_HIDE: { - EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", get_rect()); - set_process_unhandled_input(false); - } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - search_button->set_icon(get_icon("Search", "EditorIcons")); - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_button->set_icon(input_editor->get_theme_icon("Search", "EditorIcons")); + search_box->set_right_icon(input_editor->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - action_add_error->add_color_override("font_color", get_color("error_color", "Editor")); - popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), get_icon("Keyboard", "EditorIcons")); - popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY_PHYSICAL), get_icon("KeyboardPhysical", "EditorIcons")); - popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_BUTTON), get_icon("JoyButton", "EditorIcons")); - popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_MOTION), get_icon("JoyAxis", "EditorIcons")); - popup_add->set_item_icon(popup_add->get_item_index(INPUT_MOUSE_BUTTON), get_icon("Mouse", "EditorIcons")); + action_add_error->add_theme_color_override("font_color", input_editor->get_theme_color("error_color", "Editor")); + popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), input_editor->get_theme_icon("Keyboard", "EditorIcons")); + popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY_PHYSICAL), input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons")); + popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_BUTTON), input_editor->get_theme_icon("JoyButton", "EditorIcons")); + popup_add->set_item_icon(popup_add->get_item_index(INPUT_JOY_MOTION), input_editor->get_theme_icon("JoyAxis", "EditorIcons")); + popup_add->set_item_icon(popup_add->get_item_index(INPUT_MOUSE_BUTTON), input_editor->get_theme_icon("Mouse", "EditorIcons")); _update_actions(); } break; } @@ -462,7 +464,7 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) { press_a_key_label->set_text(str); press_a_key->get_ok()->set_disabled(false); - press_a_key->accept_event(); + press_a_key->set_input_as_handled(); } } @@ -479,7 +481,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even press_a_key->get_ok()->set_disabled(true); last_wait_for_key = Ref<InputEvent>(); press_a_key->popup_centered(Size2(250, 80) * EDSCALE); - press_a_key->grab_focus(); + //press_a_key->grab_focus(); } break; case INPUT_KEY_PHYSICAL: { @@ -505,7 +507,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even device_index->add_item(TTR("Wheel Right Button")); device_index->add_item(TTR("X Button 1")); device_index->add_item(TTR("X Button 2")); - device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE); + device_input->popup_centered(Size2(350, 95) * EDSCALE); Ref<InputEventMouseButton> mb = p_exiting_event; if (mb.is_valid()) { @@ -527,7 +529,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even String desc = _axis_names[i]; device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc); } - device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE); + device_input->popup_centered(Size2(350, 95) * EDSCALE); Ref<InputEventJoypadMotion> jm = p_exiting_event; if (jm.is_valid()) { @@ -549,7 +551,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even device_index->add_item(itos(i) + ": " + String(_button_names[i])); } - device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE); + device_input->popup_centered(Size2(350, 95) * EDSCALE); Ref<InputEventJoypadButton> jb = p_exiting_event; if (jb.is_valid()) { @@ -738,7 +740,7 @@ void ProjectSettingsEditor::_update_actions() { TreeItem *item = input_editor->create_item(root); item->set_text(0, name); - item->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); + item->set_custom_bg_color(0, input_editor->get_theme_color("prop_subsection", "Editor")); if (collapsed.has(name)) item->set_collapsed(collapsed[name]); @@ -746,12 +748,12 @@ void ProjectSettingsEditor::_update_actions() { item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); item->set_range_config(1, 0.0, 1.0, 0.01); item->set_range(1, action["deadzone"]); - item->set_custom_bg_color(1, get_color("prop_subsection", "Editor")); + item->set_custom_bg_color(1, input_editor->get_theme_color("prop_subsection", "Editor")); - const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL; + const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != nullptr; const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove"); - item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); - item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, tooltip); + item->add_button(2, input_editor->get_theme_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); + item->add_button(2, input_editor->get_theme_icon("Remove", "EditorIcons"), 2, false, tooltip); if (is_builtin_input) { // Built-in action (like `ui_up`). Make the action not removable, @@ -778,9 +780,9 @@ void ProjectSettingsEditor::_update_actions() { action2->set_text(0, str); if ((k->get_keycode() != 0)) { - action2->set_icon(0, get_icon("Keyboard", "EditorIcons")); + action2->set_icon(0, input_editor->get_theme_icon("Keyboard", "EditorIcons")); } else { - action2->set_icon(0, get_icon("KeyboardPhysical", "EditorIcons")); + action2->set_icon(0, input_editor->get_theme_icon("KeyboardPhysical", "EditorIcons")); } } @@ -794,7 +796,7 @@ void ProjectSettingsEditor::_update_actions() { } action2->set_text(0, str); - action2->set_icon(0, get_icon("JoyButton", "EditorIcons")); + action2->set_icon(0, input_editor->get_theme_icon("JoyButton", "EditorIcons")); } Ref<InputEventMouseButton> mb = event; @@ -811,7 +813,7 @@ void ProjectSettingsEditor::_update_actions() { } action2->set_text(0, str); - action2->set_icon(0, get_icon("Mouse", "EditorIcons")); + action2->set_icon(0, input_editor->get_theme_icon("Mouse", "EditorIcons")); } Ref<InputEventJoypadMotion> jm = event; @@ -823,13 +825,13 @@ void ProjectSettingsEditor::_update_actions() { String desc = _axis_names[n]; String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc; action2->set_text(0, str); - action2->set_icon(0, get_icon("JoyAxis", "EditorIcons")); + action2->set_icon(0, input_editor->get_theme_icon("JoyAxis", "EditorIcons")); } action2->set_metadata(0, i); action2->set_meta("__input", event); - action2->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit")); - action2->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove")); + action2->add_button(2, input_editor->get_theme_icon("Edit", "EditorIcons"), 3, false, TTR("Edit")); + action2->add_button(2, input_editor->get_theme_icon("Remove", "EditorIcons"), 2, false, TTR("Remove")); // Fade out the individual event buttons slightly to make the // Add/Remove buttons stand out more. action2->set_button_color(2, 0, Color(1, 1, 1, 0.75)); @@ -881,7 +883,7 @@ void ProjectSettingsEditor::_item_add() { // Initialize the property with the default value for the given type. // The type list starts at 1 (as we exclude Nil), so add 1 to the selected value. Callable::CallError ce; - const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), NULL, 0, ce); + const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), nullptr, 0, ce); String catname = category->get_text().strip_edges(); String propname = property->get_text().strip_edges(); @@ -1112,7 +1114,7 @@ Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control * hb->set_modulate(Color(1, 1, 1, 1.0f)); hb->add_child(label); vb->add_child(hb); - set_drag_preview(vb); + input_editor->set_drag_preview(vb); Dictionary drag_data; drag_data["type"] = "nodes"; @@ -1535,7 +1537,7 @@ void ProjectSettingsEditor::_update_translations() { updating_translations = true; translation_list->clear(); - TreeItem *root = translation_list->create_item(NULL); + TreeItem *root = translation_list->create_item(nullptr); translation_list->set_hide_root(true); if (ProjectSettings::get_singleton()->has_setting("locale/translations")) { @@ -1547,7 +1549,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); } } @@ -1587,7 +1589,7 @@ void ProjectSettingsEditor::_update_translations() { translation_locales_list_created = true; translation_filter->clear(); - root = translation_filter->create_item(NULL); + root = translation_filter->create_item(nullptr); translation_filter->set_hide_root(true); translation_filter_treeitems.clear(); for (int i = 0; i < s; i++) { @@ -1620,8 +1622,8 @@ void ProjectSettingsEditor::_update_translations() { translation_remap->clear(); translation_remap_options->clear(); - root = translation_remap->create_item(NULL); - TreeItem *root2 = translation_remap_options->create_item(NULL); + root = translation_remap->create_item(nullptr); + TreeItem *root2 = translation_remap_options->create_item(nullptr); translation_remap->set_hide_root(true); translation_remap_options->set_hide_root(true); translation_res_option_add_button->set_disabled(true); @@ -1670,7 +1672,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -1688,7 +1690,7 @@ void ProjectSettingsEditor::_update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, input_editor->get_theme_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -1774,7 +1776,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { singleton = this; set_title(TTR("Project Settings (project.godot)")); - set_resizable(true); + undo_redo = &p_data->get_undo_redo(); data = p_data; @@ -1873,7 +1875,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { add_prop_bar->add_child(popup_copy_to_feature); popup_copy_to_feature->get_popup()->connect("id_pressed", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform)); - popup_copy_to_feature->get_popup()->connect("about_to_show", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform_about_to_show)); + popup_copy_to_feature->get_popup()->connect("about_to_popup", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform_about_to_show)); get_ok()->set_text(TTR("Close")); set_hide_on_ok(true); @@ -1883,7 +1885,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { HBoxContainer *restart_hb = memnew(HBoxContainer); restart_container->add_child(restart_hb); restart_icon = memnew(TextureRect); - restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER); + restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER); restart_hb->add_child(restart_icon); restart_label = memnew(Label); restart_label->set_text(TTR("The editor must be restarted for changes to take effect.")); @@ -1907,10 +1909,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { VBoxContainer *vbc = memnew(VBoxContainer); input_base->add_child(vbc); - vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); - vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0); - vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); + vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 0); + vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, 0); + vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 0); + vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, 0); hbc = memnew(HBoxContainer); vbc->add_child(hbc); @@ -1920,7 +1922,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { l->set_text(TTR("Action:")); action_name = memnew(LineEdit); - action_name->set_h_size_flags(SIZE_EXPAND_FILL); + action_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->add_child(action_name); action_name->connect("text_entered", callable_mp(this, &ProjectSettingsEditor::_action_adds)); action_name->connect("text_changed", callable_mp(this, &ProjectSettingsEditor::_action_check)); @@ -1938,7 +1940,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { input_editor = memnew(Tree); vbc->add_child(input_editor); - input_editor->set_v_size_flags(SIZE_EXPAND_FILL); + input_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); input_editor->set_columns(3); input_editor->set_column_titles_visible(true); input_editor->set_column_title(0, TTR("Action")); @@ -1951,7 +1953,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { input_editor->connect("item_activated", callable_mp(this, &ProjectSettingsEditor::_action_activated)); input_editor->connect("cell_selected", callable_mp(this, &ProjectSettingsEditor::_action_selected)); input_editor->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_action_button_pressed)); - input_editor->set_drag_forwarding(this); +#ifndef _MSC_VER +#warning need to make drag data forwarding to non controls happen +#endif + //input_editor->set_drag_forwarding(this); popup_add = memnew(PopupMenu); add_child(popup_add); @@ -1960,7 +1965,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { press_a_key_physical = false; press_a_key = memnew(ConfirmationDialog); - press_a_key->set_focus_mode(FOCUS_ALL); + //press_a_key->set_focus_mode(Control::FOCUS_ALL); add_child(press_a_key); l = memnew(Label); @@ -1968,11 +1973,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { l->set_anchors_and_margins_preset(Control::PRESET_WIDE); l->set_align(Label::ALIGN_CENTER); l->set_margin(MARGIN_TOP, 20); - l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30); + l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30); press_a_key->get_ok()->set_disabled(true); press_a_key_label = l; press_a_key->add_child(l); - press_a_key->connect("gui_input", callable_mp(this, &ProjectSettingsEditor::_wait_for_key)); + press_a_key->connect("window_input", callable_mp(this, &ProjectSettingsEditor::_wait_for_key)); press_a_key->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_press_a_key_confirm)); device_input = memnew(ConfirmationDialog); @@ -1998,7 +2003,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { VBoxContainer *vbc_right = memnew(VBoxContainer); hbc->add_child(vbc_right); - vbc_right->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_right->set_h_size_flags(Control::SIZE_EXPAND_FILL); l = memnew(Label); l->set_text(TTR("Index:")); @@ -2006,6 +2011,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { device_index_label = l; device_index = memnew(OptionButton); + device_index->set_clip_text(true); + vbc_right->add_child(device_index); setting = false; @@ -2033,14 +2040,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { thb->add_child(addtr); VBoxContainer *tmc = memnew(VBoxContainer); tvb->add_child(tmc); - tmc->set_v_size_flags(SIZE_EXPAND_FILL); + tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL); translation_list = memnew(Tree); - translation_list->set_v_size_flags(SIZE_EXPAND_FILL); + translation_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); tmc->add_child(translation_list); translation_file_open = memnew(EditorFileDialog); add_child(translation_file_open); - translation_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); + translation_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); translation_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_add)); } @@ -2057,16 +2064,16 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { thb->add_child(addtr); VBoxContainer *tmc = memnew(VBoxContainer); tvb->add_child(tmc); - tmc->set_v_size_flags(SIZE_EXPAND_FILL); + tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL); translation_remap = memnew(Tree); - translation_remap->set_v_size_flags(SIZE_EXPAND_FILL); + translation_remap->set_v_size_flags(Control::SIZE_EXPAND_FILL); translation_remap->connect("cell_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_select)); tmc->add_child(translation_remap); translation_remap->connect("button_pressed", callable_mp(this, &ProjectSettingsEditor::_translation_res_delete)); translation_res_file_open = memnew(EditorFileDialog); add_child(translation_res_file_open); - translation_res_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); + translation_res_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); translation_res_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_add)); thb = memnew(HBoxContainer); @@ -2079,9 +2086,9 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { thb->add_child(addtr); tmc = memnew(VBoxContainer); tvb->add_child(tmc); - tmc->set_v_size_flags(SIZE_EXPAND_FILL); + tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL); translation_remap_options = memnew(Tree); - translation_remap_options->set_v_size_flags(SIZE_EXPAND_FILL); + translation_remap_options->set_v_size_flags(Control::SIZE_EXPAND_FILL); tmc->add_child(translation_remap_options); translation_remap_options->set_columns(2); @@ -2096,7 +2103,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { translation_res_option_file_open = memnew(EditorFileDialog); add_child(translation_res_option_file_open); - translation_res_option_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE); + translation_res_option_file_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); translation_res_option_file_open->connect("file_selected", callable_mp(this, &ProjectSettingsEditor::_translation_res_option_add)); } @@ -2105,7 +2112,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { translations->add_child(tvb); tvb->set_name(TTR("Locales Filter")); VBoxContainer *tmc = memnew(VBoxContainer); - tmc->set_v_size_flags(SIZE_EXPAND_FILL); + tmc->set_v_size_flags(Control::SIZE_EXPAND_FILL); tvb->add_child(tmc); translation_locale_filter_mode = memnew(OptionButton); @@ -2116,7 +2123,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { translation_locale_filter_mode->connect("item_selected", callable_mp(this, &ProjectSettingsEditor::_translation_filter_mode_changed)); translation_filter = memnew(Tree); - translation_filter->set_v_size_flags(SIZE_EXPAND_FILL); + translation_filter->set_v_size_flags(Control::SIZE_EXPAND_FILL); translation_filter->set_columns(1); tmc->add_child(memnew(Label(TTR("Locales:")))); tmc->add_child(translation_filter); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 52e7612acd..2cecb13198 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PROJECT_SETTINGS_H -#define PROJECT_SETTINGS_H +#ifndef PROJECT_SETTINGS_EDITOR_H +#define PROJECT_SETTINGS_EDITOR_H #include "core/undo_redo.h" #include "editor/editor_autoload_settings.h" @@ -204,4 +204,4 @@ public: ProjectSettingsEditor(EditorData *p_data); }; -#endif // PROJECT_SETTINGS_H +#endif // PROJECT_SETTINGS_EDITOR_H diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f4af50eb81..978c95b9c8 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -31,11 +31,11 @@ #include "property_editor.h" #include "core/class_db.h" +#include "core/input/input_filter.h" #include "core/io/image_loader.h" #include "core/io/marshalls.h" #include "core/io/resource_loader.h" #include "core/math/expression.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/pair.h" #include "core/print_string.h" @@ -53,7 +53,7 @@ #include "editor/multi_node_edit.h" #include "editor/property_selector.h" #include "scene/gui/label.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/font.h" #include "scene/resources/packed_scene.h" #include "scene/scene_string_names.h" @@ -103,12 +103,7 @@ Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_res void CustomPropertyEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - - RID ci = get_canvas_item(); - get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size())); - } - if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) { + if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) { hide(); } } @@ -151,7 +146,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { switch (p_which) { case OBJ_MENU_LOAD: { - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String(); List<String> extensions; @@ -199,7 +194,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { List<PropertyInfo> property_list; res_orig->get_property_list(&property_list); - List<Pair<String, Variant> > propvalues; + List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { @@ -222,7 +217,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) { + for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); @@ -262,7 +257,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { file_system_dock->navigate_to_path(r->get_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; default: { @@ -270,7 +265,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { int to_type = p_which - CONVERT_BASE_ID; - Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); + Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); ERR_FAIL_INDEX(to_type, conversions.size()); @@ -493,14 +488,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } else if (hint == PROPERTY_HINT_EXP_EASING) { - easing_draw->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 5 * EDSCALE); - easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -30 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 3 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -3 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -25 * EDSCALE); - type_button->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -7 * EDSCALE); + easing_draw->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5 * EDSCALE); + easing_draw->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -5 * EDSCALE); + easing_draw->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 5 * EDSCALE); + easing_draw->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -30 * EDSCALE); + type_button->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 3 * EDSCALE); + type_button->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -3 * EDSCALE); + type_button->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_END, -25 * EDSCALE); + type_button->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -7 * EDSCALE); type_button->set_text(TTR("Preset...")); type_button->get_popup()->clear(); type_button->get_popup()->add_item(TTR("Linear"), EASING_LINEAR); @@ -573,13 +568,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: text_edit->set_text(v); text_edit->deselect(); - int button_margin = get_constant("button_margin", "Dialogs"); - int margin = get_constant("margin", "Dialogs"); + int button_margin = text_edit->get_theme_constant("button_margin", "Dialogs"); + int margin = text_edit->get_theme_constant("margin", "Dialogs"); - action_buttons[0]->set_anchor(MARGIN_LEFT, ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_TOP, ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_RIGHT, ANCHOR_END); - action_buttons[0]->set_anchor(MARGIN_BOTTOM, ANCHOR_END); + action_buttons[0]->set_anchor(MARGIN_LEFT, Control::ANCHOR_END); + action_buttons[0]->set_anchor(MARGIN_TOP, Control::ANCHOR_END); + action_buttons[0]->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); + action_buttons[0]->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); action_buttons[0]->set_begin(Point2(-70 * EDSCALE, -button_margin + 5 * EDSCALE)); action_buttons[0]->set_end(Point2(-margin, -margin)); action_buttons[0]->set_text(TTR("Close")); @@ -900,7 +895,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: break; if (p_name == "script" && hint_text == "Script" && Object::cast_to<Node>(owner)) { - menu->add_icon_item(get_icon("Script", "EditorIcons"), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); + menu->add_item(TTR("New Script"), OBJ_MENU_NEW_SCRIPT); menu->add_separator(); } else if (hint_text != "") { int idx = 0; @@ -953,17 +948,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: int id = TYPE_BASE_ID + idx; - if (!icon.is_valid() && has_icon(t, "EditorIcons")) { - icon = get_icon(t, "EditorIcons"); - } - - if (icon.is_valid()) { - - menu->add_icon_item(icon, vformat(TTR("New %s"), t), id); - } else { - - menu->add_item(vformat(TTR("New %s"), t), id); - } + menu->add_item(vformat(TTR("New %s"), t), id); idx++; } @@ -973,13 +958,14 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->add_separator(); } - menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); + menu->add_item(TTR("Load"), OBJ_MENU_LOAD); if (!RES(v).is_null()) { - menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); - menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); - menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + menu->add_item(TTR("Edit"), OBJ_MENU_EDIT); + menu->add_item(TTR("Clear"), OBJ_MENU_CLEAR); + menu->add_item(TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); + RES r = v; if (r.is_valid() && r->get_path().is_resource_file()) { menu->add_separator(); @@ -1016,22 +1002,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: if (!RES(v).is_null()) { - Vector<Ref<EditorResourceConversionPlugin> > conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); + Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); if (conversions.size()) { menu->add_separator(); } for (int i = 0; i < conversions.size(); i++) { String what = conversions[i]->converts_to(); - Ref<Texture2D> icon; - if (has_icon(what, "EditorIcons")) { - - icon = get_icon(what, "EditorIcons"); - } else { - - icon = get_icon(what, "Resource"); - } - - menu->add_icon_item(icon, vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i); + menu->add_item(vformat(TTR("Convert To %s"), what), CONVERT_BASE_ID + i); } } @@ -1105,7 +1082,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { RES res = ResourceLoader::load(p_file, type); if (res.is_null()) { error->set_text(TTR("Error loading file: Not a resource!")); - error->popup_centered_minsize(); + error->popup_centered(); break; } v = res; @@ -1217,7 +1194,7 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } else if (owner) { - Node *node = NULL; + Node *node = nullptr; if (owner->is_class("Node")) node = Object::cast_to<Node>(owner); @@ -1282,7 +1259,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { else file->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file->clear_filters(); file->clear_filters(); @@ -1316,7 +1293,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->set_access(EditorFileDialog::ACCESS_RESOURCES); else file->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file->set_mode(EditorFileDialog::MODE_OPEN_DIR); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); file->clear_filters(); file->popup_centered_ratio(); } else { @@ -1385,7 +1362,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } else if (p_which == 1) { file->set_access(EditorFileDialog::ACCESS_RESOURCES); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String(); @@ -1421,7 +1398,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { List<PropertyInfo> property_list; res_orig->get_property_list(&property_list); - List<Pair<String, Variant> > propvalues; + List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { @@ -1440,7 +1417,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); - for (List<Pair<String, Variant> >::Element *E = propvalues.front(); E; E = E->next()) { + for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); @@ -1500,7 +1477,7 @@ void CustomPropertyEditor::_draw_easing() { Size2 s = easing_draw->get_size(); Rect2 r(Point2(), s); r = r.grow(3); - get_stylebox("normal", "LineEdit")->draw(ci, r); + easing_draw->get_theme_stylebox("normal", "LineEdit")->draw(ci, r); int points = 48; @@ -1508,8 +1485,8 @@ void CustomPropertyEditor::_draw_easing() { float exp = v; bool flip = hint_text == "attenuation"; - Ref<Font> f = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); + Ref<Font> f = easing_draw->get_theme_font("font", "Label"); + Color color = easing_draw->get_theme_color("font_color", "Label"); for (int i = 1; i <= points; i++) { @@ -1523,7 +1500,7 @@ void CustomPropertyEditor::_draw_easing() { iflp = 1.0 - iflp; } - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color); + RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(iflp * s.width, prev * s.height), Point2(ifl * s.width, h * s.height), color); prev = h; } @@ -1564,7 +1541,7 @@ void CustomPropertyEditor::_modified(String p_string) { v = value_editor[0]->get_text().to_int(); return; } else { - v = expr->execute(Array(), NULL, false); + v = expr->execute(Array(), nullptr, false); } emit_signal("variant_changed"); @@ -1736,14 +1713,14 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) { if (err != OK) { out = value_editor[0]->get_text().to_double(); } else { - out = expr->execute(Array(), NULL, false); + out = expr->execute(Array(), nullptr, false); } return out; } void CustomPropertyEditor::_emit_changed_whole_or_field() { - if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (!InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { emit_signal("variant_changed"); } else { emit_signal("variant_field_changed", field_names[focused_value_editor]); @@ -1805,7 +1782,7 @@ void CustomPropertyEditor::_focus_exit() { void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { - Ref<StyleBox> sb = get_stylebox("panel"); + Ref<StyleBox> sb = action_buttons[0]->get_theme_stylebox("panel"); int margin_top = sb->get_margin(MARGIN_TOP); int margin_left = sb->get_margin(MARGIN_LEFT); int margin_bottom = sb->get_margin(MARGIN_BOTTOM); @@ -1921,7 +1898,7 @@ CustomPropertyEditor::CustomPropertyEditor() { checks20[i] = memnew(CheckBox); checks20[i]->set_toggle_mode(true); - checks20[i]->set_focus_mode(FOCUS_NONE); + checks20[i]->set_focus_mode(Control::FOCUS_NONE); checks20gc->add_child(checks20[i]); checks20[i]->hide(); checks20[i]->connect("pressed", callable_mp(this, &CustomPropertyEditor::_action_pressed), make_binds(i)); @@ -1947,9 +1924,8 @@ CustomPropertyEditor::CustomPropertyEditor() { action_buttons[i]->set_flat(true); } - color_picker = NULL; + color_picker = nullptr; - set_as_toplevel(true); file = memnew(EditorFileDialog); add_child(file); file->hide(); @@ -1983,11 +1959,11 @@ CustomPropertyEditor::CustomPropertyEditor() { type_button->get_popup()->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_type_create_selected)); menu = memnew(PopupMenu); - menu->set_pass_on_modal_close_click(false); + // menu->set_pass_on_modal_close_click(false); add_child(menu); menu->connect("id_pressed", callable_mp(this, &CustomPropertyEditor::_menu_option)); - evaluator = NULL; + evaluator = nullptr; spinbox = memnew(SpinBox); add_child(spinbox); @@ -1999,6 +1975,6 @@ CustomPropertyEditor::CustomPropertyEditor() { slider->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 5); slider->connect("value_changed", callable_mp(this, &CustomPropertyEditor::_range_modified)); - create_dialog = NULL; - property_select = NULL; + create_dialog = nullptr; + property_select = nullptr; } diff --git a/editor/property_editor.h b/editor/property_editor.h index bc2a222714..45466eaa42 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -63,9 +63,9 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; -class CustomPropertyEditor : public Popup { +class CustomPropertyEditor : public PopupPanel { - GDCLASS(CustomPropertyEditor, Popup); + GDCLASS(CustomPropertyEditor, PopupPanel); enum { MAX_VALUE_EDITORS = 12, diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index ede7b860d6..1960ecc604 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -96,7 +96,7 @@ void PropertySelector::_update_search() { } else if (type != Variant::NIL) { Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); v.get_property_list(&props); } else { @@ -116,43 +116,43 @@ void PropertySelector::_update_search() { } } - TreeItem *category = NULL; + TreeItem *category = nullptr; bool found = false; Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = { - Control::get_icon("Variant", "EditorIcons"), - Control::get_icon("bool", "EditorIcons"), - Control::get_icon("int", "EditorIcons"), - Control::get_icon("float", "EditorIcons"), - Control::get_icon("String", "EditorIcons"), - Control::get_icon("Vector2", "EditorIcons"), - Control::get_icon("Rect2", "EditorIcons"), - Control::get_icon("Vector3", "EditorIcons"), - Control::get_icon("Transform2D", "EditorIcons"), - Control::get_icon("Plane", "EditorIcons"), - Control::get_icon("Quat", "EditorIcons"), - Control::get_icon("AABB", "EditorIcons"), - Control::get_icon("Basis", "EditorIcons"), - Control::get_icon("Transform", "EditorIcons"), - Control::get_icon("Color", "EditorIcons"), - Control::get_icon("Path", "EditorIcons"), - Control::get_icon("RID", "EditorIcons"), - Control::get_icon("Object", "EditorIcons"), - Control::get_icon("Dictionary", "EditorIcons"), - Control::get_icon("Array", "EditorIcons"), - Control::get_icon("PackedByteArray", "EditorIcons"), - Control::get_icon("PackedInt32Array", "EditorIcons"), - Control::get_icon("PackedFloat32Array", "EditorIcons"), - Control::get_icon("PackedStringArray", "EditorIcons"), - Control::get_icon("PackedVector2Array", "EditorIcons"), - Control::get_icon("PackedVector3Array", "EditorIcons"), - Control::get_icon("PackedColorArray", "EditorIcons") + search_options->get_theme_icon("Variant", "EditorIcons"), + search_options->get_theme_icon("bool", "EditorIcons"), + search_options->get_theme_icon("int", "EditorIcons"), + search_options->get_theme_icon("float", "EditorIcons"), + search_options->get_theme_icon("String", "EditorIcons"), + search_options->get_theme_icon("Vector2", "EditorIcons"), + search_options->get_theme_icon("Rect2", "EditorIcons"), + search_options->get_theme_icon("Vector3", "EditorIcons"), + search_options->get_theme_icon("Transform2D", "EditorIcons"), + search_options->get_theme_icon("Plane", "EditorIcons"), + search_options->get_theme_icon("Quat", "EditorIcons"), + search_options->get_theme_icon("AABB", "EditorIcons"), + search_options->get_theme_icon("Basis", "EditorIcons"), + search_options->get_theme_icon("Transform", "EditorIcons"), + search_options->get_theme_icon("Color", "EditorIcons"), + search_options->get_theme_icon("Path", "EditorIcons"), + search_options->get_theme_icon("RID", "EditorIcons"), + search_options->get_theme_icon("Object", "EditorIcons"), + search_options->get_theme_icon("Dictionary", "EditorIcons"), + search_options->get_theme_icon("Array", "EditorIcons"), + search_options->get_theme_icon("PackedByteArray", "EditorIcons"), + search_options->get_theme_icon("PackedInt32Array", "EditorIcons"), + search_options->get_theme_icon("PackedFloat32Array", "EditorIcons"), + search_options->get_theme_icon("PackedStringArray", "EditorIcons"), + search_options->get_theme_icon("PackedVector2Array", "EditorIcons"), + search_options->get_theme_icon("PackedVector3Array", "EditorIcons"), + search_options->get_theme_icon("PackedColorArray", "EditorIcons") }; for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { if (E->get().usage == PROPERTY_USAGE_CATEGORY) { - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); @@ -161,7 +161,7 @@ void PropertySelector::_update_search() { Ref<Texture2D> icon; if (E->get().name == "Script Variables") { - icon = get_icon("Script", "EditorIcons"); + icon = search_options->get_theme_icon("Script", "EditorIcons"); } else { icon = EditorNode::get_singleton()->get_class_icon(E->get().name); } @@ -191,7 +191,7 @@ void PropertySelector::_update_search() { item->set_selectable(0, true); } - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } } else { @@ -201,7 +201,7 @@ void PropertySelector::_update_search() { if (type != Variant::NIL) { Variant v; Callable::CallError ce; - v = Variant::construct(type, NULL, 0, ce); + v = Variant::construct(type, nullptr, 0, ce); v.get_method_list(&methods); } else { @@ -220,14 +220,14 @@ void PropertySelector::_update_search() { } } - TreeItem *category = NULL; + TreeItem *category = nullptr; bool found = false; bool script_methods = false; for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { if (E->get().name.begins_with("*")) { - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } category = search_options->create_item(root); @@ -238,7 +238,7 @@ void PropertySelector::_update_search() { script_methods = false; String rep = E->get().name.replace("*", ""); if (E->get().name == "*Script Methods") { - icon = get_icon("Script", "EditorIcons"); + icon = search_options->get_theme_icon("Script", "EditorIcons"); script_methods = true; } else { icon = EditorNode::get_singleton()->get_class_icon(rep); @@ -310,12 +310,12 @@ void PropertySelector::_update_search() { } } - if (category && category->get_children() == NULL) { + if (category && category->get_children() == nullptr) { memdelete(category); //old category was unused } } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void PropertySelector::_confirmed() { @@ -390,7 +390,7 @@ void PropertySelector::_item_selected() { } void PropertySelector::_hide_requested() { - _closed(); // From WindowDialog. + _cancel_pressed(); // From AcceptDialog. } void PropertySelector::_notification(int p_what) { @@ -410,7 +410,7 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const type = Variant::NIL; script = ObjectID(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = p_virtuals_only; popup_centered_ratio(0.6); @@ -427,7 +427,7 @@ void PropertySelector::select_method_from_script(const Ref<Script> &p_script, co type = Variant::NIL; script = p_script->get_instance_id(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -443,7 +443,7 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const type = p_type; script = ObjectID(); properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -464,7 +464,7 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str script = scr->get_instance_id(); } properties = false; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -480,7 +480,7 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons type = Variant::NIL; script = ObjectID(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -498,7 +498,7 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script, type = Variant::NIL; script = p_script->get_instance_id(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); @@ -515,7 +515,7 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con type = p_type; script = ObjectID(); properties = true; - instance = NULL; + instance = nullptr; virtuals_only = false; popup_centered_ratio(0.6); diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index f9efe6a50d..1363fe2942 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -38,8 +38,8 @@ #include "editor_settings.h" #include "scene/resources/texture.h" -static void (*_base_image_compress_pvrtc2_func)(Image *) = NULL; -static void (*_base_image_compress_pvrtc4_func)(Image *) = NULL; +static void (*_base_image_compress_pvrtc2_func)(Image *) = nullptr; +static void (*_base_image_compress_pvrtc4_func)(Image *) = nullptr; static void _compress_image(Image::CompressMode p_mode, Image *p_image) { diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 8a5fad269f..1b4439f0a8 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -122,7 +122,7 @@ float EditorQuickOpen::_path_cmp(String search, String path) const { return path.to_lower().similarity(search.to_lower()); } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list) { +void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list) { if (!add_directories) { for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -140,9 +140,9 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str if (path != "res://") { path = path.substr(6, path.length()); if (search_text.is_subsequence_ofi(path)) { - Pair<String, Ref<Texture2D> > pair; + Pair<String, Ref<Texture2D>> pair; pair.first = path; - pair.second = get_icon("folder", "FileDialog"); + pair.second = search_options->get_theme_icon("folder", "FileDialog"); if (search_text != String() && list.size() > 0) { @@ -169,9 +169,9 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str file = file.substr(6, file.length()); if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) { - Pair<String, Ref<Texture2D> > pair; + Pair<String, Ref<Texture2D>> pair; pair.first = file; - pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); + pair.second = search_options->get_theme_icon((search_options->has_theme_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); list.push_back(pair); } } @@ -184,10 +184,10 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str } } -Vector<Pair<String, Ref<Texture2D> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list) { +Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list) { String search_text = search_box->get_text(); - Vector<Pair<String, Ref<Texture2D> > > sorted_list; + Vector<Pair<String, Ref<Texture2D>>> sorted_list; if (search_text == String() || list.size() == 0) return list; @@ -223,7 +223,7 @@ void EditorQuickOpen::_update_search() { search_options->clear(); TreeItem *root = search_options->create_item(); EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); - Vector<Pair<String, Ref<Texture2D> > > list; + Vector<Pair<String, Ref<Texture2D>>> list; _parse_fs(efsd, list); list = _sort_fs(list); @@ -241,7 +241,7 @@ void EditorQuickOpen::_update_search() { ti->set_as_cursor(0); } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void EditorQuickOpen::_confirmed() { @@ -253,6 +253,11 @@ void EditorQuickOpen::_confirmed() { hide(); } +void EditorQuickOpen::_theme_changed() { + + search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); +} + void EditorQuickOpen::_notification(int p_what) { switch (p_what) { @@ -260,10 +265,6 @@ void EditorQuickOpen::_notification(int p_what) { connect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); search_box->set_clear_button_enabled(true); - [[fallthrough]]; - } - case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); @@ -284,6 +285,8 @@ void EditorQuickOpen::_bind_methods() { EditorQuickOpen::EditorQuickOpen() { VBoxContainer *vbc = memnew(VBoxContainer); + vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed)); + add_child(vbc); search_box = memnew(LineEdit); vbc->add_margin_child(TTR("Search:"), search_box); @@ -298,7 +301,7 @@ EditorQuickOpen::EditorQuickOpen() { search_options->connect("item_activated", callable_mp(this, &EditorQuickOpen::_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); ei = "EditorIcons"; ot = "Object"; add_directories = false; diff --git a/editor/quick_open.h b/editor/quick_open.h index 4814e5f310..c0e2cb85d8 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -49,13 +49,15 @@ class EditorQuickOpen : public ConfirmationDialog { void _update_search(); void _sbox_input(const Ref<InputEvent> &p_ie); - void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list); - Vector<Pair<String, Ref<Texture2D> > > _sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list); + void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list); + Vector<Pair<String, Ref<Texture2D>>> _sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list); float _path_cmp(String search, String path) const; void _confirmed(); void _text_changed(const String &p_newtext); + void _theme_changed(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 2d7b7027c8..0266ef6a2b 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -45,7 +45,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; - preview_node = NULL; + preview_node = nullptr; set_title(TTR("Batch Rename")); @@ -56,7 +56,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und GridContainer *grd_main = memnew(GridContainer); grd_main->set_columns(2); - grd_main->set_v_size_flags(SIZE_EXPAND_FILL); + grd_main->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(grd_main); // ---- 1st & 2nd row @@ -67,7 +67,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lne_search = memnew(LineEdit); lne_search->set_placeholder(TTR("Search")); lne_search->set_name("lne_search"); - lne_search->set_h_size_flags(SIZE_EXPAND_FILL); + lne_search->set_h_size_flags(Control::SIZE_EXPAND_FILL); Label *lbl_replace = memnew(Label); lbl_replace->set_text(TTR("Replace")); @@ -75,7 +75,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lne_replace = memnew(LineEdit); lne_replace->set_placeholder(TTR("Replace")); lne_replace->set_name("lne_replace"); - lne_replace->set_h_size_flags(SIZE_EXPAND_FILL); + lne_replace->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_main->add_child(lbl_search); grd_main->add_child(lbl_replace); @@ -90,7 +90,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lne_prefix = memnew(LineEdit); lne_prefix->set_placeholder(TTR("Prefix")); lne_prefix->set_name("lne_prefix"); - lne_prefix->set_h_size_flags(SIZE_EXPAND_FILL); + lne_prefix->set_h_size_flags(Control::SIZE_EXPAND_FILL); Label *lbl_suffix = memnew(Label); lbl_suffix->set_text(TTR("Suffix")); @@ -98,7 +98,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lne_suffix = memnew(LineEdit); lne_suffix->set_placeholder(TTR("Suffix")); lne_suffix->set_name("lne_suffix"); - lne_suffix->set_h_size_flags(SIZE_EXPAND_FILL); + lne_suffix->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_main->add_child(lbl_prefix); grd_main->add_child(lbl_suffix); @@ -124,7 +124,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und // ---- Tab Substitute VBoxContainer *vbc_substitute = memnew(VBoxContainer); - vbc_substitute->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_substitute->set_h_size_flags(Control::SIZE_EXPAND_FILL); vbc_substitute->set_custom_minimum_size(Size2(0, feature_min_height)); vbc_substitute->set_name(TTR("Substitute")); @@ -143,9 +143,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_name = memnew(Button); but_insert_name->set_text("NAME"); but_insert_name->set_tooltip(String("${NAME}\n") + TTR("Node name")); - but_insert_name->set_focus_mode(FOCUS_NONE); + but_insert_name->set_focus_mode(Control::FOCUS_NONE); but_insert_name->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${NAME}")); - but_insert_name->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_name); // Parent @@ -153,9 +153,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_parent = memnew(Button); but_insert_parent->set_text("PARENT"); but_insert_parent->set_tooltip(String("${PARENT}\n") + TTR("Node's parent name, if available")); - but_insert_parent->set_focus_mode(FOCUS_NONE); + but_insert_parent->set_focus_mode(Control::FOCUS_NONE); but_insert_parent->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${PARENT}")); - but_insert_parent->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_parent->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_parent); // Type @@ -163,9 +163,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_type = memnew(Button); but_insert_type->set_text("TYPE"); but_insert_type->set_tooltip(String("${TYPE}\n") + TTR("Node type")); - but_insert_type->set_focus_mode(FOCUS_NONE); + but_insert_type->set_focus_mode(Control::FOCUS_NONE); but_insert_type->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${TYPE}")); - but_insert_type->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_type->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_type); // Scene @@ -173,9 +173,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_scene = memnew(Button); but_insert_scene->set_text("SCENE"); but_insert_scene->set_tooltip(String("${SCENE}\n") + TTR("Current scene name")); - but_insert_scene->set_focus_mode(FOCUS_NONE); + but_insert_scene->set_focus_mode(Control::FOCUS_NONE); but_insert_scene->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${SCENE}")); - but_insert_scene->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_scene->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_scene); // Root @@ -183,9 +183,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_root = memnew(Button); but_insert_root->set_text("ROOT"); but_insert_root->set_tooltip(String("${ROOT}\n") + TTR("Root node name")); - but_insert_root->set_focus_mode(FOCUS_NONE); + but_insert_root->set_focus_mode(Control::FOCUS_NONE); but_insert_root->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${ROOT}")); - but_insert_root->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_root->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_root); // Count @@ -193,9 +193,9 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und but_insert_count = memnew(Button); but_insert_count->set_text("COUNTER"); but_insert_count->set_tooltip(String("${COUNTER}\n") + TTR("Sequential integer counter.\nCompare counter options.")); - but_insert_count->set_focus_mode(FOCUS_NONE); + but_insert_count->set_focus_mode(Control::FOCUS_NONE); but_insert_count->connect("pressed", callable_mp(this, &RenameDialog::_insert_text), make_binds("${COUNTER}")); - but_insert_count->set_h_size_flags(SIZE_EXPAND_FILL); + but_insert_count->set_h_size_flags(Control::SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_count); chk_per_level_counter = memnew(CheckBox); @@ -240,7 +240,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und // ---- Tab Process VBoxContainer *vbc_process = memnew(VBoxContainer); - vbc_process->set_h_size_flags(SIZE_EXPAND_FILL); + vbc_process->set_h_size_flags(Control::SIZE_EXPAND_FILL); vbc_process->set_name(TTR("Post-Process")); vbc_process->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_process); @@ -291,13 +291,13 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und lbl_preview = memnew(Label); lbl_preview->set_text(""); - lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); vbc->add_child(lbl_preview); // ---- Dialog related - set_custom_minimum_size(Size2(383, 0)); - set_as_toplevel(true); + set_min_size(Size2(383, 0)); + //set_as_toplevel(true); get_ok()->set_text(TTR("Rename")); Button *but_reset = add_button(TTR("Reset")); @@ -347,7 +347,7 @@ void RenameDialog::_bind_methods() { void RenameDialog::_update_substitute() { - LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(get_focus_owner()); + LineEdit *focus_owner_line_edit = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner()); bool is_main_field = _is_main_field(focus_owner_line_edit); but_insert_name->set_disabled(!is_main_field); @@ -358,18 +358,18 @@ void RenameDialog::_update_substitute() { but_insert_count->set_disabled(!is_main_field); // The focus mode seems to be reset when disabling/re-enabling - but_insert_name->set_focus_mode(FOCUS_NONE); - but_insert_parent->set_focus_mode(FOCUS_NONE); - but_insert_type->set_focus_mode(FOCUS_NONE); - but_insert_scene->set_focus_mode(FOCUS_NONE); - but_insert_root->set_focus_mode(FOCUS_NONE); - but_insert_count->set_focus_mode(FOCUS_NONE); + but_insert_name->set_focus_mode(Control::FOCUS_NONE); + but_insert_parent->set_focus_mode(Control::FOCUS_NONE); + but_insert_type->set_focus_mode(Control::FOCUS_NONE); + but_insert_scene->set_focus_mode(Control::FOCUS_NONE); + but_insert_root->set_focus_mode(Control::FOCUS_NONE); + but_insert_count->set_focus_mode(Control::FOCUS_NONE); } void RenameDialog::_post_popup() { EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); - preview_node = NULL; + preview_node = nullptr; Array selected_node_list = editor_selection->get_selected_nodes(); ERR_FAIL_COND(selected_node_list.size() == 0); @@ -386,7 +386,7 @@ void RenameDialog::_update_preview_int(int new_value) { void RenameDialog::_update_preview(String new_text) { - if (lock_preview_update || preview_node == NULL) + if (lock_preview_update || preview_node == nullptr) return; has_errors = false; @@ -401,11 +401,11 @@ void RenameDialog::_update_preview(String new_text) { if (new_name == preview_node->get_name()) { // New name is identical to the old one. Don't color it as much to avoid distracting the user. - const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_color("accent_color", "Editor"); - const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_color("default_color", "RichTextLabel"); - lbl_preview->add_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); + const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor"); + const Color text_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("default_color", "RichTextLabel"); + lbl_preview->add_theme_color_override("font_color", accent_color.linear_interpolate(text_color, 0.5)); } else { - lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("success_color", "Editor")); + lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); } } @@ -491,7 +491,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * self->has_errors = true; self->lbl_preview_title->set_text(TTR("Regular Expression Error")); - self->lbl_preview->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); + self->lbl_preview->add_theme_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); self->lbl_preview->set_text(vformat(TTR("At character %s"), err_str)); } @@ -652,7 +652,7 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) { void RenameDialog::_insert_text(String text) { - LineEdit *focus_owner = Object::cast_to<LineEdit>(get_focus_owner()); + LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner()); if (_is_main_field(focus_owner)) { focus_owner->selection_delete(); diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 2825cb2cd2..194dd57648 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -96,14 +96,13 @@ class RenameDialog : public ConfirmationDialog { Label *lbl_preview_title; Label *lbl_preview; - List<Pair<NodePath, String> > to_rename; + List<Pair<NodePath, String>> to_rename; Node *preview_node; bool lock_preview_update; ErrorHandlerList eh; bool has_errors; protected: - void _notification(int p_what){}; static void _bind_methods(); virtual void _post_popup(); @@ -111,7 +110,7 @@ public: void reset(); void rename(); - RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo = NULL); + RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo = nullptr); ~RenameDialog(){}; }; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index 551d20eddb..b71c2bd078 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -45,12 +45,6 @@ void ReparentDialog::_notification(int p_what) { disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); } - - if (p_what == NOTIFICATION_DRAW) { - - //RID ci = get_canvas_item(); - //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); - } } void ReparentDialog::_cancel() { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c5ebf40482..a729f62123 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -30,8 +30,8 @@ #include "scene_tree_dock.h" +#include "core/input/input_filter.h" #include "core/io/resource_saver.h" -#include "core/os/input.h" #include "core/os/keyboard.h" #include "core/project_settings.h" #include "editor/debugger/editor_debugger_node.h" @@ -42,10 +42,12 @@ #include "editor/multi_node_edit.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" +#include "editor/plugins/node_3d_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" -#include "editor/plugins/spatial_editor_plugin.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" +#include "servers/display_server.h" +#include "servers/rendering_server.h" void SceneTreeDock::_nodes_drag_begin() { @@ -73,9 +75,6 @@ void SceneTreeDock::_input(Ref<InputEvent> p_event) { void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { - if (get_viewport()->get_modal_stack_top()) - return; //ignore because of modal window - if (get_focus_owner() && get_focus_owner()->is_text_field()) return; @@ -131,7 +130,7 @@ void SceneTreeDock::instance(const String &p_file) { current_option = -1; accept->set_text(TTR("No parent to instance a child at.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; }; @@ -153,7 +152,7 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren if (!parent || !edited_scene) { accept->set_text(TTR("No parent to instance the scenes at.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; }; @@ -174,7 +173,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node if (!sdata.is_valid()) { current_option = -1; accept->set_text(vformat(TTR("Error loading scene from %s"), p_files[i])); - accept->popup_centered_minsize(); + accept->popup_centered(); error = true; break; } @@ -183,7 +182,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node if (!instanced_scene) { current_option = -1; accept->set_text(vformat(TTR("Error instancing scene from %s"), p_files[i])); - accept->popup_centered_minsize(); + accept->popup_centered(); error = true; break; } @@ -193,7 +192,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node if (_cyclical_dependency_exists(edited_scene->get_filename(), instanced_scene)) { accept->set_text(vformat(TTR("Cannot instance the scene '%s' because the current scene exists within one of its nodes."), p_files[i])); - accept->popup_centered_minsize(); + accept->popup_centered(); error = true; break; } @@ -240,14 +239,14 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) Ref<PackedScene> sdata = ResourceLoader::load(p_file); if (!sdata.is_valid()) { accept->set_text(vformat(TTR("Error loading scene from %s"), p_file)); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } Node *instanced_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!instanced_scene) { accept->set_text(vformat(TTR("Error instancing scene from %s"), p_file)); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } @@ -368,8 +367,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node2D")) preferred = "Node2D"; - else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Spatial")) - preferred = "Spatial"; + else if (ClassDB::is_parent_class(current_edited_scene_root->get_class_name(), "Node3D")) + preferred = "Node3D"; } create_dialog->set_preferred_search_result_type(preferred); create_dialog->popup_create(true); @@ -439,7 +438,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { return; editor_data->get_undo_redo().create_action(TTR("Clear Script")); - editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)NULL); + editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)nullptr); for (int i = 0; i < selection.size(); i++) { @@ -471,7 +470,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } @@ -496,7 +495,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (index < lowest_id) lowest_id = index; if (E->get()->get_parent() != common_parent) - common_parent = NULL; + common_parent = nullptr; } if (!common_parent || (MOVING_DOWN && highest_id >= common_parent->get_child_count() - MOVING_DOWN) || (MOVING_UP && lowest_id == 0)) @@ -535,7 +534,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } @@ -549,7 +548,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().create_action(TTR("Duplicate Node(s)")); editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); - Node *dupsingle = NULL; + Node *dupsingle = nullptr; List<Node *> editable_children; selection.sort_custom<Node::Comparator>(); @@ -618,7 +617,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } @@ -654,19 +653,19 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (root->get_scene_inherited_state().is_valid()) { accept->set_text(TTR("Can't reparent nodes in inherited scenes, order of nodes can't change.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } if (node->get_owner() != root) { accept->set_text(TTR("Node must belong to the edited scene to become root.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } if (node->get_filename() != String()) { accept->set_text(TTR("Instantiated scenes can't become root")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } @@ -676,7 +675,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(node, "add_child", root); editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename()); editor_data->get_undo_redo().add_do_method(root, "set_filename", String()); - editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)nullptr); editor_data->get_undo_redo().add_do_method(root, "set_owner", node); _node_replace_owner(root, root, node, MODE_DO); @@ -686,7 +685,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, node->get_index()); - editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)nullptr); editor_data->get_undo_redo().add_undo_method(node, "set_owner", root); _node_replace_owner(root, root, root, MODE_UNDO); @@ -745,7 +744,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { // This prevents the dialog from being too wide after displaying // a deletion confirmation for a node with a long name. delete_dialog->set_size(Size2()); - delete_dialog->popup_centered_minsize(); + delete_dialog->popup_centered(); } } break; @@ -767,7 +766,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!scene) { accept->set_text(TTR("This operation can't be done without a scene.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } @@ -775,7 +774,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (selection.size() != 1) { accept->set_text(TTR("This operation requires a single selected node.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } @@ -783,17 +782,17 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (tocopy == scene) { accept->set_text(TTR("Can not perform with the root node.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } if (tocopy != editor_data->get_edited_scene_root() && tocopy->get_filename() != "") { accept->set_text(TTR("This operation can't be done on instanced scenes.")); - accept->popup_centered_minsize(); + accept->popup_centered(); break; } - new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + new_scene_from_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); List<String> extensions; Ref<PackedScene> sd = memnew(PackedScene); @@ -822,7 +821,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (node) { Node *root = EditorNode::get_singleton()->get_edited_scene(); NodePath path = root->get_path().rel_path_to(node->get_path()); - OS::get_singleton()->set_clipboard(path); + DisplayServer::get_singleton()->clipboard_set(path); } } } break; @@ -848,7 +847,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (editable) { editable_instance_remove_dialog->set_text(TTR("Disabling \"editable_instance\" will cause all properties of the node to be reverted to their default.")); - editable_instance_remove_dialog->popup_centered_minsize(); + editable_instance_remove_dialog->popup_centered(); break; } _toggle_editable_children(node); @@ -872,7 +871,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { // Fire confirmation dialog when children are editable. if (editable && !placeholder) { placeholder_editable_instance_remove_dialog->set_text(TTR("Enabling \"Load As Placeholder\" will disable \"Editable Children\" and cause all properties of the node to be reverted to their default.")); - placeholder_editable_instance_remove_dialog->popup_centered_minsize(); + placeholder_editable_instance_remove_dialog->popup_centered(); break; } @@ -929,7 +928,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - clear_inherit_confirm->popup_centered_minsize(); + clear_inherit_confirm->popup_centered(); } break; case TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM: { if (!profile_allow_editing) { @@ -963,7 +962,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { case TOOL_CREATE_USER_INTERFACE: case TOOL_CREATE_FAVORITE: { - Node *new_node = NULL; + Node *new_node = nullptr; if (TOOL_CREATE_FAVORITE == p_tool) { String name = selected_favorite_root.get_slicec(' ', 0); @@ -985,7 +984,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } else { switch (p_tool) { case TOOL_CREATE_2D_SCENE: new_node = memnew(Node2D); break; - case TOOL_CREATE_3D_SCENE: new_node = memnew(Spatial); break; + case TOOL_CREATE_3D_SCENE: new_node = memnew(Node3D); break; case TOOL_CREATE_USER_INTERFACE: { Control *node = memnew(Control); node->set_anchors_and_margins_preset(PRESET_WIDE); //more useful for resizable UIs. @@ -999,7 +998,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", new_node); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_do_reference(new_node); - 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); editor_data->get_undo_redo().commit_action(); editor->edit_node(new_node); @@ -1031,7 +1030,7 @@ void SceneTreeDock::_node_collapsed(Object *p_obj) { if (!ti) return; - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + if (InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)) { _set_collapsed_recursive(ti, ti->is_collapsed()); } } @@ -1054,16 +1053,16 @@ void SceneTreeDock::_notification(int p_what) { scene_tree->connect("node_changed", callable_mp((CanvasItem *)canvas_item_plugin->get_canvas_item_editor()->get_viewport_control(), &CanvasItem::update)); } - SpatialEditorPlugin *spatial_editor_plugin = Object::cast_to<SpatialEditorPlugin>(editor_data->get_editor("3D")); + Node3DEditorPlugin *spatial_editor_plugin = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D")); spatial_editor_plugin->get_spatial_editor()->connect_compat("item_lock_status_changed", scene_tree, "_update_tree"); spatial_editor_plugin->get_spatial_editor()->connect_compat("item_group_status_changed", scene_tree, "_update_tree"); - button_add->set_icon(get_icon("Add", "EditorIcons")); - button_instance->set_icon(get_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons")); - button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons")); + button_add->set_icon(get_theme_icon("Add", "EditorIcons")); + button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); + button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); + button_clear_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); - filter->set_right_icon(get_icon("Search", "EditorIcons")); + filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", callable_mp(this, &SceneTreeDock::_selection_changed)); @@ -1078,7 +1077,7 @@ void SceneTreeDock::_notification(int p_what) { ToolButton *node_shortcuts_toggle = memnew(ToolButton); node_shortcuts_toggle->set_name("NodeShortcutsToggle"); - node_shortcuts_toggle->set_icon(get_icon("Favorites", "EditorIcons")); + node_shortcuts_toggle->set_icon(get_theme_icon("Favorites", "EditorIcons")); node_shortcuts_toggle->set_toggle_mode(true); node_shortcuts_toggle->set_pressed(EDITOR_GET("_use_favorites_root_selection")); node_shortcuts_toggle->set_anchors_and_margins_preset(Control::PRESET_CENTER_RIGHT); @@ -1097,18 +1096,19 @@ void SceneTreeDock::_notification(int p_what) { Button *button_2d = memnew(Button); beginner_node_shortcuts->add_child(button_2d); button_2d->set_text(TTR("2D Scene")); - button_2d->set_icon(get_icon("Node2D", "EditorIcons")); + button_2d->set_icon(get_theme_icon("Node2D", "EditorIcons")); button_2d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_2D_SCENE, false)); + button_3d = memnew(Button); beginner_node_shortcuts->add_child(button_3d); button_3d->set_text(TTR("3D Scene")); - button_3d->set_icon(get_icon("Spatial", "EditorIcons")); + button_3d->set_icon(get_theme_icon("Node3D", "EditorIcons")); button_3d->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_3D_SCENE, false)); Button *button_ui = memnew(Button); beginner_node_shortcuts->add_child(button_ui); button_ui->set_text(TTR("User Interface")); - button_ui->set_icon(get_icon("Control", "EditorIcons")); + button_ui->set_icon(get_theme_icon("Control", "EditorIcons")); button_ui->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_CREATE_USER_INTERFACE, false)); VBoxContainer *favorite_node_shortcuts = memnew(VBoxContainer); @@ -1118,7 +1118,7 @@ void SceneTreeDock::_notification(int p_what) { Button *button_custom = memnew(Button); node_shortcuts->add_child(button_custom); button_custom->set_text(TTR("Other Node")); - button_custom->set_icon(get_icon("Add", "EditorIcons")); + button_custom->set_icon(get_theme_icon("Add", "EditorIcons")); button_custom->connect("pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(TOOL_NEW, false)); node_shortcuts->add_spacer(); @@ -1134,17 +1134,17 @@ void SceneTreeDock::_notification(int p_what) { clear_inherit_confirm->disconnect("confirmed", callable_mp(this, &SceneTreeDock::_tool_selected)); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - button_add->set_icon(get_icon("Add", "EditorIcons")); - button_instance->set_icon(get_icon("Instance", "EditorIcons")); - button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons")); - button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons")); + button_add->set_icon(get_theme_icon("Add", "EditorIcons")); + button_instance->set_icon(get_theme_icon("Instance", "EditorIcons")); + button_create_script->set_icon(get_theme_icon("ScriptCreate", "EditorIcons")); + button_clear_script->set_icon(get_theme_icon("ScriptRemove", "EditorIcons")); - filter->set_right_icon(get_icon("Search", "EditorIcons")); + filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_PROCESS: { - bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == NULL; + bool show_create_root = bool(EDITOR_GET("interface/editors/show_scene_tree_root_selection")) && get_tree()->get_edited_scene_root() == nullptr; if (show_create_root != create_root_dialog->is_visible_in_tree() && !remote_tree->is_visible()) { if (show_create_root) { @@ -1202,7 +1202,7 @@ void SceneTreeDock::_node_selected() { if (!node) { - editor->push_item(NULL); + editor->push_item(nullptr); return; } @@ -1229,7 +1229,7 @@ void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { } } -void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames) { +void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames) { base_path.push_back(p_node->get_name()); if (new_base_path.size()) @@ -1252,7 +1252,7 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri } } -void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath> > *p_renames) { +void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames) { if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true))) return; @@ -1279,9 +1279,9 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai _fill_path_renames(base_path, new_base_path, p_node, p_renames); } -void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims) { +void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims) { - Map<Ref<Animation>, Set<int> > rem_anims; + Map<Ref<Animation>, Set<int>> rem_anims; if (!r_rem_anims) r_rem_anims = &rem_anims; @@ -1311,7 +1311,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP if (p.get_type() == Variant::NODE_PATH) { // Goes through all paths to check if its matching - for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) { + for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { NodePath root_path = p_base->get_path(); @@ -1353,7 +1353,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP NodePath root_path = root->get_path(); NodePath new_root_path = root_path; - for (List<Pair<NodePath, NodePath> >::Element *E = p_renames->front(); E; E = E->next()) { + for (List<Pair<NodePath, NodePath>>::Element *E = p_renames->front(); E; E = E->next()) { if (E->get().first == root_path) { new_root_path = E->get().second; @@ -1392,7 +1392,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP if (!ran.has(i)) continue; //channel was removed - for (List<Pair<NodePath, NodePath> >::Element *F = p_renames->front(); F; F = F->next()) { + for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { if (F->get().first == old_np) { @@ -1443,7 +1443,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { - List<Pair<NodePath, NodePath> > path_renames; + List<Pair<NodePath, NodePath>> path_renames; Vector<StringName> base_path; Node *n = p_node->get_parent(); @@ -1466,7 +1466,7 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { for (int i = 0; i < p_node->get_child_count(); i++) _fill_path_renames(base_path, new_base_path, p_node->get_child(i), &path_renames); - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); } bool SceneTreeDock::_validate_no_foreign() { @@ -1478,7 +1478,7 @@ bool SceneTreeDock::_validate_no_foreign() { if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) { accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); - accept->popup_centered_minsize(); + accept->popup_centered(); return false; } @@ -1492,7 +1492,7 @@ bool SceneTreeDock::_validate_no_foreign() { if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E->get())) >= 0) { accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); - accept->popup_centered_minsize(); + accept->popup_centered(); return false; } } @@ -1535,7 +1535,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_nodes[ni] == p_new_parent) return; // Attempt to reparent to itself. - if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_position_in_parent()) + if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_index()) no_change = false; } @@ -1554,7 +1554,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V editor_data->get_undo_redo().create_action(TTR("Reparent Node")); - List<Pair<NodePath, NodePath> > path_renames; + List<Pair<NodePath, NodePath>> path_renames; Vector<StringName> former_names; int inc = 0; @@ -1614,8 +1614,8 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_keep_global_xform) { if (Object::cast_to<Node2D>(node)) editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node2D>(node)->get_global_transform()); - if (Object::cast_to<Spatial>(node)) - editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Spatial>(node)->get_global_transform()); + if (Object::cast_to<Node3D>(node)) + editor_data->get_undo_redo().add_do_method(node, "set_global_transform", Object::cast_to<Node3D>(node)->get_global_transform()); if (Object::cast_to<Control>(node)) editor_data->get_undo_redo().add_do_method(node, "set_global_position", Object::cast_to<Control>(node)->get_global_position()); } @@ -1644,7 +1644,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V owners.push_back(E->get()); } - int child_pos = node->get_position_in_parent(); + int child_pos = node->get_index(); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node); editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, child_pos); @@ -1655,14 +1655,14 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_keep_global_xform) { if (Object::cast_to<Node2D>(node)) editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node2D>(node)->get_transform()); - if (Object::cast_to<Spatial>(node)) - editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Spatial>(node)->get_transform()); + if (Object::cast_to<Node3D>(node)) + editor_data->get_undo_redo().add_undo_method(node, "set_transform", Object::cast_to<Node3D>(node)->get_transform()); if (Object::cast_to<Control>(node)) editor_data->get_undo_redo().add_undo_method(node, "set_position", Object::cast_to<Control>(node)->get_position()); } } - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); editor_data->get_undo_redo().commit_action(); } @@ -1777,7 +1777,7 @@ void SceneTreeDock::_toggle_editable_children(Node *p_node) { if (editable) p_node->set_scene_instance_load_placeholder(false); - SpatialEditor::get_singleton()->update_all_gizmos(p_node); + Node3DEditor::get_singleton()->update_all_gizmos(p_node); scene_tree->update_tree(); } @@ -1805,7 +1805,7 @@ void SceneTreeDock::_delete_confirm() { if (entire_scene) { - editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)nullptr); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene); editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner()); editor_data->get_undo_redo().add_undo_method(scene_tree, "update_tree"); @@ -1814,7 +1814,7 @@ void SceneTreeDock::_delete_confirm() { } else { remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions - List<Pair<NodePath, NodePath> > path_renames; + List<Pair<NodePath, NodePath>> path_renames; //delete from animation for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { @@ -1822,10 +1822,10 @@ void SceneTreeDock::_delete_confirm() { if (!n->is_inside_tree() || !n->get_parent()) continue; - fill_path_renames(n, NULL, &path_renames); + fill_path_renames(n, nullptr, &path_renames); } - perform_node_renames(NULL, &path_renames); + perform_node_renames(nullptr, &path_renames); //delete for read for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { Node *n = E->get(); @@ -1859,7 +1859,7 @@ void SceneTreeDock::_delete_confirm() { if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) editor->get_viewport_control()->update(); - editor->push_item(NULL); + editor->push_item(nullptr); // Fixes the EditorHistory from still offering deleted notes EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); @@ -1908,7 +1908,7 @@ void SceneTreeDock::_selection_changed() { } else if (selection_size == 1) { editor->push_item(EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0]); } else { - editor->push_item(NULL); + editor->push_item(nullptr); } _update_script_button(); } @@ -1918,7 +1918,7 @@ Node *SceneTreeDock::_get_selection_group_tail(Node *p_node, List<Node *> p_list Node *tail = p_node; Node *parent = tail->get_parent(); - for (int i = p_node->get_position_in_parent(); i < parent->get_child_count(); i++) { + for (int i = p_node->get_index(); i < parent->get_child_count(); i++) { Node *sibling = parent->get_child(i); if (p_list.find(sibling)) @@ -1958,7 +1958,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); 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); } editor_data->get_undo_redo().commit_action(); @@ -1982,7 +1982,7 @@ void SceneTreeDock::_create() { if (current_option == TOOL_NEW) { - Node *parent = NULL; + Node *parent = nullptr; if (edited_scene) { // If root exists in edited scene @@ -2052,7 +2052,7 @@ void SceneTreeDock::_create() { } } - Node *parent = NULL; + Node *parent = nullptr; if (only_one_top_node) parent = top_node->get_parent(); else @@ -2096,7 +2096,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop memdelete(default_oldnode); } - editor->push_item(NULL); + editor->push_item(nullptr); //reconnect signals List<MethodInfo> sl; @@ -2120,7 +2120,7 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop List<Node *> to_erase; for (int i = 0; i < n->get_child_count(); i++) { - if (n->get_child(i)->get_owner() == NULL && n->is_owned_by_parent()) { + if (n->get_child(i)->get_owner() == nullptr && n->is_owned_by_parent()) { to_erase.push_back(n->get_child(i)); } } @@ -2187,13 +2187,13 @@ void SceneTreeDock::_new_scene_from(String p_file) { if (selection.size() != 1) { accept->set_text(TTR("This operation requires a single selected node.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } if (EditorNode::get_singleton()->is_scene_open(p_file)) { accept->set_text(TTR("Can't overwrite scene that is still open!")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } @@ -2210,7 +2210,7 @@ void SceneTreeDock::_new_scene_from(String p_file) { if (err != OK) { accept->set_text(TTR("Couldn't save new scene. Likely dependencies (instances) couldn't be satisfied.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } @@ -2221,13 +2221,13 @@ void SceneTreeDock::_new_scene_from(String p_file) { err = ResourceSaver::save(p_file, sdata, flg); if (err != OK) { accept->set_text(TTR("Error saving scene.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } _replace_with_branch_scene(p_file, base); } else { accept->set_text(TTR("Error duplicating scene to save it.")); - accept->popup_centered_minsize(); + accept->popup_centered(); return; } } @@ -2267,7 +2267,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { if (p_type == -1) { //drop at above selected node if (to_node == EditorNode::get_singleton()->get_edited_scene()) { - to_node = NULL; + to_node = nullptr; ERR_FAIL_MSG("Cannot perform drop above the root node!"); } @@ -2282,7 +2282,7 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { return; } - Node *lower_sibling = NULL; + Node *lower_sibling = nullptr; if (_has_visible_children(to_node)) { to_pos = 0; @@ -2346,7 +2346,7 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { int to_pos = -1; _normalize_drop(to_node, to_pos, p_type); - _do_reparent(to_node, to_pos, nodes, !Input::get_singleton()->is_key_pressed(KEY_SHIFT)); + _do_reparent(to_node, to_pos, nodes, !InputFilter::get_singleton()->is_key_pressed(KEY_SHIFT)); } void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { @@ -2390,8 +2390,8 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->clear(); if (profile_allow_editing) { - menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); + menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); } menu->set_size(Size2(1, 1)); @@ -2422,10 +2422,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (menu->get_item_count() > 0) menu->add_separator(); - menu->add_icon_shortcut(get_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); - menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); + menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); + menu->add_icon_shortcut(get_theme_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); } - menu->add_icon_shortcut(get_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); + menu->add_icon_shortcut(get_theme_icon("Collapse", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/expand_collapse_all"), TOOL_EXPAND_COLLAPSE); menu->add_separator(); existing_script = selected->get_script(); @@ -2440,14 +2440,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (full_selection.size() == 1) { add_separator = true; - menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); + menu->add_icon_shortcut(get_theme_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT); if (existing_script.is_valid()) { - menu->add_icon_shortcut(get_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); + menu->add_icon_shortcut(get_theme_icon("ScriptExtend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/extend_script"), TOOL_EXTEND_SCRIPT); } } if (existing_script.is_valid() && existing_script_removable) { add_separator = true; - menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); + menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); } else if (full_selection.size() > 1) { bool script_exists = false; for (List<Node *>::Element *E = full_selection.front(); E; E = E->next()) { @@ -2459,7 +2459,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (script_exists) { add_separator = true; - menu->add_icon_shortcut(get_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); + menu->add_icon_shortcut(get_theme_icon("ScriptRemove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT); } } @@ -2470,19 +2470,19 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { if (full_selection.size() == 1) { - menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); + menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/rename"), TOOL_RENAME); } - menu->add_icon_shortcut(get_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); + menu->add_icon_shortcut(get_theme_icon("Reload", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/change_node_type"), TOOL_REPLACE); if (scene_tree->get_selected() != edited_scene) { menu->add_separator(); - menu->add_icon_shortcut(get_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); - menu->add_icon_shortcut(get_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); - menu->add_icon_shortcut(get_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); - menu->add_icon_shortcut(get_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); - menu->add_icon_shortcut(get_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); + menu->add_icon_shortcut(get_theme_icon("MoveUp", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_up"), TOOL_MOVE_UP); + menu->add_icon_shortcut(get_theme_icon("MoveDown", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/move_down"), TOOL_MOVE_DOWN); + menu->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/duplicate"), TOOL_DUPLICATE); + menu->add_icon_shortcut(get_theme_icon("Reparent", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent"), TOOL_REPARENT); + menu->add_icon_shortcut(get_theme_icon("ReparentToNewNode", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/reparent_to_new_node"), TOOL_REPARENT_TO_NEW_NODE); if (selection.size() == 1) { - menu->add_icon_shortcut(get_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); + menu->add_icon_shortcut(get_theme_icon("NewRoot", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/make_root"), TOOL_MAKE_ROOT); } } } @@ -2490,24 +2490,24 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE); - menu->add_icon_shortcut(get_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); + menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE); + menu->add_icon_shortcut(get_theme_icon("CreateNewSceneFrom", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/save_branch_as_scene"), TOOL_NEW_SCENE_FROM); } if (full_selection.size() == 1) { menu->add_separator(); - menu->add_icon_shortcut(get_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); + menu->add_icon_shortcut(get_theme_icon("CopyNodePath", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/copy_node_path"), TOOL_COPY_NODE_PATH); } bool is_external = (selection[0]->get_filename() != ""); if (is_external) { - bool is_inherited = selection[0]->get_scene_inherited_state() != NULL; - bool is_top_level = selection[0]->get_owner() == NULL; + bool is_inherited = selection[0]->get_scene_inherited_state() != nullptr; + bool is_top_level = selection[0]->get_owner() == nullptr; if (is_inherited && is_top_level) { menu->add_separator(); if (profile_allow_editing) { menu->add_item(TTR("Clear Inheritance"), TOOL_SCENE_CLEAR_INHERITANCE); } - menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); + menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN_INHERITED); } else if (!is_top_level) { menu->add_separator(); bool editable = EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(selection[0]); @@ -2517,7 +2517,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER); menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL); } - menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); + menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN); if (profile_allow_editing) { menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable); menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder); @@ -2529,14 +2529,14 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { if (profile_allow_editing && selection.size() > 1) { //this is not a commonly used action, it makes no sense for it to be where it was nor always present. menu->add_separator(); - menu->add_icon_shortcut(get_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); + menu->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/batch_rename"), TOOL_BATCH_RENAME); } menu->add_separator(); - menu->add_icon_item(get_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); + menu->add_icon_item(get_theme_icon("Help", "EditorIcons"), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { menu->add_separator(); - menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); + menu->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); } menu->set_size(Size2(1, 1)); menu->set_position(p_menu_pos); @@ -2568,7 +2568,7 @@ void SceneTreeDock::_focus_node() { CanvasItemEditorPlugin *editor = Object::cast_to<CanvasItemEditorPlugin>(editor_data->get_editor("2D")); editor->get_canvas_item_editor()->focus_selection(); } else { - SpatialEditorPlugin *editor = Object::cast_to<SpatialEditorPlugin>(editor_data->get_editor("3D")); + Node3DEditorPlugin *editor = Object::cast_to<Node3DEditorPlugin>(editor_data->get_editor("3D")); editor->get_spatial_editor()->get_editor_viewport(0)->focus_selection(); } } @@ -2634,7 +2634,7 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) { } void SceneTreeDock::add_remote_tree_editor(Control *p_remote) { - ERR_FAIL_COND(remote_tree != NULL); + ERR_FAIL_COND(remote_tree != nullptr); add_child(p_remote); remote_tree = p_remote; remote_tree->hide(); @@ -2787,7 +2787,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel set_name("Scene"); editor = p_editor; - edited_scene = NULL; + edited_scene = nullptr; editor_data = &p_editor_data; editor_selection = p_editor_selection; scene_root = p_scene_root; @@ -2795,7 +2795,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel VBoxContainer *vbc = this; HBoxContainer *filter_hbc = memnew(HBoxContainer); - filter_hbc->add_constant_override("separate", 0); + filter_hbc->add_theme_constant_override("separate", 0); ED_SHORTCUT("scene_tree/rename", TTR("Rename")); ED_SHORTCUT("scene_tree/batch_rename", TTR("Batch Rename"), KEY_MASK_CMD | KEY_F2); @@ -2835,7 +2835,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel filter->set_h_size_flags(SIZE_EXPAND_FILL); filter->set_placeholder(TTR("Filter nodes")); filter_hbc->add_child(filter); - filter->add_constant_override("minimum_spaces", 0); + filter->add_theme_constant_override("minimum_spaces", 0); filter->connect("text_changed", callable_mp(this, &SceneTreeDock::_filter_changed)); button_create_script = memnew(ToolButton); @@ -2869,7 +2869,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel edit_local->set_toggle_mode(true); edit_local->connect("pressed", callable_mp(this, &SceneTreeDock::_local_tree_selected)); - remote_tree = NULL; + remote_tree = nullptr; button_hb->hide(); create_root_dialog = memnew(VBoxContainer); @@ -2939,14 +2939,14 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel import_subscene_dialog->connect("subscene_selected", callable_mp(this, &SceneTreeDock::_import_subscene)); new_scene_from_dialog = memnew(EditorFileDialog); - new_scene_from_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); + new_scene_from_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); add_child(new_scene_from_dialog); new_scene_from_dialog->connect("file_selected", callable_mp(this, &SceneTreeDock::_new_scene_from)); menu = memnew(PopupMenu); add_child(menu); menu->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(false)); - menu->set_hide_on_window_lose_focus(true); + menu_subresources = memnew(PopupMenu); menu_subresources->set_name("Sub-Resources"); menu_subresources->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(false)); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index c6ddbc3dfe..31ef1ce7d0 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -205,7 +205,7 @@ class SceneTreeDock : public VBoxContainer { void _update_script_button(); Node *_get_selection_group_tail(Node *p_node, List<Node *> p_list); - void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath> > *p_renames); + void _fill_path_renames(Vector<StringName> base_path, Vector<StringName> new_base_path, Node *p_node, List<Pair<NodePath, NodePath>> *p_renames); void _normalize_drop(Node *&to_node, int &to_pos, int p_type); @@ -247,10 +247,10 @@ public: void import_subscene(); void set_edited_scene(Node *p_scene); void instance(const String &p_file); - void instance_scenes(const Vector<String> &p_files, Node *p_parent = NULL); + void instance_scenes(const Vector<String> &p_files, Node *p_parent = nullptr); void set_selected(Node *p_node, bool p_emit_selected = false); - void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath> > *p_renames); - void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath> > *p_renames, Map<Ref<Animation>, Set<int> > *r_rem_anims = NULL); + void fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames); + void perform_node_renames(Node *p_base, List<Pair<NodePath, NodePath>> *p_renames, Map<Ref<Animation>, Set<int>> *r_rem_anims = nullptr); SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index e4e642e368..251c911038 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -37,12 +37,12 @@ #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "scene/gui/label.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" #include "scene/resources/packed_scene.h" Node *SceneTreeEditor::get_scene_node() { - ERR_FAIL_COND_V(!is_inside_tree(), NULL); + ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_tree()->get_edited_scene_root(); } @@ -78,7 +78,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->create_action(TTR("Toggle Visible")); _toggle_visible(n); List<Node *> selection = editor_selection->get_selected_node_list(); - if (selection.size() > 1 && selection.find(n) != NULL) { + if (selection.size() > 1 && selection.find(n) != nullptr) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Node *nv = E->get(); ERR_FAIL_COND(!nv); @@ -92,7 +92,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i } else if (p_id == BUTTON_LOCK) { undo_redo->create_action(TTR("Unlock Node")); - if (n->is_class("CanvasItem") || n->is_class("Spatial")) { + if (n->is_class("CanvasItem") || n->is_class("Node3D")) { undo_redo->add_do_method(n, "remove_meta", "_edit_lock_"); undo_redo->add_undo_method(n, "set_meta", "_edit_lock_", true); @@ -112,7 +112,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i } else if (p_id == BUTTON_GROUP) { undo_redo->create_action(TTR("Button Group")); - if (n->is_class("CanvasItem") || n->is_class("Spatial")) { + if (n->is_class("CanvasItem") || n->is_class("Node3D")) { undo_redo->add_do_method(n, "remove_meta", "_edit_group_"); undo_redo->add_undo_method(n, "set_meta", "_edit_group_", true); @@ -129,7 +129,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i return; config_err = config_err.word_wrap(80); warning->set_text(config_err); - warning->popup_centered_minsize(); + warning->popup_centered(); } else if (p_id == BUTTON_SIGNALS) { @@ -201,19 +201,19 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_metadata(0, p_node->get_path()); if (connect_to_script_mode) { - Color accent = get_color("accent_color", "Editor"); + Color accent = get_theme_color("accent_color", "Editor"); Ref<Script> script = p_node->get_script(); if (!script.is_null() && EditorNode::get_singleton()->get_object_custom_type_base(p_node) != script) { //has script - item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); } else { //has no script (or script is a custom type) - item->set_custom_color(0, get_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); item->set_selectable(0, false); if (!script.is_null()) { // make sure to mark the script if a custom type - item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT); + item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT); item->set_button_disabled(0, item->get_button_count(0) - 1, true); } @@ -231,7 +231,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } else if (part_of_subscene) { if (valid_types.size() == 0) { - item->set_custom_color(0, get_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); } } else if (marked.has(p_node)) { @@ -241,14 +241,14 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } item->set_text(0, node_name); item->set_selectable(0, marked_selectable); - item->set_custom_color(0, get_color("accent_color", "Editor")); + item->set_custom_color(0, get_theme_color("accent_color", "Editor")); } else if (!marked_selectable && !marked_children_selectable) { Node *node = p_node; while (node) { if (marked.has(node)) { item->set_selectable(0, false); - item->set_custom_color(0, get_color("error_color", "Editor")); + item->set_custom_color(0, get_theme_color("error_color", "Editor")); break; } node = node->get_parent(); @@ -259,7 +259,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { String warning = p_node->get_configuration_warning(); if (warning != String()) { - item->add_button(0, get_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning()); + item->add_button(0, get_theme_icon("NodeWarning", "EditorIcons"), BUTTON_WARNING, false, TTR("Node configuration warning:") + "\n" + p_node->get_configuration_warning()); } int num_connections = p_node->get_persistent_signal_connection_count(); @@ -268,21 +268,21 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { if (num_connections >= 1 && num_groups >= 1) { item->add_button( 0, - get_icon("SignalsAndGroups", "EditorIcons"), + get_theme_icon("SignalsAndGroups", "EditorIcons"), BUTTON_SIGNALS, false, vformat(TTR("Node has %s connection(s) and %s group(s).\nClick to show signals dock."), num_connections, num_groups)); } else if (num_connections >= 1) { item->add_button( 0, - get_icon("Signals", "EditorIcons"), + get_theme_icon("Signals", "EditorIcons"), BUTTON_SIGNALS, false, vformat(TTR("Node has %s connection(s).\nClick to show signals dock."), num_connections)); } else if (num_groups >= 1) { item->add_button( 0, - get_icon("Groups", "EditorIcons"), + get_theme_icon("Groups", "EditorIcons"), BUTTON_GROUPS, false, vformat(TTR("Node is in %s group(s).\nClick to show groups dock."), num_groups)); @@ -290,7 +290,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } if (p_node == get_scene_node() && p_node->get_scene_inherited_state().is_valid()) { - item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Inherits:") + " " + p_node->get_scene_inherited_state()->get_path() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -299,7 +299,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_tooltip(0, tooltip); } else if (p_node != get_scene_node() && p_node->get_filename() != "" && can_open_instance) { - item->add_button(0, get_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); + item->add_button(0, get_theme_icon("InstanceOptions", "EditorIcons"), BUTTON_SUBSCENE, false, TTR("Open in Editor")); String tooltip = TTR("Instance:") + " " + p_node->get_filename() + "\n" + TTR("Type:") + " " + p_node->get_class(); if (p_node->get_editor_description() != String()) { @@ -328,7 +328,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { Ref<Script> script = p_node->get_script(); if (!script.is_null()) { - item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); + item->add_button(0, get_theme_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); if (EditorNode::get_singleton()->get_object_custom_type_base(p_node) == script) { item->set_button_color(0, item->get_button_count(0) - 1, Color(1, 1, 1, 0.5)); } @@ -338,37 +338,37 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_ if (is_locked) - item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) - item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); bool v = p_node->call("is_visible"); if (v) - item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); else - item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node)); _update_visibility_color(p_node, item); - } else if (p_node->is_class("Spatial")) { + } else if (p_node->is_class("Node3D")) { bool is_locked = p_node->has_meta("_edit_lock_"); if (is_locked) - item->add_button(0, get_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); + item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); bool is_grouped = p_node->has_meta("_edit_group_"); if (is_grouped) - item->add_button(0, get_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); + item->add_button(0, get_theme_icon("Group", "EditorIcons"), BUTTON_GROUP, false, TTR("Children are not selectable.\nClick to make selectable.")); bool v = p_node->call("is_visible"); if (v) - item->add_button(0, get_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); else - item->add_button(0, get_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node)); @@ -379,7 +379,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned(); if (is_pinned) { - item->add_button(0, get_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); + item->add_button(0, get_theme_icon("Pin", "EditorIcons"), BUTTON_PIN, false, TTR("AnimationPlayer is pinned.\nClick to unpin.")); } } } @@ -417,7 +417,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { if (!valid) { //item->set_selectable(0,marked_selectable); - item->set_custom_color(0, get_color("disabled_font_color", "Editor")); + item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); item->set_selectable(0, false); } } @@ -457,20 +457,20 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { if (p_node->is_class("CanvasItem")) { visible = p_node->call("is_visible"); CanvasItemEditor::get_singleton()->get_viewport_control()->update(); - } else if (p_node->is_class("Spatial")) { + } else if (p_node->is_class("Node3D")) { visible = p_node->call("is_visible"); } if (visible) - item->set_button(0, idx, get_icon("GuiVisibilityVisible", "EditorIcons")); + item->set_button(0, idx, get_theme_icon("GuiVisibilityVisible", "EditorIcons")); else - item->set_button(0, idx, get_icon("GuiVisibilityHidden", "EditorIcons")); + item->set_button(0, idx, get_theme_icon("GuiVisibilityHidden", "EditorIcons")); _update_visibility_color(p_node, item); } void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) { - if (p_node->is_class("CanvasItem") || p_node->is_class("Spatial")) { + if (p_node->is_class("CanvasItem") || p_node->is_class("Node3D")) { Color color(1, 1, 1, 1); bool visible_on_screen = p_node->call("is_visible_in_tree"); if (!visible_on_screen) { @@ -498,13 +498,13 @@ void SceneTreeEditor::_node_removed(Node *p_node) { if (p_node->is_connected("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed))) p_node->disconnect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed)); - if (p_node->is_class("Spatial") || p_node->is_class("CanvasItem")) { + if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem")) { if (p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) p_node->disconnect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)); } if (p_node == selected) { - selected = NULL; + selected = nullptr; emit_signal("node_selected"); } } @@ -529,7 +529,7 @@ void SceneTreeEditor::_update_tree() { updating_tree = true; tree->clear(); if (get_scene_node()) { - _add_nodes(get_scene_node(), NULL); + _add_nodes(get_scene_node(), nullptr); last_hash = hash_djb2_one_64(0); _compute_hash(get_scene_node(), last_hash); } @@ -667,7 +667,7 @@ void SceneTreeEditor::_notification(int p_what) { TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { if (!p_node) - return NULL; + return nullptr; NodePath np = p_node->get_metadata(0); if (np == p_path) @@ -682,7 +682,7 @@ TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { children = children->get_next(); } - return NULL; + return nullptr; } void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { @@ -697,7 +697,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { if (selected == p_node) return; - TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : NULL; + TreeItem *item = p_node ? _find(tree->get_root(), p_node->get_path()) : nullptr; if (item) { // make visible when it's collapsed @@ -713,7 +713,7 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { } else { if (!p_node) - selected = NULL; + selected = nullptr; _update_tree(); selected = p_node; } @@ -757,7 +757,7 @@ void SceneTreeEditor::_renamed() { if (!Node::_validate_node_name(new_name)) { error->set_text(TTR("Invalid node name, the following characters are not allowed:") + "\n" + Node::invalid_character); - error->popup_centered_minsize(); + error->popup_centered(); if (new_name.empty()) { which->set_text(0, n->get_name()); @@ -905,8 +905,8 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from return Variant(); //not editable tree Vector<Node *> selected; - Vector<Ref<Texture2D> > icons; - TreeItem *next = tree->get_next_selected(NULL); + Vector<Ref<Texture2D>> icons; + TreeItem *next = tree->get_next_selected(nullptr); while (next) { NodePath np = next->get_metadata(0); @@ -1117,16 +1117,16 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope connect_to_script_mode = false; connecting_signal = false; - undo_redo = NULL; + undo_redo = nullptr; tree_dirty = true; - selected = NULL; + selected = nullptr; marked_selectable = false; marked_children_selectable = false; can_rename = p_can_rename; can_open_instance = p_can_open_instance; display_foreign = false; - editor_selection = NULL; + editor_selection = nullptr; if (p_label) { Label *label = memnew(Label); @@ -1141,7 +1141,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); tree->set_begin(Point2(0, p_label ? 18 : 0)); tree->set_end(Point2(0, 0)); - tree->add_constant_override("button_margin", 0); + tree->add_theme_constant_override("button_margin", 0); add_child(tree); @@ -1193,18 +1193,19 @@ SceneTreeEditor::~SceneTreeEditor() { void SceneTreeDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + + if (is_visible()) + tree->update_tree(); + } break; case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); - filter->set_right_icon(get_icon("Search", "EditorIcons")); + filter->set_right_icon(tree->get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &SceneTreeDialog::_select)); } break; - case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible_in_tree()) - tree->update_tree(); - } break; } } @@ -1239,14 +1240,14 @@ SceneTreeDialog::SceneTreeDialog() { add_child(vbc); filter = memnew(LineEdit); - filter->set_h_size_flags(SIZE_EXPAND_FILL); + filter->set_h_size_flags(Control::SIZE_EXPAND_FILL); filter->set_placeholder(TTR("Filter nodes")); - filter->add_constant_override("minimum_spaces", 0); + filter->add_theme_constant_override("minimum_spaces", 0); filter->connect("text_changed", callable_mp(this, &SceneTreeDialog::_filter_changed)); vbc->add_child(filter); tree = memnew(SceneTreeEditor(false, false, true)); - tree->set_v_size_flags(SIZE_EXPAND_FILL); + tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); tree->get_scene_tree()->connect("item_activated", callable_mp(this, &SceneTreeDialog::_select)); vbc->add_child(tree); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index eb133abcd5..12b21d871b 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -40,36 +40,38 @@ #include "editor/editor_scale.h" #include "editor_file_system.h" -void ScriptCreateDialog::_notification(int p_what) { +void ScriptCreateDialog::_theme_changed() { + for (int i = 0; i < ScriptServer::get_language_count(); i++) { + String lang = ScriptServer::get_language(i)->get_type(); + Ref<Texture2D> lang_icon = gc->get_theme_icon(lang, "EditorIcons"); + if (lang_icon.is_valid()) { + language_menu->set_item_icon(i, lang_icon); + } + } - switch (p_what) { - case NOTIFICATION_THEME_CHANGED: - case NOTIFICATION_ENTER_TREE: { - for (int i = 0; i < ScriptServer::get_language_count(); i++) { - String lang = ScriptServer::get_language(i)->get_type(); - Ref<Texture2D> lang_icon = get_icon(lang, "EditorIcons"); - if (lang_icon.is_valid()) { - language_menu->set_item_icon(i, lang_icon); - } + String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); + if (!last_lang.empty()) { + for (int i = 0; i < language_menu->get_item_count(); i++) { + if (language_menu->get_item_text(i) == last_lang) { + language_menu->select(i); + current_language = i; + break; } + } + } else { + language_menu->select(default_language); + } - String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); - if (!last_lang.empty()) { - for (int i = 0; i < language_menu->get_item_count(); i++) { - if (language_menu->get_item_text(i) == last_lang) { - language_menu->select(i); - current_language = i; - break; - } - } - } else { - language_menu->select(default_language); - } + path_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons")); + parent_browse_button->set_icon(gc->get_theme_icon("Folder", "EditorIcons")); + parent_search_button->set_icon(gc->get_theme_icon("ClassList", "EditorIcons")); + status_panel->add_theme_style_override("panel", gc->get_theme_stylebox("bg", "Tree")); +} +void ScriptCreateDialog::_notification(int p_what) { - path_button->set_icon(get_icon("Folder", "EditorIcons")); - parent_browse_button->set_icon(get_icon("Folder", "EditorIcons")); - parent_search_button->set_icon(get_icon("ClassList", "EditorIcons")); - status_panel->add_style_override("panel", get_stylebox("bg", "Tree")); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + _theme_changed(); } break; } } @@ -419,7 +421,7 @@ void ScriptCreateDialog::_lang_changed(int l) { templates[i].id = new_id; } // Disable overridden - for (Map<String, Vector<int> >::Element *E = template_overrides.front(); E; E = E->next()) { + for (Map<String, Vector<int>>::Element *E = template_overrides.front(); E; E = E->next()) { const Vector<int> &overrides = E->get(); if (overrides.size() == 1) { @@ -442,7 +444,7 @@ void ScriptCreateDialog::_lang_changed(int l) { override_info += ", "; } } - template_menu->set_item_icon(extended.id, get_icon("Override", "EditorIcons")); + template_menu->set_item_icon(extended.id, gc->get_theme_icon("Override", "EditorIcons")); template_menu->get_popup()->set_item_tooltip(extended.id, override_info.as_string()); } // Reselect last selected template @@ -517,11 +519,11 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { is_browsing_parent = browse_parent; if (p_save) { - file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE); + file_browse->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_browse->set_title(TTR("Open Script / Choose Location")); file_browse->get_ok()->set_text(TTR("Open")); } else { - file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_browse->set_title(TTR("Open Script")); } @@ -607,9 +609,9 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { error_label->set_text("- " + TTR(p_msg)); if (valid) { - error_label->add_color_override("font_color", get_color("success_color", "Editor")); + error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor")); } else { - error_label->add_color_override("font_color", get_color("error_color", "Editor")); + error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor")); } } @@ -617,9 +619,9 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) { path_error_label->set_text("- " + TTR(p_msg)); if (valid) { - path_error_label->add_color_override("font_color", get_color("success_color", "Editor")); + path_error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor")); } else { - path_error_label->add_color_override("font_color", get_color("error_color", "Editor")); + path_error_label->add_theme_color_override("font_color", gc->get_theme_color("error_color", "Editor")); } } @@ -687,6 +689,8 @@ void ScriptCreateDialog::_update_dialog() { // Is Script created or loaded from existing file? + builtin_warning_label->set_visible(is_built_in); + if (is_built_in) { get_ok()->set_text(TTR("Create")); parent_name->set_editable(true); @@ -739,9 +743,11 @@ ScriptCreateDialog::ScriptCreateDialog() { /* Main Controls */ - GridContainer *gc = memnew(GridContainer); + gc = memnew(GridContainer); gc->set_columns(2); + gc->connect("theme_changed", callable_mp(this, &ScriptCreateDialog::_theme_changed)); + /* Error Messages Field */ VBoxContainer *vb = memnew(VBoxContainer); @@ -752,6 +758,13 @@ ScriptCreateDialog::ScriptCreateDialog() { path_error_label = memnew(Label); vb->add_child(path_error_label); + builtin_warning_label = memnew(Label); + builtin_warning_label->set_text( + TTR("Note: Built-in scripts have some limitations and can't be edited using an external editor.")); + vb->add_child(builtin_warning_label); + builtin_warning_label->set_autowrap(true); + builtin_warning_label->hide(); + status_panel = memnew(PanelContainer); status_panel->set_h_size_flags(Control::SIZE_FILL); status_panel->add_child(vb); @@ -774,7 +787,7 @@ ScriptCreateDialog::ScriptCreateDialog() { language_menu = memnew(OptionButton); language_menu->set_custom_minimum_size(Size2(250, 0) * EDSCALE); - language_menu->set_h_size_flags(SIZE_EXPAND_FILL); + language_menu->set_h_size_flags(Control::SIZE_EXPAND_FILL); gc->add_child(memnew(Label(TTR("Language:")))); gc->add_child(language_menu); @@ -798,10 +811,10 @@ ScriptCreateDialog::ScriptCreateDialog() { base_type = "Object"; hb = memnew(HBoxContainer); - hb->set_h_size_flags(SIZE_EXPAND_FILL); + hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); parent_name = memnew(LineEdit); parent_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_parent_name_changed)); - parent_name->set_h_size_flags(SIZE_EXPAND_FILL); + parent_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(parent_name); parent_search_button = memnew(Button); parent_search_button->set_flat(true); @@ -819,7 +832,7 @@ ScriptCreateDialog::ScriptCreateDialog() { class_name = memnew(LineEdit); class_name->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_class_name_changed)); - class_name->set_h_size_flags(SIZE_EXPAND_FILL); + class_name->set_h_size_flags(Control::SIZE_EXPAND_FILL); gc->add_child(memnew(Label(TTR("Class Name:")))); gc->add_child(class_name); @@ -845,7 +858,7 @@ ScriptCreateDialog::ScriptCreateDialog() { file_path = memnew(LineEdit); file_path->connect("text_changed", callable_mp(this, &ScriptCreateDialog::_path_changed)); file_path->connect("text_entered", callable_mp(this, &ScriptCreateDialog::_path_entered)); - file_path->set_h_size_flags(SIZE_EXPAND_FILL); + file_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); hb->add_child(file_path); path_button = memnew(Button); path_button->set_flat(true); @@ -863,18 +876,16 @@ ScriptCreateDialog::ScriptCreateDialog() { file_browse = memnew(EditorFileDialog); file_browse->connect("file_selected", callable_mp(this, &ScriptCreateDialog::_file_selected)); - file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); add_child(file_browse); get_ok()->set_text(TTR("Create")); 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); alert->get_label()->set_custom_minimum_size(Size2(325, 60) * EDSCALE); add_child(alert); - set_as_minsize(); set_hide_on_ok(false); set_title(TTR("Attach Node Script")); diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index 00f642fcf7..63a30eba88 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -45,9 +45,11 @@ class CreateDialog; class ScriptCreateDialog : public ConfirmationDialog { GDCLASS(ScriptCreateDialog, ConfirmationDialog); + GridContainer *gc; LineEdit *class_name; Label *error_label; Label *path_error_label; + Label *builtin_warning_label; PanelContainer *status_panel; LineEdit *parent_name; Button *parent_browse_button; @@ -93,7 +95,7 @@ class ScriptCreateDialog : public ConfirmationDialog { String script_template; Vector<ScriptTemplateInfo> template_list; - Map<String, Vector<int> > template_overrides; // name : indices + Map<String, Vector<int>> template_overrides; // name : indices void _update_script_templates(const String &p_extension); @@ -123,6 +125,7 @@ class ScriptCreateDialog : public ConfirmationDialog { void _update_dialog(); protected: + void _theme_changed(); void _notification(int p_what); static void _bind_methods(); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index cf93fab9a8..8910e8ec3a 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -118,18 +118,20 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam void EditorSettingsDialog::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_VISIBILITY_CHANGED: { + if (!is_visible()) { + EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size())); + set_process_unhandled_input(false); + } + } break; case NOTIFICATION_READY: { - undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, NULL); - undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, NULL); + undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, nullptr); + undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, nullptr); undo_redo->set_commit_notify_callback(_undo_redo_callback, this); } break; case NOTIFICATION_ENTER_TREE: { _update_icons(); } break; - case NOTIFICATION_POPUP_HIDE: { - EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", get_rect()); - set_process_unhandled_input(false); - } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); // Update theme colors. @@ -143,7 +145,7 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { const Ref<InputEventKey> k = p_event; - if (k.is_valid() && is_window_modal_on_top() && k->is_pressed()) { + if (k.is_valid() && k->is_pressed()) { bool handled = false; @@ -169,22 +171,22 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } if (handled) { - accept_event(); + set_input_as_handled(); } } } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); + search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); - shortcut_search_box->set_right_icon(get_icon("Search", "EditorIcons")); + shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); shortcut_search_box->set_clear_button_enabled(true); - restart_close_button->set_icon(get_icon("Close", "EditorIcons")); - restart_container->add_style_override("panel", get_stylebox("bg", "Tree")); - restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons")); - restart_label->add_color_override("font_color", get_color("warning_color", "Editor")); + restart_close_button->set_icon(shortcuts->get_theme_icon("Close", "EditorIcons")); + restart_container->add_theme_style_override("panel", shortcuts->get_theme_stylebox("bg", "Tree")); + restart_icon->set_texture(shortcuts->get_theme_icon("StatusWarning", "EditorIcons")); + restart_label->add_theme_color_override("font_color", shortcuts->get_theme_color("warning_color", "Editor")); } void EditorSettingsDialog::_update_shortcuts() { @@ -230,8 +232,8 @@ void EditorSettingsDialog::_update_shortcuts() { } sections[section_name] = section; - section->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); - section->set_custom_bg_color(1, get_color("prop_subsection", "Editor")); + section->set_custom_bg_color(0, shortcuts->get_theme_color("prop_subsection", "Editor")); + section->set_custom_bg_color(1, shortcuts->get_theme_color("prop_subsection", "Editor")); } // Don't match unassigned shortcuts when searching for assigned keys in search results. @@ -243,16 +245,16 @@ void EditorSettingsDialog::_update_shortcuts() { item->set_text(1, sc->get_as_text()); if (!sc->is_shortcut(original) && !(sc->get_shortcut().is_null() && original.is_null())) { - item->add_button(1, get_icon("Reload", "EditorIcons"), 2); + item->add_button(1, shortcuts->get_theme_icon("Reload", "EditorIcons"), 2); } if (sc->get_as_text() == "None") { // Fade out unassigned shortcut labels for easier visual grepping. - item->set_custom_color(1, get_color("font_color", "Label") * Color(1, 1, 1, 0.5)); + item->set_custom_color(1, shortcuts->get_theme_color("font_color", "Label") * Color(1, 1, 1, 0.5)); } - item->add_button(1, get_icon("Edit", "EditorIcons"), 0); - item->add_button(1, get_icon("Close", "EditorIcons"), 1); + item->add_button(1, shortcuts->get_theme_icon("Edit", "EditorIcons"), 0); + item->add_button(1, shortcuts->get_theme_icon("Close", "EditorIcons"), 1); item->set_tooltip(0, E->get()); item->set_metadata(0, E->get()); } @@ -261,7 +263,7 @@ void EditorSettingsDialog::_update_shortcuts() { // remove sections with no shortcuts for (Map<String, TreeItem *>::Element *E = sections.front(); E; E = E->next()) { TreeItem *section = E->get(); - if (section->get_children() == NULL) { + if (section->get_children() == nullptr) { root->remove_child(section); } } @@ -279,9 +281,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column press_a_key_label->set_text(TTR("Press a Key...")); last_wait_for_key = Ref<InputEventKey>(); press_a_key->popup_centered(Size2(250, 80) * EDSCALE); - press_a_key->grab_focus(); - press_a_key->get_ok()->set_focus_mode(FOCUS_NONE); - press_a_key->get_cancel()->set_focus_mode(FOCUS_NONE); + //press_a_key->grab_focus(); + press_a_key->get_ok()->set_focus_mode(Control::FOCUS_NONE); + press_a_key->get_cancel()->set_focus_mode(Control::FOCUS_NONE); shortcut_configured = item; } else if (p_idx == 1) { //erase @@ -323,7 +325,7 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { const String str = keycode_get_string(k->get_keycode_with_modifiers()); press_a_key_label->set_text(str); - press_a_key->accept_event(); + press_a_key->set_input_as_handled(); } } @@ -360,7 +362,7 @@ void EditorSettingsDialog::_tabs_tab_changed(int p_tab) { void EditorSettingsDialog::_focus_current_search_box() { Control *tab = tabs->get_current_tab_control(); - LineEdit *current_search_box = NULL; + LineEdit *current_search_box = nullptr; if (tab == tab_general) current_search_box = search_box; else if (tab == tab_shortcuts) @@ -394,7 +396,7 @@ void EditorSettingsDialog::_bind_methods() { EditorSettingsDialog::EditorSettingsDialog() { set_title(TTR("Editor Settings")); - set_resizable(true); + undo_redo = memnew(UndoRedo); tabs = memnew(TabContainer); @@ -430,7 +432,7 @@ EditorSettingsDialog::EditorSettingsDialog() { HBoxContainer *restart_hb = memnew(HBoxContainer); restart_container->add_child(restart_hb); restart_icon = memnew(TextureRect); - restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER); + restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER); restart_hb->add_child(restart_icon); restart_label = memnew(Label); restart_label->set_text(TTR("The editor must be restarted for changes to take effect.")); @@ -462,7 +464,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts = memnew(Tree); tab_shortcuts->add_child(shortcuts, true); - shortcuts->set_v_size_flags(SIZE_EXPAND_FILL); + shortcuts->set_v_size_flags(Control::SIZE_EXPAND_FILL); shortcuts->set_columns(2); shortcuts->set_hide_root(true); shortcuts->set_column_titles_visible(true); @@ -471,7 +473,7 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcuts->connect("button_pressed", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed)); press_a_key = memnew(ConfirmationDialog); - press_a_key->set_focus_mode(FOCUS_ALL); + //press_a_key->set_focus_mode(Control::FOCUS_ALL); add_child(press_a_key); Label *l = memnew(Label); @@ -479,10 +481,10 @@ EditorSettingsDialog::EditorSettingsDialog() { l->set_anchors_and_margins_preset(Control::PRESET_WIDE); l->set_align(Label::ALIGN_CENTER); l->set_margin(MARGIN_TOP, 20); - l->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 30); + l->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_BEGIN, 30); press_a_key_label = l; press_a_key->add_child(l); - press_a_key->connect("gui_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key)); + press_a_key->connect("window_input", callable_mp(this, &EditorSettingsDialog::_wait_for_key)); press_a_key->connect("confirmed", callable_mp(this, &EditorSettingsDialog::_press_a_key_confirm)); set_hide_on_ok(true); diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h deleted file mode 100644 index b786aa2b50..0000000000 --- a/editor/spatial_editor_gizmos.h +++ /dev/null @@ -1,434 +0,0 @@ -/*************************************************************************/ -/* spatial_editor_gizmos.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef SPATIAL_EDITOR_GIZMOS_H -#define SPATIAL_EDITOR_GIZMOS_H - -#include "editor/plugins/spatial_editor_plugin.h" -#include "scene/3d/camera.h" - -class Camera; - -class LightSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(LightSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - void redraw(EditorSpatialGizmo *p_gizmo); - - LightSpatialGizmoPlugin(); -}; - -class AudioStreamPlayer3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(AudioStreamPlayer3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - void redraw(EditorSpatialGizmo *p_gizmo); - - AudioStreamPlayer3DSpatialGizmoPlugin(); -}; - -class CameraSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(CameraSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - void redraw(EditorSpatialGizmo *p_gizmo); - - CameraSpatialGizmoPlugin(); -}; - -class MeshInstanceSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(MeshInstanceSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool can_be_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - MeshInstanceSpatialGizmoPlugin(); -}; - -class Sprite3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(Sprite3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool can_be_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - Sprite3DSpatialGizmoPlugin(); -}; - -class Position3DSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(Position3DSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - - Ref<ArrayMesh> pos3d_mesh; - Vector<Vector3> cursor_points; - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - Position3DSpatialGizmoPlugin(); -}; - -class SkeletonSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(SkeletonSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - SkeletonSpatialGizmoPlugin(); -}; - -class PhysicalBoneSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(PhysicalBoneSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - PhysicalBoneSpatialGizmoPlugin(); -}; - -class RayCastSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(RayCastSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - RayCastSpatialGizmoPlugin(); -}; - -class SpringArmSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(SpringArmSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - SpringArmSpatialGizmoPlugin(); -}; - -class VehicleWheelSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(VehicleWheelSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - VehicleWheelSpatialGizmoPlugin(); -}; - -class SoftBodySpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(SoftBodySpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool is_selectable_when_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel); - bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const; - - SoftBodySpatialGizmoPlugin(); -}; - -class VisibilityNotifierGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(VisibilityNotifierGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - VisibilityNotifierGizmoPlugin(); -}; - -class CPUParticlesGizmoPlugin : public EditorSpatialGizmoPlugin { - GDCLASS(CPUParticlesGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool is_selectable_when_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - CPUParticlesGizmoPlugin(); -}; - -class ParticlesGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(ParticlesGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - bool is_selectable_when_hidden() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - ParticlesGizmoPlugin(); -}; - -class ReflectionProbeGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(ReflectionProbeGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - ReflectionProbeGizmoPlugin(); -}; - -class GIProbeGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(GIProbeGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - GIProbeGizmoPlugin(); -}; - -#if 0 -class BakedIndirectLightGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(BakedIndirectLightGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - BakedIndirectLightGizmoPlugin(); -}; -#endif -class CollisionShapeSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(CollisionShapeSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; - Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; - void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); - void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - - CollisionShapeSpatialGizmoPlugin(); -}; - -class CollisionPolygonSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - GDCLASS(CollisionPolygonSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - CollisionPolygonSpatialGizmoPlugin(); -}; - -class NavigationMeshSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(NavigationMeshSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - - struct _EdgeKey { - - Vector3 from; - Vector3 to; - - bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; } - }; - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - NavigationMeshSpatialGizmoPlugin(); -}; - -class JointGizmosDrawer { -public: - static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform); - static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform); - static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform); - static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform); - /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis - /// with axis X and Y that are looking toward the body and oriented toward up - static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform); - - // Draw circle around p_axis - static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); - static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); -}; - -class JointSpatialGizmoPlugin : public EditorSpatialGizmoPlugin { - - GDCLASS(JointSpatialGizmoPlugin, EditorSpatialGizmoPlugin); - -public: - bool has_gizmo(Spatial *p_spatial); - String get_name() const; - int get_priority() const; - void redraw(EditorSpatialGizmo *p_gizmo); - - static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points); - static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); - static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); - static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); - static void CreateGeneric6DOFJointGizmo( - const Transform &p_offset, - const Transform &p_trs_joint, - const Transform &p_trs_body_a, - const Transform &p_trs_body_b, - real_t p_angular_limit_lower_x, - real_t p_angular_limit_upper_x, - real_t p_linear_limit_lower_x, - real_t p_linear_limit_upper_x, - bool p_enable_angular_limit_x, - bool p_enable_linear_limit_x, - real_t p_angular_limit_lower_y, - real_t p_angular_limit_upper_y, - real_t p_linear_limit_lower_y, - real_t p_linear_limit_upper_y, - bool p_enable_angular_limit_y, - bool p_enable_linear_limit_y, - real_t p_angular_limit_lower_z, - real_t p_angular_limit_upper_z, - real_t p_linear_limit_lower_z, - real_t p_linear_limit_upper_z, - bool p_enable_angular_limit_z, - bool p_enable_linear_limit_z, - Vector<Vector3> &r_points, - Vector<Vector3> *r_body_a_points, - Vector<Vector3> *r_body_b_points); - - JointSpatialGizmoPlugin(); -}; - -#endif // SPATIAL_EDITOR_GIZMOS_H diff --git a/editor/translations/ca.po b/editor/translations/ca.po index 15d4265ef4..304fa8905b 100644 --- a/editor/translations/ca.po +++ b/editor/translations/ca.po @@ -11,12 +11,13 @@ # Adolfo Jayme Barrientos <fitojb@ubuntu.com>, 2020. # Xavier Gomez <hiulit@gmail.com>, 2020. # Aina <ainasoga@gmail.com>, 2020. +# Alex Mancha <codingstain@gmail.com>, 2020. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-02-07 10:32+0000\n" -"Last-Translator: Roger Blanco Ribera <roger.blancoribera@gmail.com>\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" +"Last-Translator: Alex Mancha <codingstain@gmail.com>\n" "Language-Team: Catalan <https://hosted.weblate.org/projects/godot-engine/" "godot/ca/>\n" "Language: ca\n" @@ -24,7 +25,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.11-dev\n" +"X-Generator: Weblate 4.0-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -694,9 +695,8 @@ msgid "Line Number:" msgstr "Línia:" #: editor/code_editor.cpp -#, fuzzy msgid "%d replaced." -msgstr "Substitueix..." +msgstr "%d reemplaçat." #: editor/code_editor.cpp editor/editor_help.cpp msgid "%d match." @@ -2756,7 +2756,6 @@ msgid "Set Up Version Control" msgstr "Configurar Control de Versions" #: editor/editor_node.cpp -#, fuzzy msgid "Shut Down Version Control" msgstr "Desactivar el control de versions" @@ -5974,7 +5973,7 @@ msgstr "" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Couldn't create a single convex collision shape." -msgstr "" +msgstr "No s'ha pogut crear una capa de col·lisió convexa." #: editor/plugins/mesh_instance_editor_plugin.cpp #, fuzzy diff --git a/editor/translations/cs.po b/editor/translations/cs.po index f3ae992410..595db1837f 100644 --- a/editor/translations/cs.po +++ b/editor/translations/cs.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-01 05:50+0000\n" +"PO-Revision-Date: 2020-03-12 23:33+0000\n" "Last-Translator: Vojtěch Šamla <auzkok@seznam.cz>\n" "Language-Team: Czech <https://hosted.weblate.org/projects/godot-engine/godot/" "cs/>\n" @@ -1117,7 +1117,7 @@ msgstr "Děkujeme za komunitu Godotu!" #: editor/editor_about.cpp msgid "Godot Engine contributors" -msgstr "Přispívající do Godot Enginu" +msgstr "Přispěvatelé do Godot Enginu" #: editor/editor_about.cpp msgid "Project Founders" @@ -9907,7 +9907,6 @@ msgid "Can't run project" msgstr "Nelze spustit projekt" #: editor/project_manager.cpp -#, fuzzy msgid "" "You currently don't have any projects.\n" "Would you like to explore official example projects in the Asset Library?" diff --git a/editor/translations/de.po b/editor/translations/de.po index 14d9926ecb..1520c3aa2a 100644 --- a/editor/translations/de.po +++ b/editor/translations/de.po @@ -53,8 +53,8 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-08 22:32+0000\n" -"Last-Translator: PagDev <pag.develop@gmail.com>\n" +"PO-Revision-Date: 2020-03-14 15:05+0000\n" +"Last-Translator: So Wieso <sowieso@dukun.de>\n" "Language-Team: German <https://hosted.weblate.org/projects/godot-engine/" "godot/de/>\n" "Language: de\n" @@ -6029,9 +6029,8 @@ msgstr "" "Dies ist die präziseste (aber langsamste) Methode für Kollisionsberechnungen." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" -msgstr "Ein einzelnes konvexes Kollisionsunterelement erzeugen" +msgstr "Ein einzelnes konvexes Kollisionsnachbarelement erzeugen" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -12483,7 +12482,7 @@ msgstr "" #: scene/3d/collision_shape.cpp msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." -msgstr "" +msgstr "ConcavePolygonShape unterstützt RigidBody nur im Modus Statisch." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/es.po b/editor/translations/es.po index ed82e80658..3bbe96bcb3 100644 --- a/editor/translations/es.po +++ b/editor/translations/es.po @@ -47,7 +47,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-02-27 07:01+0000\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" "Last-Translator: Javier Ocampos <xavier.ocampos@gmail.com>\n" "Language-Team: Spanish <https://hosted.weblate.org/projects/godot-engine/" "godot/es/>\n" @@ -6027,9 +6027,8 @@ msgstr "" "Es la opción más precisa (pero la más lenta) para la detección de colisiones." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" -msgstr "Crear una Única Colisión Convexa Hermana" +msgstr "Crear Colisión Convexa Única Hermana" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -12481,6 +12480,7 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape no soporta RigidBody de otro modo que no sea estático." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/es_AR.po b/editor/translations/es_AR.po index dce0d89b7e..7781d59f34 100644 --- a/editor/translations/es_AR.po +++ b/editor/translations/es_AR.po @@ -18,7 +18,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-02-27 07:01+0000\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" "Last-Translator: Javier Ocampos <xavier.ocampos@gmail.com>\n" "Language-Team: Spanish (Argentina) <https://hosted.weblate.org/projects/" "godot-engine/godot/es_AR/>\n" @@ -5991,9 +5991,8 @@ msgstr "" "Esta es la opción mas exacta (pero más lenta) de detección de colisiones." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" -msgstr "Crear Colisión Convexa Unica como Nodo Hermano" +msgstr "Crear Colisión Convexa Única Hermana" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -12435,6 +12434,7 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape no soporta RigidBody de otro modo que no sea estático." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/extract.py b/editor/translations/extract.py index e7ebda32df..749bad5fff 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -10,23 +10,23 @@ import sys line_nb = False for arg in sys.argv[1:]: - if (arg == "--with-line-nb"): + if arg == "--with-line-nb": print("Enabling line numbers in the context locations.") line_nb = True else: os.sys.exit("Non supported argument '" + arg + "'. Aborting.") -if (not os.path.exists("editor")): +if not os.path.exists("editor"): os.sys.exit("ERROR: This script should be started from the root of the git repo.") matches = [] -for root, dirnames, filenames in os.walk('.'): +for root, dirnames, filenames in os.walk("."): dirnames[:] = [d for d in dirnames if d not in ["thirdparty"]] - for filename in fnmatch.filter(filenames, '*.cpp'): + for filename in fnmatch.filter(filenames, "*.cpp"): matches.append(os.path.join(root, filename)) - for filename in fnmatch.filter(filenames, '*.h'): + for filename in fnmatch.filter(filenames, "*.h"): matches.append(os.path.join(root, filename)) matches.sort() @@ -34,7 +34,7 @@ matches.sort() unique_str = [] unique_loc = {} main_po = """ -# LANGUAGE translation of the Godot Engine editor +# LANGUAGE translation of the Godot Engine editor. # Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. # Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). # This file is distributed under the same license as the Godot source code. @@ -45,56 +45,60 @@ main_po = """ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\\n" +"Report-Msgid-Bugs-To: https://github.com/godotengine/godot\\n" +"MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8-bit\\n" """ + def process_file(f, fname): global main_po, unique_str, unique_loc l = f.readline() lc = 1 - while (l): + while l: - patterns = ['RTR(\"', 'TTR(\"', 'TTRC(\"'] + patterns = ['RTR("', 'TTR("', 'TTRC("'] idx = 0 pos = 0 - while (pos >= 0): + while pos >= 0: pos = l.find(patterns[idx], pos) - if (pos == -1): - if (idx < len(patterns) - 1): + if pos == -1: + if idx < len(patterns) - 1: idx += 1 pos = 0 continue pos += len(patterns[idx]) msg = "" - while (pos < len(l) and (l[pos] != '"' or l[pos - 1] == '\\')): + while pos < len(l) and (l[pos] != '"' or l[pos - 1] == "\\"): msg += l[pos] pos += 1 - location = os.path.relpath(fname).replace('\\', '/') - if (line_nb): + location = os.path.relpath(fname).replace("\\", "/") + if line_nb: location += ":" + str(lc) - if (not msg in unique_str): + if not msg in unique_str: main_po += "\n#: " + location + "\n" main_po += 'msgid "' + msg + '"\n' main_po += 'msgstr ""\n' unique_str.append(msg) unique_loc[msg] = [location] - elif (not location in unique_loc[msg]): + elif not location in unique_loc[msg]: # Add additional location to previous occurrence too msg_pos = main_po.find('\nmsgid "' + msg + '"') - if (msg_pos == -1): + if msg_pos == -1: print("Someone apparently thought writing Python was as easy as GDScript. Ping Akien.") - main_po = main_po[:msg_pos] + ' ' + location + main_po[msg_pos:] + main_po = main_po[:msg_pos] + " " + location + main_po[msg_pos:] unique_loc[msg].append(location) l = f.readline() lc += 1 + print("Updating the editor.pot template...") for fname in matches: @@ -104,7 +108,7 @@ for fname in matches: with open("editor.pot", "w") as f: f.write(main_po) -if (os.name == "posix"): +if os.name == "posix": print("Wrapping template at 79 characters for compatibility with Weblate.") os.system("msgmerge -w79 editor.pot editor.pot > editor.pot.wrap") shutil.move("editor.pot.wrap", "editor.pot") @@ -112,7 +116,7 @@ if (os.name == "posix"): shutil.move("editor.pot", "editor/translations/editor.pot") # TODO: Make that in a portable way, if we care; if not, kudos to Unix users -if (os.name == "posix"): +if os.name == "posix": added = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \+msgid | wc -l", shell=True) removed = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \\\-msgid | wc -l", shell=True) print("\n# Template changes compared to the staged status:") diff --git a/editor/translations/fi.po b/editor/translations/fi.po index d590546571..2798d56d28 100644 --- a/editor/translations/fi.po +++ b/editor/translations/fi.po @@ -14,7 +14,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-02-21 23:33+0000\n" +"PO-Revision-Date: 2020-03-14 15:05+0000\n" "Last-Translator: Tapani Niemi <tapani.niemi@kapsi.fi>\n" "Language-Team: Finnish <https://hosted.weblate.org/projects/godot-engine/" "godot/fi/>\n" @@ -23,7 +23,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.11.1\n" +"X-Generator: Weblate 4.0-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5945,9 +5945,8 @@ msgstr "" "Tämä on tarkin (mutta hitain) vaihtoehto törmäystunnistukselle." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" -msgstr "Luo yksittäisen konveksin törmäysmuodon sisaret" +msgstr "Luo yksittäisen konveksin törmäyksen sisar" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -12362,6 +12361,7 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape ei tue RigidBody solmua muussa kuin staattisessa tilassa." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/ja.po b/editor/translations/ja.po index 3c14b17b53..0bb76f1261 100644 --- a/editor/translations/ja.po +++ b/editor/translations/ja.po @@ -35,7 +35,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-05 08:33+0000\n" +"PO-Revision-Date: 2020-03-16 09:43+0000\n" "Last-Translator: Akihiro Ogoshi <technical@palsystem-game.com>\n" "Language-Team: Japanese <https://hosted.weblate.org/projects/godot-engine/" "godot/ja/>\n" @@ -908,7 +908,7 @@ msgstr "切断" #: editor/connections_dialog.cpp msgid "Connect a Signal to a Method" -msgstr "メソッドにシグナルを接続する" +msgstr "メソッドにシグナルを接続" #: editor/connections_dialog.cpp msgid "Edit Connection:" @@ -5834,7 +5834,7 @@ msgstr "グラデーション編集" #: editor/plugins/item_list_editor_plugin.cpp msgid "Item %d" -msgstr "アイテム%d" +msgstr "アイテム %d" #: editor/plugins/item_list_editor_plugin.cpp msgid "Items" @@ -5854,7 +5854,7 @@ msgstr "メッシュがありません!" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Couldn't create a Trimesh collision shape." -msgstr "トライメッシュコリジョンシェイプを作成できませんでした。" +msgstr "三角形メッシュ コリジョンシェイプを作成できませんでした。" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Create Static Trimesh Body" @@ -5954,7 +5954,7 @@ msgstr "" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Create Trimesh Collision Sibling" -msgstr "三角形メッシュ兄弟コリジョンを生成" +msgstr "三角形メッシュ コリジョンの兄弟を作成" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -5965,7 +5965,6 @@ msgstr "" "これは、衝突検出の最も正確な(ただし最も遅い)オプションです。" #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" msgstr "単一の凸型コリジョンの兄弟を作成" @@ -5979,7 +5978,7 @@ msgstr "" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Create Multiple Convex Collision Siblings" -msgstr "複数の凸型コリジョンの兄弟を作成する" +msgstr "複数の凸型コリジョンの兄弟を作成" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "" @@ -7654,7 +7653,7 @@ msgstr "ジオメトリが無効です。衝突ポリゴンを作成できませ #: editor/plugins/sprite_editor_plugin.cpp msgid "Create CollisionPolygon2D Sibling" -msgstr "CollisionPolygon2Dの兄弟を作成する" +msgstr "CollisionPolygon2Dの兄弟を作成" #: editor/plugins/sprite_editor_plugin.cpp msgid "Invalid geometry, can't create light occluder." @@ -7662,7 +7661,7 @@ msgstr "ジオメトリが無効です。ライトオクールダーを作成で #: editor/plugins/sprite_editor_plugin.cpp msgid "Create LightOccluder2D Sibling" -msgstr "LightOccluder2Dの兄弟を作成する" +msgstr "LightOccluder2Dの兄弟を作成" #: editor/plugins/sprite_editor_plugin.cpp msgid "Sprite" @@ -11936,9 +11935,9 @@ msgid "" " Godot Version: %s\n" "Please reinstall Android build template from 'Project' menu." msgstr "" -"Androidビルドバージョンの不一致:\n" -"インストールされたテンプレート:%s\n" -"ゴドーバージョン:%s\n" +"Androidビルド バージョンの不一致:\n" +" インストールされたテンプレート: %s\n" +" Godot バージョン: %s\n" "「プロジェクト 」メニューからAndroidビルドテンプレートを再インストールしてく" "ださい。" @@ -11952,7 +11951,7 @@ msgid "" "Alternatively visit docs.godotengine.org for Android build documentation." msgstr "" "Androidプロジェクトのビルドに失敗しました。エラーの出力を確認してください。\n" -"あるいは、Androidビルドドキュメントについてはdocs.godotengine.orgをご覧くださ" +"また、Androidビルドについてのドキュメントは docs.godotengine.org をご覧くださ" "い。" #: platform/android/export/export.cpp @@ -12372,6 +12371,8 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape は、Static 以外のモードの RigidBody をサポートしていませ" +"ん。" #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/ko.po b/editor/translations/ko.po index 37c950097b..ec33599440 100644 --- a/editor/translations/ko.po +++ b/editor/translations/ko.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-05 08:33+0000\n" +"PO-Revision-Date: 2020-03-14 00:33+0000\n" "Last-Translator: Ch. <ccwpc@hanmail.net>\n" "Language-Team: Korean <https://hosted.weblate.org/projects/godot-engine/" "godot/ko/>\n" @@ -12271,6 +12271,8 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape는 static 외의 모드가 설정된 RigidBody를 지원하지 않습니" +"다." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/lv.po b/editor/translations/lv.po index dc0a5aa151..14dfdff801 100644 --- a/editor/translations/lv.po +++ b/editor/translations/lv.po @@ -4,12 +4,13 @@ # This file is distributed under the same license as the Godot source code. # Gustavs Porietis (pg829-) <porietisgustavs@gmail.com>, 2018. # Martch Zagorski <martchzagorski@gmail.com>, 2018. +# Jānis Ondzuls <janisond@inbox.lv>, 2020. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2018-12-13 14:41+0100\n" -"Last-Translator: Martch Zagorski <martchzagorski@gmail.com>\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" +"Last-Translator: Jānis Ondzuls <janisond@inbox.lv>\n" "Language-Team: Latvian <https://hosted.weblate.org/projects/godot-engine/" "godot/lv/>\n" "Language: lv\n" @@ -18,7 +19,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n % 10 == 0 || n % 100 >= 11 && n % 100 <= " "19) ? 0 : ((n % 10 == 1 && n % 100 != 11) ? 1 : 2);\n" -"X-Generator: Poedit 2.2\n" +"X-Generator: Weblate 4.0-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -65,31 +66,31 @@ msgstr "" #: core/ustring.cpp msgid "B" -msgstr "" +msgstr "B" #: core/ustring.cpp msgid "KiB" -msgstr "" +msgstr "KiB" #: core/ustring.cpp msgid "MiB" -msgstr "" +msgstr "MiB" #: core/ustring.cpp msgid "GiB" -msgstr "" +msgstr "GiB" #: core/ustring.cpp msgid "TiB" -msgstr "" +msgstr "TiB" #: core/ustring.cpp msgid "PiB" -msgstr "" +msgstr "PiB" #: core/ustring.cpp msgid "EiB" -msgstr "" +msgstr "EiB" #: editor/animation_bezier_editor.cpp msgid "Free" @@ -101,29 +102,27 @@ msgstr "Balancēts" #: editor/animation_bezier_editor.cpp msgid "Mirror" -msgstr "" +msgstr "Spogulis" #: editor/animation_bezier_editor.cpp editor/editor_profiler.cpp msgid "Time:" -msgstr "" +msgstr "Laiks:" #: editor/animation_bezier_editor.cpp msgid "Value:" -msgstr "" +msgstr "Vērtība:" #: editor/animation_bezier_editor.cpp msgid "Insert Key Here" -msgstr "" +msgstr "Ievadiet vērtību šeit" #: editor/animation_bezier_editor.cpp -#, fuzzy msgid "Duplicate Selected Key(s)" -msgstr "Dublikāta Izvēle" +msgstr "Dublikāta Vērtības" #: editor/animation_bezier_editor.cpp -#, fuzzy msgid "Delete Selected Key(s)" -msgstr "Izdzēst izvēlētos failus?" +msgstr "Izdzēst izvēlēto(ās) vērtību(as)?" #: editor/animation_bezier_editor.cpp msgid "Add Bezier Point" @@ -682,7 +681,7 @@ msgstr "" #: editor/array_property_edit.cpp msgid "Change Array Value" -msgstr "" +msgstr "Izmainīt masīva vērtību" #: editor/code_editor.cpp msgid "Go to Line" @@ -690,20 +689,19 @@ msgstr "Doties uz Rindu" #: editor/code_editor.cpp msgid "Line Number:" -msgstr "" +msgstr "Rindas Numurs:" #: editor/code_editor.cpp -#, fuzzy msgid "%d replaced." -msgstr "Aizvietot" +msgstr "%d aizvietots." #: editor/code_editor.cpp editor/editor_help.cpp msgid "%d match." -msgstr "" +msgstr "%d sakritība." #: editor/code_editor.cpp editor/editor_help.cpp msgid "%d matches." -msgstr "" +msgstr "%d sakritības." #: editor/code_editor.cpp editor/find_in_files.cpp msgid "Match Case" @@ -719,16 +717,16 @@ msgstr "Aizvietot" #: editor/code_editor.cpp msgid "Replace All" -msgstr "" +msgstr "Aizvietot visu" #: editor/code_editor.cpp msgid "Selection Only" -msgstr "" +msgstr "Tikai izvēlētais" #: editor/code_editor.cpp editor/plugins/script_text_editor.cpp #: editor/plugins/text_editor.cpp msgid "Standard" -msgstr "" +msgstr "Standarts" #: editor/code_editor.cpp editor/plugins/script_editor_plugin.cpp msgid "Toggle Scripts Panel" diff --git a/editor/translations/nl.po b/editor/translations/nl.po index 458ff0b5b8..a729ea6119 100644 --- a/editor/translations/nl.po +++ b/editor/translations/nl.po @@ -44,7 +44,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-08 22:33+0000\n" +"PO-Revision-Date: 2020-03-16 09:43+0000\n" "Last-Translator: Stijn Hinlopen <f.a.hinlopen@gmail.com>\n" "Language-Team: Dutch <https://hosted.weblate.org/projects/godot-engine/godot/" "nl/>\n" @@ -12434,7 +12434,7 @@ msgstr "" #: scene/3d/collision_shape.cpp msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." -msgstr "" +msgstr "ConcavePolygonShape ondersteunt RigidBody alleen in statische modus." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/pl.po b/editor/translations/pl.po index 14bbb799aa..de1d6d5375 100644 --- a/editor/translations/pl.po +++ b/editor/translations/pl.po @@ -42,7 +42,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-08 22:33+0000\n" +"PO-Revision-Date: 2020-03-16 09:43+0000\n" "Last-Translator: Tomek <kobewi4e@gmail.com>\n" "Language-Team: Polish <https://hosted.weblate.org/projects/godot-engine/" "godot/pl/>\n" @@ -5981,7 +5981,6 @@ msgstr "" "To jest najdokładniejsza (ale najwolniejsza) opcja do detekcji kolizji." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" msgstr "Utwórz pojedynczego wypukłego sąsiada kolizji" @@ -12400,6 +12399,8 @@ msgstr "" msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." msgstr "" +"ConcavePolygonShape nie obsługuje węzła RigidBody w innym trybie niż " +"statyczny." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/pt_PT.po b/editor/translations/pt_PT.po index 60009b3171..d7532e38d4 100644 --- a/editor/translations/pt_PT.po +++ b/editor/translations/pt_PT.po @@ -19,7 +19,7 @@ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-02-18 15:09+0000\n" +"PO-Revision-Date: 2020-03-16 09:43+0000\n" "Last-Translator: João Lopes <linux-man@hotmail.com>\n" "Language-Team: Portuguese (Portugal) <https://hosted.weblate.org/projects/" "godot-engine/godot/pt_PT/>\n" @@ -28,7 +28,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.11\n" +"X-Generator: Weblate 4.0-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -5958,7 +5958,6 @@ msgstr "" "Esta é a mais precisa (mas mais lenta) opção para deteção de colisão." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Collision Sibling" msgstr "Criar Irmãos Únicos de Colisão Convexa" @@ -12362,7 +12361,7 @@ msgstr "" #: scene/3d/collision_shape.cpp msgid "" "ConcavePolygonShape doesn't support RigidBody in another mode than static." -msgstr "" +msgstr "ConcavePolygonShape apenas suporta RigidBody no modo estático." #: scene/3d/cpu_particles.cpp msgid "Nothing is visible because no mesh has been assigned." diff --git a/editor/translations/ru.po b/editor/translations/ru.po index b05077637a..d3402fd63e 100644 --- a/editor/translations/ru.po +++ b/editor/translations/ru.po @@ -66,12 +66,13 @@ # Artur Tretiak <stikyt@protonmail.com>, 2020. # Smadjavul <o1985af@gmail.com>, 2020. # anonymous <noreply@weblate.org>, 2020. +# Vinsent Insaider_red <vinsent.in7aider@gmail.com>, 2020. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-03-07 21:18+0000\n" -"Last-Translator: Smadjavul <o1985af@gmail.com>\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" +"Last-Translator: Vinsent Insaider_red <vinsent.in7aider@gmail.com>\n" "Language-Team: Russian <https://hosted.weblate.org/projects/godot-engine/" "godot/ru/>\n" "Language: ru\n" @@ -98,9 +99,8 @@ msgid "Not enough bytes for decoding bytes, or invalid format." msgstr "Недостаточно байтов для декодирования байтов или неверный формат." #: core/math/expression.cpp -#, fuzzy msgid "Invalid input %i (not passed) in expression" -msgstr "Некорректный ввод %i (не был передан) в выражении" +msgstr "Некорректный ввод %i (не подходит) в выражении" #: core/math/expression.cpp msgid "self can't be used because instance is null (not passed)" diff --git a/editor/translations/tr.po b/editor/translations/tr.po index c73724c7b7..83eb878d8c 100644 --- a/editor/translations/tr.po +++ b/editor/translations/tr.po @@ -42,12 +42,13 @@ # Muhammet Mustafa Tozlu <m.mustafatozlu@gmail.com>, 2019. # HALİL ATAŞ <halillatass@gmail.com>, 2019. # Zsosu Ktosu <zktosu@gmail.com>, 2020. +# Mesut Aslan <kontinyu@gmail.com>, 2020. msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2020-01-30 03:56+0000\n" -"Last-Translator: Zsosu Ktosu <zktosu@gmail.com>\n" +"PO-Revision-Date: 2020-03-11 12:20+0000\n" +"Last-Translator: Mesut Aslan <kontinyu@gmail.com>\n" "Language-Team: Turkish <https://hosted.weblate.org/projects/godot-engine/" "godot/tr/>\n" "Language: tr\n" @@ -55,7 +56,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.11-dev\n" +"X-Generator: Weblate 4.0-dev\n" #: core/math/expression.cpp modules/gdscript/gdscript_functions.cpp #: modules/visual_script/visual_script_builtin_funcs.cpp @@ -726,9 +727,8 @@ msgid "Line Number:" msgstr "Satır Numarası:" #: editor/code_editor.cpp -#, fuzzy msgid "%d replaced." -msgstr "Değiştir..." +msgstr "%d değiştirildi." #: editor/code_editor.cpp editor/editor_help.cpp msgid "%d match." @@ -3989,9 +3989,8 @@ msgid "Saving..." msgstr "Kaydediliyor..." #: editor/import_dock.cpp -#, fuzzy msgid "%d Files" -msgstr " Dosyalar" +msgstr "%d Dosya" #: editor/import_dock.cpp msgid "Set as Default for '%s'" @@ -5870,9 +5869,8 @@ msgid "Mesh is empty!" msgstr "Örüntü boş!" #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Couldn't create a Trimesh collision shape." -msgstr "Üçlü Örüntü Çarpışma Kardeşi Oluştur" +msgstr "Trimesh çarpışma şekli oluşturulamadı." #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Create Static Trimesh Body" @@ -5888,25 +5886,23 @@ msgstr "Üçlü Örüntü Yüzeyi Oluştur" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Can't create a single convex collision shape for the scene root." -msgstr "" +msgstr "Sahne kökü için tek bir dışbükey çarpışma şekli oluşturulamaz." #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Couldn't create a single convex collision shape." -msgstr "" +msgstr "Tek dışbükey çarpışma şekli oluşturulamadı." #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Create Single Convex Shape" -msgstr "Dışbükey Şekil[ler] Oluştur" +msgstr "Tekil Dışbükey Şekil Oluştur" #: editor/plugins/mesh_instance_editor_plugin.cpp msgid "Can't create multiple convex collision shapes for the scene root." msgstr "" #: editor/plugins/mesh_instance_editor_plugin.cpp -#, fuzzy msgid "Couldn't create any collision shapes." -msgstr "Klasör oluşturulamadı." +msgstr "Herhangi bir çarpışma şekli oluşturulamadı." #: editor/plugins/mesh_instance_editor_plugin.cpp #, fuzzy @@ -5977,6 +5973,8 @@ msgid "" "Creates a polygon-based collision shape.\n" "This is the most accurate (but slowest) option for collision detection." msgstr "" +"Poligon bazlı bir çarpışma şekli oluştur.\n" +"Bu en hassas (fakat en yavaş) çarpışma algılama seçeneğidir." #: editor/plugins/mesh_instance_editor_plugin.cpp #, fuzzy |