diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 13:23:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch) | |
tree | a27e497da7104dd0a64f98a04fa3067668735e91 /editor | |
parent | 710b34b70227becdc652b4ae027fe0ac47409642 (diff) |
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.
This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.
There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).
Part of #33027.
Diffstat (limited to 'editor')
279 files changed, 0 insertions, 7683 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 57c63dd40d..893a3f62b1 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -51,7 +51,6 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, const Vector2 &start, con } void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { - float scale = timeline->get_zoom_scale(); int limit = timeline->get_name_limit(); int right_limit = get_size().width - timeline->get_buttons_width(); @@ -69,7 +68,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { } for (Map<float, int>::Element *E = key_order.front(); E; E = E->next()) { - int i = E->get(); if (!E->next()) @@ -127,7 +125,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { Vector2 prev_pos; for (int j = from_x; j <= to_x; j++) { - float t = (j - limit) / scale + timeline->get_value(); float h; @@ -144,7 +141,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { //narrow high and low as much as possible for (int k = 0; k < iterations; k++) { - middle = (low + high) / 2; Vector2 interp = _bezier_interp(middle, start, out_handle, in_handle, end); @@ -183,7 +179,6 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { } void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, int p_clip_left, int p_clip_right) { - Vector2 from = p_from; Vector2 to = p_to; @@ -213,7 +208,6 @@ void AnimationBezierTrackEdit::_draw_line_clipped(const Vector2 &p_from, const V } void AnimationBezierTrackEdit::_notification(int p_what) { - if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { bezier_icon = get_theme_icon("KeyBezierPoint", "EditorIcons"); bezier_handle_icon = get_theme_icon("KeyBezierHandle", "EditorIcons"); @@ -225,7 +219,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } } if (p_what == NOTIFICATION_RESIZED) { - int right_limit = get_size().width - timeline->get_buttons_width(); int hsep = get_theme_constant("hseparation", "ItemList"); int vsep = get_theme_constant("vseparation", "ItemList"); @@ -365,7 +358,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) { bool first = true; int prev_iv = 0; for (int i = font->get_height(); i < get_size().height; i++) { - float ofs = get_size().height / 2 - i; ofs *= v_zoom; ofs += v_scroll; @@ -374,7 +366,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) { if (ofs < 0) iv -= 1; if (!first && iv != prev_iv) { - Color lc = linecolor; lc.a *= 0.5; draw_line(Point2(limit, i), Point2(right_limit, i), lc); @@ -393,11 +384,9 @@ void AnimationBezierTrackEdit::_notification(int p_what) { float scale = timeline->get_zoom_scale(); 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()); for (int i = 0; i < animation->track_get_key_count(E->key()); i++) { - float offset = animation->track_get_key_time(E->key(), i); float value = animation->bezier_track_get_key_value(E->key(), i); @@ -416,12 +405,10 @@ void AnimationBezierTrackEdit::_notification(int p_what) { //draw editor handles { - float scale = timeline->get_zoom_scale(); edit_points.clear(); for (int i = 0; i < animation->track_get_key_count(track); i++) { - float offset = animation->track_get_key_time(track, i); float value = animation->bezier_track_get_key_value(track, i); @@ -499,7 +486,6 @@ Ref<Animation> AnimationBezierTrackEdit::get_animation() const { } void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) { - animation = p_animation; track = p_track; if (is_connected_compat("select_key", editor, "_key_selected")) @@ -512,7 +498,6 @@ void AnimationBezierTrackEdit::set_animation_and_track(const Ref<Animation> &p_a } Size2 AnimationBezierTrackEdit::get_minimum_size() const { - return Vector2(1, 1); } @@ -530,7 +515,6 @@ void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) { } void AnimationBezierTrackEdit::_play_position_draw() { - if (!animation.is_valid() || play_position_pos < 0) return; @@ -546,7 +530,6 @@ void AnimationBezierTrackEdit::_play_position_draw() { } void AnimationBezierTrackEdit::set_play_position(float p_pos) { - play_position_pos = p_pos; play_position->update(); } @@ -563,7 +546,6 @@ void AnimationBezierTrackEdit::_zoom_changed() { } String AnimationBezierTrackEdit::get_tooltip(const Point2 &p_pos) const { - return Control::get_tooltip(p_pos); } @@ -574,7 +556,6 @@ void AnimationBezierTrackEdit::_clear_selection() { } void AnimationBezierTrackEdit::_clear_selection_for_anim(const Ref<Animation> &p_anim) { - if (!(animation == p_anim)) return; //selection.clear(); @@ -582,7 +563,6 @@ void AnimationBezierTrackEdit::_clear_selection_for_anim(const Ref<Animation> &p } void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) { - if (!(animation == p_anim)) return; @@ -595,7 +575,6 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int } void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { - if (p_event->is_pressed()) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { duplicate_selection(); @@ -636,7 +615,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && mb->get_button_index() == BUTTON_MIDDLE) { - if (mb->is_pressed()) { int x = mb->get_position().x - timeline->get_name_limit(); panning_timeline_from = x / timeline->get_zoom_scale(); @@ -648,7 +626,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - menu_insert_key = mb->get_position(); if (menu_insert_key.x >= timeline->get_name_limit() && menu_insert_key.x <= get_size().width - timeline->get_buttons_width()) { Vector2 popup_pos = get_global_transform().xform(mb->get_position()); @@ -669,7 +646,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - if (close_icon_rect.has_point(mb->get_position())) { emit_signal("close_request"); return; @@ -683,7 +659,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } for (int i = 0; i < edit_points.size(); i++) { - //first check point //command makes it ignore the main point, so control point editors can be force-edited //path 2D editing in the 3D and 2D editors works the same way @@ -706,7 +681,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { select_single_attempt = i; update(); } else { - moving_selection_attempt = true; moving_selection = true; moving_selection_from_key = i; @@ -741,7 +715,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { //insert new point if (mb->get_command() && mb->get_position().x >= timeline->get_name_limit() && mb->get_position().x < get_size().width - timeline->get_buttons_width()) { - Array new_point; new_point.resize(5); @@ -790,7 +763,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (box_selecting_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - if (box_selecting) { //do actual select if (!box_selecting_add) { @@ -808,7 +780,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { Rect2 selection_rect(bs_from, bs_to - bs_from); for (int i = 0; i < edit_points.size(); i++) { - if (edit_points[i].point_rect.intersects(selection_rect)) { selection.insert(i); } @@ -822,7 +793,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (moving_handle != 0 && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - undo_redo->create_action(TTR("Move Bezier Points")); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, moving_handle_key, moving_handle_left); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, moving_handle_key, moving_handle_right); @@ -835,7 +805,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (moving_selection_attempt && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - if (moving_selection) { //combit it @@ -844,12 +813,10 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { List<AnimMoveRestore> to_restore; // 1-remove the keys for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, E->get()); } // 2- remove overlapped keys for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float newtime = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x); int idx = animation->track_find_key(track, newtime, true); @@ -871,7 +838,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { // 3-move the keys (re insert them) for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x); /* if (newpos<0) @@ -886,7 +852,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { // 4-(undo) remove inserted keys for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = editor->snap_time(animation->track_get_key_time(track, E->get()) + moving_selection_offset.x); /* if (newpos<0) @@ -897,14 +862,12 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { // 5-(undo) reinsert keys for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = animation->track_get_key_time(track, E->get()); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, oldpos, animation->track_get_key_value(track, E->get()), 1); } // 6-(undo) reinsert overlapped keys for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - AnimMoveRestore &amr = E->get(); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } @@ -915,7 +878,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { // 7-reselect for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = animation->track_get_key_time(track, E->get()); float newpos = editor->snap_time(oldpos + moving_selection_offset.x); @@ -951,7 +913,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { update(); } if (moving_selection_attempt && mm.is_valid()) { - if (!moving_selection) { moving_selection = true; select_single_attempt = -1; @@ -965,7 +926,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (box_selecting_attempt && mm.is_valid()) { - if (!box_selecting) { box_selecting = true; box_selecting_add = mm->get_shift(); @@ -981,7 +941,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (moving_handle != 0 && mm.is_valid()) { - float y = (get_size().height / 2 - mm->get_position().y) * v_zoom + v_scroll; float x = ((mm->get_position().x - timeline->get_name_limit()) / timeline->get_zoom_scale()) + timeline->get_value(); @@ -1026,10 +985,8 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } void AnimationBezierTrackEdit::_menu_selected(int p_index) { - switch (p_index) { case MENU_KEY_INSERT: { - Array new_point; new_point.resize(5); @@ -1062,13 +1019,11 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) { } void AnimationBezierTrackEdit::duplicate_selection() { - if (selection.size() == 0) return; float top_time = 1e10; for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float t = animation->track_get_key_time(track, E->get()); if (t < top_time) top_time = t; @@ -1079,7 +1034,6 @@ void AnimationBezierTrackEdit::duplicate_selection() { List<Pair<int, float>> new_selection_values; for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - float t = animation->track_get_key_time(track, E->get()); float dst_time = t + (timeline->get_play_position() - top_time); int existing_idx = animation->track_find_key(track, dst_time, true); @@ -1093,7 +1047,6 @@ void AnimationBezierTrackEdit::duplicate_selection() { new_selection_values.push_back(p); if (existing_idx != -1) { - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, dst_time, animation->track_get_key_value(track, existing_idx), animation->track_get_key_transition(track, existing_idx)); } } @@ -1104,7 +1057,6 @@ void AnimationBezierTrackEdit::duplicate_selection() { selection.clear(); for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; float time = E->get().second; @@ -1124,7 +1076,6 @@ void AnimationBezierTrackEdit::delete_selection() { undo_redo->create_action(TTR("Anim Delete Keys")); for (Set<int>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", track, E->get()); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, animation->track_get_key_time(track, E->get()), animation->track_get_key_value(track, E->get()), 1); } @@ -1140,7 +1091,6 @@ void AnimationBezierTrackEdit::set_block_animation_update_ptr(bool *p_block_ptr) } void AnimationBezierTrackEdit::_bind_methods() { - ClassDB::bind_method("_gui_input", &AnimationBezierTrackEdit::_gui_input); ClassDB::bind_method("_clear_selection", &AnimationBezierTrackEdit::_clear_selection); diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index 2be388fd57..1c1cde47b4 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -34,7 +34,6 @@ #include "animation_track_editor.h" class AnimationBezierTrackEdit : public Control { - GDCLASS(AnimationBezierTrackEdit, Control); enum HandleMode { @@ -112,7 +111,6 @@ class AnimationBezierTrackEdit : public Control { Vector2 menu_insert_key; struct AnimMoveRestore { - int track; float time; Variant key; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 4a43cb0c18..92879fb193 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -41,7 +41,6 @@ #include "servers/audio/audio_stream.h" class AnimationTrackKeyEdit : public Object { - GDCLASS(AnimationTrackKeyEdit, Object); public: @@ -56,7 +55,6 @@ public: } static void _bind_methods() { - ClassDB::bind_method("_update_obj", &AnimationTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationTrackKeyEdit::_hide_script_from_inspector); @@ -65,7 +63,6 @@ public: } void _fix_node_path(Variant &value) { - NodePath np = value; if (np == NodePath()) @@ -83,7 +80,6 @@ public: } void _update_obj(const Ref<Animation> &p_anim) { - if (setting || animation != p_anim) return; @@ -91,7 +87,6 @@ public: } void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) { - if (animation != p_anim || from != key_ofs) return; @@ -104,13 +99,11 @@ public: } bool _set(const StringName &p_name, const Variant &p_value) { - int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); String name = p_name; if (name == "time" || name == "frame") { - float new_time = p_value; if (name == "frame") { @@ -151,7 +144,6 @@ public: } if (name == "easing") { - float val = p_value; float prev_val = animation->track_get_key_transition(track, key); setting = true; @@ -167,9 +159,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { - Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); d_new[p_name] = p_value; @@ -185,9 +175,7 @@ public: return true; } break; case Animation::TYPE_VALUE: { - if (name == "value") { - Variant value = p_value; if (value.get_type() == Variant::NODE_PATH) { @@ -208,7 +196,6 @@ public: } } break; case Animation::TYPE_METHOD: { - Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); @@ -216,16 +203,13 @@ public: bool mergeable = false; if (name == "name") { - d_new["method"] = p_value; } else if (name == "arg_count") { - Vector<Variant> args = d_old["args"]; args.resize(p_value); d_new["args"] = args; change_notify_deserved = true; } else if (name.begins_with("args/")) { - Vector<Variant> args = d_old["args"]; int idx = name.get_slice("/", 1).to_int(); ERR_FAIL_INDEX_V(idx, args.size(), false); @@ -241,17 +225,14 @@ public: Variant *ptrs[1] = { &old }; args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; } } else if (what == "value") { - Variant value = p_value; if (value.get_type() == Variant::NODE_PATH) { - _fix_node_path(value); } @@ -279,9 +260,7 @@ public: return true; } break; case Animation::TYPE_BEZIER: { - if (name == "value") { - const Variant &value = p_value; setting = true; @@ -298,7 +277,6 @@ public: } if (name == "in_handle") { - const Variant &value = p_value; setting = true; @@ -315,7 +293,6 @@ public: } if (name == "out_handle") { - const Variant &value = p_value; setting = true; @@ -332,9 +309,7 @@ public: } } break; case Animation::TYPE_AUDIO: { - if (name == "stream") { - Ref<AudioStream> stream = p_value; setting = true; @@ -351,7 +326,6 @@ public: } if (name == "start_offset") { - float value = p_value; setting = true; @@ -368,7 +342,6 @@ public: } if (name == "end_offset") { - float value = p_value; setting = true; @@ -385,9 +358,7 @@ public: } } break; case Animation::TYPE_ANIMATION: { - if (name == "animation") { - StringName anim_name = p_value; setting = true; @@ -409,7 +380,6 @@ public: } bool _get(const StringName &p_name, Variant &r_ret) const { - int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); @@ -420,7 +390,6 @@ public: } if (name == "frame") { - float fps = animation->get_step(); if (fps > 0) { fps = 1.0 / fps; @@ -436,7 +405,6 @@ public: switch (animation->track_get_type(track)) { case Animation::TYPE_TRANSFORM: { - Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND_V(!d.has(name), false); r_ret = d[p_name]; @@ -444,7 +412,6 @@ public: } break; case Animation::TYPE_VALUE: { - if (name == "value") { r_ret = animation->track_get_key_value(track, key); return true; @@ -452,11 +419,9 @@ public: } break; case Animation::TYPE_METHOD: { - Dictionary d = animation->track_get_key_value(track, key); if (name == "name") { - ERR_FAIL_COND_V(!d.has("method"), false); r_ret = d["method"]; return true; @@ -472,7 +437,6 @@ public: } if (name.begins_with("args/")) { - int idx = name.get_slice("/", 1).to_int(); ERR_FAIL_INDEX_V(idx, args.size(), false); @@ -490,7 +454,6 @@ public: } break; case Animation::TYPE_BEZIER: { - if (name == "value") { r_ret = animation->bezier_track_get_key_value(track, key); return true; @@ -508,7 +471,6 @@ public: } break; case Animation::TYPE_AUDIO: { - if (name == "stream") { r_ret = animation->audio_track_get_key_stream(track, key); return true; @@ -526,7 +488,6 @@ public: } break; case Animation::TYPE_ANIMATION: { - if (name == "animation") { r_ret = animation->animation_track_get_key_animation(track, key); return true; @@ -538,7 +499,6 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - if (animation.is_null()) return; @@ -554,25 +514,20 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "location")); p_list->push_back(PropertyInfo(Variant::QUAT, "rotation")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale")); } break; case Animation::TYPE_VALUE: { - Variant v = animation->track_get_key_value(track, key); if (hint.type != Variant::NIL) { - PropertyInfo pi = hint; pi.name = "value"; p_list->push_back(pi); } else { - PropertyHint hint = PROPERTY_HINT_NONE; String hint_string; @@ -580,7 +535,6 @@ public: //could actually check the object property if exists..? yes i will! Ref<Resource> res = v; if (res.is_valid()) { - hint = PROPERTY_HINT_RESOURCE_TYPE; hint_string = res->get_class(); } @@ -592,7 +546,6 @@ public: } break; case Animation::TYPE_METHOD: { - p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1")); @@ -601,14 +554,12 @@ public: Vector<Variant> args = d["args"]; String vtypes; for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i > 0) vtypes += ","; vtypes += Variant::get_type_name(Variant::Type(i)); } for (int i = 0; i < args.size(); i++) { - p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes)); if (args[i].get_type() != Variant::NIL) p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value")); @@ -616,25 +567,21 @@ public: } break; case Animation::TYPE_BEZIER: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "value")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle")); } break; case Animation::TYPE_AUDIO: { - p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream")); p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); } break; case Animation::TYPE_ANIMATION: { - String animations; if (root_path && root_path->has_node(animation->track_get_path(track))) { - AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(root_path->get_node(animation->track_get_path(track))); if (ap) { List<StringName> anims; @@ -675,7 +622,6 @@ public: bool use_fps; void notify_change() { - _change_notify(); } @@ -698,7 +644,6 @@ public: }; class AnimationMultiTrackKeyEdit : public Object { - GDCLASS(AnimationMultiTrackKeyEdit, Object); public: @@ -713,7 +658,6 @@ public: } static void _bind_methods() { - ClassDB::bind_method("_update_obj", &AnimationMultiTrackKeyEdit::_update_obj); ClassDB::bind_method("_key_ofs_changed", &AnimationMultiTrackKeyEdit::_key_ofs_changed); ClassDB::bind_method("_hide_script_from_inspector", &AnimationMultiTrackKeyEdit::_hide_script_from_inspector); @@ -722,7 +666,6 @@ public: } void _fix_node_path(Variant &value, NodePath &base) { - NodePath np = value; if (np == NodePath()) @@ -740,7 +683,6 @@ public: } void _update_obj(const Ref<Animation> &p_anim) { - if (setting || animation != p_anim) return; @@ -748,15 +690,12 @@ public: } void _key_ofs_changed(const Ref<Animation> &p_anim, float from, float to) { - if (animation != p_anim) return; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int key = 0; for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); if (from != key_ofs) { key++; @@ -777,21 +716,17 @@ public: } bool _set(const StringName &p_name, const Variant &p_value) { - bool update_obj = false; bool change_notify_deserved = false; for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int track = E->key(); for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); int key = animation->track_find_key(track, key_ofs, true); ERR_FAIL_COND_V(key == -1, false); String name = p_name; if (name == "time" || name == "frame") { - float new_time = p_value; if (name == "frame") { @@ -825,7 +760,6 @@ public: undo_redo->add_undo_method(animation.ptr(), "track_insert_key", track, new_time, v, trans); } } else if (name == "easing") { - float val = p_value; float prev_val = animation->track_get_key_transition(track, key); @@ -839,9 +773,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { - Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); d_new[p_name] = p_value; @@ -855,9 +787,7 @@ public: update_obj = true; } break; case Animation::TYPE_VALUE: { - if (name == "value") { - Variant value = p_value; if (value.get_type() == Variant::NODE_PATH) { @@ -875,23 +805,19 @@ public: } } break; case Animation::TYPE_METHOD: { - Dictionary d_old = animation->track_get_key_value(track, key); Dictionary d_new = d_old.duplicate(); bool mergeable = false; if (name == "name") { - d_new["method"] = p_value; } else if (name == "arg_count") { - Vector<Variant> args = d_old["args"]; args.resize(p_value); d_new["args"] = args; change_notify_deserved = true; } else if (name.begins_with("args/")) { - Vector<Variant> args = d_old["args"]; int idx = name.get_slice("/", 1).to_int(); ERR_FAIL_INDEX_V(idx, args.size(), false); @@ -907,17 +833,14 @@ public: Variant *ptrs[1] = { &old }; args.write[idx] = Variant::construct(t, (const Variant **)ptrs, 1, err); } else { - args.write[idx] = Variant::construct(t, nullptr, 0, err); } change_notify_deserved = true; d_new["args"] = args; } } else if (what == "value") { - Variant value = p_value; if (value.get_type() == Variant::NODE_PATH) { - _fix_node_path(value, base_map[track]); } @@ -943,9 +866,7 @@ public: update_obj = true; } break; case Animation::TYPE_BEZIER: { - if (name == "value") { - const Variant &value = p_value; if (!setting) { @@ -957,7 +878,6 @@ public: undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_value", track, key, prev); update_obj = true; } else if (name == "in_handle") { - const Variant &value = p_value; if (!setting) { @@ -969,7 +889,6 @@ public: undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, key, prev); update_obj = true; } else if (name == "out_handle") { - const Variant &value = p_value; if (!setting) { @@ -983,9 +902,7 @@ public: } } break; case Animation::TYPE_AUDIO: { - if (name == "stream") { - Ref<AudioStream> stream = p_value; if (!setting) { @@ -997,7 +914,6 @@ public: undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_stream", track, key, prev); update_obj = true; } else if (name == "start_offset") { - float value = p_value; if (!setting) { @@ -1009,7 +925,6 @@ public: undo_redo->add_undo_method(animation.ptr(), "audio_track_set_key_start_offset", track, key, prev); update_obj = true; } else if (name == "end_offset") { - float value = p_value; if (!setting) { @@ -1023,9 +938,7 @@ public: } } break; case Animation::TYPE_ANIMATION: { - if (name == "animation") { - StringName anim_name = p_value; if (!setting) { @@ -1043,7 +956,6 @@ public: } if (setting) { - if (update_obj) { undo_redo->add_do_method(this, "_update_obj", animation); undo_redo->add_undo_method(this, "_update_obj", animation); @@ -1062,12 +974,9 @@ public: } bool _get(const StringName &p_name, Variant &r_ret) const { - for (Map<int, List<float>>::Element *E = key_ofs_map.front(); E; E = E->next()) { - int track = E->key(); for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - float key_ofs = F->get(); int key = animation->track_find_key(track, key_ofs, true); ERR_CONTINUE(key == -1); @@ -1079,7 +988,6 @@ public: } if (name == "frame") { - float fps = animation->get_step(); if (fps > 0) { fps = 1.0 / fps; @@ -1094,9 +1002,7 @@ public: } switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { - Dictionary d = animation->track_get_key_value(track, key); ERR_FAIL_COND_V(!d.has(name), false); r_ret = d[p_name]; @@ -1104,7 +1010,6 @@ public: } break; case Animation::TYPE_VALUE: { - if (name == "value") { r_ret = animation->track_get_key_value(track, key); return true; @@ -1112,11 +1017,9 @@ public: } break; case Animation::TYPE_METHOD: { - Dictionary d = animation->track_get_key_value(track, key); if (name == "name") { - ERR_FAIL_COND_V(!d.has("method"), false); r_ret = d["method"]; return true; @@ -1127,13 +1030,11 @@ public: Vector<Variant> args = d["args"]; if (name == "arg_count") { - r_ret = args.size(); return true; } if (name.begins_with("args/")) { - int idx = name.get_slice("/", 1).to_int(); ERR_FAIL_INDEX_V(idx, args.size(), false); @@ -1151,7 +1052,6 @@ public: } break; case Animation::TYPE_BEZIER: { - if (name == "value") { r_ret = animation->bezier_track_get_key_value(track, key); return true; @@ -1169,7 +1069,6 @@ public: } break; case Animation::TYPE_AUDIO: { - if (name == "stream") { r_ret = animation->audio_track_get_key_stream(track, key); return true; @@ -1187,7 +1086,6 @@ public: } break; case Animation::TYPE_ANIMATION: { - if (name == "animation") { r_ret = animation->animation_track_get_key_animation(track, key); return true; @@ -1201,7 +1099,6 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - if (animation.is_null()) return; @@ -1212,7 +1109,6 @@ public: 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()) { - int track = E->key(); ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -1223,14 +1119,12 @@ public: show_time = false; if (same_track_type) { - if (animation->track_get_type(first_track) != animation->track_get_type(track)) { same_track_type = false; same_key_type = false; } for (List<float>::Element *F = E->value().front(); F; F = F->next()) { - int key = animation->track_find_key(track, F->get(), true); ERR_FAIL_COND(key == -1); if (first_key < 0) @@ -1243,7 +1137,6 @@ public: } if (show_time) { - if (use_fps && animation->get_step() > 0) { float max_frame = animation->get_length() / animation->get_step(); p_list->push_back(PropertyInfo(Variant::FLOAT, "frame", PROPERTY_HINT_RANGE, "0," + rtos(max_frame) + ",1")); @@ -1254,27 +1147,22 @@ public: if (same_track_type) { switch (animation->track_get_type(first_track)) { - case Animation::TYPE_TRANSFORM: { - p_list->push_back(PropertyInfo(Variant::VECTOR3, "location")); p_list->push_back(PropertyInfo(Variant::QUAT, "rotation")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "scale")); } break; case Animation::TYPE_VALUE: { - if (!same_key_type) break; Variant v = animation->track_get_key_value(first_track, first_key); if (hint.type != Variant::NIL) { - PropertyInfo pi = hint; pi.name = "value"; p_list->push_back(pi); } else { - PropertyHint hint = PROPERTY_HINT_NONE; String hint_string; @@ -1282,7 +1170,6 @@ public: //could actually check the object property if exists..? yes i will! Ref<Resource> res = v; if (res.is_valid()) { - hint = PROPERTY_HINT_RESOURCE_TYPE; hint_string = res->get_class(); } @@ -1295,7 +1182,6 @@ public: p_list->push_back(PropertyInfo(Variant::FLOAT, "easing", PROPERTY_HINT_EXP_EASING)); } break; case Animation::TYPE_METHOD: { - p_list->push_back(PropertyInfo(Variant::STRING_NAME, "name")); p_list->push_back(PropertyInfo(Variant::INT, "arg_count", PROPERTY_HINT_RANGE, "0,5,1")); @@ -1304,40 +1190,34 @@ public: Vector<Variant> args = d["args"]; String vtypes; for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i > 0) vtypes += ","; vtypes += Variant::get_type_name(Variant::Type(i)); } for (int i = 0; i < args.size(); i++) { - p_list->push_back(PropertyInfo(Variant::INT, "args/" + itos(i) + "/type", PROPERTY_HINT_ENUM, vtypes)); if (args[i].get_type() != Variant::NIL) p_list->push_back(PropertyInfo(args[i].get_type(), "args/" + itos(i) + "/value")); } } break; case Animation::TYPE_BEZIER: { - p_list->push_back(PropertyInfo(Variant::FLOAT, "value")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "in_handle")); p_list->push_back(PropertyInfo(Variant::VECTOR2, "out_handle")); } break; case Animation::TYPE_AUDIO: { - p_list->push_back(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream")); p_list->push_back(PropertyInfo(Variant::FLOAT, "start_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); p_list->push_back(PropertyInfo(Variant::FLOAT, "end_offset", PROPERTY_HINT_RANGE, "0,3600,0.01,or_greater")); } break; case Animation::TYPE_ANIMATION: { - if (key_ofs_map.size() > 1) break; String animations; if (root_path && root_path->has_node(animation->track_get_path(first_track))) { - AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(root_path->get_node(animation->track_get_path(first_track))); if (ap) { List<StringName> anims; @@ -1376,7 +1256,6 @@ public: UndoRedo *undo_redo; void notify_change() { - _change_notify(); } @@ -1397,14 +1276,12 @@ public: }; void AnimationTimelineEdit::_zoom_changed(double) { - update(); play_position->update(); emit_signal("zoom_changed"); } float AnimationTimelineEdit::get_zoom_scale() const { - float zv = zoom->get_max() - zoom->get_value(); if (zv < 1) { zv = 1.0 - zv; @@ -1415,7 +1292,6 @@ float AnimationTimelineEdit::get_zoom_scale() const { } void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { - if (editing) return; @@ -1436,7 +1312,6 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { } void AnimationTimelineEdit::_anim_loop_pressed() { - undo_redo->create_action(TTR("Change Animation Loop")); undo_redo->add_do_method(animation.ptr(), "set_loop", loop->is_pressed()); undo_redo->add_undo_method(animation.ptr(), "set_loop", animation->has_loop()); @@ -1444,7 +1319,6 @@ void AnimationTimelineEdit::_anim_loop_pressed() { } int AnimationTimelineEdit::get_buttons_width() const { - Ref<Texture2D> interp_mode = get_theme_icon("TrackContinuous", "EditorIcons"); Ref<Texture2D> interp_type = get_theme_icon("InterpRaw", "EditorIcons"); Ref<Texture2D> loop_type = get_theme_icon("InterpWrapClamp", "EditorIcons"); @@ -1458,7 +1332,6 @@ int AnimationTimelineEdit::get_buttons_width() const { } int AnimationTimelineEdit::get_name_limit() const { - Ref<Texture2D> hsize_icon = get_theme_icon("Hsize", "EditorIcons"); int limit = MAX(name_limit, add_track->get_minimum_size().width + hsize_icon->get_width()); @@ -1469,7 +1342,6 @@ int AnimationTimelineEdit::get_name_limit() const { } void AnimationTimelineEdit::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { add_track->set_icon(get_theme_icon("Add", "EditorIcons")); loop->set_icon(get_theme_icon("Loop", "EditorIcons")); @@ -1490,7 +1362,6 @@ void AnimationTimelineEdit::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - int key_range = get_size().width - get_buttons_width() - get_name_limit(); if (!animation.is_valid()) @@ -1515,9 +1386,7 @@ void AnimationTimelineEdit::_notification(int p_what) { float time_min = 0; float time_max = animation->get_length(); for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_key_count(i) > 0) { - float beg = animation->track_get_key_time(i, 0); /*if (animation->track_get_type(i) == Animation::TYPE_BEZIER) { beg += animation->bezier_track_get_key_in_handle(i, 0).x; @@ -1548,7 +1417,6 @@ void AnimationTimelineEdit::_notification(int p_what) { hscroll->show(); } else { - hscroll->hide(); } } @@ -1564,11 +1432,9 @@ void AnimationTimelineEdit::_notification(int p_what) { linecolor.a = 0.2; { - draw_rect(Rect2(Point2(get_name_limit(), 0), Point2(zoomw - 1, h)), notimecol); if (begin_px < zoomw && end_px > 0) { - if (begin_px < 0) begin_px = 0; if (end_px > zoomw) @@ -1598,14 +1464,12 @@ void AnimationTimelineEdit::_notification(int p_what) { const int max_sc_width = String::num(max_sc).length() * max_digit_width; while (!step_found) { - min = max_sc_width; if (decimals > 0) min += period_width + max_digit_width * decimals; static const int _multp[3] = { 1, 2, 5 }; for (int i = 0; i < 3; i++) { - step = (_multp[i] * dec); if (step * scale / SC_ADJ > min) { step_found = true; @@ -1621,14 +1485,11 @@ void AnimationTimelineEdit::_notification(int p_what) { } if (use_fps) { - float step_size = animation->get_step(); if (step_size > 0) { - int prev_frame_ofs = -10000000; for (int i = 0; i < zoomw; i++) { - float pos = get_value() + double(i) / scale; float prev = get_value() + (double(i) - 1.0) / scale; @@ -1638,7 +1499,6 @@ void AnimationTimelineEdit::_notification(int p_what) { bool sub = Math::floor(prev) == Math::floor(pos); if (frame != prev_frame && i >= prev_frame_ofs) { - draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE)); draw_string(font, Point2(get_name_limit() + i + 3 * EDSCALE, (h - font->get_height()) / 2 + font->get_ascent()).floor(), itos(frame), sub ? color_time_dec : color_time_sec, zoomw - i); @@ -1649,7 +1509,6 @@ void AnimationTimelineEdit::_notification(int p_what) { } else { for (int i = 0; i < zoomw; i++) { - float pos = get_value() + double(i) / scale; float prev = get_value() + (double(i) - 1.0) / scale; @@ -1658,7 +1517,6 @@ void AnimationTimelineEdit::_notification(int p_what) { bool sub = (sc % SC_ADJ); if ((sc / step) != (prev_sc / step) || (prev_sc < 0 && sc >= 0)) { - int scd = sc < 0 ? prev_sc : sc; draw_line(Point2(get_name_limit() + i, 0), Point2(get_name_limit() + i, h), linecolor, Math::round(EDSCALE)); draw_string(font, Point2(get_name_limit() + i + 3, (h - font->get_height()) / 2 + font->get_ascent()).floor(), String::num((scd - (scd % step)) / double(SC_ADJ), decimals), sub ? color_time_dec : color_time_sec, zoomw - i); @@ -1686,7 +1544,6 @@ void AnimationTimelineEdit::set_animation(const Ref<Animation> &p_animation) { } Size2 AnimationTimelineEdit::get_minimum_size() const { - Size2 ms = add_track->get_minimum_size(); Ref<Font> font = get_theme_font("font", "Label"); ms.height = MAX(ms.height, font->get_height()); @@ -1704,7 +1561,6 @@ void AnimationTimelineEdit::set_zoom(Range *p_zoom) { } void AnimationTimelineEdit::set_play_position(float p_pos) { - play_position_pos = p_pos; play_position->update(); } @@ -1718,7 +1574,6 @@ void AnimationTimelineEdit::update_play_position() { } void AnimationTimelineEdit::update_values() { - if (!animation.is_valid() || editing) return; @@ -1739,7 +1594,6 @@ void AnimationTimelineEdit::update_values() { } void AnimationTimelineEdit::_play_position_draw() { - if (!animation.is_valid() || play_position_pos < 0) return; @@ -1759,11 +1613,9 @@ void AnimationTimelineEdit::_play_position_draw() { } void AnimationTimelineEdit::_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 && hsize_rect.has_point(mb->get_position())) { - dragging_hsize = true; dragging_hsize_from = mb->get_position().x; dragging_hsize_at = name_limit; @@ -1773,7 +1625,6 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { dragging_hsize = false; } if (mb.is_valid() && mb->get_position().x > get_name_limit() && mb->get_position().x < (get_size().width - get_buttons_width())) { - if (!panning_timeline && mb->get_button_index() == BUTTON_LEFT) { int x = mb->get_position().x - get_name_limit(); @@ -1800,7 +1651,6 @@ void AnimationTimelineEdit::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (hsize_rect.has_point(mm->get_position())) { // Change the cursor to indicate that the track name column's width can be adjusted set_default_cursor_shape(Control::CURSOR_HSIZE); @@ -1839,7 +1689,6 @@ bool AnimationTimelineEdit::is_using_fps() const { } void AnimationTimelineEdit::set_hscroll(HScrollBar *p_hscroll) { - hscroll = p_hscroll; } @@ -1858,7 +1707,6 @@ void AnimationTimelineEdit::_bind_methods() { } AnimationTimelineEdit::AnimationTimelineEdit() { - use_fps = false; editing = false; name_limit = 150 * EDSCALE; @@ -1914,9 +1762,7 @@ AnimationTimelineEdit::AnimationTimelineEdit() { //////////////////////////////////// void AnimationTrackEdit::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - if (animation.is_null()) return; ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -1947,7 +1793,6 @@ void AnimationTrackEdit::_notification(int p_what) { // NAMES AND ICONS // { - 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.. @@ -1973,7 +1818,6 @@ void AnimationTrackEdit::_notification(int p_what) { } if (in_group) { - if (animation->track_get_type(track) == Animation::TYPE_METHOD) { text = TTR("Functions:"); } else if (animation->track_get_type(track) == Animation::TYPE_AUDIO) { @@ -2020,14 +1864,12 @@ void AnimationTrackEdit::_notification(int p_what) { int limit_end = get_size().width - timeline->get_buttons_width(); for (int i = 0; i < animation->track_get_key_count(track); i++) { - float offset = animation->track_get_key_time(track, i) - timeline->get_value(); if (editor->is_key_selected(track, i) && editor->is_moving_selection()) { offset = editor->snap_time(offset + editor->get_moving_selection_offset(), true); } offset = offset * scale + limit; if (i < animation->track_get_key_count(track) - 1) { - float offset_n = animation->track_get_key_time(track, i + 1) - timeline->get_value(); if (editor->is_key_selected(track, i + 1) && editor->is_moving_selection()) { offset_n = editor->snap_time(offset_n + editor->get_moving_selection_offset()); @@ -2046,7 +1888,6 @@ void AnimationTrackEdit::_notification(int p_what) { // BUTTONS // { - Ref<Texture2D> wrap_icon[2] = { get_theme_icon("InterpWrapClamp", "EditorIcons"), get_theme_icon("InterpWrapLoop", "EditorIcons"), @@ -2226,7 +2067,6 @@ int AnimationTrackEdit::get_key_height() const { return type_icon->get_height(); } Rect2 AnimationTrackEdit::get_key_rect(int p_index, float p_pixels_sec) { - if (!animation.is_valid()) return Rect2(); Rect2 rect = Rect2(-type_icon->get_width() / 2, 0, type_icon->get_width(), get_size().height); @@ -2262,7 +2102,6 @@ void AnimationTrackEdit::draw_key_link(int p_index, float p_pixels_sec, int p_x, } void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - if (!animation.is_valid()) return; @@ -2297,7 +2136,6 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (d.has("args")) args = d["args"]; for (int i = 0; i < args.size(); i++) { - if (i > 0) text += ", "; text += String(args[i]); @@ -2315,7 +2153,6 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool //helper void AnimationTrackEdit::draw_rect_clipped(const Rect2 &p_rect, const Color &p_color, bool p_filled) { - int clip_left = timeline->get_name_limit(); int clip_right = get_size().width - timeline->get_buttons_width(); @@ -2334,12 +2171,10 @@ void AnimationTrackEdit::draw_fg(int p_clip_left, int p_clip_right) { } void AnimationTrackEdit::draw_texture_clipped(const Ref<Texture2D> &p_texture, const Vector2 &p_pos) { - draw_texture_region_clipped(p_texture, Rect2(p_pos, p_texture->get_size()), Rect2(Point2(), p_texture->get_size())); } void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_region) { - int clip_left = timeline->get_name_limit(); int clip_right = get_size().width - timeline->get_buttons_width(); @@ -2364,7 +2199,6 @@ void AnimationTrackEdit::draw_texture_region_clipped(const Ref<Texture2D> &p_tex } if (clip_right < rect.position.x + rect.size.x) { - int rect_pixels = rect.position.x + rect.size.x - clip_right; int region_pixels = rect_pixels * region.size.x / rect.size.x; @@ -2384,7 +2218,6 @@ Ref<Animation> AnimationTrackEdit::get_animation() const { } void AnimationTrackEdit::set_animation_and_track(const Ref<Animation> &p_animation, int p_track) { - animation = p_animation; track = p_track; update(); @@ -2410,7 +2243,6 @@ NodePath AnimationTrackEdit::get_path() const { } Size2 AnimationTrackEdit::get_minimum_size() const { - Ref<Texture2D> texture = get_theme_icon("Object", "EditorIcons"); Ref<Font> font = get_theme_font("font", "Label"); int separation = get_theme_constant("vseparation", "ItemList"); @@ -2435,7 +2267,6 @@ void AnimationTrackEdit::set_editor(AnimationTrackEditor *p_editor) { } void AnimationTrackEdit::_play_position_draw() { - if (!animation.is_valid() || play_position_pos < 0) return; @@ -2451,7 +2282,6 @@ void AnimationTrackEdit::_play_position_draw() { } void AnimationTrackEdit::set_play_position(float p_pos) { - play_position_pos = p_pos; play_position->update(); } @@ -2478,7 +2308,6 @@ void AnimationTrackEdit::_path_entered(const String &p_text) { } bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const { - if (root == nullptr) return false; @@ -2502,7 +2331,6 @@ bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant } String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { - if (check_rect.has_point(p_pos)) { return TTR("Toggle this track on/off."); } @@ -2534,20 +2362,17 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { int limit_start_hitbox = limit - type_icon->get_width(); if (p_pos.x >= limit_start_hitbox && p_pos.x <= limit_end) { - int key_idx = -1; float key_distance = 1e20; // Select should happen in the opposite order of drawing for more accurate overlap select. for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) { - Rect2 rect = const_cast<AnimationTrackEdit *>(this)->get_key_rect(i, timeline->get_zoom_scale()); float offset = animation->track_get_key_time(track, i) - timeline->get_value(); offset = offset * timeline->get_zoom_scale() + limit; rect.position.x += offset; if (rect.has_point(p_pos)) { - if (const_cast<AnimationTrackEdit *>(this)->is_key_selectable_by_distance()) { float distance = ABS(offset - p_pos.x); if (key_idx == -1 || distance < key_distance) { @@ -2562,12 +2387,9 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } if (key_idx != -1) { - String text = TTR("Time (s): ") + rtos(animation->track_get_key_time(track, key_idx)) + "\n"; switch (animation->track_get_type(track)) { - case Animation::TYPE_TRANSFORM: { - Dictionary d = animation->track_get_key_value(track, key_idx); if (d.has("location")) text += "Pos: " + String(d["location"]) + "\n"; @@ -2577,7 +2399,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { text += "Scale: " + String(d["scale"]) + "\n"; } break; case Animation::TYPE_VALUE: { - const Variant &v = animation->track_get_key_value(track, key_idx); text += "Type: " + Variant::get_type_name(v.get_type()) + "\n"; Variant::Type valid_type = Variant::NIL; @@ -2590,7 +2411,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } break; case Animation::TYPE_METHOD: { - Dictionary d = animation->track_get_key_value(track, key_idx); if (d.has("method")) text += String(d["method"]); @@ -2599,7 +2419,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (d.has("args")) args = d["args"]; for (int i = 0; i < args.size(); i++) { - if (i > 0) text += ", "; text += String(args[i]); @@ -2608,7 +2427,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } break; case Animation::TYPE_BEZIER: { - float h = animation->bezier_track_get_key_value(track, key_idx); text += "Value: " + rtos(h) + "\n"; Vector2 ih = animation->bezier_track_get_key_in_handle(track, key_idx); @@ -2617,7 +2435,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { text += "Out-Handle: " + oh + "\n"; } break; case Animation::TYPE_AUDIO: { - String stream_name = "null"; RES stream = animation->audio_track_get_key_stream(track, key_idx); if (stream.is_valid()) { @@ -2637,7 +2454,6 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { text += "End (s): " + rtos(eo) + "\n"; } break; case Animation::TYPE_ANIMATION: { - String name = animation->animation_track_get_key_animation(track, key_idx); text += "Animation Clip: " + name + "\n"; } break; @@ -2760,20 +2576,17 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { int limit_start_hitbox = limit - type_icon->get_width(); if (pos.x >= limit_start_hitbox && pos.x <= limit_end) { - int key_idx = -1; float key_distance = 1e20; // Select should happen in the opposite order of drawing for more accurate overlap select. for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) { - Rect2 rect = get_key_rect(i, scale); float offset = animation->track_get_key_time(track, i) - timeline->get_value(); offset = offset * scale + limit; rect.position.x += offset; if (rect.has_point(pos)) { - if (is_key_selectable_by_distance()) { float distance = ABS(offset - pos.x); if (key_idx == -1 || distance < key_distance) { @@ -2845,7 +2658,6 @@ 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); @@ -2867,7 +2679,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && moving_selection_attempt) { - if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { moving_selection_attempt = false; if (moving_selection) { @@ -2880,7 +2691,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } if (moving_selection && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { - moving_selection_attempt = false; moving_selection = false; emit_signal("move_selection_cancel"); @@ -2889,7 +2699,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT && moving_selection_attempt) { - if (!moving_selection) { moving_selection = true; emit_signal("move_selection_begin"); @@ -2901,7 +2710,6 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { } Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) { - if (!clicking_on_name) return Variant(); @@ -2923,7 +2731,6 @@ Variant AnimationTrackEdit::get_drag_data(const Point2 &p_point) { } bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - Dictionary d = p_data; if (!d.has("type")) { return false; @@ -2955,7 +2762,6 @@ bool AnimationTrackEdit::can_drop_data(const Point2 &p_point, const Variant &p_d return true; } void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) { - Dictionary d = p_data; if (!d.has("type")) { return; @@ -2985,13 +2791,11 @@ void AnimationTrackEdit::drop_data(const Point2 &p_point, const Variant &p_data) } void AnimationTrackEdit::_menu_selected(int p_index) { - switch (p_index) { case MENU_CALL_MODE_CONTINUOUS: case MENU_CALL_MODE_DISCRETE: case MENU_CALL_MODE_TRIGGER: case MENU_CALL_MODE_CAPTURE: { - Animation::UpdateMode update_mode = Animation::UpdateMode(p_index); undo_redo->create_action(TTR("Change Animation Update Mode")); undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode); @@ -3003,7 +2807,6 @@ void AnimationTrackEdit::_menu_selected(int p_index) { case MENU_INTERPOLATION_NEAREST: case MENU_INTERPOLATION_LINEAR: case MENU_INTERPOLATION_CUBIC: { - Animation::InterpolationType interp_mode = Animation::InterpolationType(p_index - MENU_INTERPOLATION_NEAREST); undo_redo->create_action(TTR("Change Animation Interpolation Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode); @@ -3013,7 +2816,6 @@ void AnimationTrackEdit::_menu_selected(int p_index) { } break; case MENU_LOOP_WRAP: case MENU_LOOP_CLAMP: { - bool loop_wrap = p_index == MENU_LOOP_WRAP; undo_redo->create_action(TTR("Change Animation Loop Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap); @@ -3055,7 +2857,6 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect // Select should happen in the opposite order of drawing for more accurate overlap select. for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) { - Rect2 rect = const_cast<AnimationTrackEdit *>(this)->get_key_rect(i, timeline->get_zoom_scale()); float offset = animation->track_get_key_time(track, i) - timeline->get_value(); offset = offset * timeline->get_zoom_scale() + timeline->get_name_limit(); @@ -3071,7 +2872,6 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect } void AnimationTrackEdit::_bind_methods() { - ClassDB::bind_method("_gui_input", &AnimationTrackEdit::_gui_input); ADD_SIGNAL(MethodInfo("timeline_changed", PropertyInfo(Variant::FLOAT, "position"), PropertyInfo(Variant::BOOL, "drag"))); @@ -3147,7 +2947,6 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_value_track_edit(Object *p_ } 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 *()); } @@ -3164,7 +2963,6 @@ AnimationTrackEdit *AnimationTrackEditPlugin::create_animation_track_edit(Object /////////////////////////////////////// void AnimationTrackEditGroup::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { Ref<Font> font = get_theme_font("font", "Label"); int separation = get_theme_constant("hseparation", "ItemList"); @@ -3210,7 +3008,6 @@ void AnimationTrackEditGroup::set_type_and_name(const Ref<Texture2D> &p_type, co } Size2 AnimationTrackEditGroup::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); int separation = get_theme_constant("vseparation", "ItemList"); @@ -3242,19 +3039,16 @@ AnimationTrackEditGroup::AnimationTrackEditGroup() { ////////////////////////////////////// void AnimationTrackEditor::add_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin) { - if (track_edit_plugins.find(p_plugin) != -1) return; track_edit_plugins.push_back(p_plugin); } void AnimationTrackEditor::remove_track_edit_plugin(const Ref<AnimationTrackEditPlugin> &p_plugin) { - track_edit_plugins.erase(p_plugin); } void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { - if (animation != p_anim && _get_track_selected() >= 0) { track_edits[_get_track_selected()]->release_focus(); } @@ -3302,7 +3096,6 @@ void AnimationTrackEditor::set_animation(const Ref<Animation> &p_anim) { } Ref<Animation> AnimationTrackEditor::get_current_animation() const { - return animation; } @@ -3325,7 +3118,6 @@ void AnimationTrackEditor::set_root(Node *p_root) { } Node *AnimationTrackEditor::get_root() const { - return root; } @@ -3386,22 +3178,18 @@ void AnimationTrackEditor::cleanup() { } void AnimationTrackEditor::_name_limit_changed() { - for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->update(); } } void AnimationTrackEditor::_timeline_changed(float p_new_pos, bool p_drag) { - emit_signal("timeline_changed", p_new_pos, p_drag); } void AnimationTrackEditor::_track_remove_request(int p_track) { - int idx = p_track; if (idx >= 0 && idx < animation->get_track_count()) { - undo_redo->create_action(TTR("Remove Anim Track")); undo_redo->add_do_method(this, "_clear_selection", false); undo_redo->add_do_method(animation.ptr(), "remove_track", idx); @@ -3410,7 +3198,6 @@ void AnimationTrackEditor::_track_remove_request(int p_track) { // TODO interpolation. for (int i = 0; i < animation->track_get_key_count(idx); i++) { - Variant v = animation->track_get_key_value(idx, i); float time = animation->track_get_key_time(idx, i); float trans = animation->track_get_key_transition(idx, i); @@ -3429,14 +3216,12 @@ void AnimationTrackEditor::_track_remove_request(int p_track) { } void AnimationTrackEditor::_track_grab_focus(int p_track) { - // Don't steal focus if not working with the track editor. if (Object::cast_to<AnimationTrackEdit>(get_focus_owner())) track_edits[p_track]->grab_focus(); } void AnimationTrackEditor::set_anim_pos(float p_pos) { - timeline->set_play_position(p_pos); for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->set_play_position(p_pos); @@ -3448,7 +3233,6 @@ void AnimationTrackEditor::set_anim_pos(float p_pos) { } 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()) @@ -3520,7 +3304,6 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } void AnimationTrackEditor::_insert_delay() { - if (insert_query) { //discard since it's entered into query mode insert_queue = false; @@ -3532,7 +3315,6 @@ void AnimationTrackEditor::_insert_delay() { int last_track = animation->get_track_count(); bool advance = false; while (insert_data.size()) { - if (insert_data.front()->get().advance) advance = true; last_track = _confirm_insert(insert_data.front()->get(), last_track); @@ -3558,7 +3340,6 @@ void AnimationTrackEditor::_insert_delay() { } void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) { - if (!keying) return; if (!animation.is_valid()) @@ -3575,7 +3356,6 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ int track_idx = -1; for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_type(i) != Animation::TYPE_TRANSFORM) continue; if (animation->track_get_path(i) != np) @@ -3601,12 +3381,10 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_ } void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant &p_value) { - String path = p_path; //animation property is a special case, always creates an animation track for (int i = 0; i < animation->get_track_count(); i++) { - String np = animation->track_get_path(i); if (path == np && animation->track_get_type(i) == Animation::TYPE_ANIMATION) { @@ -3636,7 +3414,6 @@ void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant } void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists) { - ERR_FAIL_COND(!root); //let's build a node path @@ -3655,7 +3432,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); for (int i = 1; i < history->get_path_size(); i++) { - String prop = history->get_path_property(i); ERR_FAIL_COND(prop == ""); path += ":" + prop; @@ -3670,7 +3446,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p bool inserted = false; for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_type(i) == Animation::TYPE_VALUE) { if (animation->track_get_path(i) != np) continue; @@ -3686,7 +3461,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p _query_insert(id); inserted = true; } else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) { - Variant value; String track_path = animation->track_get_path(i); if (track_path == np) { @@ -3731,7 +3505,6 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p } void AnimationTrackEditor::insert_value_key(const String &p_property, const Variant &p_value, bool p_advance) { - EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); ERR_FAIL_COND(!root); @@ -3754,7 +3527,6 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari } for (int i = 1; i < history->get_path_size(); i++) { - String prop = history->get_path_property(i); ERR_FAIL_COND(prop == ""); path += ":" + prop; @@ -3769,7 +3541,6 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari bool inserted = false; for (int i = 0; i < animation->get_track_count(); i++) { - if (animation->track_get_type(i) == Animation::TYPE_VALUE) { if (animation->track_get_path(i) != np) continue; @@ -3785,7 +3556,6 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari _query_insert(id); inserted = true; } else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) { - Variant value; if (animation->track_get_path(i) == np) { value = p_value; //all good @@ -3827,12 +3597,10 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari } void AnimationTrackEditor::_confirm_insert_list() { - undo_redo->create_action(TTR("Anim Create & Insert")); int last_track = animation->get_track_count(); while (insert_data.size()) { - last_track = _confirm_insert(insert_data.front()->get(), last_track, insert_confirm_bezier->is_pressed()); insert_data.pop_front(); } @@ -3841,7 +3609,6 @@ void AnimationTrackEditor::_confirm_insert_list() { } PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_base_path, Variant *r_current_val) { - r_base_path = NodePath(); ERR_FAIL_COND_V(!animation.is_valid(), PropertyInfo()); ERR_FAIL_INDEX_V(p_idx, animation->get_track_count(), PropertyInfo()); @@ -3896,7 +3663,6 @@ PropertyInfo AnimationTrackEditor::_find_hint_for_track(int p_idx, NodePath &r_b property_info_base.get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (E->get().name == leftover_path[leftover_path.size() - 1]) { return E->get(); } @@ -3955,13 +3721,11 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool } int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, bool p_create_beziers) { - if (p_last_track == -1) p_last_track = animation->get_track_count(); bool created = false; if (p_id.track_idx < 0) { - if (p_create_beziers) { bool valid; Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type(), &valid); @@ -4002,7 +3766,6 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo h.type == Variant::PLANE || h.type == Variant::TRANSFORM2D || h.type == Variant::TRANSFORM) { - update_mode = Animation::UPDATE_CONTINUOUS; } @@ -4027,14 +3790,11 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo Variant value; switch (p_id.type) { - case Animation::TYPE_VALUE: { - value = p_id.value; } break; case Animation::TYPE_TRANSFORM: { - Transform tr = p_id.value; Dictionary d; d["location"] = tr.origin; @@ -4063,13 +3823,11 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_id.track_idx, time, value); if (created) { - // Just remove the track. undo_redo->add_undo_method(this, "_clear_selection", false); undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); p_last_track++; } else { - undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_id.track_idx, time); int existing = animation->track_find_key(p_id.track_idx, time, true); if (existing != -1) { @@ -4085,12 +3843,10 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo } void AnimationTrackEditor::show_select_node_warning(bool p_show) { - info_message->set_visible(p_show); } bool AnimationTrackEditor::is_key_selected(int p_track, int p_key) const { - SelectedKey sk; sk.key = p_key; sk.track = p_track; @@ -4107,7 +3863,6 @@ bool AnimationTrackEditor::is_snap_enabled() const { } void AnimationTrackEditor::_update_tracks() { - int selected = _get_track_selected(); while (track_vbox->get_child_count()) { @@ -4145,7 +3900,6 @@ void AnimationTrackEditor::_update_tracks() { } if (animation->track_get_type(i) == Animation::TYPE_VALUE) { - NodePath path = animation->track_get_path(i); if (root && root->has_node_and_resource(path)) { @@ -4175,7 +3929,6 @@ void AnimationTrackEditor::_update_tracks() { } } if (animation->track_get_type(i) == Animation::TYPE_AUDIO) { - for (int j = 0; j < track_edit_plugins.size(); j++) { track_edit = track_edit_plugins.write[j]->create_audio_track_edit(); if (track_edit) { @@ -4277,7 +4030,6 @@ void AnimationTrackEditor::_update_tracks() { } void AnimationTrackEditor::_animation_changed() { - if (animation_changing_awaiting_update) { return; //all will be updated, don't bother with anything } @@ -4298,7 +4050,6 @@ void AnimationTrackEditor::_animation_changed() { } void AnimationTrackEditor::_snap_mode_changed(int p_mode) { - timeline->set_use_fps(p_mode == 1); if (key_edit) { key_edit->set_use_fps(p_mode == 1); @@ -4326,7 +4077,6 @@ void AnimationTrackEditor::_update_step_spinbox() { step->set_block_signals(false); } void AnimationTrackEditor::_animation_update() { - timeline->update(); timeline->update_values(); @@ -4405,7 +4155,6 @@ void AnimationTrackEditor::_update_scroll(double) { } void AnimationTrackEditor::_update_step(double p_new_step) { - undo_redo->create_action(TTR("Change Animation Step")); float step_value = p_new_step; if (timeline->is_using_fps()) { @@ -4422,7 +4171,6 @@ void AnimationTrackEditor::_update_step(double p_new_step) { } void AnimationTrackEditor::_update_length(double p_new_len) { - emit_signal("animation_len_changed", p_new_len); } @@ -4443,7 +4191,6 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { } void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { - ERR_FAIL_COND(!root); Node *node = get_node(p_path); ERR_FAIL_COND(!node); @@ -4462,7 +4209,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { } break; case Animation::TYPE_TRANSFORM: case Animation::TYPE_METHOD: { - undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); @@ -4471,7 +4217,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { } break; case Animation::TYPE_BEZIER: { - Vector<Variant::Type> filter; filter.push_back(Variant::INT); filter.push_back(Variant::FLOAT); @@ -4486,7 +4231,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { prop_selector->select_property_from_instance(node); } break; case Animation::TYPE_AUDIO: { - if (!node->is_class("AudioStreamPlayer") && !node->is_class("AudioStreamPlayer2D") && !node->is_class("AudioStreamPlayer3D")) { EditorNode::get_singleton()->show_warning(TTR("Audio tracks can only point to nodes of type:\n-AudioStreamPlayer\n-AudioStreamPlayer2D\n-AudioStreamPlayer3D")); return; @@ -4500,7 +4244,6 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { } break; case Animation::TYPE_ANIMATION: { - if (!node->is_class("AnimationPlayer")) { EditorNode::get_singleton()->show_warning(TTR("Animation tracks can only point to AnimationPlayer nodes.")); return; @@ -4531,11 +4274,9 @@ void AnimationTrackEditor::_add_track(int p_type) { } void AnimationTrackEditor::_new_track_property_selected(String p_name) { - String full_path = String(adding_track_path) + ":" + p_name; if (adding_track_type == Animation::TYPE_VALUE) { - Animation::UpdateMode update_mode = Animation::UPDATE_DISCRETE; { //hack @@ -4554,7 +4295,6 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { h.type == Variant::PLANE || h.type == Variant::TRANSFORM2D || h.type == Variant::TRANSFORM) { - update_mode = Animation::UPDATE_CONTINUOUS; } @@ -4598,7 +4338,6 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { } void AnimationTrackEditor::_timeline_value_changed(double) { - timeline->update_play_position(); for (int i = 0; i < track_edits.size(); i++) { @@ -4615,7 +4354,6 @@ void AnimationTrackEditor::_timeline_value_changed(double) { } int AnimationTrackEditor::_get_track_selected() { - for (int i = 0; i < track_edits.size(); i++) { if (track_edits[i]->has_focus()) return i; @@ -4625,7 +4363,6 @@ int AnimationTrackEditor::_get_track_selected() { } void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { - ERR_FAIL_INDEX(p_track, animation->get_track_count()); if (snap->is_pressed() && step->get_value() != 0) { @@ -4661,7 +4398,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { } break; case Animation::TYPE_VALUE: { - NodePath bp; Variant value; _find_hint_for_track(p_track, bp, &value); @@ -4687,7 +4423,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { } break; case Animation::TYPE_BEZIER: { - NodePath bp; Variant value; _find_hint_for_track(p_track, bp, &value); @@ -4706,7 +4441,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { } break; case Animation::TYPE_AUDIO: { - Dictionary ak; ak["stream"] = RES(); ak["start_offset"] = 0; @@ -4718,7 +4452,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { undo_redo->commit_action(); } break; case Animation::TYPE_ANIMATION: { - StringName anim = "[stop]"; undo_redo->create_action(TTR("Add Track Key")); @@ -4730,7 +4463,6 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { } void AnimationTrackEditor::_add_method_key(const String &p_method) { - if (!root->has_node(animation->track_get_path(insert_key_from_track_call_track))) { EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a method key.")); return; @@ -4742,14 +4474,12 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { if (E->get().name == p_method) { - Dictionary d; d["method"] = p_method; Array params; int first_defarg = E->get().arguments.size() - E->get().default_arguments.size(); for (int i = 0; i < E->get().arguments.size(); i++) { - if (i >= first_defarg) { Variant arg = E->get().default_arguments[i - first_defarg]; params.push_back(arg); @@ -4774,7 +4504,6 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { } void AnimationTrackEditor::_key_selected(int p_key, bool p_single, int p_track) { - ERR_FAIL_INDEX(p_track, animation->get_track_count()); ERR_FAIL_INDEX(p_key, animation->track_get_key_count(p_track)); @@ -4798,7 +4527,6 @@ void AnimationTrackEditor::_key_selected(int p_key, bool p_single, int p_track) } void AnimationTrackEditor::_key_deselected(int p_key, int p_track) { - ERR_FAIL_INDEX(p_track, animation->get_track_count()); ERR_FAIL_INDEX(p_key, animation->track_get_key_count(p_track)); @@ -4829,7 +4557,6 @@ void AnimationTrackEditor::_move_selection(float p_offset) { } struct _AnimMoveRestore { - int track; float time; Variant key; @@ -4860,7 +4587,6 @@ void AnimationTrackEditor::_clear_key_edit() { } void AnimationTrackEditor::_clear_selection(bool p_update) { - selection.clear(); if (p_update) { @@ -4873,13 +4599,11 @@ void AnimationTrackEditor::_clear_selection(bool p_update) { } void AnimationTrackEditor::_update_key_edit() { - _clear_key_edit(); if (!animation.is_valid()) return; if (selection.size() == 1) { - key_edit = memnew(AnimationTrackKeyEdit); key_edit->animation = animation; key_edit->track = selection.front()->key().track; @@ -4896,7 +4620,6 @@ void AnimationTrackEditor::_update_key_edit() { EditorNode::get_singleton()->push_item(key_edit); } else if (selection.size() > 1) { - multi_key_edit = memnew(AnimationMultiTrackKeyEdit); multi_key_edit->animation = animation; @@ -4904,7 +4627,6 @@ void AnimationTrackEditor::_update_key_edit() { Map<int, NodePath> base_map; int first_track = -1; for (Map<SelectedKey, KeyInfo>::Element *E = selection.front(); E; E = E->next()) { - int track = E->key().track; if (first_track < 0) first_track = track; @@ -4931,7 +4653,6 @@ void AnimationTrackEditor::_update_key_edit() { } void AnimationTrackEditor::_clear_selection_for_anim(const Ref<Animation> &p_anim) { - if (animation != p_anim) return; @@ -4939,7 +4660,6 @@ void AnimationTrackEditor::_clear_selection_for_anim(const Ref<Animation> &p_ani } void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos) { - if (animation != p_anim) return; @@ -4956,7 +4676,6 @@ void AnimationTrackEditor::_select_at_anim(const Ref<Animation> &p_anim, int p_t } void AnimationTrackEditor::_move_selection_commit() { - undo_redo->create_action(TTR("Anim Move Keys")); List<_AnimMoveRestore> to_restore; @@ -4964,12 +4683,10 @@ void AnimationTrackEditor::_move_selection_commit() { float motion = moving_selection_offset; // 1 - remove the keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); } // 2 - remove overlapped keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newtime = snap_time(E->get().pos + motion); int idx = animation->track_find_key(E->key().track, newtime, true); if (idx == -1) @@ -4993,27 +4710,23 @@ void AnimationTrackEditor::_move_selection_commit() { // 3 - move the keys (re insert them) for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = snap_time(E->get().pos + motion); undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 4 - (undo) remove inserted keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = snap_time(E->get().pos + motion); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos); } // 5 - (undo) reinsert keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 6 - (undo) reinsert overlapped keys for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5023,7 +4736,6 @@ void AnimationTrackEditor::_move_selection_commit() { // 7 - reselect for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = E->get().pos; float newpos = snap_time(oldpos + motion); @@ -5041,7 +4753,6 @@ void AnimationTrackEditor::_move_selection_commit() { _update_key_edit(); } void AnimationTrackEditor::_move_selection_cancel() { - moving_selection = false; for (int i = 0; i < track_edits.size(); i++) { track_edits[i]->update(); @@ -5056,24 +4767,20 @@ float AnimationTrackEditor::get_moving_selection_offset() const { } void AnimationTrackEditor::_box_selection_draw() { - const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size()); box_selection->draw_rect(selection_rect, get_theme_color("box_selection_fill_color", "Editor")); box_selection->draw_rect(selection_rect, get_theme_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE)); } void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_DOWN) { - timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() * 1.05); scroll->accept_event(); } if (mb.is_valid() && mb->is_pressed() && mb->get_command() && mb->get_button_index() == BUTTON_WHEEL_UP) { - timeline->get_zoom()->set_value(timeline->get_zoom()->get_value() / 1.05); scroll->accept_event(); } @@ -5084,11 +4791,9 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { box_selecting_from = scroll->get_global_transform().xform(mb->get_position()); box_select_rect = Rect2(); } else if (box_selecting) { - if (box_selection->is_visible_in_tree()) { //only if moved for (int i = 0; i < track_edits.size(); i++) { - Rect2 local_rect = box_select_rect; local_rect.position -= track_edits[i]->get_global_position(); track_edits[i]->append_to_selection(local_rect, mb->get_command()); @@ -5109,12 +4814,10 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) { - timeline->set_value(timeline->get_value() - mm->get_relative().x / timeline->get_zoom_scale()); } if (mm.is_valid() && box_selecting) { - if (!(mm->get_button_mask() & BUTTON_MASK_LEFT)) { //no longer box_selection->hide(); @@ -5161,7 +4864,6 @@ void AnimationTrackEditor::_cancel_bezier_edit() { } void AnimationTrackEditor::_bezier_edit(int p_for_track) { - _clear_selection(); //bezier probably wants to use a separate selection mode bezier_edit->set_root(root); bezier_edit->set_animation_and_track(animation, p_for_track); @@ -5173,11 +4875,9 @@ void AnimationTrackEditor::_bezier_edit(int p_for_track) { void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { //duplicait! if (selection.size() && animation.is_valid() && (!transpose || (_get_track_selected() >= 0 && _get_track_selected() < animation->get_track_count()))) { - int top_track = 0x7FFFFFFF; float top_time = 1e10; for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - const SelectedKey &sk = E->key(); float t = animation->track_get_key_time(sk.track, sk.key); @@ -5197,7 +4897,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { List<Pair<int, float>> new_selection_values; for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - const SelectedKey &sk = E->key(); float t = animation->track_get_key_time(sk.track, sk.key); @@ -5222,7 +4921,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { new_selection_values.push_back(p); if (existing_idx != -1) { - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", dst_track, dst_time, animation->track_get_key_value(dst_track, existing_idx), animation->track_get_key_transition(dst_track, existing_idx)); } } @@ -5233,7 +4931,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { Map<SelectedKey, KeyInfo> new_selection; for (List<Pair<int, float>>::Element *E = new_selection_values.front(); E; E = E->next()) { - int track = E->get().first; float time = E->get().second; @@ -5257,7 +4954,6 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { } } void AnimationTrackEditor::_edit_menu_pressed(int p_option) { - last_menu_track_opt = p_option; switch (p_option) { case EDIT_COPY_TRACKS: { @@ -5265,7 +4961,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { TreeItem *troot = track_copy_select->create_item(); for (int i = 0; i < animation->get_track_count(); i++) { - NodePath path = animation->track_get_path(i); Node *node = nullptr; @@ -5328,11 +5023,9 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { track_copy_dialog->popup_centered(Size2(350, 500) * EDSCALE); } break; case EDIT_COPY_TRACKS_CONFIRM: { - track_clipboard.clear(); TreeItem *root = track_copy_select->get_root(); if (root) { - TreeItem *it = root->get_children(); while (it) { Dictionary md = it->get_metadata(0); @@ -5362,7 +5055,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } break; case EDIT_PASTE_TRACKS: { - if (track_clipboard.size() == 0) { EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty")); break; @@ -5429,7 +5121,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { pivot = timeline->get_play_position(); } else { - pivot = from_t; } @@ -5444,12 +5135,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { // 1-remove the keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); } // 2- remove overlapped keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newtime = (E->get().pos - from_t) * s + from_t; int idx = animation->track_find_key(E->key().track, newtime, true); if (idx == -1) @@ -5474,27 +5163,23 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { #define _NEW_POS(m_ofs) (((s > 0) ? m_ofs : from_t + (len - (m_ofs - from_t))) - pivot) * ABS(s) + from_t // 3-move the keys (re insert them) for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = _NEW_POS(E->get().pos); undo_redo->add_do_method(animation.ptr(), "track_insert_key", E->key().track, newpos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 4-(undo) remove inserted keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float newpos = _NEW_POS(E->get().pos); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", E->key().track, newpos); } // 5-(undo) reinsert keys for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } // 6-(undo) reinsert overlapped keys for (List<_AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - _AnimMoveRestore &amr = E->get(); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, amr.transition); } @@ -5504,7 +5189,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { // 7-reselect for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - float oldpos = E->get().pos; float newpos = _NEW_POS(oldpos); if (newpos >= 0) @@ -5515,7 +5199,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->commit_action(); } break; case EDIT_DUPLICATE_SELECTION: { - if (bezier_edit->is_visible()) { bezier_edit->duplicate_selection(); break; @@ -5530,7 +5213,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { _anim_duplicate_keys(true); } break; case EDIT_DELETE_SELECTION: { - if (bezier_edit->is_visible()) { bezier_edit->delete_selection(); break; @@ -5540,7 +5222,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { undo_redo->create_action(TTR("Anim Delete Keys")); for (Map<SelectedKey, KeyInfo>::Element *E = selection.back(); E; E = E->prev()) { - undo_redo->add_do_method(animation.ptr(), "track_remove_key", E->key().track, E->key().key); undo_redo->add_undo_method(animation.ptr(), "track_insert_key", E->key().track, E->get().pos, animation->track_get_key_value(E->key().track, E->key().key), animation->track_get_key_transition(E->key().track, E->key().key)); } @@ -5551,7 +5232,6 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } } break; case EDIT_GOTO_NEXT_STEP: { - if (animation.is_null()) break; float step = animation->get_step(); @@ -5613,9 +5293,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { - for (int i = 0; i < p_animation->get_track_count(); i++) { - bool prop_exists = false; Variant::Type valid_type = Variant::NIL; Object *obj = nullptr; @@ -5636,7 +5314,6 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { } if (!obj && cleanup_tracks->is_pressed()) { - p_animation->remove_track(i); i--; continue; @@ -5646,7 +5323,6 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { continue; for (int j = 0; j < p_animation->track_get_key_count(i); j++) { - Variant v = p_animation->track_get_key_value(i, j); if (!Variant::can_convert(v.get_type(), valid_type)) { @@ -5666,13 +5342,11 @@ void AnimationTrackEditor::_cleanup_animation(Ref<Animation> p_animation) { } void AnimationTrackEditor::_view_group_toggle() { - _update_tracks(); view_group->set_icon(get_theme_icon(view_group->is_pressed() ? "AnimationTrackList" : "AnimationTrackGroup", "EditorIcons")); } bool AnimationTrackEditor::is_grouping_tracks() { - if (!view_group) { return false; } @@ -5681,7 +5355,6 @@ bool AnimationTrackEditor::is_grouping_tracks() { } void AnimationTrackEditor::_selection_changed() { - if (selected_filter->is_pressed()) { _update_tracks(); //needs updatin } else { @@ -5696,9 +5369,7 @@ void AnimationTrackEditor::_selection_changed() { } float AnimationTrackEditor::snap_time(float p_value, bool p_relative) { - if (is_snap_enabled()) { - double snap_increment; if (timeline->is_using_fps() && step->get_value() > 0) snap_increment = 1.0 / step->get_value(); @@ -5717,14 +5388,12 @@ float AnimationTrackEditor::snap_time(float p_value, bool p_relative) { } void AnimationTrackEditor::_show_imported_anim_warning() { - // It looks terrible on a single line but the TTR extractor doesn't support line breaks yet. EditorNode::get_singleton()->show_warning(TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo enable the ability to add custom tracks, navigate to the scene's import settings and set\n\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks\", then re-import.\nAlternatively, use an import preset that imports animations to separate files."), TTR("Warning: Editing imported animation")); } void AnimationTrackEditor::_select_all_tracks_for_copy() { - TreeItem *track = track_copy_select->get_root()->get_children(); if (!track) return; @@ -5745,7 +5414,6 @@ void AnimationTrackEditor::_select_all_tracks_for_copy() { } void AnimationTrackEditor::_bind_methods() { - ClassDB::bind_method("_animation_update", &AnimationTrackEditor::_animation_update); ClassDB::bind_method("_track_grab_focus", &AnimationTrackEditor::_track_grab_focus); ClassDB::bind_method("_update_tracks", &AnimationTrackEditor::_update_tracks); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 96a60cc135..6a46a1e3ff 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -121,7 +121,6 @@ public: class AnimationTrackEditor; class AnimationTrackEdit : public Control { - GDCLASS(AnimationTrackEdit, Control); enum { @@ -354,7 +353,6 @@ class AnimationTrackEditor : public VBoxContainer { bool keying; struct InsertData { - Animation::TrackType type; NodePath path; int track_idx; @@ -395,14 +393,12 @@ class AnimationTrackEditor : public VBoxContainer { //selection struct SelectedKey { - int track; int key; bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; }; }; struct KeyInfo { - float pos; }; diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 0ce3ab292e..424c3db15f 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -41,22 +41,18 @@ /// BOOL /// int AnimationTrackEditBool::get_key_height() const { - 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_theme_icon("checked", "CheckBox"); return Rect2(-checked->get_width() / 2, 0, checked->get_width(), get_size().height); } bool AnimationTrackEditBool::is_key_selectable_by_distance() const { - return false; } 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_theme_icon(checked ? "checked" : "unchecked", "CheckBox"); @@ -79,24 +75,20 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x, /// COLOR /// int AnimationTrackEditColor::get_key_height() const { - Ref<Font> font = get_theme_font("font", "Label"); return font->get_height() * 0.8; } Rect2 AnimationTrackEditColor::get_key_rect(int p_index, float p_pixels_sec) { - Ref<Font> font = get_theme_font("font", "Label"); int fh = font->get_height() * 0.8; return Rect2(-fh / 2, 0, fh, get_size().height); } bool AnimationTrackEditColor::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) { - Ref<Font> font = get_theme_font("font", "Label"); int fh = (font->get_height() * 0.8); @@ -143,7 +135,6 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int } void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Color color = get_animation()->track_get_key_value(get_track(), p_index); Ref<Font> font = get_theme_font("font", "Label"); @@ -166,7 +157,6 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x, /// AUDIO /// void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) { - Object *object = ObjectDB::get_instance(id); if (!object) @@ -180,7 +170,6 @@ void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) { } int AnimationTrackEditAudio::get_key_height() const { - if (!ObjectDB::get_instance(id)) { return AnimationTrackEdit::get_key_height(); } @@ -189,7 +178,6 @@ int AnimationTrackEditAudio::get_key_height() const { return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -207,7 +195,6 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { float len = stream->get_length(); if (len == 0) { - Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream); len = preview->get_length(); } @@ -225,11 +212,9 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) { } bool AnimationTrackEditAudio::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -289,7 +274,6 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, preview_len = preview->get_length(); for (int i = from_x; i < to_x; i++) { - float ofs = (i - pixel_begin) * preview_len / pixel_len; float ofs_n = ((i + 1) - pixel_begin) * preview_len / pixel_len; float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5; @@ -325,7 +309,6 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, } void AnimationTrackEditAudio::set_node(Object *p_object) { - id = p_object->get_instance_id(); } @@ -339,7 +322,6 @@ AnimationTrackEditAudio::AnimationTrackEditAudio() { /// SPRITE FRAME / FRAME_COORDS /// int AnimationTrackEditSpriteFrame::get_key_height() const { - if (!ObjectDB::get_instance(id)) { return AnimationTrackEdit::get_key_height(); } @@ -348,7 +330,6 @@ int AnimationTrackEditSpriteFrame::get_key_height() const { return int(font->get_height() * 2); } Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_sec) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -358,7 +339,6 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se Size2 size; if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) { - Ref<Texture2D> texture = object->call("get_texture"); if (!texture.is_valid()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); @@ -380,7 +360,6 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se size.y /= vframes; } } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) { - Ref<SpriteFrames> sf = object->call("get_sprite_frames"); if (sf.is_null()) { return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec); @@ -421,11 +400,9 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se } bool AnimationTrackEditSpriteFrame::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -437,7 +414,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in Rect2 region; if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) { - texture = object->call("get_texture"); if (!texture.is_valid()) { AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right); @@ -459,7 +435,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.size = texture->get_size(); if (bool(object->call("is_region"))) { - region = Rect2(object->call("get_region_rect")); } @@ -474,7 +449,6 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in region.position.y += region.size.y * coords.y; } else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) { - Ref<SpriteFrames> sf = object->call("get_sprite_frames"); if (sf.is_null()) { AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right); @@ -534,19 +508,16 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in } void AnimationTrackEditSpriteFrame::set_node(Object *p_object) { - id = p_object->get_instance_id(); } void AnimationTrackEditSpriteFrame::set_as_coords() { - is_coords = true; } /// SUB ANIMATION /// int AnimationTrackEditSubAnim::get_key_height() const { - if (!ObjectDB::get_instance(id)) { return AnimationTrackEdit::get_key_height(); } @@ -555,7 +526,6 @@ int AnimationTrackEditSubAnim::get_key_height() const { return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -571,7 +541,6 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { String anim = get_animation()->track_get_key_value(get_track(), p_index); if (anim != "[stop]" && ap->has_animation(anim)) { - float len = ap->get_animation(anim)->get_length(); if (get_animation()->track_get_key_count(get_track()) > p_index + 1) { @@ -587,11 +556,9 @@ Rect2 AnimationTrackEditSubAnim::get_key_rect(int p_index, float p_pixels_sec) { } bool AnimationTrackEditSubAnim::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -609,7 +576,6 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ String anim = get_animation()->track_get_key_value(get_track(), p_index); if (anim != "[stop]" && ap->has_animation(anim)) { - float len = ap->get_animation(anim)->get_length(); if (get_animation()->track_get_key_count(get_track()) > p_index + 1) { @@ -651,13 +617,11 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ Ref<Animation> animation = ap->get_animation(anim); for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); int y = 2 + h * i + h / 2; for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; @@ -701,20 +665,17 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ } void AnimationTrackEditSubAnim::set_node(Object *p_object) { - id = p_object->get_instance_id(); } //// VOLUME DB //// int AnimationTrackEditVolumeDB::get_key_height() const { - 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_theme_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); @@ -726,7 +687,6 @@ void AnimationTrackEditVolumeDB::draw_bg(int p_clip_left, int p_clip_right) { } void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { - Ref<Texture2D> volume_texture = get_theme_icon("ColorTrackVu", "EditorIcons"); int tex_h = volume_texture->get_height(); int y_from = (get_size().height - tex_h) / 2; @@ -736,7 +696,6 @@ void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) { } void AnimationTrackEditVolumeDB::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) { - if (p_x > p_clip_right || p_next_x < p_clip_left) return; @@ -778,7 +737,6 @@ void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, /// AUDIO /// void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { - for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) { Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i); if (stream.is_valid() && stream->get_instance_id() == p_which) { @@ -789,12 +747,10 @@ void AnimationTrackEditTypeAudio::_preview_changed(ObjectID p_which) { } int AnimationTrackEditTypeAudio::get_key_height() const { - 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) { - Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index); if (!stream.is_valid()) { @@ -807,7 +763,6 @@ Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) float len = stream->get_length(); if (len == 0) { - Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream); len = preview->get_length(); } @@ -826,11 +781,9 @@ Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) } bool AnimationTrackEditTypeAudio::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index); if (!stream.is_valid()) { @@ -909,7 +862,6 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int preview_len = preview->get_length(); for (int i = from_x; i < to_x; i++) { - float ofs = (i - pixel_begin) * preview_len / pixel_total_len; float ofs_n = ((i + 1) - pixel_begin) * preview_len / pixel_total_len; ofs += start_ofs; @@ -952,9 +904,7 @@ AnimationTrackEditTypeAudio::AnimationTrackEditTypeAudio() { } bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (p_point.x > get_timeline()->get_name_limit() && p_point.x < get_size().width - get_timeline()->get_buttons_width()) { - Dictionary drag_data = p_data; if (drag_data.has("type") && String(drag_data["type"]) == "resource") { Ref<AudioStream> res = drag_data["resource"]; @@ -964,7 +914,6 @@ bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Var } if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; if (files.size() == 1) { @@ -980,15 +929,12 @@ bool AnimationTrackEditTypeAudio::can_drop_data(const Point2 &p_point, const Var return AnimationTrackEdit::can_drop_data(p_point, p_data); } void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant &p_data) { - if (p_point.x > get_timeline()->get_name_limit() && p_point.x < get_size().width - get_timeline()->get_buttons_width()) { - Ref<AudioStream> stream; Dictionary drag_data = p_data; if (drag_data.has("type") && String(drag_data["type"]) == "resource") { stream = drag_data["resource"]; } else if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; if (files.size() == 1) { @@ -998,7 +944,6 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant } if (stream.is_valid()) { - int x = p_point.x - get_timeline()->get_name_limit(); float ofs = x / get_timeline()->get_zoom_scale(); ofs += get_timeline()->get_value(); @@ -1023,12 +968,10 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant } void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseMotion> mm = p_event; if (!len_resizing && mm.is_valid()) { bool use_hsize_cursor = false; for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) { - Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i); if (!stream.is_valid()) { @@ -1086,7 +1029,6 @@ void AnimationTrackEditTypeAudio::_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 && get_default_cursor_shape() == CURSOR_HSIZE) { - len_resizing = true; len_resizing_start = mb->get_shift(); len_resizing_from_px = mb->get_position().x; @@ -1097,7 +1039,6 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { } if (len_resizing && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - float ofs_local = -len_resizing_rel / get_timeline()->get_zoom_scale(); if (len_resizing_start) { float prev_ofs = get_animation()->audio_track_get_key_start_offset(get_track(), len_resizing_index); @@ -1128,7 +1069,6 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { /// SUB ANIMATION /// int AnimationTrackEditTypeAnimation::get_key_height() const { - if (!ObjectDB::get_instance(id)) { return AnimationTrackEdit::get_key_height(); } @@ -1137,7 +1077,6 @@ int AnimationTrackEditTypeAnimation::get_key_height() const { return int(font->get_height() * 1.5); } Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_sec) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -1153,7 +1092,6 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_ String anim = get_animation()->animation_track_get_key_animation(get_track(), p_index); if (anim != "[stop]" && ap->has_animation(anim)) { - float len = ap->get_animation(anim)->get_length(); if (get_animation()->track_get_key_count(get_track()) > p_index + 1) { @@ -1169,11 +1107,9 @@ Rect2 AnimationTrackEditTypeAnimation::get_key_rect(int p_index, float p_pixels_ } bool AnimationTrackEditTypeAnimation::is_key_selectable_by_distance() const { - return false; } void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) { - Object *object = ObjectDB::get_instance(id); if (!object) { @@ -1191,7 +1127,6 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, String anim = get_animation()->animation_track_get_key_animation(get_track(), p_index); if (anim != "[stop]" && ap->has_animation(anim)) { - float len = ap->get_animation(anim)->get_length(); if (get_animation()->track_get_key_count(get_track()) > p_index + 1) { @@ -1233,13 +1168,11 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, Ref<Animation> animation = ap->get_animation(anim); for (int i = 0; i < animation->get_track_count(); i++) { - float h = (rect.size.height - 2) / animation->get_track_count(); int y = 2 + h * i + h / 2; for (int j = 0; j < animation->track_get_key_count(i); j++) { - float ofs = animation->track_get_key_time(i, j); int x = p_x + ofs * p_pixels_sec + 2; @@ -1283,7 +1216,6 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, } void AnimationTrackEditTypeAnimation::set_node(Object *p_object) { - id = p_object->get_instance_id(); } @@ -1292,23 +1224,19 @@ AnimationTrackEditTypeAnimation::AnimationTrackEditTypeAnimation() { ///////// AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Object *p_object, Variant::Type p_type, const String &p_property, PropertyHint p_hint, const String &p_hint_string, int p_usage) { - if (p_property == "playing" && (p_object->is_class("AudioStreamPlayer") || p_object->is_class("AudioStreamPlayer2D") || p_object->is_class("AudioStreamPlayer3D"))) { - AnimationTrackEditAudio *audio = memnew(AnimationTrackEditAudio); audio->set_node(p_object); return audio; } 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("Sprite2D") || p_object->is_class("Sprite3D"))) { - AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame); sprite->set_as_coords(); sprite->set_node(p_object); @@ -1316,14 +1244,12 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj } if (p_property == "current_animation" && (p_object->is_class("AnimationPlayer"))) { - AnimationTrackEditSubAnim *player = memnew(AnimationTrackEditSubAnim); player->set_node(p_object); return player; } if (p_property == "volume_db") { - AnimationTrackEditVolumeDB *vu = memnew(AnimationTrackEditVolumeDB); return vu; } @@ -1339,12 +1265,10 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj } AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_audio_track_edit() { - return memnew(AnimationTrackEditTypeAudio); } AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_animation_track_edit(Object *p_object) { - AnimationTrackEditTypeAnimation *an = memnew(AnimationTrackEditTypeAnimation); an->set_node(p_object); return an; diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index 9f6785ec06..a239d2e909 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -36,7 +36,6 @@ #define ITEMS_PER_PAGE 100 Variant ArrayPropertyEdit::get_array() const { - Object *o = ObjectDB::get_instance(obj); if (!o) return Array(); @@ -52,12 +51,10 @@ void ArrayPropertyEdit::_notif_change() { _change_notify(); } void ArrayPropertyEdit::_notif_changev(const String &p_v) { - _change_notify(p_v.utf8().get_data()); } void ArrayPropertyEdit::_set_size(int p_size) { - Variant arr = get_array(); arr.call("resize", p_size); Object *o = ObjectDB::get_instance(obj); @@ -68,7 +65,6 @@ void ArrayPropertyEdit::_set_size(int p_size) { } void ArrayPropertyEdit::_set_value(int p_idx, const Variant &p_value) { - Variant arr = get_array(); arr.set(p_idx, p_value); Object *o = ObjectDB::get_instance(obj); @@ -79,13 +75,10 @@ void ArrayPropertyEdit::_set_value(int p_idx, const Variant &p_value) { } bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; if (pn.begins_with("array/")) { - if (pn == "array/size") { - Variant arr = get_array(); int size = arr.call("size"); @@ -102,7 +95,6 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { ur->add_undo_method(this, "_set_value", i, arr.get(i)); } } else if (newsize > size) { - Variant init; Callable::CallError ce; Variant::Type new_type = subtype; @@ -128,7 +120,6 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { } } else if (pn.begins_with("indices")) { - if (pn.find("_") != -1) { //type int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int(); @@ -173,13 +164,11 @@ bool ArrayPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { } bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { - Variant arr = get_array(); //int size = arr.call("size"); String pn = p_name; if (pn.begins_with("array/")) { - if (pn == "array/size") { r_ret = arr.call("size"); return true; @@ -189,7 +178,6 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { return true; } } else if (pn.begins_with("indices")) { - if (pn.find("_") != -1) { //type int idx = pn.get_slicec('/', 1).get_slicec('_', 0).to_int(); @@ -216,7 +204,6 @@ bool ArrayPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { } void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { - Variant arr = get_array(); int size = arr.call("size"); @@ -230,7 +217,6 @@ void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { int items = MIN(size - offset, ITEMS_PER_PAGE); for (int i = 0; i < items; i++) { - Variant v = arr.get(i + offset); bool is_typed = arr.get_type() != Variant::ARRAY || subtype != Variant::NIL; @@ -260,7 +246,6 @@ void ArrayPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { } void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const String &p_hint_string, Variant::Type p_deftype) { - page = 0; property = p_prop; obj = p_obj->get_instance_id(); @@ -284,7 +269,6 @@ void ArrayPropertyEdit::edit(Object *p_obj, const StringName &p_prop, const Stri } Node *ArrayPropertyEdit::get_node() { - return Object::cast_to<Node>(ObjectDB::get_instance(obj)); } @@ -293,7 +277,6 @@ bool ArrayPropertyEdit::_dont_undo_redo() { } void ArrayPropertyEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_size"), &ArrayPropertyEdit::_set_size); ClassDB::bind_method(D_METHOD("_set_value"), &ArrayPropertyEdit::_set_value); ClassDB::bind_method(D_METHOD("_notif_change"), &ArrayPropertyEdit::_notif_change); @@ -304,7 +287,6 @@ void ArrayPropertyEdit::_bind_methods() { ArrayPropertyEdit::ArrayPropertyEdit() { page = 0; for (int i = 0; i < Variant::VARIANT_MAX; i++) { - if (i > 0) vtypes += ","; vtypes += Variant::get_type_name(Variant::Type(i)); diff --git a/editor/array_property_edit.h b/editor/array_property_edit.h index 675b842128..d91701ccaf 100644 --- a/editor/array_property_edit.h +++ b/editor/array_property_edit.h @@ -34,7 +34,6 @@ #include "scene/main/node.h" class ArrayPropertyEdit : public Reference { - GDCLASS(ArrayPropertyEdit, Reference); int page; diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index fe28c913a7..e0891e808b 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -36,7 +36,6 @@ float AudioStreamPreview::get_length() const { return length; } float AudioStreamPreview::get_max(float p_time, float p_time_next) const { - if (length == 0) return 0; @@ -53,7 +52,6 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const { uint8_t vmax = 0; for (int i = time_from; i < time_to; i++) { - uint8_t v = preview[i * 2 + 1]; if (i == 0 || v > vmax) { vmax = v; @@ -63,7 +61,6 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const { return (vmax / 255.0) * 2.0 - 1.0; } float AudioStreamPreview::get_min(float p_time, float p_time_next) const { - if (length == 0) return 0; @@ -80,7 +77,6 @@ float AudioStreamPreview::get_min(float p_time, float p_time_next) const { uint8_t vmin = 255; for (int i = time_from; i < time_to; i++) { - uint8_t v = preview[i * 2]; if (i == 0 || v < vmin) { vmin = v; @@ -101,7 +97,6 @@ void AudioStreamPreviewGenerator::_update_emit(ObjectID p_id) { } void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { - Preview *preview = (Preview *)p_preview; float muxbuff_chunk_s = 0.25; @@ -117,7 +112,6 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { preview->playback->start(); while (frames_todo) { - int ofs_write = uint64_t(frames_total - frames_todo) * uint64_t(preview->preview->preview.size() / 2) / uint64_t(frames_total); int to_read = MIN(frames_todo, mixbuff_chunk_frames); int to_write = uint64_t(to_read) * uint64_t(preview->preview->preview.size() / 2) / uint64_t(frames_total); @@ -137,7 +131,6 @@ void AudioStreamPreviewGenerator::_preview_thread(void *p_preview) { } for (int j = from; j < to; j++) { - max = MAX(max, mix_chunk[j].l); max = MAX(max, mix_chunk[j].r); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 76716f01b7..381e3f8dfb 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -41,7 +41,6 @@ #include "scene/resources/dynamic_font.h" void GotoLineDialog::popup_find_line(TextEdit *p_edit) { - text_editor = p_edit; line->set_text(itos(text_editor->cursor_get_line())); @@ -51,12 +50,10 @@ void GotoLineDialog::popup_find_line(TextEdit *p_edit) { } int GotoLineDialog::get_line() const { - return line->get_text().to_int(); } void GotoLineDialog::ok_pressed() { - if (get_line() < 1 || get_line() > text_editor->get_line_count()) return; text_editor->unfold_line(get_line() - 1); @@ -65,7 +62,6 @@ void GotoLineDialog::ok_pressed() { } GotoLineDialog::GotoLineDialog() { - set_title(TTR("Go to Line")); VBoxContainer *vbc = memnew(VBoxContainer); @@ -88,9 +84,7 @@ GotoLineDialog::GotoLineDialog() { } void FindReplaceBar::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); @@ -98,10 +92,8 @@ void FindReplaceBar::_notification(int p_what) { 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_theme_icon("MoveUp", "EditorIcons")); find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); @@ -114,22 +106,16 @@ void FindReplaceBar::_notification(int p_what) { } void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) { - bool accepted = true; switch (k->get_keycode()) { - case KEY_ESCAPE: { - _hide_bar(); } break; default: { - accepted = false; } break; } @@ -142,7 +128,6 @@ void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) { } bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) { - int line, col; String text = get_search_text(); @@ -180,7 +165,6 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) } void FindReplaceBar::_replace() { - if (result_line != -1 && result_col != -1) { text_edit->begin_complex_operation(); @@ -199,7 +183,6 @@ void FindReplaceBar::_replace() { } void FindReplaceBar::_replace_all() { - text_edit->disconnect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); // Line as x so it gets priority in comparison, column as y. Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column()); @@ -289,7 +272,6 @@ void FindReplaceBar::_replace_all() { } 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(); @@ -335,7 +317,6 @@ void FindReplaceBar::_update_results_count() { } void FindReplaceBar::_update_matches_label() { - if (search_text->get_text().empty() || results_count == -1) { matches_label->hide(); } else { @@ -347,7 +328,6 @@ void FindReplaceBar::_update_matches_label() { } bool FindReplaceBar::search_current() { - uint32_t flags = 0; if (is_whole_words()) @@ -362,7 +342,6 @@ bool FindReplaceBar::search_current() { } bool FindReplaceBar::search_prev() { - if (!is_visible()) popup_search(true); @@ -393,7 +372,6 @@ bool FindReplaceBar::search_prev() { } bool FindReplaceBar::search_next() { - if (!is_visible()) popup_search(true); @@ -426,7 +404,6 @@ bool FindReplaceBar::search_next() { } void FindReplaceBar::_hide_bar() { - if (replace_text->has_focus() || search_text->has_focus()) text_edit->grab_focus(); @@ -437,7 +414,6 @@ void FindReplaceBar::_hide_bar() { } void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { - show(); if (p_show_only) return; @@ -470,7 +446,6 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) { } void FindReplaceBar::popup_search(bool p_show_only) { - replace_text->hide(); hbc_button_replace->hide(); hbc_option_replace->hide(); @@ -479,7 +454,6 @@ void FindReplaceBar::popup_search(bool p_show_only) { } void FindReplaceBar::popup_replace() { - if (!replace_text->is_visible_in_tree()) { replace_text->show(); hbc_button_replace->show(); @@ -492,13 +466,11 @@ void FindReplaceBar::popup_replace() { } void FindReplaceBar::_search_options_changed(bool p_pressed) { - results_count = -1; search_current(); } void FindReplaceBar::_editor_text_changed() { - results_count = -1; if (is_visible_in_tree()) { preserve_cursor = true; @@ -508,13 +480,11 @@ void FindReplaceBar::_editor_text_changed() { } void FindReplaceBar::_search_text_changed(const String &p_text) { - results_count = -1; search_current(); } void FindReplaceBar::_search_text_entered(const String &p_text) { - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { search_prev(); } else { @@ -523,7 +493,6 @@ void FindReplaceBar::_search_text_entered(const String &p_text) { } void FindReplaceBar::_replace_text_entered(const String &p_text) { - if (selection_only->is_pressed() && text_edit->is_selection_active()) { _replace_all(); _hide_bar(); @@ -536,44 +505,36 @@ void FindReplaceBar::_replace_text_entered(const String &p_text) { } String FindReplaceBar::get_search_text() const { - return search_text->get_text(); } String FindReplaceBar::get_replace_text() const { - return replace_text->get_text(); } bool FindReplaceBar::is_case_sensitive() const { - return case_sensitive->is_pressed(); } bool FindReplaceBar::is_whole_words() const { - return whole_words->is_pressed(); } bool FindReplaceBar::is_selection_only() const { - return selection_only->is_pressed(); } void FindReplaceBar::set_error(const String &p_label) { - emit_signal("error", p_label); } void FindReplaceBar::set_text_edit(TextEdit *p_text_edit) { - results_count = -1; text_edit = p_text_edit; text_edit->connect("text_changed", callable_mp(this, &FindReplaceBar::_editor_text_changed)); } void FindReplaceBar::_bind_methods() { - ClassDB::bind_method("_unhandled_input", &FindReplaceBar::_unhandled_input); ClassDB::bind_method("_search_current", &FindReplaceBar::search_current); @@ -583,7 +544,6 @@ void FindReplaceBar::_bind_methods() { } FindReplaceBar::FindReplaceBar() { - results_count = -1; replace_all_mode = false; preserve_cursor = false; @@ -676,7 +636,6 @@ FindReplaceBar::FindReplaceBar() { // This function should be used to handle shortcuts that could otherwise // be handled too late if they weren't handled here. void CodeTextEditor::_input(const Ref<InputEvent> &event) { - const Ref<InputEventKey> key_event = event; if (!key_event.is_valid() || !key_event->is_pressed()) return; @@ -704,13 +663,10 @@ void CodeTextEditor::_input(const Ref<InputEvent> &event) { } void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - if (mb->is_pressed() && mb->get_command()) { - if (mb->get_button_index() == BUTTON_WHEEL_UP) { _zoom_in(); } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN) { @@ -721,7 +677,6 @@ 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_theme_font("font"); if (font.is_valid()) { @@ -739,7 +694,6 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (k->is_pressed()) { if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) { _zoom_in(); @@ -779,7 +733,6 @@ void CodeTextEditor::_reset_zoom() { } void CodeTextEditor::_line_col_changed() { - String line = text_editor->get_line(text_editor->cursor_get_line()); int positional_column = 0; @@ -802,7 +755,6 @@ void CodeTextEditor::_line_col_changed() { } void CodeTextEditor::_text_changed() { - if (text_editor->is_insert_text_operation()) { code_complete_timer->start(); } @@ -817,7 +769,6 @@ void CodeTextEditor::_code_complete_timer_timeout() { } void CodeTextEditor::_complete_request() { - List<ScriptCodeCompletionOption> entries; String ctext = text_editor->get_text_for_completion(); _code_complete_script(ctext, &entries); @@ -879,14 +830,12 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOp } void CodeTextEditor::_font_resize_timeout() { - if (_add_font_size(font_resize_val)) { font_resize_val = 0; } } bool CodeTextEditor::_add_font_size(int p_delta) { - Ref<DynamicFont> font = text_editor->get_theme_font("font"); if (font.is_valid()) { @@ -904,7 +853,6 @@ bool CodeTextEditor::_add_font_size(int p_delta) { } void CodeTextEditor::update_editor_settings() { - text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting")); text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences")); text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line")); @@ -940,7 +888,6 @@ void CodeTextEditor::trim_trailing_whitespace() { for (int i = 0; i < text_editor->get_line_count(); i++) { String line = text_editor->get_line(i); if (line.ends_with(" ") || line.ends_with("\t")) { - if (!trimed_whitespace) { text_editor->begin_complex_operation(); trimed_whitespace = true; @@ -1440,7 +1387,6 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) { } void CodeTextEditor::set_error(const String &p_error) { - error->set_text(p_error); if (p_error != "") { error->set_default_cursor_shape(CURSOR_POINTING_HAND); @@ -1463,7 +1409,6 @@ void CodeTextEditor::goto_error() { } void CodeTextEditor::_update_font() { - text_editor->add_theme_font_override("font", get_theme_font("source", "EditorFonts")); error->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); @@ -1480,7 +1425,6 @@ void CodeTextEditor::_update_font() { } void CodeTextEditor::_on_settings_change() { - _update_font(); font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size"); @@ -1537,7 +1481,6 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) { } void CodeTextEditor::_notification(int p_what) { - switch (p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _load_theme_settings(); @@ -1573,13 +1516,11 @@ void CodeTextEditor::set_warning_nb(int p_warning_nb) { } void CodeTextEditor::toggle_bookmark() { - int line = text_editor->cursor_get_line(); text_editor->set_line_as_bookmark(line, !text_editor->is_line_set_as_bookmark(line)); } void CodeTextEditor::goto_next_bookmark() { - List<int> bmarks; text_editor->get_bookmarks(&bmarks); if (bmarks.size() <= 0) { @@ -1605,7 +1546,6 @@ void CodeTextEditor::goto_next_bookmark() { } void CodeTextEditor::goto_prev_bookmark() { - List<int> bmarks; text_editor->get_bookmarks(&bmarks); if (bmarks.size() <= 0) { @@ -1631,7 +1571,6 @@ void CodeTextEditor::goto_prev_bookmark() { } void CodeTextEditor::remove_all_bookmarks() { - List<int> bmarks; text_editor->get_bookmarks(&bmarks); @@ -1641,7 +1580,6 @@ void CodeTextEditor::remove_all_bookmarks() { } void CodeTextEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_input"), &CodeTextEditor::_input); ADD_SIGNAL(MethodInfo("validate_script")); @@ -1665,7 +1603,6 @@ void CodeTextEditor::update_toggle_scripts_button() { } CodeTextEditor::CodeTextEditor() { - 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); diff --git a/editor/code_editor.h b/editor/code_editor.h index 6b733a2b3c..d806be885f 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -41,7 +41,6 @@ #include "scene/main/timer.h" class GotoLineDialog : public ConfirmationDialog { - GDCLASS(GotoLineDialog, ConfirmationDialog); Label *line_label; @@ -60,7 +59,6 @@ public: }; class FindReplaceBar : public HBoxContainer { - GDCLASS(FindReplaceBar, HBoxContainer); LineEdit *search_text; @@ -138,7 +136,6 @@ public: typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_forced); class CodeTextEditor : public VBoxContainer { - GDCLASS(CodeTextEditor, VBoxContainer); TextEdit *text_editor; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 4556a6e827..2e47be32ca 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -47,7 +47,6 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { } for (int i = 0; i < p_node->get_child_count(); i++) { - Node *ret = _find_first_script(p_root, p_node->get_child(i)); if (ret) { return ret; @@ -58,14 +57,12 @@ static Node *_find_first_script(Node *p_root, Node *p_node) { } class ConnectDialogBinds : public Object { - GDCLASS(ConnectDialogBinds, Object); public: Vector<Variant> params; bool _set(const StringName &p_name, const Variant &p_value) { - String name = p_name; if (name.begins_with("bind/")) { @@ -79,7 +76,6 @@ public: } bool _get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; if (name.begins_with("bind/")) { @@ -93,14 +89,12 @@ public: } void _get_property_list(List<PropertyInfo> *p_list) const { - for (int i = 0; i < params.size(); i++) { p_list->push_back(PropertyInfo(params[i].get_type(), "bind/" + itos(i + 1))); } } void notify_changed() { - _change_notify(); } @@ -112,7 +106,6 @@ public: * Signal automatically called by parent dialog. */ void ConnectDialog::ok_pressed() { - if (dst_method->get_text() == "") { error->set_text(TTR("Method in target node must be specified.")); error->popup_centered(); @@ -149,7 +142,6 @@ void ConnectDialog::_text_entered(const String &p_text) { * Called each time a target node is selected within the target node tree. */ void ConnectDialog::_tree_node_selected() { - Node *current = tree->get_selected(); if (!current) @@ -163,7 +155,6 @@ void ConnectDialog::_tree_node_selected() { * Adds a new parameter bind to connection. */ void ConnectDialog::_add_bind() { - if (cdbinds->params.size() >= VARIANT_ARG_MAX) return; Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected()); @@ -228,7 +219,6 @@ void ConnectDialog::_add_bind() { * Remove parameter bind from connection. */ void ConnectDialog::_remove_bind() { - String st = bind_editor->get_selected_path(); if (st == "") return; @@ -244,7 +234,6 @@ void ConnectDialog::_remove_bind() { * node is selected and valid in the selected mode. */ void ConnectDialog::_update_ok_enabled() { - Node *target = tree->get_selected(); if (target == nullptr) { @@ -261,14 +250,12 @@ void ConnectDialog::_update_ok_enabled() { } void ConnectDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { bind_editor->edit(cdbinds); } } void ConnectDialog::_bind_methods() { - ClassDB::bind_method("_cancel", &ConnectDialog::_cancel_pressed); ClassDB::bind_method("_update_ok_enabled", &ConnectDialog::_update_ok_enabled); @@ -276,27 +263,22 @@ void ConnectDialog::_bind_methods() { } Node *ConnectDialog::get_source() const { - return source; } StringName ConnectDialog::get_signal_name() const { - return signal; } NodePath ConnectDialog::get_dst_path() const { - return dst_path; } void ConnectDialog::set_dst_node(Node *p_node) { - tree->set_selected(p_node); } StringName ConnectDialog::get_dst_method_name() const { - String txt = dst_method->get_text(); if (txt.find("(") != -1) txt = txt.left(txt.find("(")).strip_edges(); @@ -304,22 +286,18 @@ StringName ConnectDialog::get_dst_method_name() const { } void ConnectDialog::set_dst_method(const StringName &p_method) { - dst_method->set_text(p_method); } Vector<Variant> ConnectDialog::get_binds() const { - return cdbinds->params; } bool ConnectDialog::get_deferred() const { - return deferred->is_pressed(); } bool ConnectDialog::get_oneshot() const { - return oneshot->is_pressed(); } @@ -327,7 +305,6 @@ bool ConnectDialog::get_oneshot() const { * Returns true if ConnectDialog is being used to edit an existing connection. */ bool ConnectDialog::is_editing() const { - return bEditMode; } @@ -337,7 +314,6 @@ bool ConnectDialog::is_editing() const { * If editing an existing connection, previous data is retained. */ void ConnectDialog::init(ConnectionData c, bool bEdit) { - set_hide_on_ok(false); source = static_cast<Node *>(c.source); @@ -367,7 +343,6 @@ void ConnectDialog::init(ConnectionData c, bool bEdit) { } void ConnectDialog::popup_dialog(const String &p_for_signal) { - from_signal->set_text(p_for_signal); error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor")); if (!advanced->is_pressed()) @@ -377,7 +352,6 @@ void ConnectDialog::popup_dialog(const String &p_for_signal) { } void ConnectDialog::_advanced_pressed() { - if (advanced->is_pressed()) { set_min_size(Size2(900, 500) * EDSCALE); connect_to_label->set_text(TTR("Connect to Node:")); @@ -401,7 +375,6 @@ void ConnectDialog::_advanced_pressed() { } ConnectDialog::ConnectDialog() { - set_min_size(Size2(600, 500) * EDSCALE); VBoxContainer *vbc = memnew(VBoxContainer); @@ -515,7 +488,6 @@ ConnectDialog::ConnectDialog() { } ConnectDialog::~ConnectDialog() { - memdelete(cdbinds); } @@ -523,7 +495,6 @@ ConnectDialog::~ConnectDialog() { // Originally copied and adapted from EditorProperty, try to keep style in sync. Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { - EditorHelpBit *help_bit = memnew(EditorHelpBit); help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); help_bit->get_rich_text()->set_fixed_size_to_width(360 * EDSCALE); @@ -536,7 +507,6 @@ Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const { } struct _ConnectionsDockMethodInfoSort { - _FORCE_INLINE_ bool operator()(const MethodInfo &a, const MethodInfo &b) const { return a.name < b.name; } @@ -547,7 +517,6 @@ struct _ConnectionsDockMethodInfoSort { * Creates or edits connections based on state of the ConnectDialog when "Connect" is pressed. */ void ConnectionsDock::_make_or_edit_connection() { - TreeItem *it = tree->get_selected(); ERR_FAIL_COND(!it); @@ -616,7 +585,6 @@ void ConnectionsDock::_make_or_edit_connection() { * Creates single connection w/ undo-redo functionality. */ void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) { - Node *source = static_cast<Node *>(cToMake.source); Node *target = static_cast<Node *>(cToMake.target); @@ -641,7 +609,6 @@ void ConnectionsDock::_connect(ConnectDialog::ConnectionData cToMake) { * Break single connection w/ undo-redo functionality. */ void ConnectionsDock::_disconnect(TreeItem &item) { - Connection cd = item.get_metadata(0); ConnectDialog::ConnectionData c = cd; @@ -664,7 +631,6 @@ void ConnectionsDock::_disconnect(TreeItem &item) { * Can undo-redo as a single action. */ void ConnectionsDock::_disconnect_all() { - TreeItem *item = tree->get_selected(); if (!_is_item_signal(*item)) @@ -691,7 +657,6 @@ void ConnectionsDock::_disconnect_all() { } void ConnectionsDock::_tree_item_selected() { - TreeItem *item = tree->get_selected(); if (!item) { // Unlikely. Disable button just in case. connect_button->set_text(TTR("Connect...")); @@ -720,7 +685,6 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click. } bool ConnectionsDock::_is_item_signal(TreeItem &item) { - return (item.get_parent() == tree->get_root() || item.get_parent()->get_parent() == tree->get_root()); } @@ -728,7 +692,6 @@ bool ConnectionsDock::_is_item_signal(TreeItem &item) { * Open connection dialog with TreeItem data to CREATE a brand-new connection. */ void ConnectionsDock::_open_connection_dialog(TreeItem &item) { - String signal = item.get_metadata(0).operator Dictionary()["name"]; const String &signalname = signal; String midname = selectedNode->get_name(); @@ -769,7 +732,6 @@ void ConnectionsDock::_open_connection_dialog(TreeItem &item) { * Open connection dialog with Connection data to EDIT an existing connection. */ void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToEdit) { - Node *src = static_cast<Node *>(cToEdit.source); Node *dst = static_cast<Node *>(cToEdit.target); @@ -784,7 +746,6 @@ void ConnectionsDock::_open_connection_dialog(ConnectDialog::ConnectionData cToE * Open slot method location in script editor. */ void ConnectionsDock::_go_to_script(TreeItem &item) { - if (_is_item_signal(item)) return; @@ -806,7 +767,6 @@ void ConnectionsDock::_go_to_script(TreeItem &item) { } void ConnectionsDock::_handle_signal_menu_option(int option) { - TreeItem *item = tree->get_selected(); if (!item) @@ -825,7 +785,6 @@ void ConnectionsDock::_handle_signal_menu_option(int option) { } void ConnectionsDock::_handle_slot_menu_option(int option) { - TreeItem *item = tree->get_selected(); if (!item) @@ -847,7 +806,6 @@ void ConnectionsDock::_handle_slot_menu_option(int option) { } void ConnectionsDock::_rmb_pressed(Vector2 position) { - TreeItem *item = tree->get_selected(); if (!item) @@ -865,12 +823,10 @@ void ConnectionsDock::_rmb_pressed(Vector2 position) { } void ConnectionsDock::_close() { - hide(); } void ConnectionsDock::_connect_pressed() { - TreeItem *item = tree->get_selected(); if (!item) { connect_button->set_disabled(true); @@ -886,25 +842,21 @@ void ConnectionsDock::_connect_pressed() { } void ConnectionsDock::_notification(int p_what) { - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { update_tree(); } } void ConnectionsDock::_bind_methods() { - ClassDB::bind_method("update_tree", &ConnectionsDock::update_tree); } void ConnectionsDock::set_node(Node *p_node) { - selectedNode = p_node; update_tree(); } void ConnectionsDock::update_tree() { - tree->clear(); if (!selectedNode) @@ -920,13 +872,11 @@ void ConnectionsDock::update_tree() { StringName base = selectedNode->get_class(); while (base) { - List<MethodInfo> node_signals2; Ref<Texture2D> icon; String name; if (!did_script) { - Ref<Script> scr = selectedNode->get_script(); if (scr.is_valid()) { scr->get_script_signal_list(&node_signals2); @@ -940,7 +890,6 @@ void ConnectionsDock::update_tree() { } } } else { - ClassDB::get_signal_list(base, &node_signals2, true); if (has_theme_icon(base, "EditorIcons")) { icon = get_theme_icon(base, "EditorIcons"); @@ -965,7 +914,6 @@ void ConnectionsDock::update_tree() { } for (List<MethodInfo>::Element *E = node_signals2.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); StringName signal_name = mi.name; @@ -973,7 +921,6 @@ void ConnectionsDock::update_tree() { PackedStringArray argnames; if (mi.arguments.size()) { for (int i = 0; i < mi.arguments.size(); i++) { - PropertyInfo &pi = mi.arguments[i]; if (i > 0) @@ -1040,7 +987,6 @@ void ConnectionsDock::update_tree() { selectedNode->get_signal_connection_list(signal_name, &connections); for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) { - Connection cn = F->get(); if (!(cn.flags & CONNECT_PERSIST)) continue; @@ -1056,10 +1002,8 @@ void ConnectionsDock::update_tree() { if (c.flags & CONNECT_ONESHOT) path += " (oneshot)"; if (c.binds.size()) { - path += " binds("; for (int i = 0; i < c.binds.size(); i++) { - if (i > 0) path += ", "; path += c.binds[i].operator String(); @@ -1087,7 +1031,6 @@ void ConnectionsDock::update_tree() { } ConnectionsDock::ConnectionsDock(EditorNode *p_editor) { - editor = p_editor; set_name(TTR("Signals")); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 91d0d5c32c..d0c8d939cf 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -50,7 +50,6 @@ class PopupMenu; class ConnectDialogBinds; class ConnectDialog : public ConfirmationDialog { - GDCLASS(ConnectDialog, ConfirmationDialog); public: @@ -142,12 +141,10 @@ public: // Custom Tree needed to use a RichTextLabel as tooltip control // when display signal documentation. class ConnectionsDockTree : public Tree { - virtual Control *make_custom_tooltip(const String &p_text) const; }; class ConnectionsDock : public VBoxContainer { - GDCLASS(ConnectionsDock, VBoxContainer); //Right-click Pop-up Menu Options. diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 6cbb1b1791..cacf5c744f 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -41,7 +41,6 @@ #include "scene/gui/box_container.h" void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const String &p_select_type) { - type_list.clear(); ClassDB::get_class_list(&type_list); ScriptServer::get_global_class_list(&type_list); @@ -52,7 +51,6 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::READ); if (f) { - TreeItem *root = recent->create_item(); while (!f->eof_reached()) { @@ -75,7 +73,6 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St favorite_list.clear(); if (f) { - while (!f->eof_reached()) { String l = f->get_line().strip_edges(); @@ -120,25 +117,21 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St } void CreateDialog::_text_changed(const String &p_newtext) { - _update_search(); } void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; if (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_PAGEUP || k->get_keycode() == KEY_PAGEDOWN)) { - search_options->call("_gui_input", k); search_box->accept_event(); } } void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) { - if (p_types.has(p_type)) return; @@ -171,9 +164,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p TreeItem *parent = p_root; if (inherits.length()) { - if (!p_types.has(inherits)) { - add_type(inherits, p_types, p_root, to_select); } @@ -267,7 +258,6 @@ bool CreateDialog::_is_type_prefered(const String &type) { } bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_class) { - Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); if (profile.is_null()) { return false; @@ -277,7 +267,6 @@ bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_cla } void CreateDialog::select_type(const String &p_type) { - TreeItem *to_select; if (search_options_types.has(p_type)) { to_select = search_options_types[p_type]; @@ -317,7 +306,6 @@ void CreateDialog::_update_search() { TreeItem *to_select = search_box->get_text() == base_type ? root : nullptr; for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) { - String type = I->get(); if (_is_class_disabled_by_feature_profile(type)) { @@ -345,7 +333,6 @@ void CreateDialog::_update_search() { if (search_box->get_text() == "") { add_type(type, search_options_types, root, &to_select); } else { - bool found = false; String type2 = type; @@ -355,7 +342,6 @@ void CreateDialog::_update_search() { while (type2 != "" && (cpp_type ? ClassDB::is_parent_class(type2, base_type) : ed.script_class_is_parent(type2, base_type)) && type2 != base_type) { if (search_box->get_text().is_subsequence_ofi(type2)) { - found = true; break; } @@ -377,7 +363,6 @@ void CreateDialog::_update_search() { const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; for (int i = 0; i < ct.size(); i++) { - bool show = search_box->get_text().is_subsequence_ofi(ct[i].name); if (!show) @@ -421,7 +406,6 @@ void CreateDialog::_update_search() { } void CreateDialog::_confirmed() { - TreeItem *ti = search_options->get_selected(); if (!ti) return; @@ -436,7 +420,6 @@ void CreateDialog::_confirmed() { int count = 0; while (t) { if (t->get_text(0) != get_selected_type()) { - f->store_line(t->get_text(0)); } @@ -456,7 +439,6 @@ void CreateDialog::_confirmed() { } void CreateDialog::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &CreateDialog::_confirmed)); @@ -480,7 +462,6 @@ void CreateDialog::_notification(int p_what) { } void CreateDialog::set_base_type(const String &p_base) { - base_type = p_base; if (is_replace_mode) set_title(vformat(TTR("Change %s Type"), p_base)); @@ -491,7 +472,6 @@ void CreateDialog::set_base_type(const String &p_base) { } String CreateDialog::get_base_type() const { - return base_type; } @@ -500,11 +480,9 @@ void CreateDialog::set_preferred_search_result_type(const String &p_preferred_ty } String CreateDialog::get_preferred_search_result_type() { - return preferred_search_result_type; } String CreateDialog::get_selected_type() { - TreeItem *selected = search_options->get_selected(); if (selected) return selected->get_text(0); @@ -513,11 +491,9 @@ String CreateDialog::get_selected_type() { } Object *CreateDialog::instance_selected() { - TreeItem *selected = search_options->get_selected(); if (selected) { - Variant md = selected->get_metadata(0); String custom; @@ -542,7 +518,6 @@ Object *CreateDialog::instance_selected() { } void CreateDialog::_item_selected() { - TreeItem *item = search_options->get_selected(); if (!item) return; @@ -565,7 +540,6 @@ void CreateDialog::_hide_requested() { } void CreateDialog::_favorite_toggled() { - TreeItem *item = search_options->get_selected(); if (!item) return; @@ -584,11 +558,9 @@ void CreateDialog::_favorite_toggled() { } void CreateDialog::_save_favorite_list() { - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); if (f) { - for (int i = 0; i < favorite_list.size(); i++) { String l = favorite_list[i]; String name = l.split(" ")[0]; @@ -601,7 +573,6 @@ void CreateDialog::_save_favorite_list() { } void CreateDialog::_update_favorite_list() { - favorites->clear(); TreeItem *root = favorites->create_item(); for (int i = 0; i < favorite_list.size(); i++) { @@ -617,7 +588,6 @@ void CreateDialog::_update_favorite_list() { } void CreateDialog::_history_selected() { - TreeItem *item = recent->get_selected(); if (!item) return; @@ -628,7 +598,6 @@ void CreateDialog::_history_selected() { } void CreateDialog::_favorite_selected() { - TreeItem *item = favorites->get_selected(); if (!item) return; @@ -639,19 +608,16 @@ void CreateDialog::_favorite_selected() { } void CreateDialog::_history_activated() { - _history_selected(); _confirmed(); } void CreateDialog::_favorite_activated() { - _favorite_selected(); _confirmed(); } Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - TreeItem *ti = favorites->get_item_at_position(p_point); if (ti) { Dictionary d; @@ -670,7 +636,6 @@ Variant CreateDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) { } bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (d.has("type") && String(d["type"]) == "create_favorite_drag") { favorites->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN); @@ -680,7 +645,6 @@ bool CreateDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data return false; } void CreateDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - Dictionary d = p_data; TreeItem *ti = favorites->get_item_at_position(p_point); @@ -727,7 +691,6 @@ void CreateDialog::_save_and_update_favorite_list() { } void CreateDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("_save_and_update_favorite_list"), &CreateDialog::_save_and_update_favorite_list); ClassDB::bind_method("get_drag_data_fw", &CreateDialog::get_drag_data_fw); @@ -739,7 +702,6 @@ void CreateDialog::_bind_methods() { } CreateDialog::CreateDialog() { - is_replace_mode = false; HSplitContainer *hsc = memnew(HSplitContainer); diff --git a/editor/create_dialog.h b/editor/create_dialog.h index f2e2eb1b04..cdc91ae535 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -40,7 +40,6 @@ #include "scene/gui/tree.h" class CreateDialog : public ConfirmationDialog { - GDCLASS(CreateDialog, ConfirmationDialog); Vector<String> favorite_list; diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 00ed2bbc4c..0c5fce91a6 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -36,7 +36,6 @@ #include "scene/debugger/scene_debugger.h" bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p_value) { - if (!editable || !prop_values.has(p_name) || String(p_name).begins_with("Constants/")) return false; @@ -46,7 +45,6 @@ bool EditorDebuggerRemoteObject::_set(const StringName &p_name, const Variant &p } bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) const { - if (!prop_values.has(p_name)) return false; @@ -55,7 +53,6 @@ bool EditorDebuggerRemoteObject::_get(const StringName &p_name, Variant &r_ret) } void EditorDebuggerRemoteObject::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->clear(); //sorry, no want category for (const List<PropertyInfo>::Element *E = prop_list.front(); E; E = E->next()) { p_list->push_back(E->get()); @@ -76,7 +73,6 @@ Variant EditorDebuggerRemoteObject::get_variant(const StringName &p_name) { } void EditorDebuggerRemoteObject::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_title"), &EditorDebuggerRemoteObject::get_title); ClassDB::bind_method(D_METHOD("get_variant"), &EditorDebuggerRemoteObject::get_variant); ClassDB::bind_method(D_METHOD("clear"), &EditorDebuggerRemoteObject::clear); @@ -115,12 +111,10 @@ void EditorDebuggerInspector::_notification(int p_what) { } void EditorDebuggerInspector::_object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value) { - emit_signal("object_edited", p_id, p_prop, p_value); } void EditorDebuggerInspector::_object_selected(ObjectID p_object) { - emit_signal("object_selected", p_object); } @@ -147,7 +141,6 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { int new_props_added = 0; Set<String> changed; for (int i = 0; i < obj.properties.size(); i++) { - PropertyInfo &pinfo = obj.properties[i].first; Variant &var = obj.properties[i].second; @@ -187,7 +180,6 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { new_props_added++; debugObj->prop_values[pinfo.name] = var; } else { - if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debugObj->prop_values[pinfo.name], var))) { debugObj->prop_values[pinfo.name] = var; changed.insert(pinfo.name); @@ -225,7 +217,6 @@ Object *EditorDebuggerInspector::get_object(ObjectID p_id) { } void EditorDebuggerInspector::add_stack_variable(const Array &p_array) { - DebuggerMarshalls::ScriptStackVariable var; var.deserialize(p_array); String n = var.name; diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index f0ee7a2535..638dee3c3f 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -33,7 +33,6 @@ #include "editor/editor_inspector.h" class EditorDebuggerRemoteObject : public Object { - GDCLASS(EditorDebuggerRemoteObject, Object); protected: @@ -65,7 +64,6 @@ public: }; class EditorDebuggerInspector : public EditorInspector { - GDCLASS(EditorDebuggerInspector, EditorInspector); private: diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 5bfb79806e..3c9fd39069 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -141,7 +141,6 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d } void EditorDebuggerNode::_bind_methods() { - // LiveDebug. ClassDB::bind_method("live_debug_create_node", &EditorDebuggerNode::live_debug_create_node); ClassDB::bind_method("live_debug_instance_node", &EditorDebuggerNode::live_debug_instance_node); @@ -243,7 +242,6 @@ void EditorDebuggerNode::_notification(int p_what) { }); if (error_count != last_error_count || warning_count != last_warning_count) { - _for_all(tabs, [&](ScriptEditorDebugger *dbg) { dbg->update_tabs(); }); @@ -547,7 +545,6 @@ void EditorDebuggerNode::_property_changeds(void *p_ud, Object *p_base, const St // LiveDebug void EditorDebuggerNode::set_live_debugging(bool p_enabled) { - _for_all(tabs, [&](ScriptEditorDebugger *dbg) { dbg->set_live_debugging(p_enabled); }); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 88b82d37fd..9138651147 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -42,7 +42,6 @@ class ScriptEditorDebugger; class TabContainer; class EditorDebuggerNode : public MarginContainer { - GDCLASS(EditorDebuggerNode, MarginContainer); public: diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp index 33f20d9a12..0b655044a8 100644 --- a/editor/debugger/editor_debugger_server.cpp +++ b/editor/debugger/editor_debugger_server.cpp @@ -39,7 +39,6 @@ #include "editor/editor_settings.h" class EditorDebuggerServerTCP : public EditorDebuggerServer { - private: Ref<TCP_Server> server; diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index 515ffce628..10a9a232ab 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -35,7 +35,6 @@ #include "core/reference.h" class EditorDebuggerServer : public Reference { - public: typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index c2b94c79bb..ecffa0f05d 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -64,7 +64,6 @@ void EditorDebuggerTree::_bind_methods() { } void EditorDebuggerTree::_scene_tree_selected() { - if (updating_scene_tree) { return; } @@ -80,9 +79,7 @@ void EditorDebuggerTree::_scene_tree_selected() { } void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { - if (updating_scene_tree) { - return; } TreeItem *item = Object::cast_to<TreeItem>(p_obj); @@ -99,7 +96,6 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) { } void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) { - TreeItem *item = get_item_at_position(p_position); if (!item) return; @@ -224,11 +220,8 @@ String EditorDebuggerTree::_get_path(TreeItem *p_item) { } void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { - switch (p_option) { - case ITEM_MENU_SAVE_REMOTE_NODE: { - file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES); file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); @@ -243,7 +236,6 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { file_dialog->popup_centered_ratio(); } break; case ITEM_MENU_COPY_NODE_PATH: { - String text = get_selected_path(); if (text.empty()) { return; diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index 342eb23194..5ec1423c07 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -37,7 +37,6 @@ class SceneDebuggerTree; class EditorFileDialog; class EditorDebuggerTree : public Tree { - GDCLASS(EditorDebuggerTree, Tree); private: diff --git a/editor/debugger/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index b8c795d9ca..baa88bcdbc 100644 --- a/editor/debugger/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -39,7 +39,6 @@ void EditorNetworkProfiler::_bind_methods() { } void EditorNetworkProfiler::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { activate->set_icon(get_theme_icon("Play", "EditorIcons")); clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); @@ -53,13 +52,11 @@ void EditorNetworkProfiler::_notification(int p_what) { } void EditorNetworkProfiler::_update_frame() { - counters_display->clear(); TreeItem *root = counters_display->create_item(); for (Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo>::Element *E = nodes_data.front(); E; E = E->next()) { - TreeItem *node = counters_display->create_item(root); for (int j = 0; j < counters_display->get_columns(); ++j) { @@ -75,7 +72,6 @@ void EditorNetworkProfiler::_update_frame() { } void EditorNetworkProfiler::_activate_pressed() { - if (activate->is_pressed()) { activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); @@ -96,7 +92,6 @@ void EditorNetworkProfiler::_clear_pressed() { } void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame) { - if (!nodes_data.has(p_frame.node)) { nodes_data.insert(p_frame.node, p_frame); } else { @@ -113,7 +108,6 @@ void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::Multipl } void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { - incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming))); outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing))); @@ -131,7 +125,6 @@ bool EditorNetworkProfiler::is_profiling() { } EditorNetworkProfiler::EditorNetworkProfiler() { - HBoxContainer *hb = memnew(HBoxContainer); hb->add_theme_constant_override("separation", 8 * EDSCALE); add_child(hb); diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index f532dc5dd0..cf65fb5316 100644 --- a/editor/debugger/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -39,7 +39,6 @@ #include "scene/gui/tree.h" class EditorNetworkProfiler : public VBoxContainer { - GDCLASS(EditorNetworkProfiler, VBoxContainer) private: diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 347de2470b..0b10602c54 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -35,7 +35,6 @@ #include "editor/editor_settings.h" void EditorProfiler::_make_metric_ptrs(Metric &m) { - for (int i = 0; i < m.categories.size(); i++) { m.category_ptrs[m.categories[i].signature] = &m.categories.write[i]; for (int j = 0; j < m.categories[i].items.size(); j++) { @@ -45,7 +44,6 @@ void EditorProfiler::_make_metric_ptrs(Metric &m) { } void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { - ++last_metric; if (last_metric >= frame_metrics.size()) last_metric = 0; @@ -69,7 +67,6 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { updating_frame = false; if (frame_delay->is_stopped()) { - frame_delay->set_wait_time(p_final ? 0.1 : 1); frame_delay->start(); } @@ -81,7 +78,6 @@ void EditorProfiler::add_frame_metric(const Metric &p_metric, bool p_final) { } void EditorProfiler::clear() { - int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); metric_size = CLAMP(metric_size, 60, 1024); frame_metrics.clear(); @@ -110,7 +106,6 @@ static String _get_percent_txt(float p_value, float p_total) { } String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_calls) { - const int dmode = display_mode->get_selected(); if (dmode == DISPLAY_FRAME_TIME) { @@ -131,7 +126,6 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca } Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; @@ -140,7 +134,6 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c } void EditorProfiler::_item_edited() { - if (updating_frame) return; @@ -164,7 +157,6 @@ void EditorProfiler::_item_edited() { } void EditorProfiler::_update_plot() { - const int w = graph->get_size().width; const int h = graph->get_size().height; bool reset_texture = false; @@ -197,7 +189,6 @@ void EditorProfiler::_update_plot() { continue; for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - const Map<StringName, Metric::Category *>::Element *F = m.category_ptrs.find(E->get()); if (F) { highest = MAX(F->get()->total_time, highest); @@ -228,7 +219,6 @@ void EditorProfiler::_update_plot() { //Map<StringName,int> plot_max; for (int i = 0; i < w; i++) { - for (int j = 0; j < h * 4; j++) { column[j] = 0; } @@ -242,11 +232,9 @@ void EditorProfiler::_update_plot() { next = current + 1; //just because for loop must work for (Set<StringName>::Element *E = plot_sigs.front(); E; E = E->next()) { - int plot_pos = -1; for (int j = current; j < next; j++) { - //wrap int idx = last_metric + 1 + j; while (idx >= frame_metrics.size()) { @@ -292,7 +280,6 @@ void EditorProfiler::_update_plot() { } if (prev_plot != -1 && plot_pos == -1) { - plot_pos = prev_plot; } @@ -310,7 +297,6 @@ void EditorProfiler::_update_plot() { Color col = _get_color_from_signature(E->get()); for (int j = prev_plot; j <= plot_pos; j++) { - column[j * 4 + 0] += Math::fast_ftoi(CLAMP(col.r * 255, 0, 255)); column[j * 4 + 1] += Math::fast_ftoi(CLAMP(col.g * 255, 0, 255)); column[j * 4 + 2] += Math::fast_ftoi(CLAMP(col.b * 255, 0, 255)); @@ -319,7 +305,6 @@ void EditorProfiler::_update_plot() { } for (int j = 0; j < h * 4; j += 4) { - const int a = column[j + 3]; if (a > 0) { column[j + 0] /= a; @@ -347,7 +332,6 @@ void EditorProfiler::_update_plot() { img->create(w, h, false, Image::FORMAT_RGBA8, graph_image); if (reset_texture) { - if (graph_texture.is_null()) { graph_texture.instance(); } @@ -361,7 +345,6 @@ void EditorProfiler::_update_plot() { } void EditorProfiler::_update_frame() { - int cursor_metric = _get_cursor_index(); ERR_FAIL_INDEX(cursor_metric, frame_metrics.size()); @@ -375,7 +358,6 @@ void EditorProfiler::_update_frame() { int dtime = display_time->get_selected(); for (int i = 0; i < m.categories.size(); i++) { - TreeItem *category = variables->create_item(root); category->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); category->set_editable(0, true); @@ -418,7 +400,6 @@ void EditorProfiler::_update_frame() { } void EditorProfiler::_activate_pressed() { - if (activate->is_pressed()) { activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); @@ -430,13 +411,11 @@ void EditorProfiler::_activate_pressed() { } void EditorProfiler::_clear_pressed() { - clear(); _update_plot(); } void EditorProfiler::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { activate->set_icon(get_theme_icon("Play", "EditorIcons")); clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); @@ -444,11 +423,9 @@ void EditorProfiler::_notification(int p_what) { } void EditorProfiler::_graph_tex_draw() { - if (last_metric < 0) return; if (seeking) { - int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); if (frame < 0) @@ -460,7 +437,6 @@ void EditorProfiler::_graph_tex_draw() { } if (hover_metric != -1 && frame_metrics[hover_metric].valid) { - int max_frames = frame_metrics.size(); int frame = frame_metrics[hover_metric].frame_number - (frame_metrics[last_metric].frame_number - max_frames + 1); if (frame < 0) @@ -473,7 +449,6 @@ void EditorProfiler::_graph_tex_draw() { } void EditorProfiler::_graph_tex_mouse_exit() { - hover_metric = -1; graph->update(); } @@ -487,7 +462,6 @@ void EditorProfiler::_cursor_metric_changed(double) { } void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { - if (last_metric < 0) return; @@ -498,7 +472,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { if ( (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) || (mm.is_valid())) { - int x = me->get_position().x; x = x * frame_metrics.size() / graph->get_size().width; @@ -519,7 +492,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } if (show_hover) { - hover_metric = metric; } else { @@ -533,7 +505,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { //metric may be invalid, so look for closest metric that is valid, this makes snap feel better bool valid = false; for (int i = 0; i < frame_metrics.size(); i++) { - if (frame_metrics[metric].valid) { valid = true; break; @@ -568,7 +539,6 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } int EditorProfiler::_get_cursor_index() const { - if (last_metric < 0) return 0; if (!frame_metrics[last_metric].valid) @@ -585,25 +555,21 @@ int EditorProfiler::_get_cursor_index() const { } void EditorProfiler::disable_seeking() { - seeking = false; graph->update(); } void EditorProfiler::_combo_changed(int) { - _update_frame(); _update_plot(); } void EditorProfiler::_bind_methods() { - ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable"))); ADD_SIGNAL(MethodInfo("break_request")); } void EditorProfiler::set_enabled(bool p_enable) { - activate->set_disabled(!p_enable); } @@ -623,7 +589,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { const Vector<EditorProfiler::Metric::Category> &categories = frame_metrics[0].categories; for (int j = 0; j < categories.size(); j++) { - const EditorProfiler::Metric::Category &c = categories[j]; signatures.push_back(c.signature); @@ -640,7 +605,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { int index = last_metric; for (int i = 0; i < frame_metrics.size(); i++) { - ++index; if (index >= frame_metrics.size()) { @@ -654,7 +618,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { const Vector<EditorProfiler::Metric::Category> &frame_cat = frame_metrics[index].categories; for (int j = 0; j < frame_cat.size(); j++) { - const EditorProfiler::Metric::Category &c = frame_cat[j]; values.write[it++] = String::num_real(c.total_time); @@ -669,7 +632,6 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const { } EditorProfiler::EditorProfiler() { - HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); activate = memnew(Button); diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 4afd2c8302..aa2ef58db4 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -41,12 +41,10 @@ #include "scene/gui/tree.h" class EditorProfiler : public VBoxContainer { - GDCLASS(EditorProfiler, VBoxContainer); public: struct Metric { - bool valid; int frame_number; @@ -56,13 +54,11 @@ public: float physics_frame_time; struct Category { - StringName signature; String name; float total_time; //total for category struct Item { - StringName signature; String name; String script; diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 589ef0d64e..e1bd00f6f6 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -35,7 +35,6 @@ #include "editor/editor_settings.h" void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { - ++last_metric; if (last_metric >= frame_metrics.size()) last_metric = 0; @@ -60,7 +59,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { } if (name[0] == '>') { - stack.push_back(full_name + "/"); } @@ -83,7 +81,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { updating_frame = false; if (frame_delay->is_stopped()) { - frame_delay->set_wait_time(0.1); frame_delay->start(); } @@ -95,7 +92,6 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { } void EditorVisualProfiler::clear() { - int metric_size = EditorSettings::get_singleton()->get("debugger/profiler_frame_history_size"); metric_size = CLAMP(metric_size, 60, 1024); frame_metrics.clear(); @@ -114,7 +110,6 @@ void EditorVisualProfiler::clear() { } String EditorVisualProfiler::_get_time_as_text(float p_time) { - int dmode = display_mode->get_selected(); if (dmode == DISPLAY_FRAME_TIME) { @@ -127,7 +122,6 @@ String EditorVisualProfiler::_get_time_as_text(float p_time) { } Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signature) const { - Color bc = get_theme_color("error_color", "Editor"); double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF)); Color c; @@ -136,7 +130,6 @@ Color EditorVisualProfiler::_get_color_from_signature(const StringName &p_signat } void EditorVisualProfiler::_item_selected() { - if (updating_frame) return; @@ -148,7 +141,6 @@ void EditorVisualProfiler::_item_selected() { } void EditorVisualProfiler::_update_plot() { - int w = graph->get_size().width; int h = graph->get_size().height; @@ -188,7 +180,6 @@ void EditorVisualProfiler::_update_plot() { } if (highest_cpu > 0 || highest_gpu > 0) { - if (frame_relative->is_pressed()) { highest_cpu = MAX(graph_limit, highest_cpu); highest_gpu = MAX(graph_limit, highest_gpu); @@ -229,7 +220,6 @@ void EditorVisualProfiler::_update_plot() { next = current + 1; //just because for loop must work for (int j = current; j < next; j++) { - //wrap int idx = last_metric + 1 + j; while (idx >= frame_metrics.size()) { @@ -262,7 +252,6 @@ void EditorVisualProfiler::_update_plot() { //plot CPU for (int j = 0; j < h; j++) { - uint8_t r, g, b; if (column_cpu[j].a == 0) { @@ -283,7 +272,6 @@ void EditorVisualProfiler::_update_plot() { } //plot GPU for (int j = 0; j < h; j++) { - uint8_t r, g, b; if (column_gpu[j].a == 0) { @@ -310,7 +298,6 @@ void EditorVisualProfiler::_update_plot() { img->create(w, h, false, Image::FORMAT_RGBA8, graph_image); if (reset_texture) { - if (graph_texture.is_null()) { graph_texture.instance(); } @@ -324,7 +311,6 @@ void EditorVisualProfiler::_update_plot() { } void EditorVisualProfiler::_update_frame(bool p_focus_selected) { - int cursor_metric = _get_cursor_index(); Ref<Texture> track_icon = get_theme_icon("TrackColor", "EditorIcons"); @@ -343,7 +329,6 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { TreeItem *ensure_selected = nullptr; for (int i = 1; i < m.areas.size() - 1; i++) { - TreeItem *parent = stack.size() ? stack.back()->get() : root; String name = m.areas[i].name; @@ -416,7 +401,6 @@ void EditorVisualProfiler::_update_frame(bool p_focus_selected) { } void EditorVisualProfiler::_activate_pressed() { - if (activate->is_pressed()) { activate->set_icon(get_theme_icon("Stop", "EditorIcons")); activate->set_text(TTR("Stop")); @@ -429,13 +413,11 @@ void EditorVisualProfiler::_activate_pressed() { } void EditorVisualProfiler::_clear_pressed() { - clear(); _update_plot(); } void EditorVisualProfiler::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { activate->set_icon(get_theme_icon("Play", "EditorIcons")); clear_button->set_icon(get_theme_icon("Clear", "EditorIcons")); @@ -443,12 +425,10 @@ void EditorVisualProfiler::_notification(int p_what) { } void EditorVisualProfiler::_graph_tex_draw() { - if (last_metric < 0) return; Ref<Font> font = get_theme_font("font", "Label"); if (seeking) { - int max_frames = frame_metrics.size(); int frame = cursor_metric_edit->get_value() - (frame_metrics[last_metric].frame_number - max_frames + 1); if (frame < 0) @@ -503,7 +483,6 @@ void EditorVisualProfiler::_graph_tex_draw() { } void EditorVisualProfiler::_graph_tex_mouse_exit() { - hover_metric = -1; graph->update(); } @@ -517,7 +496,6 @@ void EditorVisualProfiler::_cursor_metric_changed(double) { } void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { - if (last_metric < 0) return; @@ -528,7 +506,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { if ( (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) || (mm.is_valid())) { - int half_w = graph->get_size().width / 2; int x = me->get_position().x; if (x > half_w) { @@ -553,7 +530,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } if (show_hover) { - hover_metric = metric; } else { @@ -567,7 +543,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { //metric may be invalid, so look for closest metric that is valid, this makes snap feel better bool valid = false; for (int i = 0; i < frame_metrics.size(); i++) { - if (frame_metrics[metric].valid) { valid = true; break; @@ -607,7 +582,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { int last_valid = -1; bool found = false; for (int i = 0; i < area_count - 1; i++) { - if (areas[i].name[0] != '<' && areas[i].name[0] != '>') { last_valid = i; } @@ -636,7 +610,6 @@ void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { } int EditorVisualProfiler::_get_cursor_index() const { - if (last_metric < 0) return 0; if (!frame_metrics[last_metric].valid) @@ -653,24 +626,20 @@ int EditorVisualProfiler::_get_cursor_index() const { } void EditorVisualProfiler::disable_seeking() { - seeking = false; graph->update(); } void EditorVisualProfiler::_combo_changed(int) { - _update_frame(); _update_plot(); } void EditorVisualProfiler::_bind_methods() { - ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable"))); } void EditorVisualProfiler::set_enabled(bool p_enable) { - activate->set_disabled(!p_enable); } @@ -736,7 +705,6 @@ Vector<Vector<String>> EditorVisualProfiler::get_data_as_csv() const { } EditorVisualProfiler::EditorVisualProfiler() { - HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); activate = memnew(Button); diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index d3a758557c..3c1a55dc38 100644 --- a/editor/debugger/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h @@ -42,12 +42,10 @@ #include "scene/gui/tree.h" class EditorVisualProfiler : public VBoxContainer { - GDCLASS(EditorVisualProfiler, VBoxContainer); public: struct Metric { - bool valid; uint64_t frame_number; diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 3ed271c7c6..5ac62bf0ba 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -92,14 +92,12 @@ void ScriptEditorDebugger::debug_skip_breakpoints() { } void ScriptEditorDebugger::debug_next() { - ERR_FAIL_COND(!breaked); _put_msg("next", Array()); _clear_execution(); } void ScriptEditorDebugger::debug_step() { - ERR_FAIL_COND(!breaked); _put_msg("step", Array()); @@ -107,14 +105,12 @@ void ScriptEditorDebugger::debug_step() { } void ScriptEditorDebugger::debug_break() { - ERR_FAIL_COND(breaked); _put_msg("break", Array()); } void ScriptEditorDebugger::debug_continue() { - ERR_FAIL_COND(!breaked); // Allow focus stealing only if we actually run this client for security. @@ -153,7 +149,6 @@ void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) { } void ScriptEditorDebugger::_file_selected(const String &p_file) { - switch (file_dialog_purpose) { case SAVE_MONITORS_CSV: { Error err; @@ -175,10 +170,8 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { // values List<Vector<float>>::Element *E = perf_history.back(); while (E) { - Vector<float> &perf_data = E->get(); for (int i = 0; i < perf_data.size(); i++) { - line.write[i] = String::num_real(perf_data[i]); } file->store_csv_line(line); @@ -225,7 +218,6 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { } void ScriptEditorDebugger::request_remote_tree() { - _put_msg("scene:request_scene_tree", Array()); } @@ -234,7 +226,6 @@ const SceneDebuggerTree *ScriptEditorDebugger::get_remote_tree() { } void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String &p_prop, const Variant &p_value) { - Array msg; msg.push_back(p_obj_id); msg.push_back(p_prop); @@ -243,7 +234,6 @@ void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String } void ScriptEditorDebugger::request_remote_object(ObjectID p_obj_id) { - ERR_FAIL_COND(p_obj_id.is_null()); Array msg; msg.push_back(p_obj_id); @@ -268,12 +258,10 @@ void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const } void ScriptEditorDebugger::_video_mem_request() { - _put_msg("core:memory", Array()); } void ScriptEditorDebugger::_video_mem_export() { - file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog->clear_filters(); @@ -282,16 +270,13 @@ void ScriptEditorDebugger::_video_mem_export() { } Size2 ScriptEditorDebugger::get_minimum_size() const { - Size2 ms = MarginContainer::get_minimum_size(); ms.y = MAX(ms.y, 250 * EDSCALE); return ms; } void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_data) { - if (p_msg == "debug_enter") { - _put_msg("get_stack_dump", Array()); ERR_FAIL_COND(p_data.size() != 2); @@ -310,7 +295,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da inspector->clear_cache(); // Take a chance to force remote objects update. } else if (p_msg == "debug_exit") { - breaked = false; can_debug = false; _clear_execution(); @@ -320,27 +304,22 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da profiler->set_enabled(true); profiler->disable_seeking(); } else if (p_msg == "set_pid") { - ERR_FAIL_COND(p_data.size() < 1); remote_pid = p_data[0]; } else if (p_msg == "scene:click_ctrl") { - ERR_FAIL_COND(p_data.size() < 2); clicked_ctrl->set_text(p_data[0]); clicked_ctrl_type->set_text(p_data[1]); } else if (p_msg == "scene:scene_tree") { - scene_tree->nodes.clear(); scene_tree->deserialize(p_data); emit_signal("remote_tree_updated"); _update_buttons_state(); } else if (p_msg == "scene:inspect_object") { - ObjectID id = inspector->add_object(p_data); if (id.is_valid()) emit_signal("remote_object_updated", id); } else if (p_msg == "memory:usage") { - vmem_tree->clear(); TreeItem *root = vmem_tree->create_item(); DebuggerMarshalls::ResourceUsage usage; @@ -349,7 +328,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da int total = 0; for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { - TreeItem *it = vmem_tree->create_item(root); String type = E->get().type; int bytes = E->get().vram; @@ -367,7 +345,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da vmem_total->set_text(String::humanize_size(total)); } else if (p_msg == "stack_dump") { - DebuggerMarshalls::ScriptStackDump stack; stack.deserialize(p_data); @@ -376,7 +353,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da TreeItem *r = stack_dump->create_item(); for (int i = 0; i < stack.frames.size(); i++) { - TreeItem *s = stack_dump->create_item(r); Dictionary d; d["frame"] = i; @@ -392,11 +368,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da s->select(0); } } else if (p_msg == "stack_frame_vars") { - inspector->clear_stack_variables(); } else if (p_msg == "stack_frame_var") { - inspector->add_stack_variable(p_data); } else if (p_msg == "output") { @@ -433,7 +407,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da for (int i = 0; i < p_data.size(); i++) { p.write[i] = p_data[i]; if (i < perf_items.size()) { - const float value = p[i]; String label = rtos(value); String tooltip = label; @@ -480,7 +453,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da visual_profiler->add_frame_metric(metric); } else if (p_msg == "error") { - DebuggerMarshalls::OutputError oe; ERR_FAIL_COND_MSG(oe.deserialize(p_data) == false, "Failed to deserialize error message"); @@ -566,7 +538,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da // of the stack trace (script, method, line). const ScriptLanguage::StackInfo *infos = oe.callstack.ptr(); for (unsigned int i = 0; i < (unsigned int)oe.callstack.size(); i++) { - TreeItem *stack_trace = error_tree->create_item(error); Array meta; @@ -639,7 +610,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } for (int i = 0; i < frame.servers.size(); i++) { - const DebuggerMarshalls::ServerInfo &srv = frame.servers[i]; EditorProfiler::Metric::Category c; const String name = srv.name; @@ -648,7 +618,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da c.total_time = 0; c.signature = "categ::" + name; for (int j = 0; j < srv.functions.size(); j++) { - EditorProfiler::Metric::Category::Item item; item.calls = 1; item.line = 0; @@ -669,7 +638,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da funcs.name = "Script Functions"; funcs.signature = "script_functions"; for (int i = 0; i < frame.script_functions.size(); i++) { - int signature = frame.script_functions[i].sig_id; int calls = frame.script_functions[i].call_count; float total = frame.script_functions[i].total_time; @@ -677,7 +645,6 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da EditorProfiler::Metric::Category::Item item; if (profiler_signature.has(signature)) { - item.signature = profiler_signature[signature]; String name = profiler_signature[signature]; @@ -745,15 +712,12 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType } void ScriptEditorDebugger::_performance_select() { - perf_draw->update(); } void ScriptEditorDebugger::_performance_draw() { - Vector<int> which; for (int i = 0; i < perf_items.size(); i++) { - if (perf_items[i]->is_checked(0)) which.push_back(i); } @@ -777,7 +741,6 @@ void ScriptEditorDebugger::_performance_draw() { int point_sep = 5; Size2i s = Size2i(perf_draw->get_size()) / Size2i(cols, rows); for (int i = 0; i < which.size(); i++) { - Point2i p(i % cols, i / cols); Rect2i r(p * s, s); r.position += Point2(margin, margin); @@ -803,7 +766,6 @@ void ScriptEditorDebugger::_performance_draw() { List<Vector<float>>::Element *E = perf_history.front(); float prev = -1; while (from >= 0 && E) { - float m = perf_max[pi]; if (m == 0) m = 0.00001; @@ -820,11 +782,8 @@ void ScriptEditorDebugger::_performance_draw() { } void ScriptEditorDebugger::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_theme_icon("DebugSkipBreakpointsOff", "EditorIcons")); copy->set_icon(get_theme_icon("ActionCopy", "EditorIcons")); @@ -843,9 +802,7 @@ void ScriptEditorDebugger::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { - if (is_session_active()) { - peer->poll(); if (camera_override == CameraOverride::OVERRIDE_2D) { @@ -886,7 +843,6 @@ void ScriptEditorDebugger::_notification(int p_what) { const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; 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) { _stop_and_notify(); @@ -903,7 +859,6 @@ void ScriptEditorDebugger::_notification(int p_what) { }; } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - if (tabs->has_theme_stylebox_override("panel")) { tabs->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("DebuggerPanel", "EditorStyles")); } @@ -934,7 +889,6 @@ void ScriptEditorDebugger::_clear_execution() { } void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { - error_count = 0; warning_count = 0; stop(); @@ -944,7 +898,6 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { perf_history.clear(); for (int i = 0; i < Performance::MONITOR_MAX; i++) { - perf_max.write[i] = 0; } @@ -978,7 +931,6 @@ void ScriptEditorDebugger::_stop_and_notify() { } void ScriptEditorDebugger::stop() { - set_process(false); breaked = false; can_debug = false; @@ -1003,7 +955,6 @@ void ScriptEditorDebugger::stop() { } void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { - Array data; data.push_back(p_enable); switch (p_type) { @@ -1031,14 +982,12 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { } void ScriptEditorDebugger::_profiler_seeked() { - if (breaked) return; debug_break(); } void ScriptEditorDebugger::_stack_dump_frame_selected() { - emit_signal("stack_frame_selected"); int frame = get_stack_script_frame(); @@ -1053,7 +1002,6 @@ void ScriptEditorDebugger::_stack_dump_frame_selected() { } void ScriptEditorDebugger::_export_csv() { - file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_dialog_purpose = SAVE_MONITORS_CSV; @@ -1067,7 +1015,6 @@ String ScriptEditorDebugger::get_var_value(const String &p_var) const { } int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { - const int *r = node_path_cache.getptr(p_path); if (r) return *r; @@ -1084,7 +1031,6 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { } int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { - Map<String, int>::Element *E = res_path_cache.find(p_path); if (E) @@ -1102,7 +1048,6 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { } void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_name, VARIANT_ARG_DECLARE) { - if (!p_base || !live_debug || !is_session_active() || !editor->get_edited_scene()) return; @@ -1117,7 +1062,6 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n } if (node) { - NodePath path = editor->get_edited_scene()->get_path_to(node); int pathid = _get_node_path_cache(path); @@ -1136,7 +1080,6 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n Resource *res = Object::cast_to<Resource>(p_base); if (res && res->get_path() != String()) { - String respath = res->get_path(); int pathid = _get_res_path_cache(respath); @@ -1154,21 +1097,18 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n } void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p_property, const Variant &p_value) { - if (!p_base || !live_debug || !editor->get_edited_scene()) return; Node *node = Object::cast_to<Node>(p_base); if (node) { - NodePath path = editor->get_edited_scene()->get_path_to(node); int pathid = _get_node_path_cache(path); if (p_value.is_ref()) { Ref<Resource> res = p_value; if (res.is_valid() && res->get_path() != String()) { - Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1176,7 +1116,6 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p _put_msg("scene:live_node_prop_res", msg); } } else { - Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1190,14 +1129,12 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p Resource *res = Object::cast_to<Resource>(p_base); if (res && res->get_path() != String()) { - String respath = res->get_path(); int pathid = _get_res_path_cache(respath); if (p_value.is_ref()) { Ref<Resource> res2 = p_value; if (res2.is_valid() && res2->get_path() != String()) { - Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1205,7 +1142,6 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p _put_msg("scene:live_res_prop_res", msg); } } else { - Array msg; msg.push_back(pathid); msg.push_back(p_property); @@ -1242,12 +1178,10 @@ int ScriptEditorDebugger::get_stack_script_frame() const { } void ScriptEditorDebugger::set_live_debugging(bool p_enable) { - live_debug = p_enable; } void ScriptEditorDebugger::_live_edit_set() { - if (!is_session_active() || !editor_remote_tree) return; @@ -1271,7 +1205,6 @@ void ScriptEditorDebugger::_live_edit_set() { } void ScriptEditorDebugger::_live_edit_clear() { - NodePath np = NodePath("/root"); editor->get_editor_data().set_edited_scene_live_edit_root(np); @@ -1279,7 +1212,6 @@ void ScriptEditorDebugger::_live_edit_clear() { } void ScriptEditorDebugger::update_live_edit_root() { - NodePath np = editor->get_editor_data().get_edited_scene_live_edit_root(); Array msg; @@ -1293,7 +1225,6 @@ void ScriptEditorDebugger::update_live_edit_root() { } void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, const String &p_type, const String &p_name) { - if (live_debug) { Array msg; msg.push_back(p_parent); @@ -1304,7 +1235,6 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, cons } void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, const String &p_path, const String &p_name) { - if (live_debug) { Array msg; msg.push_back(p_parent); @@ -1314,7 +1244,6 @@ void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, co } } void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) { - if (live_debug) { Array msg; msg.push_back(p_at); @@ -1322,7 +1251,6 @@ void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) { } } void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) { - if (live_debug) { Array msg; msg.push_back(p_at); @@ -1331,7 +1259,6 @@ void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, } } void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) { - if (live_debug) { Array msg; msg.push_back(p_id); @@ -1341,7 +1268,6 @@ void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath } } void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) { - if (live_debug) { Array msg; msg.push_back(p_at); @@ -1350,7 +1276,6 @@ void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const } } void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) { - if (live_debug) { Array msg; msg.push_back(p_at); @@ -1366,7 +1291,6 @@ CameraOverride ScriptEditorDebugger::get_camera_override() const { } void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) { - if (p_override == CameraOverride::OVERRIDE_2D && camera_override != CameraOverride::OVERRIDE_2D) { Array msg; msg.push_back(true); @@ -1389,7 +1313,6 @@ void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) { } void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool p_enabled) { - Array msg; msg.push_back(p_path); msg.push_back(p_line); @@ -1398,7 +1321,6 @@ void ScriptEditorDebugger::set_breakpoint(const String &p_path, int p_line, bool } void ScriptEditorDebugger::reload_scripts() { - _put_msg("reload_scripts", Array()); } @@ -1426,7 +1348,6 @@ void ScriptEditorDebugger::_error_selected() { } void ScriptEditorDebugger::_expand_errors_list() { - TreeItem *root = error_tree->get_root(); if (!root) return; @@ -1439,7 +1360,6 @@ void ScriptEditorDebugger::_expand_errors_list() { } void ScriptEditorDebugger::_collapse_errors_list() { - TreeItem *root = error_tree->get_root(); if (!root) return; @@ -1452,7 +1372,6 @@ void ScriptEditorDebugger::_collapse_errors_list() { } void ScriptEditorDebugger::_clear_errors_list() { - error_tree->clear(); error_count = 0; warning_count = 0; @@ -1460,7 +1379,6 @@ void ScriptEditorDebugger::_clear_errors_list() { // Right click on specific file(s) or folder(s). void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) { - item_menu->clear(); item_menu->set_size(Size2(1, 1)); @@ -1508,7 +1426,6 @@ void ScriptEditorDebugger::_tab_changed(int p_tab) { } void ScriptEditorDebugger::_bind_methods() { - ClassDB::bind_method(D_METHOD("live_debug_create_node"), &ScriptEditorDebugger::live_debug_create_node); ClassDB::bind_method(D_METHOD("live_debug_instance_node"), &ScriptEditorDebugger::live_debug_instance_node); ClassDB::bind_method(D_METHOD("live_debug_remove_node"), &ScriptEditorDebugger::live_debug_remove_node); @@ -1533,7 +1450,6 @@ void ScriptEditorDebugger::_bind_methods() { } ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { - editor = p_editor; tabs = memnew(TabContainer); @@ -1729,7 +1645,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { TreeItem *root = perf_monitors->create_item(); perf_monitors->set_hide_root(true); for (int i = 0; i < Performance::MONITOR_MAX; i++) { - String n = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)); Performance::MonitorType mtype = Performance::get_singleton()->get_monitor_type(Performance::Monitor(i)); String base = n.get_slice("/", 0); @@ -1866,7 +1781,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { } ScriptEditorDebugger::~ScriptEditorDebugger() { - if (peer.is_valid()) { peer->close(); peer.unref(); diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index a08a7c67c2..2984051aa1 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -55,7 +55,6 @@ class EditorNetworkProfiler; class SceneDebuggerTree; class ScriptEditorDebugger : public MarginContainer { - GDCLASS(ScriptEditorDebugger, MarginContainer); friend class EditorDebuggerNode; diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 2302fb0780..9c8a7eaef0 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -37,7 +37,6 @@ #include "scene/gui/margin_container.h" void DependencyEditor::_searched(const String &p_path) { - Map<String, String> dep_rename; dep_rename[replacing] = p_path; @@ -48,7 +47,6 @@ void DependencyEditor::_searched(const String &p_path) { } void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); replacing = ti->get_text(1); @@ -64,13 +62,11 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) { } 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); } for (int i = 0; i < efsd->get_file_count(); i++) { - String file = efsd->get_file(i); if (!candidates.has(file)) continue; @@ -78,7 +74,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String String path = efsd->get_file_path(i); for (Map<String, String>::Element *E = candidates[file].front(); E; E = E->next()) { - if (E->get() == String()) { E->get() = path; continue; @@ -100,7 +95,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String int current_score = 0; for (int j = 0; j < lostv.size(); j++) { - if (j < existingv.size() && lostv[j] == existingv[j]) { existing_score++; } @@ -110,7 +104,6 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String } if (current_score > existing_score) { - //if it was the same, could track distance to new path but.. E->get() = path; //replace by more accurate @@ -120,14 +113,12 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String } void DependencyEditor::_fix_all() { - if (!EditorFileSystem::get_singleton()->get_filesystem()) return; Map<String, Map<String, String>> candidates; for (List<String>::Element *E = missing.front(); E; E = E->next()) { - String base = E->get().get_file(); if (!candidates.has(base)) { candidates[base] = Map<String, String>(); @@ -141,9 +132,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, String>::Element *F = E->get().front(); F; F = F->next()) { - if (F->get() != String()) { remaps[F->key()] = F->get(); } @@ -151,7 +140,6 @@ void DependencyEditor::_fix_all() { } if (remaps.size()) { - ResourceLoader::rename_dependencies(editing, remaps); _update_list(); @@ -160,12 +148,10 @@ void DependencyEditor::_fix_all() { } void DependencyEditor::_update_file() { - EditorFileSystem::get_singleton()->update_file(editing); } void DependencyEditor::_update_list() { - List<String> deps; ResourceLoader::get_dependencies(editing, &deps, true); @@ -179,7 +165,6 @@ void DependencyEditor::_update_list() { bool broken = false; for (List<String>::Element *E = deps.front(); E; E = E->next()) { - TreeItem *item = tree->create_item(root); String n = E->get(); @@ -214,7 +199,6 @@ void DependencyEditor::_update_list() { } void DependencyEditor::edit(const String &p_path) { - editing = p_path; set_title(TTR("Dependencies For:") + " " + p_path.get_file()); @@ -232,7 +216,6 @@ void DependencyEditor::_bind_methods() { } DependencyEditor::DependencyEditor() { - VBoxContainer *vb = memnew(VBoxContainer); vb->set_name(TTR("Dependencies")); add_child(vb); @@ -271,7 +254,6 @@ DependencyEditor::DependencyEditor() { ///////////////////////////////////// void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos) { - file_options->clear(); file_options->set_size(Size2(1, 1)); if (p_item >= 0) { @@ -283,7 +265,6 @@ void DependencyEditorOwners::_list_rmb_select(int p_item, const Vector2 &p_pos) } void DependencyEditorOwners::_select_file(int p_idx) { - String fpath = owners->get_item_text(p_idx); if (ResourceLoader::get_resource_type(fpath) == "PackedScene") { @@ -294,7 +275,6 @@ void DependencyEditorOwners::_select_file(int p_idx) { } void DependencyEditorOwners::_file_option(int p_option) { - switch (p_option) { case FILE_OPEN: { int idx = owners->get_current(); @@ -309,7 +289,6 @@ void DependencyEditorOwners::_bind_methods() { } void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { - if (!efsd) return; @@ -318,7 +297,6 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { } for (int i = 0; i < efsd->get_file_count(); i++) { - Vector<String> deps = efsd->get_file_deps(i); bool found = false; for (int j = 0; j < deps.size(); j++) { @@ -337,7 +315,6 @@ void DependencyEditorOwners::_fill_owners(EditorFileSystemDirectory *efsd) { } void DependencyEditorOwners::show(const String &p_path) { - editing = p_path; owners->clear(); _fill_owners(EditorFileSystem::get_singleton()->get_filesystem()); @@ -347,7 +324,6 @@ void DependencyEditorOwners::show(const String &p_path) { } DependencyEditorOwners::DependencyEditorOwners(EditorNode *p_editor) { - editor = p_editor; file_options = memnew(PopupMenu); @@ -479,7 +455,6 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector< } void DependencyRemoveDialog::ok_pressed() { - for (int i = 0; i < files_to_delete.size(); ++i) { if (ResourceCache::has(files_to_delete[i])) { Resource *res = ResourceCache::get(files_to_delete[i]); @@ -528,7 +503,6 @@ void DependencyRemoveDialog::ok_pressed() { for (int i = 0; i < files_to_delete.size(); ++i) EditorFileSystem::get_singleton()->update_file(files_to_delete[i]); } else { - for (int i = 0; i < dirs_to_delete.size(); ++i) { String path = OS::get_singleton()->get_resource_dir() + dirs_to_delete[i].replace_first("res://", "/"); print_verbose("Moving to trash: " + path); @@ -568,7 +542,6 @@ void DependencyRemoveDialog::_bind_methods() { } DependencyRemoveDialog::DependencyRemoveDialog() { - get_ok()->set_text(TTR("Remove")); VBoxContainer *vb = memnew(VBoxContainer); @@ -586,7 +559,6 @@ DependencyRemoveDialog::DependencyRemoveDialog() { ////////////// void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Vector<String> &report) { - mode = p_mode; for_file = p_for_file; set_title(TTR("Error loading:") + " " + p_for_file.get_file()); @@ -594,7 +566,6 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve TreeItem *root = files->create_item(nullptr); for (int i = 0; i < report.size(); i++) { - String dep; String type = "Object"; dep = report[i].get_slice("::", 0); @@ -612,7 +583,6 @@ void DependencyErrorDialog::show(Mode p_mode, const String &p_for_file, const Ve } void DependencyErrorDialog::ok_pressed() { - switch (mode) { case MODE_SCENE: EditorNode::get_singleton()->load_scene(for_file, true); @@ -624,12 +594,10 @@ void DependencyErrorDialog::ok_pressed() { } void DependencyErrorDialog::custom_action(const String &) { - EditorNode::get_singleton()->fix_dependencies(for_file); } DependencyErrorDialog::DependencyErrorDialog() { - VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -654,7 +622,6 @@ DependencyErrorDialog::DependencyErrorDialog() { ////////////////////////////////////////////////////////////////////// void OrphanResourcesDialog::ok_pressed() { - paths.clear(); _find_to_delete(files->get_root(), paths); @@ -666,14 +633,12 @@ void OrphanResourcesDialog::ok_pressed() { } bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent) { - if (!efsd) return false; bool has_children = false; for (int i = 0; i < efsd->get_subdir_count(); i++) { - TreeItem *dir_item = nullptr; if (p_parent) { dir_item = files->create_item(p_parent); @@ -692,17 +657,14 @@ bool OrphanResourcesDialog::_fill_owners(EditorFileSystemDirectory *efsd, HashMa } for (int i = 0; i < efsd->get_file_count(); i++) { - if (!p_parent) { Vector<String> deps = efsd->get_file_deps(i); for (int j = 0; j < deps.size(); j++) { - if (!refs.has(deps[j])) { refs[deps[j]] = 1; } } } else { - String path = efsd->get_file_path(i); if (!refs.has(path)) { TreeItem *ti = files->create_item(p_parent); @@ -737,15 +699,12 @@ void OrphanResourcesDialog::refresh() { } void OrphanResourcesDialog::show() { - refresh(); popup_centered_ratio(); } void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &paths) { - while (p_item) { - if (p_item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK && p_item->is_checked(0)) { paths.push_back(p_item->get_metadata(0)); } @@ -759,10 +718,8 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path } void OrphanResourcesDialog::_delete_confirm() { - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); for (List<String>::Element *E = paths.front(); E; E = E->next()) { - da->remove(E->get()); EditorFileSystem::get_singleton()->update_file(E->get()); } @@ -771,7 +728,6 @@ void OrphanResourcesDialog::_delete_confirm() { } void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); String path = ti->get_metadata(0); @@ -782,7 +738,6 @@ void OrphanResourcesDialog::_bind_methods() { } OrphanResourcesDialog::OrphanResourcesDialog() { - set_title(TTR("Orphan Resource Explorer")); delete_confirm = memnew(ConfirmationDialog); get_ok()->set_text(TTR("Delete")); diff --git a/editor/dictionary_property_edit.cpp b/editor/dictionary_property_edit.cpp index 7169986b14..c92f62cf58 100644 --- a/editor/dictionary_property_edit.cpp +++ b/editor/dictionary_property_edit.cpp @@ -40,12 +40,10 @@ void DictionaryPropertyEdit::_notif_changev(const String &p_v) { } void DictionaryPropertyEdit::_set_key(const Variant &p_old_key, const Variant &p_new_key) { - // TODO: Set key of a dictionary is not allowed yet } void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_value) { - Dictionary dict = get_dictionary(); dict[p_key] = p_value; Object *o = ObjectDB::get_instance(obj); @@ -56,7 +54,6 @@ void DictionaryPropertyEdit::_set_value(const Variant &p_key, const Variant &p_v } Variant DictionaryPropertyEdit::get_dictionary() const { - Object *o = ObjectDB::get_instance(obj); if (!o) return Dictionary(); @@ -67,7 +64,6 @@ Variant DictionaryPropertyEdit::get_dictionary() const { } void DictionaryPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) const { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); @@ -87,13 +83,11 @@ void DictionaryPropertyEdit::_get_property_list(List<PropertyInfo> *p_list) cons } void DictionaryPropertyEdit::edit(Object *p_obj, const StringName &p_prop) { - property = p_prop; obj = p_obj->get_instance_id(); } Node *DictionaryPropertyEdit::get_node() { - Object *o = ObjectDB::get_instance(obj); if (!o) return nullptr; @@ -106,7 +100,6 @@ bool DictionaryPropertyEdit::_dont_undo_redo() { } void DictionaryPropertyEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_key"), &DictionaryPropertyEdit::_set_key); ClassDB::bind_method(D_METHOD("_set_value"), &DictionaryPropertyEdit::_set_value); ClassDB::bind_method(D_METHOD("_notif_change"), &DictionaryPropertyEdit::_notif_change); @@ -115,7 +108,6 @@ void DictionaryPropertyEdit::_bind_methods() { } bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_value) { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); keys.sort(); @@ -126,7 +118,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val String type = pn.substr(slash + 2, pn.length()); int index = pn.substr(0, slash).to_int(); if (type == "key" && index < keys.size()) { - const Variant &key = keys[index]; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -141,7 +132,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val } else if (type == "value" && index < keys.size()) { const Variant &key = keys[index]; if (dict.has(key)) { - Variant value = dict[key]; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -161,7 +151,6 @@ bool DictionaryPropertyEdit::_set(const StringName &p_name, const Variant &p_val } bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) const { - Dictionary dict = get_dictionary(); Array keys = dict.keys(); keys.sort(); @@ -170,7 +159,6 @@ bool DictionaryPropertyEdit::_get(const StringName &p_name, Variant &r_ret) cons int slash = pn.find(": "); if (slash != -1 && pn.length() > slash) { - String type = pn.substr(slash + 2, pn.length()); int index = pn.substr(0, slash).to_int(); diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index 310e78ee60..99ebf16697 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -44,9 +44,7 @@ #include "modules/modules_enabled.gen.h" void DocData::merge_from(const DocData &p_data) { - for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) { - ClassDoc &c = E->get(); if (!p_data.class_list.has(c.name)) @@ -59,11 +57,9 @@ void DocData::merge_from(const DocData &p_data) { c.tutorials = cf.tutorials; for (int i = 0; i < c.methods.size(); i++) { - MethodDoc &m = c.methods.write[i]; for (int j = 0; j < cf.methods.size(); j++) { - if (cf.methods[j].name != m.name) continue; if (cf.methods[j].arguments.size() != m.arguments.size()) @@ -99,11 +95,9 @@ void DocData::merge_from(const DocData &p_data) { } for (int i = 0; i < c.signals.size(); i++) { - MethodDoc &m = c.signals.write[i]; for (int j = 0; j < cf.signals.size(); j++) { - if (cf.signals[j].name != m.name) continue; const MethodDoc &mf = cf.signals[j]; @@ -114,11 +108,9 @@ void DocData::merge_from(const DocData &p_data) { } for (int i = 0; i < c.constants.size(); i++) { - ConstantDoc &m = c.constants.write[i]; for (int j = 0; j < cf.constants.size(); j++) { - if (cf.constants[j].name != m.name) continue; const ConstantDoc &mf = cf.constants[j]; @@ -129,11 +121,9 @@ void DocData::merge_from(const DocData &p_data) { } for (int i = 0; i < c.properties.size(); i++) { - PropertyDoc &p = c.properties.write[i]; for (int j = 0; j < cf.properties.size(); j++) { - if (cf.properties[j].name != p.name) continue; const PropertyDoc &pf = cf.properties[j]; @@ -144,11 +134,9 @@ void DocData::merge_from(const DocData &p_data) { } for (int i = 0; i < c.theme_properties.size(); i++) { - PropertyDoc &p = c.theme_properties.write[i]; for (int j = 0; j < cf.theme_properties.size(); j++) { - if (cf.theme_properties[j].name != p.name) continue; const PropertyDoc &pf = cf.theme_properties[j]; @@ -185,7 +173,6 @@ void DocData::remove_from(const DocData &p_data) { } static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const PropertyInfo &p_retinfo) { - if (p_retinfo.type == Variant::INT && p_retinfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { p_method.return_enum = p_retinfo.class_name; if (p_method.return_enum.begins_with("_")) //proxy class @@ -207,7 +194,6 @@ static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const Property } static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const PropertyInfo &p_arginfo) { - p_argument.name = p_arginfo.name; if (p_arginfo.type == Variant::INT && p_arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { @@ -230,7 +216,6 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr } static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) { - Variant default_value = Variant(); r_default_value_valid = false; @@ -253,7 +238,6 @@ static Variant get_documentation_default_value(const StringName &p_class_name, c } void DocData::generate(bool p_basic_types) { - List<StringName> classes; ClassDB::get_class_list(&classes); classes.sort_custom<StringName::AlphCompare>(); @@ -263,7 +247,6 @@ void DocData::generate(bool p_basic_types) { bool skip_setter_getter_methods = true; while (classes.size()) { - Set<StringName> setters_getters; String name = classes.front()->get(); @@ -361,10 +344,8 @@ void DocData::generate(bool p_basic_types) { } else if (retinfo.type == Variant::ARRAY && retinfo.hint == PROPERTY_HINT_ARRAY_TYPE) { prop.type = retinfo.hint_string + "[]"; } else if (retinfo.hint == PROPERTY_HINT_RESOURCE_TYPE) { - prop.type = retinfo.hint_string; } else if (retinfo.type == Variant::NIL && retinfo.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { - prop.type = "Variant"; } else if (retinfo.type == Variant::NIL) { prop.type = "void"; @@ -377,12 +358,10 @@ void DocData::generate(bool p_basic_types) { } if (setter != StringName()) { - setters_getters.insert(setter); } if (!found_type) { - if (E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) prop.type = E->get().hint_string; else @@ -397,7 +376,6 @@ void DocData::generate(bool p_basic_types) { method_list.sort(); for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || (E->get().name[0] == '_' && !(E->get().flags & METHOD_FLAG_VIRTUAL))) continue; //hidden, don't count @@ -428,13 +406,11 @@ void DocData::generate(bool p_basic_types) { } for (int i = -1; i < E->get().arguments.size(); i++) { - if (i == -1) { #ifdef DEBUG_METHODS_ENABLED return_doc_from_retinfo(method, E->get().return_val); #endif } else { - const PropertyInfo &arginfo = E->get().arguments[i]; ArgumentDoc argument; argument_doc_from_arginfo(argument, arginfo); @@ -456,13 +432,10 @@ void DocData::generate(bool p_basic_types) { ClassDB::get_signal_list(name, &signal_list, true); if (signal_list.size()) { - for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) { - MethodDoc signal; signal.name = EV->get().name; for (int i = 0; i < EV->get().arguments.size(); i++) { - const PropertyInfo &arginfo = EV->get().arguments[i]; ArgumentDoc argument; argument_doc_from_arginfo(argument, arginfo); @@ -478,7 +451,6 @@ void DocData::generate(bool p_basic_types) { ClassDB::get_integer_constant_list(name, &constant_list, true); for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { - ConstantDoc constant; constant.name = E->get(); constant.value = itos(ClassDB::get_integer_constant(name, E->get())); @@ -492,7 +464,6 @@ void DocData::generate(bool p_basic_types) { List<StringName> l; Theme::get_default()->get_constant_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { - PropertyDoc pd; pd.name = E->get(); pd.type = "int"; @@ -503,7 +474,6 @@ void DocData::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_color_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { - PropertyDoc pd; pd.name = E->get(); pd.type = "Color"; @@ -514,7 +484,6 @@ void DocData::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_icon_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { - PropertyDoc pd; pd.name = E->get(); pd.type = "Texture2D"; @@ -523,7 +492,6 @@ void DocData::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_font_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { - PropertyDoc pd; pd.name = E->get(); pd.type = "Font"; @@ -532,7 +500,6 @@ void DocData::generate(bool p_basic_types) { l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); for (List<StringName>::Element *E = l.front(); E; E = E->next()) { - PropertyDoc pd; pd.name = E->get(); pd.type = "StyleBox"; @@ -574,14 +541,12 @@ void DocData::generate(bool p_basic_types) { Variant::get_constructor_list(Variant::Type(i), &method_list); for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); MethodDoc method; method.name = mi.name; for (int j = 0; j < mi.arguments.size(); j++) { - PropertyInfo arginfo = mi.arguments[j]; ArgumentDoc ad; argument_doc_from_arginfo(ad, mi.arguments[j]); @@ -610,7 +575,6 @@ void DocData::generate(bool p_basic_types) { List<PropertyInfo> properties; v.get_property_list(&properties); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); PropertyDoc property; property.name = pi.name; @@ -624,7 +588,6 @@ void DocData::generate(bool p_basic_types) { Variant::get_constants_for_type(Variant::Type(i), &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - ConstantDoc constant; constant.name = E->get(); Variant value = Variant::get_constant_value(Variant::Type(i), E->get()); @@ -636,14 +599,12 @@ void DocData::generate(bool p_basic_types) { //built in constants and functions { - String cname = "@GlobalScope"; class_list[cname] = ClassDoc(); ClassDoc &c = class_list[cname]; c.name = cname; for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { - ConstantDoc cd; cd.name = GlobalConstants::get_global_constant_name(i); cd.value = itos(GlobalConstants::get_global_constant_value(i)); @@ -656,7 +617,6 @@ void DocData::generate(bool p_basic_types) { //servers (this is kind of hackish) for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { - PropertyDoc pd; Engine::Singleton &s = E->get(); if (!s.ptr) { @@ -675,9 +635,7 @@ void DocData::generate(bool p_basic_types) { //built in script reference { - for (int i = 0; i < ScriptServer::get_language_count(); i++) { - ScriptLanguage *lang = ScriptServer::get_language(i); String cname = "@" + lang->get_name(); class_list[cname] = ClassDoc(); @@ -689,7 +647,6 @@ void DocData::generate(bool p_basic_types) { lang->get_public_functions(&minfo); for (List<MethodInfo>::Element *E = minfo.front(); E; E = E->next()) { - MethodInfo &mi = E->get(); MethodDoc md; md.name = mi.name; @@ -703,7 +660,6 @@ void DocData::generate(bool p_basic_types) { return_doc_from_retinfo(md, mi.return_val); for (int j = 0; j < mi.arguments.size(); j++) { - ArgumentDoc ad; argument_doc_from_arginfo(ad, mi.arguments[j]); @@ -723,7 +679,6 @@ void DocData::generate(bool p_basic_types) { lang->get_public_constants(&cinfo); for (List<Pair<String, Variant>>::Element *E = cinfo.front(); E; E = E->next()) { - ConstantDoc cd; cd.name = E->get().first; cd.value = E->get().second; @@ -734,16 +689,12 @@ void DocData::generate(bool p_basic_types) { } static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) { - String section = parser->get_node_name(); String element = section.substr(0, section.length() - 1); while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser->get_node_name() == element) { - DocData::MethodDoc method; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); method.name = parser->get_attribute_value("name"); @@ -751,19 +702,15 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & method.qualifiers = parser->get_attribute_value("qualifiers"); while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser->get_node_name(); if (name == "return") { - ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT); method.return_type = parser->get_attribute_value("type"); if (parser->has_attribute("enum")) { method.return_enum = parser->get_attribute_value("enum"); } } else if (name == "argument") { - DocData::ArgumentDoc argument; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); argument.name = parser->get_attribute_value("name"); @@ -776,7 +723,6 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & method.arguments.push_back(argument); } else if (name == "description") { - parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) method.description = parser->get_node_data(); @@ -800,7 +746,6 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & } Error DocData::load_classes(const String &p_dir) { - Error err; DirAccessRef da = DirAccess::open(p_dir, &err); if (!da) { @@ -827,7 +772,6 @@ Error DocData::load_classes(const String &p_dir) { return OK; } Error DocData::erase_classes(const String &p_dir) { - Error err; DirAccessRef da = DirAccess::open(p_dir, &err); if (!da) { @@ -855,11 +799,9 @@ Error DocData::erase_classes(const String &p_dir) { return OK; } Error DocData::_load(Ref<XMLParser> parser) { - Error err = OK; while ((err = parser->read()) == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT && parser->get_node_name() == "?xml") { parser->skip_section(); } @@ -879,13 +821,10 @@ Error DocData::_load(Ref<XMLParser> parser) { c.inherits = parser->get_attribute_value("inherits"); while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name2 = parser->get_node_name(); if (name2 == "brief_description") { - parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) c.brief_description = parser->get_node_data(); @@ -896,13 +835,10 @@ Error DocData::_load(Ref<XMLParser> parser) { c.description = parser->get_node_data(); } else if (name2 == "tutorials") { while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name3 = parser->get_node_name(); if (name3 == "link") { - parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) c.tutorials.push_back(parser->get_node_data().strip_edges()); @@ -913,24 +849,18 @@ Error DocData::_load(Ref<XMLParser> parser) { break; // End of <tutorials>. } } else if (name2 == "methods") { - Error err2 = _parse_methods(parser, c.methods); ERR_FAIL_COND_V(err2, err2); } else if (name2 == "signals") { - Error err2 = _parse_methods(parser, c.signals); ERR_FAIL_COND_V(err2, err2); } else if (name2 == "members") { - while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name3 = parser->get_node_name(); if (name3 == "member") { - PropertyDoc prop2; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); @@ -958,15 +888,11 @@ Error DocData::_load(Ref<XMLParser> parser) { } } else if (name2 == "theme_items") { - while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name3 = parser->get_node_name(); if (name3 == "theme_item") { - PropertyDoc prop2; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); @@ -988,15 +914,11 @@ Error DocData::_load(Ref<XMLParser> parser) { } } else if (name2 == "constants") { - while (parser->read() == OK) { - if (parser->get_node_type() == XMLParser::NODE_ELEMENT) { - String name3 = parser->get_node_name(); if (name3 == "constant") { - ConstantDoc constant2; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); constant2.name = parser->get_attribute_value("name"); @@ -1020,7 +942,6 @@ Error DocData::_load(Ref<XMLParser> parser) { } } else { - ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name2 + "."); } @@ -1033,7 +954,6 @@ Error DocData::_load(Ref<XMLParser> parser) { } static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { - if (p_string == "") return; String tab; @@ -1043,9 +963,7 @@ static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) } Error DocData::save_classes(const String &p_default_path, const Map<String, String> &p_class_path) { - for (Map<String, ClassDoc>::Element *E = class_list.front(); E; E = E->next()) { - ClassDoc &c = E->get(); String save_path; @@ -1089,7 +1007,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri c.methods.sort(); for (int i = 0; i < c.methods.size(); i++) { - const MethodDoc &m = c.methods[i]; String qualifiers; @@ -1099,7 +1016,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 2, "<method name=\"" + m.name + "\"" + qualifiers + ">"); if (m.return_type != "") { - String enum_text; if (m.return_enum != String()) { enum_text = " enum=\"" + m.return_enum + "\""; @@ -1109,7 +1025,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } for (int j = 0; j < m.arguments.size(); j++) { - const ArgumentDoc &a = m.arguments[j]; String enum_text; @@ -1140,7 +1055,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri c.properties.sort(); for (int i = 0; i < c.properties.size(); i++) { - String additional_attributes; if (c.properties[i].enumeration != String()) { additional_attributes += " enum=\"" + c.properties[i].enumeration + "\""; @@ -1163,16 +1077,13 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } if (c.signals.size()) { - c.signals.sort(); _write_string(f, 1, "<signals>"); for (int i = 0; i < c.signals.size(); i++) { - const MethodDoc &m = c.signals[i]; _write_string(f, 2, "<signal name=\"" + m.name + "\">"); for (int j = 0; j < m.arguments.size(); j++) { - const ArgumentDoc &a = m.arguments[j]; _write_string(f, 3, "<argument index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape() + "\" type=\"" + a.type.xml_escape() + "\">"); _write_string(f, 3, "</argument>"); @@ -1191,7 +1102,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 1, "<constants>"); for (int i = 0; i < c.constants.size(); i++) { - const ConstantDoc &k = c.constants[i]; if (k.enumeration != String()) { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); @@ -1205,12 +1115,10 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri _write_string(f, 1, "</constants>"); if (c.theme_properties.size()) { - c.theme_properties.sort(); _write_string(f, 1, "<theme_items>"); for (int i = 0; i < c.theme_properties.size(); i++) { - const PropertyDoc &p = c.theme_properties[i]; if (p.default_value != "") @@ -1232,7 +1140,6 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size) { - Vector<uint8_t> data; data.resize(p_uncompressed_size); Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE); diff --git a/editor/doc_data.h b/editor/doc_data.h index 073705f0b1..06d0889af6 100644 --- a/editor/doc_data.h +++ b/editor/doc_data.h @@ -38,7 +38,6 @@ class DocData { public: struct ArgumentDoc { - String name; String type; String enumeration; @@ -46,7 +45,6 @@ public: }; struct MethodDoc { - String name; String return_type; String return_enum; @@ -59,7 +57,6 @@ public: }; struct ConstantDoc { - String name; String value; String enumeration; @@ -67,7 +64,6 @@ public: }; struct PropertyDoc { - String name; String type; String enumeration; @@ -84,7 +80,6 @@ public: }; struct ClassDoc { - String name; String inherits; String category; diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index b0bcc2b448..a41444a27f 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -38,7 +38,6 @@ #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); @@ -49,9 +48,7 @@ void EditorAbout::_theme_changed() { } void EditorAbout::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { _theme_changed(); } break; @@ -59,7 +56,6 @@ void EditorAbout::_notification(int p_what) { } void EditorAbout::_license_tree_selected() { - TreeItem *selected = _tpl_tree->get_selected(); _tpl_text->scroll_to_line(0); _tpl_text->set_text(selected->get_metadata(0)); @@ -69,12 +65,10 @@ void EditorAbout::_bind_methods() { } TextureRect *EditorAbout::get_logo() const { - return _logo; } ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column) { - ScrollContainer *sc = memnew(ScrollContainer); sc->set_name(p_name); sc->set_v_size_flags(Control::SIZE_EXPAND); @@ -84,11 +78,9 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St sc->add_child(vbc); for (int i = 0; i < p_sections.size(); i++) { - bool single_column = p_flag_single_column & 1 << i; const char *const *names_ptr = p_src[i]; if (*names_ptr) { - Label *lbl = memnew(Label); lbl->set_text(p_sections[i]); vbc->add_child(lbl); @@ -115,7 +107,6 @@ ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<St } EditorAbout::EditorAbout() { - set_title(TTR("Thanks from the Godot community!")); set_hide_on_ok(true); @@ -213,7 +204,6 @@ EditorAbout::EditorAbout() { tpl_ti_lc->set_selectable(0, false); String long_text = ""; for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) { - const ComponentCopyright &component = COPYRIGHT_INFO[component_index]; TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp); String component_name = component.name; @@ -239,7 +229,6 @@ EditorAbout::EditorAbout() { ti->set_metadata(0, text); } for (int i = 0; i < LICENSE_COUNT; i++) { - TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc); String licensename = String(LICENSE_NAMES[i]); ti->set_text(0, licensename); diff --git a/editor/editor_about.h b/editor/editor_about.h index 83e9e9f490..ae4d9c73bf 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -45,7 +45,6 @@ #include "editor_scale.h" class EditorAbout : public AcceptDialog { - GDCLASS(EditorAbout, AcceptDialog); private: diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 74c4102003..9b05826e92 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -37,7 +37,6 @@ #include "progress_dialog.h" void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool p_first) { - if (p_check) { if (p_item->get_custom_color(0) == Color()) { p_item->set_checked(0, true); @@ -56,7 +55,6 @@ void EditorAssetInstaller::_update_subitems(TreeItem *p_item, bool p_check, bool } void EditorAssetInstaller::_item_edited() { - if (updating) return; @@ -81,7 +79,6 @@ void EditorAssetInstaller::_item_edited() { } void EditorAssetInstaller::open(const String &p_path, int p_depth) { - package_path = p_path; Set<String> files_sorted; @@ -90,7 +87,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io); if (!pkg) { - error->set_text(TTR("Error opening package file, not in ZIP format.")); return; } @@ -98,7 +94,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { int ret = unzGoToFirstFile(pkg); while (ret == UNZ_OK) { - //get filename unz_file_info info; char fname[16384]; @@ -137,7 +132,6 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { Map<String, TreeItem *> dir_map; for (Set<String>::Element *E = files_sorted.front(); E; E = E->next()) { - String path = E->get(); int depth = p_depth; bool skip = false; @@ -211,13 +205,11 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) { } void EditorAssetInstaller::ok_pressed() { - FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io); if (!pkg) { - error->set_text(TTR("Error opening package file, not in ZIP format.")); return; } @@ -230,7 +222,6 @@ void EditorAssetInstaller::ok_pressed() { int idx = 0; while (ret == UNZ_OK) { - //get filename unz_file_info info; char fname[16384]; @@ -239,7 +230,6 @@ void EditorAssetInstaller::ok_pressed() { String name = fname; if (status_map.has(name) && status_map[name]->is_checked(0)) { - String path = status_map[name]->get_metadata(0); if (path == String()) { // a dir @@ -259,7 +249,6 @@ void EditorAssetInstaller::ok_pressed() { memdelete(da); } else { - Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -290,7 +279,6 @@ void EditorAssetInstaller::ok_pressed() { if (failed_files.size()) { String msg = TTR("The following files failed extraction from package:") + "\n\n"; for (int i = 0; i < failed_files.size(); i++) { - if (i > 15) { msg += "\n" + vformat(TTR("And %s more files."), itos(failed_files.size() - i)); break; @@ -310,7 +298,6 @@ void EditorAssetInstaller::_bind_methods() { } EditorAssetInstaller::EditorAssetInstaller() { - VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index 840e780264..7f3d00994f 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -34,7 +34,6 @@ #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" class EditorAssetInstaller : public ConfirmationDialog { - GDCLASS(EditorAssetInstaller, ConfirmationDialog); Tree *tree; diff --git a/editor/editor_atlas_packer.cpp b/editor/editor_atlas_packer.cpp index d17b3bba4f..c2df1fd82a 100644 --- a/editor/editor_atlas_packer.cpp +++ b/editor/editor_atlas_packer.cpp @@ -31,14 +31,12 @@ #include "editor_atlas_packer.h" void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices) { - int width = p_bitmap->get_size().width; int height = p_bitmap->get_size().height; int x[3]; int y[3]; for (int j = 0; j < 3; j++) { - x[j] = vertices[j].x; y[j] = vertices[j].y; } @@ -71,7 +69,6 @@ void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices) } for (int xi = (xf < width ? int(xf) : width - 1); xi >= (xt > 0 ? xt : 0); xi--) { - p_bitmap->set_bit(Point2(xi, yi), true); } } @@ -83,14 +80,12 @@ void EditorAtlasPacker::_plot_triangle(Ref<BitMap> p_bitmap, Vector2i *vertices) } } void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_height, int p_atlas_max_size, int p_cell_resolution) { - int divide_by = MIN(64, p_cell_resolution); Vector<PlottedBitmap> bitmaps; int max_w = 0; for (int i = 0; i < charts.size(); i++) { - const Chart &chart = charts[i]; //generate aabb @@ -100,7 +95,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h const Vector2 *vertices = chart.vertices.ptr(); for (int j = 0; j < vertex_count; j++) { - if (j == 0) { aabb.position = vertices[j]; } else { @@ -118,7 +112,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h //plot triangles, using divisor for (int j = 0; j < chart.faces.size(); j++) { - Vector2i v[3]; for (int k = 0; k < 3; k++) { Vector2 vtx = chart.vertices[chart.faces[j].vertex[k]]; @@ -163,7 +156,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h bool found_pixel = false; for (int lx = x - 1; lx < x + 2 && !found_pixel; lx++) { for (int ly = y - 1; ly < y + 2 && !found_pixel; ly++) { - int px = lx - 1; if (px < 0 || px >= w) continue; @@ -177,7 +169,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h } } if (found_pixel) { - if (transpose) { if (x > top_heights[y]) { top_heights.write[y] = x; @@ -231,7 +222,6 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h int *atlas_ptr = heights.ptrw(); for (int i = 0; i < bitmaps.size(); i++) { - int best_height = 0x7FFFFFFF; int best_height_offset = -1; int w = bitmaps[i].top_heights.size(); @@ -240,11 +230,9 @@ void EditorAtlasPacker::chart_pack(Vector<Chart> &charts, int &r_width, int &r_h const int *bottom_heights = bitmaps[i].bottom_heights.ptr(); for (int j = 0; j < atlas_w - w; j++) { - int height = 0; for (int k = 0; k < w; k++) { - int pixmap_h = bottom_heights[k]; if (pixmap_h == -1) { continue; //no pixel here, anything is fine diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 39c94cc523..8b5658423b 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -40,10 +40,8 @@ #include "servers/audio_server.h" void EditorAudioBus::_update_visible_channels() { - int i = 0; for (; i < cc; i++) { - if (!channel[i].vu_l->is_visible()) { channel[i].vu_l->show(); } @@ -53,7 +51,6 @@ void EditorAudioBus::_update_visible_channels() { } for (; i < CHANNELS_MAX; i++) { - if (channel[i].vu_l->is_visible()) { channel[i].vu_l->hide(); } @@ -64,10 +61,8 @@ void EditorAudioBus::_update_visible_channels() { } void EditorAudioBus::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: { - for (int i = 0; i < CHANNELS_MAX; i++) { channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); @@ -95,7 +90,6 @@ void EditorAudioBus::_notification(int p_what) { set_process(true); } break; case NOTIFICATION_DRAW: { - if (is_master) { draw_style_box(get_theme_stylebox("disabled", "Button"), Rect2(Vector2(), get_size())); } else if (has_focus()) { @@ -111,7 +105,6 @@ void EditorAudioBus::_notification(int p_what) { } } break; case NOTIFICATION_PROCESS: { - if (cc != AudioServer::get_singleton()->get_bus_channels(get_index())) { cc = AudioServer::get_singleton()->get_bus_channels(get_index()); _update_visible_channels(); @@ -156,7 +149,6 @@ void EditorAudioBus::_notification(int p_what) { } } break; case NOTIFICATION_VISIBILITY_CHANGED: { - for (int i = 0; i < CHANNELS_MAX; i++) { channel[i].peak_l = -100; channel[i].peak_r = -100; @@ -166,7 +158,6 @@ void EditorAudioBus::_notification(int p_what) { set_process(is_visible_in_tree()); } break; case NOTIFICATION_THEME_CHANGED: { - for (int i = 0; i < CHANNELS_MAX; i++) { channel[i].vu_l->set_under_texture(get_theme_icon("BusVuEmpty", "EditorIcons")); channel[i].vu_l->set_progress_texture(get_theme_icon("BusVuFull", "EditorIcons")); @@ -185,7 +176,6 @@ void EditorAudioBus::_notification(int p_what) { } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { - if (hovering_drop) { hovering_drop = false; update(); @@ -195,7 +185,6 @@ void EditorAudioBus::_notification(int p_what) { } void EditorAudioBus::update_send() { - send->clear(); if (is_master) { send->set_disabled(true); @@ -218,7 +207,6 @@ void EditorAudioBus::update_send() { } void EditorAudioBus::update_bus() { - if (updating_bus) return; @@ -240,7 +228,6 @@ void EditorAudioBus::update_bus() { TreeItem *root = effects->create_item(); for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) { - Ref<AudioEffect> afx = AudioServer::get_singleton()->get_bus_effect(index, i); TreeItem *fx = effects->create_item(root); @@ -263,7 +250,6 @@ void EditorAudioBus::update_bus() { } void EditorAudioBus::_name_changed(const String &p_new_name) { - if (p_new_name == AudioServer::get_singleton()->get_bus_name(get_index())) return; @@ -271,10 +257,8 @@ void EditorAudioBus::_name_changed(const String &p_new_name) { int attempts = 1; while (true) { - bool name_free = true; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { - if (AudioServer::get_singleton()->get_bus_name(i) == attempt) { name_free = false; break; @@ -317,7 +301,6 @@ void EditorAudioBus::_name_changed(const String &p_new_name) { } void EditorAudioBus::_volume_changed(float p_normalized) { - if (updating_bus) return; @@ -384,7 +367,6 @@ 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)) { // Display the correct (snapped) value when holding Ctrl @@ -415,7 +397,6 @@ void EditorAudioBus::_hide_value_preview() { } void EditorAudioBus::_solo_toggled() { - updating_bus = true; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -429,7 +410,6 @@ void EditorAudioBus::_solo_toggled() { updating_bus = false; } void EditorAudioBus::_mute_toggled() { - updating_bus = true; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -443,7 +423,6 @@ void EditorAudioBus::_mute_toggled() { updating_bus = false; } void EditorAudioBus::_bypass_toggled() { - updating_bus = true; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -458,7 +437,6 @@ void EditorAudioBus::_bypass_toggled() { } void EditorAudioBus::_send_selected(int p_which) { - updating_bus = true; UndoRedo *ur = EditorNode::get_undo_redo(); @@ -473,14 +451,12 @@ void EditorAudioBus::_send_selected(int p_which) { } void EditorAudioBus::_effect_selected() { - TreeItem *effect = effects->get_selected(); if (!effect) return; updating_bus = true; if (effect->get_metadata(0) != Variant()) { - int index = effect->get_metadata(0); Ref<AudioEffect> effect2 = AudioServer::get_singleton()->get_bus_effect(get_index(), index); if (effect2.is_valid()) { @@ -492,7 +468,6 @@ void EditorAudioBus::_effect_selected() { } void EditorAudioBus::_effect_edited() { - if (updating_bus) return; @@ -523,7 +498,6 @@ void EditorAudioBus::_effect_edited() { } void EditorAudioBus::_effect_add(int p_which) { - if (updating_bus) return; @@ -547,7 +521,6 @@ void EditorAudioBus::_effect_add(int p_which) { } void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { accept_event(); @@ -556,7 +529,6 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) { - Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y); bus_popup->set_position(get_global_position() + pos); bus_popup->popup(); @@ -564,7 +536,6 @@ void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) { } void EditorAudioBus::_bus_popup_pressed(int p_option) { - if (p_option == 2) { // Reset volume emit_signal("vol_reset_request"); @@ -577,7 +548,6 @@ void EditorAudioBus::_bus_popup_pressed(int p_option) { } Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { - if (get_index() == 0) { return Variant(); } @@ -602,7 +572,6 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { } bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - if (get_index() == 0) { return false; } @@ -617,13 +586,11 @@ bool EditorAudioBus::can_drop_data(const Point2 &p_point, const Variant &p_data) } void EditorAudioBus::drop_data(const Point2 &p_point, const Variant &p_data) { - Dictionary d = p_data; emit_signal("dropped", d["index"], get_index()); } Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - TreeItem *item = effects->get_item_at_position(p_point); if (!item) { return Variant(); @@ -647,7 +614,6 @@ Variant EditorAudioBus::get_drag_data_fw(const Point2 &p_point, Control *p_from) } bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type") || String(d["type"]) != "audio_bus_effect") return false; @@ -662,7 +628,6 @@ bool EditorAudioBus::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - Dictionary d = p_data; TreeItem *item = effects->get_item_at_position(p_point); @@ -720,7 +685,6 @@ void EditorAudioBus::drop_data_fw(const Point2 &p_point, const Variant &p_data, } void EditorAudioBus::_delete_effect_pressed(int p_option) { - TreeItem *item = effects->get_selected(); if (!item) return; @@ -741,7 +705,6 @@ void EditorAudioBus::_delete_effect_pressed(int p_option) { } void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) { - TreeItem *item = effects->get_selected(); if (!item) return; @@ -754,7 +717,6 @@ void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) { } void EditorAudioBus::_bind_methods() { - ClassDB::bind_method("update_bus", &EditorAudioBus::update_bus); ClassDB::bind_method("update_send", &EditorAudioBus::update_send); ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input); @@ -770,7 +732,6 @@ void EditorAudioBus::_bind_methods() { } EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { - buses = p_buses; updating_bus = false; is_master = p_is_master; @@ -950,7 +911,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { } void EditorAudioBusDrop::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_DRAW: { draw_style_box(get_theme_stylebox("normal", "Button"), Rect2(Vector2(), get_size())); @@ -962,7 +922,6 @@ void EditorAudioBusDrop::_notification(int p_what) { } } break; case NOTIFICATION_MOUSE_ENTER: { - if (!hovering_drop) { hovering_drop = true; update(); @@ -970,7 +929,6 @@ void EditorAudioBusDrop::_notification(int p_what) { } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { - if (hovering_drop) { hovering_drop = false; update(); @@ -980,29 +938,24 @@ void EditorAudioBusDrop::_notification(int p_what) { } bool EditorAudioBusDrop::can_drop_data(const Point2 &p_point, const Variant &p_data) const { - Dictionary d = p_data; return (d.has("type") && String(d["type"]) == "move_audio_bus"); } void EditorAudioBusDrop::drop_data(const Point2 &p_point, const Variant &p_data) { - Dictionary d = p_data; emit_signal("dropped", d["index"], AudioServer::get_singleton()->get_bus_count()); } void EditorAudioBusDrop::_bind_methods() { - ADD_SIGNAL(MethodInfo("dropped")); } EditorAudioBusDrop::EditorAudioBusDrop() { - hovering_drop = false; } void EditorAudioBuses::_update_buses() { - while (bus_hb->get_child_count() > 0) { memdelete(bus_hb->get_child(0)); } @@ -1010,7 +963,6 @@ void EditorAudioBuses::_update_buses() { drop_end = nullptr; for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { - bool is_master = (i == 0); EditorAudioBus *audio_bus = memnew(EditorAudioBus(this, is_master)); bus_hb->add_child(audio_bus); @@ -1023,33 +975,27 @@ void EditorAudioBuses::_update_buses() { } EditorAudioBuses *EditorAudioBuses::register_editor() { - EditorAudioBuses *audio_buses = memnew(EditorAudioBuses); EditorNode::get_singleton()->add_bottom_panel_item(TTR("Audio"), audio_buses); return audio_buses; } void EditorAudioBuses::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - bus_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } break; case NOTIFICATION_READY: { - _update_buses(); } break; case NOTIFICATION_DRAG_END: { - if (drop_end) { drop_end->queue_delete(); drop_end = nullptr; } } break; case NOTIFICATION_PROCESS: { - // Check if anything was edited. bool edited = AudioServer::get_singleton()->is_edited(); for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { @@ -1072,7 +1018,6 @@ void EditorAudioBuses::_notification(int p_what) { } void EditorAudioBuses::_add_bus() { - UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Add Audio Bus")); @@ -1084,7 +1029,6 @@ void EditorAudioBuses::_add_bus() { } void EditorAudioBuses::_update_bus(int p_index) { - if (p_index >= bus_hb->get_child_count()) return; @@ -1092,14 +1036,12 @@ void EditorAudioBuses::_update_bus(int p_index) { } void EditorAudioBuses::_update_sends() { - for (int i = 0; i < bus_hb->get_child_count(); i++) { bus_hb->get_child(i)->call("update_send"); } } void EditorAudioBuses::_delete_bus(Object *p_which) { - EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which); int index = bus->get_index(); if (index == 0) { @@ -1119,7 +1061,6 @@ void EditorAudioBuses::_delete_bus(Object *p_which) { ur->add_undo_method(AudioServer::get_singleton(), "set_bus_mute", index, AudioServer::get_singleton()->is_bus_mute(index)); ur->add_undo_method(AudioServer::get_singleton(), "set_bus_bypass_effects", index, AudioServer::get_singleton()->is_bus_bypassing_effects(index)); for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(index); i++) { - ur->add_undo_method(AudioServer::get_singleton(), "add_bus_effect", index, AudioServer::get_singleton()->get_bus_effect(index, i)); ur->add_undo_method(AudioServer::get_singleton(), "set_bus_effect_enabled", index, i, AudioServer::get_singleton()->is_bus_effect_enabled(index, i)); } @@ -1129,7 +1070,6 @@ void EditorAudioBuses::_delete_bus(Object *p_which) { } void EditorAudioBuses::_duplicate_bus(int p_which) { - int add_at_pos = p_which + 1; UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Duplicate Audio Bus")); @@ -1141,7 +1081,6 @@ void EditorAudioBuses::_duplicate_bus(int p_which) { ur->add_do_method(AudioServer::get_singleton(), "set_bus_mute", add_at_pos, AudioServer::get_singleton()->is_bus_mute(p_which)); ur->add_do_method(AudioServer::get_singleton(), "set_bus_bypass_effects", add_at_pos, AudioServer::get_singleton()->is_bus_bypassing_effects(p_which)); for (int i = 0; i < AudioServer::get_singleton()->get_bus_effect_count(p_which); i++) { - ur->add_do_method(AudioServer::get_singleton(), "add_bus_effect", add_at_pos, AudioServer::get_singleton()->get_bus_effect(p_which, i)); ur->add_do_method(AudioServer::get_singleton(), "set_bus_effect_enabled", add_at_pos, i, AudioServer::get_singleton()->is_bus_effect_enabled(p_which, i)); } @@ -1152,7 +1091,6 @@ void EditorAudioBuses::_duplicate_bus(int p_which) { } void EditorAudioBuses::_reset_bus_volume(Object *p_which) { - EditorAudioBus *bus = Object::cast_to<EditorAudioBus>(p_which); int index = bus->get_index(); @@ -1166,7 +1104,6 @@ void EditorAudioBuses::_reset_bus_volume(Object *p_which) { } void EditorAudioBuses::_request_drop_end() { - if (!drop_end && bus_hb->get_child_count()) { drop_end = memnew(EditorAudioBusDrop); @@ -1177,7 +1114,6 @@ void EditorAudioBuses::_request_drop_end() { } void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) { - UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Move Audio Bus")); @@ -1192,18 +1128,15 @@ void EditorAudioBuses::_drop_at_index(int p_bus, int p_index) { } void EditorAudioBuses::_server_save() { - Ref<AudioBusLayout> state = AudioServer::get_singleton()->generate_bus_layout(); ResourceSaver::save(edited_path, state); } void EditorAudioBuses::_select_layout() { - EditorNode::get_singleton()->get_filesystem_dock()->select_file(edited_path); } void EditorAudioBuses::_save_as_layout() { - 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); @@ -1212,7 +1145,6 @@ void EditorAudioBuses::_save_as_layout() { } void EditorAudioBuses::_new_layout() { - 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); @@ -1221,7 +1153,6 @@ void EditorAudioBuses::_new_layout() { } void EditorAudioBuses::_load_layout() { - 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); @@ -1230,7 +1161,6 @@ void EditorAudioBuses::_load_layout() { } void EditorAudioBuses::_load_default_layout() { - String layout_path = ProjectSettings::get_singleton()->get("audio/default_bus_layout"); Ref<AudioBusLayout> state = ResourceLoader::load(layout_path, "", true); @@ -1248,7 +1178,6 @@ void EditorAudioBuses::_load_default_layout() { } void EditorAudioBuses::_file_dialog_callback(const String &p_string) { - if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_OPEN_FILE) { Ref<AudioBusLayout> state = ResourceLoader::load(p_string, "", true); if (state.is_null()) { @@ -1264,7 +1193,6 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { call_deferred("_select_layout"); } else if (file_dialog->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { - if (new_layout) { Ref<AudioBusLayout> empty_state; empty_state.instance(); @@ -1287,7 +1215,6 @@ void EditorAudioBuses::_file_dialog_callback(const String &p_string) { } void EditorAudioBuses::_bind_methods() { - ClassDB::bind_method("_update_buses", &EditorAudioBuses::_update_buses); ClassDB::bind_method("_update_bus", &EditorAudioBuses::_update_bus); ClassDB::bind_method("_update_sends", &EditorAudioBuses::_update_sends); @@ -1295,7 +1222,6 @@ void EditorAudioBuses::_bind_methods() { } EditorAudioBuses::EditorAudioBuses() { - drop_end = nullptr; top_hb = memnew(HBoxContainer); add_child(top_hb); @@ -1372,7 +1298,6 @@ EditorAudioBuses::EditorAudioBuses() { } void EditorAudioBuses::open_layout(const String &p_path) { - EditorNode::get_singleton()->make_bottom_panel_item_visible(this); Ref<AudioBusLayout> state = ResourceLoader::load(p_path, "", true); @@ -1390,9 +1315,7 @@ void EditorAudioBuses::open_layout(const String &p_path) { } void AudioBusesEditorPlugin::edit(Object *p_node) { - if (Object::cast_to<AudioBusLayout>(p_node)) { - String path = Object::cast_to<AudioBusLayout>(p_node)->get_path(); if (path.is_resource_file()) { audio_bus_editor->open_layout(path); @@ -1401,7 +1324,6 @@ void AudioBusesEditorPlugin::edit(Object *p_node) { } bool AudioBusesEditorPlugin::handles(Object *p_node) const { - return (Object::cast_to<AudioBusLayout>(p_node) != nullptr); } @@ -1409,7 +1331,6 @@ void AudioBusesEditorPlugin::make_visible(bool p_visible) { } AudioBusesEditorPlugin::AudioBusesEditorPlugin(EditorAudioBuses *p_node) { - audio_bus_editor = p_node; } @@ -1417,12 +1338,10 @@ AudioBusesEditorPlugin::~AudioBusesEditorPlugin() { } void EditorAudioMeterNotches::add_notch(float p_normalized_offset, float p_db_value, bool p_render_value) { - notches.push_back(AudioNotch(p_normalized_offset, p_db_value, p_render_value)); } Size2 EditorAudioMeterNotches::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Label"); float font_height = font->get_height(); @@ -1441,13 +1360,11 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const { } void EditorAudioMeterNotches::_bind_methods() { - ClassDB::bind_method("add_notch", &EditorAudioMeterNotches::add_notch); ClassDB::bind_method("_draw_audio_notches", &EditorAudioMeterNotches::_draw_audio_notches); } void EditorAudioMeterNotches::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_THEME_CHANGED: { notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0); @@ -1459,7 +1376,6 @@ void EditorAudioMeterNotches::_notification(int p_what) { } void EditorAudioMeterNotches::_draw_audio_notches() { - Ref<Font> font = get_theme_font("font", "Label"); float font_height = font->get_height(); @@ -1481,6 +1397,5 @@ void EditorAudioMeterNotches::_draw_audio_notches() { } EditorAudioMeterNotches::EditorAudioMeterNotches() { - notch_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(0, 0, 0); } diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 3e911bcc65..6b2d9e4436 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -51,7 +51,6 @@ class EditorAudioBuses; class EditorAudioBus : public PanelContainer { - GDCLASS(EditorAudioBus, PanelContainer); Ref<Texture2D> disabled_vu; @@ -137,7 +136,6 @@ public: }; class EditorAudioBusDrop : public Control { - GDCLASS(EditorAudioBusDrop, Control); virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const; @@ -154,7 +152,6 @@ public: }; class EditorAudioBuses : public VBoxContainer { - GDCLASS(EditorAudioBuses, VBoxContainer); HBoxContainer *top_hb; @@ -265,7 +262,6 @@ public: }; class AudioBusesEditorPlugin : public EditorPlugin { - GDCLASS(AudioBusesEditorPlugin, EditorPlugin); EditorAudioBuses *audio_bus_editor; diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 6917b2b775..1132cda415 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -41,15 +41,12 @@ #define PREVIEW_LIST_MAX_SIZE 10 void EditorAutoloadSettings::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - List<String> afn; ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); for (List<String>::Element *E = afn.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); } @@ -66,7 +63,6 @@ void EditorAutoloadSettings::_notification(int p_what) { } bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) { - if (!p_name.is_valid_identifier()) { if (r_error) *r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:") + " a-z, A-Z, 0-9 or _"; @@ -116,7 +112,6 @@ 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_text())) autoload_add_path->set_text(""); @@ -125,7 +120,6 @@ void EditorAutoloadSettings::_autoload_add() { } void EditorAutoloadSettings::_autoload_selected() { - TreeItem *ti = tree->get_selected(); if (!ti) @@ -135,7 +129,6 @@ void EditorAutoloadSettings::_autoload_selected() { } void EditorAutoloadSettings::_autoload_edited() { - if (updating_autoload) return; @@ -227,7 +220,6 @@ void EditorAutoloadSettings::_autoload_edited() { } void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); String name = "autoload/" + ti->get_text(0); @@ -240,7 +232,6 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu } break; case BUTTON_MOVE_UP: case BUTTON_MOVE_DOWN: { - TreeItem *swap = nullptr; if (p_button == BUTTON_MOVE_UP) { @@ -274,7 +265,6 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu undo_redo->commit_action(); } break; case BUTTON_DELETE: { - int order = ProjectSettings::get_singleton()->get_order(name); undo_redo->create_action(TTR("Remove Autoload")); @@ -313,7 +303,6 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) { } void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { - // Convert the file name to PascalCase, which is the convention for classes in GDScript. const String class_name = p_path.get_file().get_basename().capitalize().replace(" ", ""); @@ -326,20 +315,17 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { } void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { - if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } 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(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { - add_autoload->set_disabled( autoload_add_path->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr)); } @@ -371,7 +357,6 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { } void EditorAutoloadSettings::update_autoload() { - if (updating_autoload) return; @@ -394,7 +379,6 @@ void EditorAutoloadSettings::update_autoload() { ProjectSettings::get_singleton()->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); if (!pi.name.begins_with("autoload/")) @@ -518,7 +502,6 @@ void EditorAutoloadSettings::update_autoload() { } Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) { - if (autoload_cache.size() <= 1) return false; @@ -579,7 +562,6 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Varia } void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) { - TreeItem *ti = tree->get_item_at_position(p_point); if (!ti) @@ -665,7 +647,6 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & } bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_path) { - String name = p_name; String error; @@ -711,7 +692,6 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_ } void EditorAutoloadSettings::autoload_remove(const String &p_name) { - String name = "autoload/" + p_name; UndoRedo *undo_redo = EditorNode::get_undo_redo(); @@ -736,7 +716,6 @@ void EditorAutoloadSettings::autoload_remove(const String &p_name) { } void EditorAutoloadSettings::_bind_methods() { - ClassDB::bind_method("_autoload_open", &EditorAutoloadSettings::_autoload_open); ClassDB::bind_method("get_drag_data_fw", &EditorAutoloadSettings::get_drag_data_fw); @@ -751,12 +730,10 @@ void EditorAutoloadSettings::_bind_methods() { } EditorAutoloadSettings::EditorAutoloadSettings() { - // Make first cache List<PropertyInfo> props; ProjectSettings::get_singleton()->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); if (!pi.name.begins_with("autoload/")) @@ -904,12 +881,10 @@ 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 94a581401c..646fe3992c 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -36,7 +36,6 @@ #include "editor_file_dialog.h" class EditorAutoloadSettings : public VBoxContainer { - GDCLASS(EditorAutoloadSettings, VBoxContainer); enum { diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9c739474d1..6f6a863b70 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -39,9 +39,7 @@ #include "scene/resources/packed_scene.h" void EditorHistory::cleanup_history() { - for (int i = 0; i < history.size(); i++) { - bool fail = false; for (int j = 0; j < history[i].path.size(); j++) { @@ -79,7 +77,6 @@ void EditorHistory::cleanup_history() { } void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change, bool p_inspector_only) { - Object *obj = ObjectDB::get_instance(p_object); ERR_FAIL_COND(!obj); Reference *r = Object::cast_to<Reference>(obj); @@ -122,22 +119,18 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int } void EditorHistory::add_object_inspector_only(ObjectID p_object) { - _add_object(p_object, "", -1, true); } void EditorHistory::add_object(ObjectID p_object) { - _add_object(p_object, "", -1); } void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) { - _add_object(p_object, p_subprop, -1); } void EditorHistory::add_object(ObjectID p_object, int p_relevel) { - _add_object(p_object, "", p_relevel); } @@ -149,7 +142,6 @@ int EditorHistory::get_history_pos() { } bool EditorHistory::is_history_obj_inspector_only(int p_obj) const { - ERR_FAIL_INDEX_V(p_obj, history.size(), false); ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), false); return history[p_obj].path[history[p_obj].level].inspector_only; @@ -165,12 +157,10 @@ bool EditorHistory::is_at_beginning() const { return current <= 0; } bool EditorHistory::is_at_end() const { - return ((current + 1) >= history.size()); } bool EditorHistory::next() { - cleanup_history(); if ((current + 1) < history.size()) @@ -182,7 +172,6 @@ bool EditorHistory::next() { } bool EditorHistory::previous() { - cleanup_history(); if (current > 0) @@ -194,7 +183,6 @@ bool EditorHistory::previous() { } bool EditorHistory::is_current_inspector_only() const { - if (current < 0 || current >= history.size()) return false; @@ -202,7 +190,6 @@ bool EditorHistory::is_current_inspector_only() const { return h.path[h.level].inspector_only; } ObjectID EditorHistory::get_current() { - if (current < 0 || current >= history.size()) return ObjectID(); @@ -215,7 +202,6 @@ ObjectID EditorHistory::get_current() { } int EditorHistory::get_path_size() const { - if (current < 0 || current >= history.size()) return 0; @@ -224,7 +210,6 @@ int EditorHistory::get_path_size() const { } ObjectID EditorHistory::get_path_object(int p_index) const { - if (current < 0 || current >= history.size()) return ObjectID(); @@ -240,7 +225,6 @@ ObjectID EditorHistory::get_path_object(int p_index) const { } String EditorHistory::get_path_property(int p_index) const { - if (current < 0 || current >= history.size()) return ""; @@ -252,20 +236,16 @@ String EditorHistory::get_path_property(int p_index) const { } void EditorHistory::clear() { - history.clear(); current = -1; } EditorHistory::EditorHistory() { - current = -1; } EditorPlugin *EditorData::get_editor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; } @@ -274,9 +254,7 @@ EditorPlugin *EditorData::get_editor(Object *p_object) { } EditorPlugin *EditorData::get_subeditor(Object *p_object) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) return editor_plugins[i]; } @@ -295,9 +273,7 @@ Vector<EditorPlugin *> EditorData::get_subeditors(Object *p_object) { } EditorPlugin *EditorData::get_editor(String p_name) { - for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->get_name() == p_name) return editor_plugins[i]; } @@ -306,14 +282,12 @@ EditorPlugin *EditorData::get_editor(String p_name) { } void EditorData::copy_object_params(Object *p_object) { - clipboard.clear(); List<PropertyInfo> pinfo; p_object->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR) || E->get().name == "script" || E->get().name == "scripts") continue; @@ -325,18 +299,14 @@ void EditorData::copy_object_params(Object *p_object) { } void EditorData::get_editor_breakpoints(List<String> *p_breakpoints) { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->get_breakpoints(p_breakpoints); } } Dictionary EditorData::get_editor_states() const { - Dictionary metadata; for (int i = 0; i < editor_plugins.size(); i++) { - Dictionary state = editor_plugins[i]->get_state(); if (state.empty()) continue; @@ -353,17 +323,14 @@ Dictionary EditorData::get_scene_editor_states(int p_idx) const { } void EditorData::set_editor_states(const Dictionary &p_states) { - List<Variant> keys; p_states.get_key_list(&keys); List<Variant>::Element *E = keys.front(); for (; E; E = E->next()) { - String name = E->get(); int idx = -1; for (int i = 0; i < editor_plugins.size(); i++) { - if (editor_plugins[i]->get_name() == name) { idx = i; break; @@ -377,64 +344,49 @@ void EditorData::set_editor_states(const Dictionary &p_states) { } void EditorData::notify_edited_scene_changed() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->edited_scene_changed(); editor_plugins[i]->notify_scene_changed(get_edited_scene_root()); } } void EditorData::notify_resource_saved(const Ref<Resource> &p_resource) { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->notify_resource_saved(p_resource); } } void EditorData::clear_editor_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->clear(); } } void EditorData::save_editor_external_data() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->save_external_data(); } } void EditorData::apply_changes_in_editors() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->apply_changes(); } } void EditorData::save_editor_global_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->save_global_state(); } } void EditorData::restore_editor_global_states() { - for (int i = 0; i < editor_plugins.size(); i++) { - editor_plugins[i]->restore_global_state(); } } void EditorData::paste_object_params(Object *p_object) { - ERR_FAIL_NULL(p_object); undo_redo.create_action(TTR("Paste Params")); for (List<PropertyData>::Element *E = clipboard.front(); E; E = E->next()) { @@ -446,11 +398,9 @@ void EditorData::paste_object_params(Object *p_object) { } bool EditorData::call_build() { - bool result = true; for (int i = 0; i < editor_plugins.size() && result; i++) { - result &= editor_plugins[i]->build(); } @@ -458,18 +408,15 @@ bool EditorData::call_build() { } UndoRedo &EditorData::get_undo_redo() { - return undo_redo; } void EditorData::remove_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = nullptr; editor_plugins.erase(p_plugin); } void EditorData::add_editor_plugin(EditorPlugin *p_plugin) { - p_plugin->undo_redo = &undo_redo; editor_plugins.push_back(p_plugin); } @@ -478,13 +425,11 @@ int EditorData::get_editor_plugin_count() const { return editor_plugins.size(); } EditorPlugin *EditorData::get_editor_plugin(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, editor_plugins.size(), nullptr); return editor_plugins[p_idx]; } void EditorData::add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { - ERR_FAIL_COND_MSG(p_script.is_null(), "It's not a reference to a valid Script object."); CustomType ct; ct.name = p_type; @@ -498,9 +443,7 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits, } Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) { - if (get_custom_types().has(p_inherits)) { - for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) { if (get_custom_types()[p_inherits][i].name == p_type) { Ref<Script> script = get_custom_types()[p_inherits][i].script; @@ -520,9 +463,7 @@ Object *EditorData::instance_custom_type(const String &p_type, const String &p_i } void EditorData::remove_custom_type(const String &p_type) { - 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) { E->get().remove(i); @@ -536,7 +477,6 @@ void EditorData::remove_custom_type(const String &p_type) { } int EditorData::add_edited_scene(int p_at_pos) { - if (p_at_pos < 0) p_at_pos = edited_scene.size(); EditedScene es; @@ -557,7 +497,6 @@ int EditorData::add_edited_scene(int p_at_pos) { } void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); ERR_FAIL_INDEX(p_to_idx, edited_scene.size()); SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]); @@ -566,7 +505,6 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { void EditorData::remove_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); if (edited_scene[p_idx].root) { - for (int i = 0; i < editor_plugins.size(); i++) { editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename()); } @@ -584,7 +522,6 @@ void EditorData::remove_scene(int p_idx) { } bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> &checked_paths) { - /* if (p_root!=p_node && p_node->get_owner()!=p_root && !p_root->is_editable_instance(p_node->get_owner())) return false; @@ -602,7 +539,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> String path = ss->get_path(); if (!checked_paths.has(path)) { - uint64_t modified_time = FileAccess::get_modified_time(path); if (modified_time != ss->get_last_modified_time()) { return true; //external scene changed @@ -613,7 +549,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> } for (int i = 0; i < p_node->get_child_count(); i++) { - bool found = _find_updated_instances(p_root, p_node->get_child(i), checked_paths); if (found) return true; @@ -623,7 +558,6 @@ bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, Set<String> } bool EditorData::check_and_update_scene(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), false); if (!edited_scene[p_idx].root) return false; @@ -669,11 +603,9 @@ bool EditorData::check_and_update_scene(int p_idx) { } int EditorData::get_edited_scene() const { - return current_edited_scene; } void EditorData::set_edited_scene(int p_idx) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); current_edited_scene = p_idx; //swap @@ -688,7 +620,6 @@ Node *EditorData::get_edited_scene_root(int p_idx) { } } void EditorData::set_edited_scene_root(Node *p_root) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); edited_scene.write[current_edited_scene].root = p_root; if (p_root) { @@ -700,12 +631,10 @@ void EditorData::set_edited_scene_root(Node *p_root) { } int EditorData::get_edited_scene_count() const { - return edited_scene.size(); } Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const { - Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>(); for (int i = 0; i < edited_scene.size(); i++) { @@ -726,7 +655,6 @@ void EditorData::set_edited_scene_version(uint64_t version, int p_scene_idx) { } uint64_t EditorData::get_edited_scene_version() const { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), 0); return edited_scene[current_edited_scene].version; } @@ -736,14 +664,12 @@ uint64_t EditorData::get_scene_version(int p_idx) const { } String EditorData::get_scene_type(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (!edited_scene[p_idx].root) return ""; return edited_scene[p_idx].root->get_class(); } void EditorData::move_edited_scene_to_index(int p_idx) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); ERR_FAIL_INDEX(p_idx, edited_scene.size()); @@ -754,7 +680,6 @@ void EditorData::move_edited_scene_to_index(int p_idx) { } Ref<Script> EditorData::get_scene_root_script(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Ref<Script>()); if (!edited_scene[p_idx].root) return Ref<Script>(); @@ -784,7 +709,6 @@ String EditorData::get_scene_title(int p_idx) const { } void EditorData::set_scene_path(int p_idx, const String &p_path) { - ERR_FAIL_INDEX(p_idx, edited_scene.size()); edited_scene.write[p_idx].path = p_path; @@ -794,7 +718,6 @@ void EditorData::set_scene_path(int p_idx, const String &p_path) { } String EditorData::get_scene_path(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String()); if (edited_scene[p_idx].root) { @@ -813,14 +736,12 @@ void EditorData::set_edited_scene_live_edit_root(const NodePath &p_root) { edited_scene.write[current_edited_scene].live_edit_root = p_root; } NodePath EditorData::get_edited_scene_live_edit_root() { - ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), String()); return edited_scene[current_edited_scene].live_edit_root; } void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom) { - ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); EditedScene &es = edited_scene.write[current_edited_scene]; @@ -849,7 +770,6 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, } void EditorData::clear_edited_scenes() { - for (int i = 0; i < edited_scene.size(); i++) { if (edited_scene[i].root) { memdelete(edited_scene[i].root); @@ -892,7 +812,6 @@ bool EditorData::script_class_is_parent(const String &p_class, const String &p_i } StringName EditorData::script_class_get_base(const String &p_class) const { - Ref<Script> script = script_class_load_script(p_class); if (script.is_null()) return StringName(); @@ -919,7 +838,6 @@ Object *EditorData::script_class_instance(const String &p_class) { } Ref<Script> EditorData::script_class_load_script(const String &p_class) const { - if (!ScriptServer::is_global_class(p_class)) return Ref<Script>(); @@ -988,7 +906,6 @@ void EditorData::script_class_load_icon_paths() { } EditorData::EditorData() { - current_edited_scene = -1; //load_imported_scenes_from_globals(); @@ -997,7 +914,6 @@ EditorData::EditorData() { /////////// void EditorSelection::_node_removed(Node *p_node) { - if (!selection.has(p_node)) return; @@ -1010,7 +926,6 @@ void EditorSelection::_node_removed(Node *p_node) { } void EditorSelection::add_node(Node *p_node) { - ERR_FAIL_NULL(p_node); ERR_FAIL_COND(!p_node->is_inside_tree()); if (selection.has(p_node)) @@ -1020,7 +935,6 @@ void EditorSelection::add_node(Node *p_node) { nl_changed = true; Object *meta = nullptr; for (List<Object *>::Element *E = editor_plugins.front(); E; E = E->next()) { - meta = E->get()->call("_get_editor_data", p_node); if (meta) { break; @@ -1034,7 +948,6 @@ void EditorSelection::add_node(Node *p_node) { } void EditorSelection::remove_node(Node *p_node) { - ERR_FAIL_NULL(p_node); if (!selection.has(p_node)) @@ -1050,16 +963,13 @@ void EditorSelection::remove_node(Node *p_node) { //emit_signal("selection_changed"); } bool EditorSelection::is_selected(Node *p_node) const { - return selection.has(p_node); } Array EditorSelection::_get_transformable_selected_nodes() { - Array ret; for (List<Node *>::Element *E = selected_node_list.front(); E; E = E->next()) { - ret.push_back(E->get()); } @@ -1067,11 +977,9 @@ Array EditorSelection::_get_transformable_selected_nodes() { } TypedArray<Node> EditorSelection::get_selected_nodes() { - TypedArray<Node> ret; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - ret.push_back(E->key()); } @@ -1079,7 +987,6 @@ TypedArray<Node> EditorSelection::get_selected_nodes() { } void EditorSelection::_bind_methods() { - ClassDB::bind_method(D_METHOD("clear"), &EditorSelection::clear); ClassDB::bind_method(D_METHOD("add_node", "node"), &EditorSelection::add_node); ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node); @@ -1090,19 +997,16 @@ void EditorSelection::_bind_methods() { } void EditorSelection::add_editor_plugin(Object *p_object) { - editor_plugins.push_back(p_object); } void EditorSelection::_update_nl() { - if (!nl_changed) return; selected_node_list.clear(); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node *parent = E->key(); parent = parent->get_parent(); bool skip = false; @@ -1123,7 +1027,6 @@ void EditorSelection::_update_nl() { } void EditorSelection::update() { - _update_nl(); if (!changed) @@ -1141,7 +1044,6 @@ void EditorSelection::_emit_change() { } List<Node *> &EditorSelection::get_selected_node_list() { - if (changed) update(); else @@ -1150,7 +1052,6 @@ List<Node *> &EditorSelection::get_selected_node_list() { } List<Node *> EditorSelection::get_full_selected_node_list() { - List<Node *> node_list; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { node_list.push_back(E->key()); @@ -1160,9 +1061,7 @@ List<Node *> EditorSelection::get_full_selected_node_list() { } void EditorSelection::clear() { - while (!selection.empty()) { - remove_node(selection.front()->key()); } @@ -1170,13 +1069,11 @@ void EditorSelection::clear() { nl_changed = true; } EditorSelection::EditorSelection() { - emitted = false; changed = false; nl_changed = false; } EditorSelection::~EditorSelection() { - clear(); } diff --git a/editor/editor_data.h b/editor/editor_data.h index e4f4c67c8e..1dd2214e53 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -39,14 +39,12 @@ #include "scene/resources/texture.h" class EditorHistory { - enum { HISTORY_MAX = 64 }; struct Obj { - REF ref; ObjectID object; String property; @@ -54,7 +52,6 @@ class EditorHistory { }; struct History { - Vector<Obj> path; int level; }; @@ -66,7 +63,6 @@ class EditorHistory { //Vector<EditorPlugin*> editor_plugins; struct PropertyData { - String name; Variant value; }; @@ -106,10 +102,8 @@ public: class EditorSelection; class EditorData { - public: struct CustomType { - String name; Ref<Script> script; Ref<Texture2D> icon; @@ -131,7 +125,6 @@ private: Vector<EditorPlugin *> editor_plugins; struct PropertyData { - String name; Variant value; }; @@ -234,7 +227,6 @@ public: }; class EditorSelection : public Object { - GDCLASS(EditorSelection, Object); private: diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index cb87656382..3039c3adb5 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -38,7 +38,6 @@ #include "servers/display_server.h" void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p_dir, const String &p_select_path) { - updating = true; String path = p_dir->get_path(); @@ -49,7 +48,6 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p if (!p_item->get_parent()) { p_item->set_text(0, "res://"); } else { - if (!opened_paths.has(path) && (p_select_path == String() || !p_select_path.begins_with(path))) { p_item->set_collapsed(true); } @@ -61,14 +59,12 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p //bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"); updating = false; for (int i = 0; i < p_dir->get_subdir_count(); i++) { - TreeItem *ti = tree->create_item(p_item); _update_dir(ti, p_dir->get_subdir(i)); } } void EditorDirDialog::reload(const String &p_path) { - if (!is_visible()) { must_reload = true; return; @@ -82,7 +78,6 @@ void EditorDirDialog::reload(const String &p_path) { } void EditorDirDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorDirDialog::reload), make_binds("")); reload(); @@ -110,7 +105,6 @@ void EditorDirDialog::_notification(int p_what) { } void EditorDirDialog::_item_collapsed(Object *p_item) { - TreeItem *item = Object::cast_to<TreeItem>(p_item); if (updating) @@ -127,7 +121,6 @@ void EditorDirDialog::_item_activated() { } void EditorDirDialog::ok_pressed() { - TreeItem *ti = tree->get_selected(); if (!ti) return; @@ -138,7 +131,6 @@ void EditorDirDialog::ok_pressed() { } void EditorDirDialog::_make_dir() { - TreeItem *ti = tree->get_selected(); if (!ti) { mkdirerr->set_text(TTR("Please select a base directory first.")); @@ -151,7 +143,6 @@ void EditorDirDialog::_make_dir() { } void EditorDirDialog::_make_dir_confirm() { - TreeItem *ti = tree->get_selected(); if (!ti) return; @@ -173,12 +164,10 @@ void EditorDirDialog::_make_dir_confirm() { } void EditorDirDialog::_bind_methods() { - ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir"))); } EditorDirDialog::EditorDirDialog() { - updating = false; set_title(TTR("Choose a Directory")); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index abfd8e5484..476f9bcfea 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -48,7 +48,6 @@ #include "scene/resources/resource_format_text.h" static int _get_pad(int p_alignment, int p_n) { - int rest = p_n % p_alignment; int pad = 0; if (rest > 0) { @@ -61,7 +60,6 @@ static int _get_pad(int p_alignment, int p_n) { #define PCK_PADDING 16 bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) { - if (values.has(p_name)) { values[p_name] = p_value; EditorExport::singleton->save_presets(); @@ -72,7 +70,6 @@ bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) } bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { - if (values.has(p_name)) { r_ret = values[p_name]; return true; @@ -82,9 +79,7 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { } void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (platform->get_option_visibility(E->get().name, values)) { p_list->push_back(E->get()); } @@ -92,12 +87,10 @@ void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { } Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { - return platform; } Vector<String> EditorExportPreset::get_files_to_export() const { - Vector<String> files; for (Set<String>::Element *E = selected_files.front(); E; E = E->next()) { files.push_back(E->get()); @@ -115,18 +108,15 @@ String EditorExportPreset::get_name() const { } void EditorExportPreset::set_runnable(bool p_enable) { - runnable = p_enable; EditorExport::singleton->save_presets(); } bool EditorExportPreset::is_runnable() const { - return runnable; } void EditorExportPreset::set_export_filter(ExportFilter p_filter) { - export_filter = p_filter; EditorExport::singleton->save_presets(); } @@ -136,18 +126,15 @@ EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const { } void EditorExportPreset::set_include_filter(const String &p_include) { - include_filter = p_include; EditorExport::singleton->save_presets(); } String EditorExportPreset::get_include_filter() const { - return include_filter; } void EditorExportPreset::set_export_path(const String &p_path) { - export_path = p_path; /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path, * this should be removed. */ @@ -159,23 +146,19 @@ void EditorExportPreset::set_export_path(const String &p_path) { } String EditorExportPreset::get_export_path() const { - return export_path; } void EditorExportPreset::set_exclude_filter(const String &p_exclude) { - exclude_filter = p_exclude; EditorExport::singleton->save_presets(); } String EditorExportPreset::get_exclude_filter() const { - return exclude_filter; } void EditorExportPreset::add_export_file(const String &p_path) { - selected_files.insert(p_path); EditorExport::singleton->save_presets(); } @@ -186,12 +169,10 @@ void EditorExportPreset::remove_export_file(const String &p_path) { } bool EditorExportPreset::has_export_file(const String &p_path) { - return selected_files.has(p_path); } void EditorExportPreset::add_patch(const String &p_path, int p_at_pos) { - if (p_at_pos < 0) patches.push_back(p_path); else @@ -210,7 +191,6 @@ void EditorExportPreset::set_patch(int p_index, const String &p_path) { EditorExport::singleton->save_presets(); } String EditorExportPreset::get_patch(int p_index) { - ERR_FAIL_INDEX_V(p_index, patches.size(), String()); return patches[p_index]; } @@ -220,42 +200,35 @@ Vector<String> EditorExportPreset::get_patches() const { } void EditorExportPreset::set_custom_features(const String &p_custom_features) { - custom_features = p_custom_features; EditorExport::singleton->save_presets(); } String EditorExportPreset::get_custom_features() const { - return custom_features; } void EditorExportPreset::set_script_export_mode(int p_mode) { - script_mode = p_mode; EditorExport::singleton->save_presets(); } int EditorExportPreset::get_script_export_mode() const { - return script_mode; } void EditorExportPreset::set_script_encryption_key(const String &p_key) { - script_key = p_key; EditorExport::singleton->save_presets(); } String EditorExportPreset::get_script_encryption_key() const { - return script_key; } /////////////////////////////////// void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) { - String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); @@ -274,7 +247,6 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) } if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { - r_flags.push_back("--remote-debug"); r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port)); @@ -283,11 +255,9 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) ScriptEditor::get_singleton()->get_breakpoints(&breakpoints); if (breakpoints.size()) { - r_flags.push_back("--breakpoints"); String bpoints; for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { - bpoints += E->get().replace(" ", "%20"); if (E->next()) bpoints += ","; @@ -298,18 +268,15 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags) } if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { - r_flags.push_back("--debug-collisions"); } if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { - r_flags.push_back("--debug-navigation"); } } Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) { - PackData *pd = (PackData *)p_userdata; SavedData sd; @@ -342,7 +309,6 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa } Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) { - String path = p_path.replace_first("res://", ""); ZipData *zd = (ZipData *)p_userdata; @@ -377,7 +343,6 @@ Ref<ImageTexture> EditorExportPlatform::get_option_icon(int p_index) const { } String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { - String current_version = VERSION_FULL_CONFIG; String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version).plus_file(template_file_name); @@ -397,7 +362,6 @@ bool EditorExportPlatform::exists_export_template(String template_file_name, Str } Ref<EditorExportPreset> EditorExportPlatform::create_preset() { - Ref<EditorExportPreset> preset; preset.instance(); preset->platform = Ref<EditorExportPlatform>(this); @@ -406,7 +370,6 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { get_export_options(&options); for (List<ExportOption>::Element *E = options.front(); E; E = E->next()) { - preset->properties.push_back(E->get().option); preset->values[E->get().option.name] = E->get().default_value; } @@ -415,7 +378,6 @@ Ref<EditorExportPreset> EditorExportPlatform::create_preset() { } void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths) { - for (int i = 0; i < p_dir->get_subdir_count(); i++) { _export_find_resources(p_dir->get_subdir(i), p_paths); } @@ -426,7 +388,6 @@ void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_d } void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) { - if (p_paths.has(p_path)) return; @@ -441,13 +402,11 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<S Vector<String> deps = dir->get_file_deps(file_idx); for (int i = 0; i < deps.size(); i++) { - _export_find_dependencies(deps[i], p_paths); } } void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) { - da->list_dir_begin(); String cur_dir = da->get_current_dir().replace("\\", "/"); if (!cur_dir.ends_with("/")) @@ -488,7 +447,6 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S } void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) { - if (p_filter == "") return; Vector<String> split = p_filter.split(","); @@ -507,19 +465,16 @@ void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String & } void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) { - if (p_preset.is_valid()) { export_preset = p_preset; } } Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const { - return export_preset; } void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) { - ExtraFile ef; ef.data = p_file; ef.path = p_path; @@ -528,7 +483,6 @@ void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p } void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &tags) { - shared_objects.push_back(SharedObject(p_path, tags)); } @@ -584,21 +538,18 @@ Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { } void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { - if (get_script_instance()) { get_script_instance()->call("_export_file", p_path, p_type, p_features); } } void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) { - if (get_script_instance()) { get_script_instance()->call("_export_begin", p_features, p_debug, p_path, p_flags); } } void EditorExportPlugin::_export_end_script() { - if (get_script_instance()) { get_script_instance()->call("_export_end"); } @@ -611,12 +562,10 @@ void EditorExportPlugin::_export_begin(const Set<String> &p_features, bool p_deb } void EditorExportPlugin::skip() { - skipped = true; } 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); @@ -649,7 +598,6 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai } if (p_preset->get_custom_features() != String()) { - Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); for (int i = 0; i < tmp_custom_list.size(); i++) { @@ -716,7 +664,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & 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); if (p_so_func) { @@ -740,7 +687,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & int total = paths.size(); for (Set<String>::Element *E = paths.front(); E; E = E->next()) { - String path = E->get(); String type = ResourceLoader::get_resource_type(path); @@ -760,7 +706,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Set<String> remap_features; for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); String feature = remap.get_slice(".", 1); if (features.has(feature)) { @@ -775,7 +720,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & err = OK; for (List<String>::Element *F = remaps.front(); F; F = F->next()) { - String remap = F->get(); if (remap == "path") { String remapped_path = config->get_value("remap", remap); @@ -805,7 +749,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } else { - bool do_export = true; for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based @@ -851,7 +794,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & Vector<String> custom_list; if (p_preset->get_custom_features() != String()) { - Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); for (int i = 0; i < tmp_custom_list.size(); i++) { @@ -917,7 +859,6 @@ Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObj } Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) { - EditorProgress ep("savepack", TTR("Packing"), 102, true); String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp"); @@ -1002,7 +943,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c int header_padding = _get_pad(PCK_PADDING, header_size); for (int i = 0; i < pd.file_ofs.size(); i++) { - int string_len = pd.file_ofs[i].path_utf8.length(); int pad = _get_pad(4, string_len); @@ -1034,7 +974,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c uint8_t buf[bufsize]; while (true) { - int got = ftmp->get_buffer(buf, bufsize); if (got <= 0) break; @@ -1067,7 +1006,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c } Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path) { - EditorProgress ep("savezip", TTR("Packing"), 102, true); FileAccess *src_f; @@ -1098,7 +1036,6 @@ Error EditorExportPlatform::export_zip(const Ref<EditorExportPreset> &p_preset, } void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) { - String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); @@ -1117,7 +1054,6 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags } if (p_flags & DEBUG_FLAG_REMOTE_DEBUG) { - r_flags.push_back("--remote-debug"); r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port)); @@ -1126,11 +1062,9 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags ScriptEditor::get_singleton()->get_breakpoints(&breakpoints); if (breakpoints.size()) { - r_flags.push_back("--breakpoints"); String bpoints; for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) { - bpoints += E->get().replace(" ", "%20"); if (E->next()) bpoints += ","; @@ -1141,12 +1075,10 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags } if (p_flags & DEBUG_FLAG_VIEW_COLLISONS) { - r_flags.push_back("--debug-collisions"); } if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { - r_flags.push_back("--debug-navigation"); } } @@ -1158,11 +1090,9 @@ EditorExportPlatform::EditorExportPlatform() { EditorExport *EditorExport::singleton = nullptr; void EditorExport::_save() { - Ref<ConfigFile> config; config.instance(); for (int i = 0; i < export_presets.size(); i++) { - Ref<EditorExportPreset> preset = export_presets[i]; String section = "preset." + itos(i); @@ -1208,7 +1138,6 @@ void EditorExport::_save() { } void EditorExport::save_presets() { - if (block_save) return; save_timer->start(); @@ -1218,24 +1147,20 @@ void EditorExport::_bind_methods() { } void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) { - export_platforms.push_back(p_platform); } int EditorExport::get_export_platform_count() { - return export_platforms.size(); } Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>()); return export_platforms[p_idx]; } void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) { - if (p_at_pos < 0) export_presets.push_back(p_preset); else @@ -1243,7 +1168,6 @@ void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, in } String EditorExportPlatform::test_etc2() const { - String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name"); bool etc_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc"); bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2"); @@ -1258,48 +1182,40 @@ String EditorExportPlatform::test_etc2() const { } int EditorExport::get_export_preset_count() const { - return export_presets.size(); } Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>()); return export_presets[p_idx]; } void EditorExport::remove_export_preset(int p_idx) { - export_presets.remove(p_idx); save_presets(); } void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { - if (export_plugins.find(p_plugin) == -1) { export_plugins.push_back(p_plugin); } } void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { - export_plugins.erase(p_plugin); } Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() { - return export_plugins; } void EditorExport::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { load_config(); } } void EditorExport::load_config() { - Ref<ConfigFile> config; config.instance(); Error err = config->load("res://export_presets.cfg"); @@ -1310,7 +1226,6 @@ void EditorExport::load_config() { int index = 0; while (true) { - String section = "preset." + itos(index); if (!config->has_section(section)) break; @@ -1353,7 +1268,6 @@ void EditorExport::load_config() { } if (get_files) { - Vector<String> files = config->get_value(section, "export_files"); for (int i = 0; i < files.size(); i++) { @@ -1385,7 +1299,6 @@ void EditorExport::load_config() { config->get_section_keys(option_section, &options); for (List<String>::Element *E = options.front(); E; E = E->next()) { - Variant value = config->get_value(option_section, E->get()); preset->set(E->get(), value); @@ -1399,7 +1312,6 @@ void EditorExport::load_config() { } bool EditorExport::poll_export_platforms() { - bool changed = false; for (int i = 0; i < export_platforms.size(); i++) { if (export_platforms.write[i]->poll_export()) { @@ -1411,7 +1323,6 @@ bool EditorExport::poll_export_platforms() { } EditorExport::EditorExport() { - save_timer = memnew(Timer); add_child(save_timer); save_timer->set_wait_time(0.8); @@ -1428,7 +1339,6 @@ EditorExport::~EditorExport() { ////////// void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { - if (p_preset->get("texture_format/s3tc")) { r_features->push_back("s3tc"); } @@ -1447,7 +1357,6 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> & } void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false)); @@ -1460,21 +1369,17 @@ void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { } String EditorExportPlatformPC::get_name() const { - return name; } String EditorExportPlatformPC::get_os_name() const { - return os_name; } Ref<Texture2D> EditorExportPlatformPC::get_logo() const { - return logo; } bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { - String err; bool valid = false; @@ -1537,7 +1442,6 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr template_path = template_path.strip_edges(); if (template_path == String()) { - if (p_preset->get("binary_format/64_bits")) { if (p_debug) { template_path = find_export_template(debug_file_64); @@ -1576,7 +1480,6 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr int64_t embedded_size; err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size); if (err == OK && p_preset->get("binary_format/embed_pck")) { - if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) { EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB.")); return ERR_INVALID_PARAMETER; @@ -1625,25 +1528,20 @@ void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) { } void EditorExportPlatformPC::set_release_64(const String &p_file) { - release_file_64 = p_file; } void EditorExportPlatformPC::set_release_32(const String &p_file) { - release_file_32 = p_file; } void EditorExportPlatformPC::set_debug_64(const String &p_file) { - debug_file_64 = p_file; } void EditorExportPlatformPC::set_debug_32(const String &p_file) { - debug_file_32 = p_file; } void EditorExportPlatformPC::add_platform_feature(const String &p_feature) { - extra_features.insert(p_feature); } @@ -1657,7 +1555,6 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { } void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { - if (p_features.has("bptc")) { if (p_preset->has("texture_format/no_bptc_fallbacks")) { p_features.erase("s3tc"); @@ -1666,27 +1563,22 @@ void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<Edito } int EditorExportPlatformPC::get_chmod_flags() const { - return chmod_flags; } void EditorExportPlatformPC::set_chmod_flags(int p_flags) { - chmod_flags = p_flags; } EditorExportPlatformPC::FixUpEmbeddedPckFunc EditorExportPlatformPC::get_fixup_embedded_pck_func() const { - return fixup_embedded_pck_func; } void EditorExportPlatformPC::set_fixup_embedded_pck_func(FixUpEmbeddedPckFunc p_fixup_embedded_pck_func) { - fixup_embedded_pck_func = p_fixup_embedded_pck_func; } EditorExportPlatformPC::EditorExportPlatformPC() { - chmod_flags = -1; fixup_embedded_pck_func = nullptr; } @@ -1694,7 +1586,6 @@ EditorExportPlatformPC::EditorExportPlatformPC() { /////////////////////// void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { - String extension = p_path.get_extension().to_lower(); if (extension != "tres" && extension != "tscn") { return; @@ -1719,6 +1610,5 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con } EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() { - GLOBAL_DEF("editor/convert_text_resources_to_binary_on_export", false); } diff --git a/editor/editor_export.h b/editor/editor_export.h index 1dedc21350..797649855f 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -43,7 +43,6 @@ class EditorFileSystemDirectory; struct EditorProgress; class EditorExportPreset : public Reference { - GDCLASS(EditorExportPreset, Reference); public: @@ -152,7 +151,6 @@ struct SharedObject { }; class EditorExportPlatform : public Reference { - GDCLASS(EditorExportPlatform, Reference); public: @@ -161,7 +159,6 @@ public: private: struct SavedData { - uint64_t ofs; uint64_t size; Vector<uint8_t> md5; @@ -173,7 +170,6 @@ private: }; struct PackData { - FileAccess *f; Vector<SavedData> file_ofs; EditorProgress *ep; @@ -181,7 +177,6 @@ private: }; struct ZipData { - void *zip; EditorProgress *ep; }; @@ -394,7 +389,6 @@ public: }; class EditorExportPlatformPC : public EditorExportPlatform { - GDCLASS(EditorExportPlatformPC, EditorExportPlatform); public: @@ -456,7 +450,6 @@ public: }; class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin { - GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin); public: diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index e2b79efb43..7c8d9ff08f 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -86,7 +86,6 @@ bool EditorFeatureProfile::is_class_editor_disabled(const StringName &p_class) c } void EditorFeatureProfile::set_disable_class_property(const StringName &p_class, const StringName &p_property, bool p_disabled) { - if (p_disabled) { if (!disabled_properties.has(p_class)) { disabled_properties[p_class] = Set<StringName>(); @@ -102,7 +101,6 @@ void EditorFeatureProfile::set_disable_class_property(const StringName &p_class, } } bool EditorFeatureProfile::is_class_property_disabled(const StringName &p_class, const StringName &p_property) const { - if (!disabled_properties.has(p_class)) { return false; } @@ -119,7 +117,6 @@ bool EditorFeatureProfile::has_class_properties_disabled(const StringName &p_cla } void EditorFeatureProfile::set_disable_feature(Feature p_feature, bool p_disable) { - ERR_FAIL_INDEX(p_feature, FEATURE_MAX); features_disabled[p_feature] = p_disable; } @@ -134,7 +131,6 @@ String EditorFeatureProfile::get_feature_name(Feature p_feature) { } Error EditorFeatureProfile::save_to_file(const String &p_path) { - Dictionary json; json["type"] = "feature_profile"; Array dis_classes; @@ -180,7 +176,6 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { } Error EditorFeatureProfile::load_from_file(const String &p_path) { - Error err; String text = FileAccess::get_file_as_string(p_path, &err); if (err != OK) { @@ -232,7 +227,6 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { } if (json.has("disabled_features")) { - Array disabled_features_arr = json["disabled_features"]; for (int i = 0; i < FEATURE_MAX; i++) { bool found = false; @@ -253,7 +247,6 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { } void EditorFeatureProfile::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_disable_class", "class_name", "disable"), &EditorFeatureProfile::set_disable_class); ClassDB::bind_method(D_METHOD("is_class_disabled", "class_name"), &EditorFeatureProfile::is_class_disabled); @@ -282,7 +275,6 @@ void EditorFeatureProfile::_bind_methods() { } EditorFeatureProfile::EditorFeatureProfile() { - for (int i = 0; i < FEATURE_MAX; i++) { features_disabled[i] = false; } @@ -292,7 +284,6 @@ EditorFeatureProfile::EditorFeatureProfile() { void EditorFeatureProfileManager::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - current_profile = EDITOR_GET("_default_feature_profile"); if (current_profile != String()) { current.instance(); @@ -317,7 +308,6 @@ String EditorFeatureProfileManager::_get_selected_profile() { } void EditorFeatureProfileManager::_update_profile_list(const String &p_select_profile) { - String selected_profile; if (p_select_profile == String()) { //default, keep if (profile_list->get_selected() >= 0) { @@ -382,10 +372,8 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr } void EditorFeatureProfileManager::_profile_action(int p_action) { - switch (p_action) { case PROFILE_CLEAR: { - EditorSettings::get_singleton()->set("_default_feature_profile", ""); EditorSettings::get_singleton()->save(); current_profile = ""; @@ -395,7 +383,6 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { _emit_current_profile_changed(); } break; case PROFILE_SET: { - String selected = _get_selected_profile(); ERR_FAIL_COND(selected == String()); if (selected == current_profile) { @@ -410,22 +397,18 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { _emit_current_profile_changed(); } break; case PROFILE_IMPORT: { - import_profiles->popup_centered_ratio(); } break; case PROFILE_EXPORT: { - export_profile->popup_centered_ratio(); export_profile->set_current_file(_get_selected_profile() + ".profile"); } break; case PROFILE_NEW: { - new_profile_dialog->popup_centered(); new_profile_name->clear(); new_profile_name->grab_focus(); } break; case PROFILE_ERASE: { - String selected = _get_selected_profile(); ERR_FAIL_COND(selected == String()); @@ -436,7 +419,6 @@ void EditorFeatureProfileManager::_profile_action(int p_action) { } void EditorFeatureProfileManager::_erase_selected_profile() { - String selected = _get_selected_profile(); ERR_FAIL_COND(selected == String()); DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir()); @@ -470,12 +452,10 @@ void EditorFeatureProfileManager::_create_new_profile() { } void EditorFeatureProfileManager::_profile_selected(int p_what) { - _update_selected_profile(); } void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) { - TreeItem *class_item = class_list->create_item(p_parent); class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class, "Node")); @@ -522,7 +502,6 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S } void EditorFeatureProfileManager::_class_list_item_selected() { - if (updating_features) return; @@ -567,7 +546,6 @@ void EditorFeatureProfileManager::_class_list_item_selected() { ClassDB::get_property_list(class_name, &props, true); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - String name = E->get().name; if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) continue; @@ -586,7 +564,6 @@ void EditorFeatureProfileManager::_class_list_item_selected() { } void EditorFeatureProfileManager::_class_list_item_edited() { - if (updating_features) return; @@ -651,7 +628,6 @@ void EditorFeatureProfileManager::_property_item_edited() { } void EditorFeatureProfileManager::_update_selected_profile() { - String class_selected; int feature_selected = -1; @@ -690,7 +666,6 @@ void EditorFeatureProfileManager::_update_selected_profile() { TreeItem *features = class_list->create_item(root); features->set_text(0, TTR("Enabled Features:")); for (int i = 0; i < EditorFeatureProfile::FEATURE_MAX; i++) { - TreeItem *feature = class_list->create_item(features); feature->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); feature->set_text(0, TTRGET(EditorFeatureProfile::get_feature_name(EditorFeatureProfile::Feature(i)))); @@ -718,7 +693,6 @@ void EditorFeatureProfileManager::_update_selected_profile() { } void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths) { - //test it first for (int i = 0; i < p_paths.size(); i++) { Ref<EditorFeatureProfile> profile; @@ -753,7 +727,6 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths } void EditorFeatureProfileManager::_export_profile(const String &p_path) { - ERR_FAIL_COND(edited.is_null()); Error err = edited->save_to_file(p_path); if (err != OK) { @@ -762,7 +735,6 @@ void EditorFeatureProfileManager::_export_profile(const String &p_path) { } void EditorFeatureProfileManager::_save_and_update() { - String edited_path = _get_selected_profile(); ERR_FAIL_COND(edited_path == String()); ERR_FAIL_COND(edited.is_null()); @@ -775,7 +747,6 @@ void EditorFeatureProfileManager::_save_and_update() { } void EditorFeatureProfileManager::_emit_current_profile_changed() { - emit_signal("current_feature_profile_changed"); } @@ -790,14 +761,12 @@ Ref<EditorFeatureProfile> EditorFeatureProfileManager::get_current_profile() { EditorFeatureProfileManager *EditorFeatureProfileManager::singleton = nullptr; void EditorFeatureProfileManager::_bind_methods() { - ClassDB::bind_method("_update_selected_profile", &EditorFeatureProfileManager::_update_selected_profile); ADD_SIGNAL(MethodInfo("current_feature_profile_changed")); } EditorFeatureProfileManager::EditorFeatureProfileManager() { - VBoxContainer *main_vbc = memnew(VBoxContainer); add_child(main_vbc); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 5ae2398027..4036ec7ec6 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -94,7 +94,6 @@ public: VARIANT_ENUM_CAST(EditorFeatureProfile::Feature) class EditorFeatureProfileManager : public AcceptDialog { - GDCLASS(EditorFeatureProfileManager, AcceptDialog); enum Action { diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 2411852541..561ebb6298 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -55,9 +55,7 @@ VBoxContainer *EditorFileDialog::get_vbox() { } void EditorFileDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - // update icons mode_thumbnails->set_icon(item_list->get_theme_icon("FileThumbnail", "EditorIcons")); mode_list->set_icon(item_list->get_theme_icon("FileList", "EditorIcons")); @@ -72,7 +70,6 @@ void EditorFileDialog::_notification(int p_what) { fav_down->set_icon(item_list->get_theme_icon("MoveDown", "EditorIcons")); } else if (p_what == NOTIFICATION_PROCESS) { - if (preview_waiting) { preview_wheel_timeout -= get_process_delta_time(); if (preview_wheel_timeout <= 0) { @@ -86,7 +83,6 @@ void EditorFileDialog::_notification(int p_what) { } } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"); if (show_hidden_files != is_showing_hidden) set_show_hidden_files(is_showing_hidden); @@ -106,7 +102,6 @@ void EditorFileDialog::_notification(int p_what) { // 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,13 +109,10 @@ void EditorFileDialog::_notification(int p_what) { } void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (k->is_pressed()) { - bool handled = false; if (ED_IS_SHORTCUT("file_dialog/go_back", p_event)) { @@ -186,12 +178,10 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorFileDialog::set_enable_multiple_selection(bool p_enable) { - item_list->set_select_mode(p_enable ? ItemList::SELECT_MULTI : ItemList::SELECT_SINGLE); }; Vector<String> EditorFileDialog::get_selected_files() const { - Vector<String> list; for (int i = 0; i < item_list->get_item_count(); i++) { if (item_list->is_selected(i)) @@ -201,7 +191,6 @@ Vector<String> EditorFileDialog::get_selected_files() const { }; void EditorFileDialog::update_dir() { - if (drives->is_visible()) { drives->select(dir_access->get_current_drive()); } @@ -210,7 +199,6 @@ void EditorFileDialog::update_dir() { // Disable "Open" button only when selecting file(s) mode. get_ok()->set_disabled(_is_open_should_be_disabled()); switch (mode) { - case FILE_MODE_OPEN_FILE: case FILE_MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); @@ -226,7 +214,6 @@ void EditorFileDialog::update_dir() { } void EditorFileDialog::_dir_entered(String p_dir) { - dir_access->change_dir(p_dir); file->set_text(""); invalidate(); @@ -235,12 +222,10 @@ void EditorFileDialog::_dir_entered(String p_dir) { } void EditorFileDialog::_file_entered(const String &p_file) { - _action_pressed(); } void EditorFileDialog::_save_confirm_pressed() { - String f = dir_access->get_current_dir().plus_file(file->get_text()); _save_to_recent(); hide(); @@ -248,7 +233,6 @@ void EditorFileDialog::_save_confirm_pressed() { } void EditorFileDialog::_post_popup() { - ConfirmationDialog::_post_popup(); if (invalidated) { update_file_list(); @@ -302,7 +286,6 @@ void EditorFileDialog::_post_popup() { } void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { - if (display_mode == DISPLAY_LIST || p_preview.is_null()) return; @@ -317,12 +300,10 @@ void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture } void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { - set_process(false); preview_waiting = false; if (p_preview.is_valid() && get_current_path() == p_path) { - preview->set_texture(p_preview); if (display_mode == DISPLAY_THUMBNAILS) { preview_vb->hide(); @@ -337,7 +318,6 @@ void EditorFileDialog::_thumbnail_done(const String &p_path, const Ref<Texture2D } void EditorFileDialog::_request_single_thumbnail(const String &p_path) { - if (!FileAccess::exists(p_path)) return; @@ -348,9 +328,7 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) { } void EditorFileDialog::_action_pressed() { - if (mode == FILE_MODE_OPEN_FILES) { - String fbase = dir_access->get_current_dir(); Vector<String> files; @@ -375,7 +353,6 @@ void EditorFileDialog::_action_pressed() { hide(); emit_signal("file_selected", f); } else if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_DIR) { - String path = dir_access->get_current_dir(); path = path.replace("\\", "/"); @@ -397,7 +374,6 @@ void EditorFileDialog::_action_pressed() { } if (mode == FILE_MODE_SAVE_FILE) { - bool valid = false; if (filter->get_selected() == filter->get_item_count() - 1) { @@ -405,10 +381,8 @@ void EditorFileDialog::_action_pressed() { } else if (filters.size() > 1 && filter->get_selected() == 0) { // match all filters for (int i = 0; i < filters.size(); i++) { - String flt = filters[i].get_slice(";", 0); for (int j = 0; j < flt.get_slice_count(","); j++) { - String str = flt.get_slice(",", j).strip_edges(); if (f.match(str)) { valid = true; @@ -423,11 +397,9 @@ void EditorFileDialog::_action_pressed() { if (filters.size() > 1) idx--; if (idx >= 0 && idx < filters.size()) { - String flt = filters[idx].get_slice(";", 0); int filterSliceCount = flt.get_slice_count(","); for (int j = 0; j < filterSliceCount; j++) { - String str = (flt.get_slice(",", j).strip_edges()); if (f.match(str)) { valid = true; @@ -448,7 +420,6 @@ void EditorFileDialog::_action_pressed() { } if (!valid) { - exterr->popup_centered(Size2(250, 80) * EDSCALE); return; } @@ -457,7 +428,6 @@ void EditorFileDialog::_action_pressed() { confirm_save->set_text(TTR("File Exists, Overwrite?")); confirm_save->popup_centered(Size2(200, 80)); } else { - _save_to_recent(); hide(); emit_signal("file_selected", f); @@ -466,14 +436,12 @@ void EditorFileDialog::_action_pressed() { } void EditorFileDialog::_cancel_pressed() { - file->set_text(""); invalidate(); hide(); } void EditorFileDialog::_item_selected(int p_item) { - int current = p_item; if (current < 0 || current >= item_list->get_item_count()) return; @@ -481,7 +449,6 @@ void EditorFileDialog::_item_selected(int p_item) { Dictionary d = item_list->get_item_metadata(current); if (!d["dir"]) { - file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } else if (mode == FILE_MODE_OPEN_DIR) { @@ -492,7 +459,6 @@ void EditorFileDialog::_item_selected(int p_item) { } void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { - int current = p_item; if (current < 0 || current >= item_list->get_item_count()) return; @@ -500,7 +466,6 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { Dictionary d = item_list->get_item_metadata(current); if (!d["dir"] && p_selected) { - file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } @@ -509,12 +474,10 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { } void EditorFileDialog::_items_clear_selection() { - item_list->unselect_all(); // If nothing is selected, then block Open button. switch (mode) { - case FILE_MODE_OPEN_FILE: case FILE_MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); @@ -534,7 +497,6 @@ void EditorFileDialog::_items_clear_selection() { } void EditorFileDialog::_push_history() { - local_history.resize(local_history_pos + 1); String new_path = dir_access->get_current_dir(); if (local_history.size() == 0 || new_path != local_history[local_history_pos]) { @@ -545,7 +507,6 @@ void EditorFileDialog::_push_history() { } } void EditorFileDialog::_item_dc_selected(int p_item) { - int current = p_item; if (current < 0 || current >= item_list->get_item_count()) return; @@ -553,7 +514,6 @@ void EditorFileDialog::_item_dc_selected(int p_item) { Dictionary d = item_list->get_item_metadata(current); if (d["dir"]) { - dir_access->change_dir(d["name"]); call_deferred("_update_file_list"); call_deferred("_update_dir"); @@ -561,13 +521,11 @@ void EditorFileDialog::_item_dc_selected(int p_item) { _push_history(); } else { - _action_pressed(); } } void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p_pos) { - // Right click on specific file(s) or folder(s). item_menu->clear(); item_menu->set_size(Size2(1, 1)); @@ -608,7 +566,6 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p } void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { - // Right click on folder background. Deselect all files so that actions are applied on the current folder. for (int i = 0; i < item_list->get_item_count(); i++) { item_list->unselect(i); @@ -629,9 +586,7 @@ void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { } void EditorFileDialog::_item_menu_id_pressed(int p_option) { - switch (p_option) { - case ITEM_MENU_COPY_PATH: { Dictionary item_meta = item_list->get_item_metadata(item_list->get_current()); DisplayServer::get_singleton()->clipboard_set(item_meta["path"]); @@ -669,7 +624,6 @@ void EditorFileDialog::_item_menu_id_pressed(int p_option) { } bool EditorFileDialog::_is_open_should_be_disabled() { - if (mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_SAVE_FILE) return false; @@ -678,7 +632,6 @@ bool EditorFileDialog::_is_open_should_be_disabled() { 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 == FILE_MODE_OPEN_FILE || mode == FILE_MODE_OPEN_FILES) && d["dir"]) || (mode == FILE_MODE_OPEN_DIR && !d["dir"])) @@ -708,7 +661,6 @@ void EditorFileDialog::update_file_name() { // DO NOT USE THIS FUNCTION UNLESS NEEDED, CALL INVALIDATE() INSTEAD. void EditorFileDialog::update_file_list() { - int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; Ref<Texture2D> folder_thumbnail; @@ -720,7 +672,6 @@ void EditorFileDialog::update_file_list() { item_list->get_v_scroll()->set_value(0); if (display_mode == DISPLAY_THUMBNAILS) { - item_list->set_max_columns(0); item_list->set_icon_mode(ItemList::ICON_MODE_TOP); item_list->set_fixed_column_width(thumbnail_size * 3 / 2); @@ -738,7 +689,6 @@ void EditorFileDialog::update_file_list() { preview_vb->hide(); } else { - item_list->set_icon_mode(ItemList::ICON_MODE_LEFT); item_list->set_max_columns(1); item_list->set_max_text_lines(1); @@ -760,7 +710,6 @@ void EditorFileDialog::update_file_list() { String item; while ((item = dir_access->get_next()) != "") { - if (item == "." || item == "..") continue; @@ -781,10 +730,8 @@ void EditorFileDialog::update_file_list() { item_list->add_item(dir_name); if (display_mode == DISPLAY_THUMBNAILS) { - item_list->set_item_icon(item_list->get_item_count() - 1, folder_thumbnail); } else { - item_list->set_item_icon(item_list->get_item_count() - 1, folder); } @@ -802,15 +749,12 @@ void EditorFileDialog::update_file_list() { List<String> patterns; // build filter if (filter->get_selected() == filter->get_item_count() - 1) { - // match all } else if (filters.size() > 1 && filter->get_selected() == 0) { // match all filters for (int i = 0; i < filters.size(); i++) { - String f = filters[i].get_slice(";", 0); for (int j = 0; j < f.get_slice_count(","); j++) { - patterns.push_back(f.get_slice(",", j).strip_edges()); } } @@ -820,37 +764,29 @@ void EditorFileDialog::update_file_list() { idx--; if (idx >= 0 && idx < filters.size()) { - String f = filters[idx].get_slice(";", 0); for (int j = 0; j < f.get_slice_count(","); j++) { - patterns.push_back(f.get_slice(",", j).strip_edges()); } } } while (!files.empty()) { - bool match = patterns.empty(); for (List<String>::Element *E = patterns.front(); E; E = E->next()) { - if (files.front()->get().matchn(E->get())) { - match = true; break; } } if (match) { - item_list->add_item(files.front()->get()); if (get_icon_func) { - Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { - item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail); item_list->set_item_tag_icon(item_list->get_item_count() - 1, icon); } else { @@ -905,7 +841,6 @@ void EditorFileDialog::_filter_selected(int) { } void EditorFileDialog::update_filters() { - filter->clear(); if (filters.size() > 1) { @@ -926,7 +861,6 @@ void EditorFileDialog::update_filters() { filter->add_item(TTR("All Recognized") + " (" + all_filters + ")"); } for (int i = 0; i < filters.size(); i++) { - String flt = filters[i].get_slice(";", 0).strip_edges(); String desc = filters[i].get_slice(";", 1).strip_edges(); if (desc.length()) @@ -939,32 +873,26 @@ void EditorFileDialog::update_filters() { } void EditorFileDialog::clear_filters() { - filters.clear(); update_filters(); invalidate(); } void EditorFileDialog::add_filter(const String &p_filter) { - filters.push_back(p_filter); update_filters(); invalidate(); } String EditorFileDialog::get_current_dir() const { - return dir_access->get_current_dir(); } String EditorFileDialog::get_current_file() const { - return file->get_text(); } String EditorFileDialog::get_current_path() const { - return dir_access->get_current_dir().plus_file(file->get_text()); } void EditorFileDialog::set_current_dir(const String &p_dir) { - if (p_dir.is_rel_path()) dir_access->change_dir(OS::get_singleton()->get_resource_dir()); dir_access->change_dir(p_dir); @@ -972,7 +900,6 @@ void EditorFileDialog::set_current_dir(const String &p_dir) { invalidate(); } void EditorFileDialog::set_current_file(const String &p_file) { - file->set_text(p_file); update_dir(); invalidate(); @@ -986,15 +913,12 @@ void EditorFileDialog::set_current_file(const String &p_file) { _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } void EditorFileDialog::set_current_path(const String &p_path) { - if (!p_path.size()) return; int pos = MAX(p_path.find_last("/"), p_path.find_last("\\")); if (pos == -1) { - set_current_file(p_path); } else { - String dir = p_path.substr(0, pos); String file = p_path.substr(pos + 1, p_path.length()); set_current_dir(dir); @@ -1003,10 +927,8 @@ void EditorFileDialog::set_current_path(const String &p_path) { } void EditorFileDialog::set_file_mode(FileMode p_mode) { - mode = p_mode; switch (mode) { - case FILE_MODE_OPEN_FILE: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a File")); @@ -1048,27 +970,22 @@ void EditorFileDialog::set_file_mode(FileMode p_mode) { } EditorFileDialog::FileMode EditorFileDialog::get_file_mode() const { - return mode; } void EditorFileDialog::set_access(Access p_access) { - ERR_FAIL_INDEX(p_access, 3); if (access == p_access) return; memdelete(dir_access); switch (p_access) { case ACCESS_FILESYSTEM: { - dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); } break; case ACCESS_RESOURCES: { - dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); } break; case ACCESS_USERDATA: { - dir_access = DirAccess::create(DirAccess::ACCESS_USERDATA); } break; } @@ -1080,7 +997,6 @@ void EditorFileDialog::set_access(Access p_access) { } void EditorFileDialog::invalidate() { - if (is_visible()) { update_file_list(); _update_favorites(); @@ -1091,12 +1007,10 @@ void EditorFileDialog::invalidate() { } EditorFileDialog::Access EditorFileDialog::get_access() const { - return access; } void EditorFileDialog::_make_dir_confirm() { - Error err = dir_access->make_dir(makedirname->get_text()); if (err == OK) { dir_access->change_dir(makedirname->get_text()); @@ -1112,13 +1026,11 @@ void EditorFileDialog::_make_dir_confirm() { } void EditorFileDialog::_make_dir() { - makedialog->popup_centered(Size2(250, 80) * EDSCALE); makedirname->grab_focus(); } void EditorFileDialog::_delete_items() { - // Collect the selected folders and files to delete and check them in the deletion dependency dialog. Vector<String> folders; Vector<String> files; @@ -1140,7 +1052,6 @@ void EditorFileDialog::_delete_items() { } void EditorFileDialog::_select_drive(int p_idx) { - String d = drives->get_item_text(p_idx); dir_access->change_dir(d); file->set_text(""); @@ -1150,7 +1061,6 @@ void EditorFileDialog::_select_drive(int p_idx) { } void EditorFileDialog::_update_drives() { - int dc = dir_access->get_drive_count(); if (dc == 0 || access != ACCESS_FILESYSTEM) { drives->hide(); @@ -1174,7 +1084,6 @@ void EditorFileDialog::_update_drives() { } void EditorFileDialog::_favorite_selected(int p_idx) { - dir_access->change_dir(favorites->get_item_metadata(p_idx)); file->set_text(""); update_dir(); @@ -1183,7 +1092,6 @@ void EditorFileDialog::_favorite_selected(int p_idx) { } void EditorFileDialog::_favorite_move_up() { - int current = favorites->get_current(); if (current > 0 && current < favorites->get_item_count()) { @@ -1203,7 +1111,6 @@ void EditorFileDialog::_favorite_move_up() { } } void EditorFileDialog::_favorite_move_down() { - int current = favorites->get_current(); if (current >= 0 && current < favorites->get_item_count() - 1) { @@ -1224,7 +1131,6 @@ void EditorFileDialog::_favorite_move_down() { } void EditorFileDialog::_update_favorites() { - bool res = access == ACCESS_RESOURCES; String current = get_current_dir(); @@ -1302,7 +1208,6 @@ void EditorFileDialog::_favorite_pressed() { } void EditorFileDialog::_recent_selected(int p_idx) { - Vector<String> recentd = EditorSettings::get_singleton()->get_recent_dirs(); ERR_FAIL_INDEX(p_idx, recentd.size()); @@ -1313,7 +1218,6 @@ void EditorFileDialog::_recent_selected(int p_idx) { } void EditorFileDialog::_go_up() { - dir_access->change_dir(".."); update_file_list(); update_dir(); @@ -1321,7 +1225,6 @@ void EditorFileDialog::_go_up() { } void EditorFileDialog::_go_back() { - if (local_history_pos <= 0) { return; } @@ -1335,7 +1238,6 @@ void EditorFileDialog::_go_back() { dir_next->set_disabled(local_history_pos == local_history.size() - 1); } void EditorFileDialog::_go_forward() { - if (local_history_pos == local_history.size() - 1) { return; } @@ -1354,7 +1256,6 @@ bool EditorFileDialog::default_show_hidden_files = false; EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode = DISPLAY_THUMBNAILS; void EditorFileDialog::set_display_mode(DisplayMode p_mode) { - if (display_mode == p_mode) return; if (p_mode == DISPLAY_THUMBNAILS) { @@ -1369,12 +1270,10 @@ void EditorFileDialog::set_display_mode(DisplayMode p_mode) { } EditorFileDialog::DisplayMode EditorFileDialog::get_display_mode() const { - return display_mode; } void EditorFileDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorFileDialog::_unhandled_input); ClassDB::bind_method(D_METHOD("_cancel_pressed"), &EditorFileDialog::_cancel_pressed); @@ -1452,7 +1351,6 @@ void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) { } void EditorFileDialog::_save_to_recent() { - String dir = get_current_dir(); Vector<String> recent = EditorSettings::get_singleton()->get_recent_dirs(); @@ -1476,17 +1374,14 @@ void EditorFileDialog::_save_to_recent() { } void EditorFileDialog::set_disable_overwrite_warning(bool p_disable) { - disable_overwrite_warning = p_disable; } bool EditorFileDialog::is_overwrite_warning_disabled() const { - return disable_overwrite_warning; } EditorFileDialog::EditorFileDialog() { - show_hidden_files = default_show_hidden_files; display_mode = default_display_mode; local_history_pos = 0; @@ -1730,7 +1625,6 @@ EditorFileDialog::EditorFileDialog() { } EditorFileDialog::~EditorFileDialog() { - if (unregister_func) unregister_func(this); memdelete(dir_access); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 8efb8f5368..cbedfc72a6 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -45,7 +45,6 @@ class DependencyRemoveDialog; class EditorFileDialog : public ConfirmationDialog { - GDCLASS(EditorFileDialog, ConfirmationDialog); public: diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index c211d5852a..acfb554766 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -46,12 +46,10 @@ EditorFileSystem *EditorFileSystem::singleton = nullptr; #define CACHE_FILE_NAME "filesystem_cache6" void EditorFileSystemDirectory::sort_files() { - files.sort_custom<FileInfoSort>(); } int EditorFileSystemDirectory::find_file_index(const String &p_file) const { - for (int i = 0; i < files.size(); i++) { if (files[i]->file == p_file) return i; @@ -59,7 +57,6 @@ int EditorFileSystemDirectory::find_file_index(const String &p_file) const { return -1; } int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const { - for (int i = 0; i < subdirs.size(); i++) { if (subdirs[i]->name == p_dir) return i; @@ -69,30 +66,25 @@ int EditorFileSystemDirectory::find_dir_index(const String &p_dir) const { } int EditorFileSystemDirectory::get_subdir_count() const { - return subdirs.size(); } EditorFileSystemDirectory *EditorFileSystemDirectory::get_subdir(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, subdirs.size(), nullptr); return subdirs[p_idx]; } int EditorFileSystemDirectory::get_file_count() const { - return files.size(); } String EditorFileSystemDirectory::get_file(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, files.size(), ""); return files[p_idx]->file; } String EditorFileSystemDirectory::get_path() const { - String p; const EditorFileSystemDirectory *d = this; while (d->parent) { @@ -104,7 +96,6 @@ String EditorFileSystemDirectory::get_path() const { } String EditorFileSystemDirectory::get_file_path(int p_idx) const { - String file = get_file(p_idx); const EditorFileSystemDirectory *d = this; while (d->parent) { @@ -116,13 +107,11 @@ String EditorFileSystemDirectory::get_file_path(int p_idx) const { } Vector<String> EditorFileSystemDirectory::get_file_deps(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, files.size(), Vector<String>()); return files[p_idx]->deps; } bool EditorFileSystemDirectory::get_file_import_is_valid(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, files.size(), false); return files[p_idx]->import_valid; } @@ -140,23 +129,19 @@ String EditorFileSystemDirectory::get_file_script_class_icon_path(int p_idx) con } StringName EditorFileSystemDirectory::get_file_type(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, files.size(), ""); return files[p_idx]->type; } String EditorFileSystemDirectory::get_name() { - return name; } EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() { - return parent; } void EditorFileSystemDirectory::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_subdir_count"), &EditorFileSystemDirectory::get_subdir_count); ClassDB::bind_method(D_METHOD("get_subdir", "idx"), &EditorFileSystemDirectory::get_subdir); ClassDB::bind_method(D_METHOD("get_file_count"), &EditorFileSystemDirectory::get_file_count); @@ -174,27 +159,22 @@ void EditorFileSystemDirectory::_bind_methods() { } EditorFileSystemDirectory::EditorFileSystemDirectory() { - modified_time = 0; parent = nullptr; verified = false; } EditorFileSystemDirectory::~EditorFileSystemDirectory() { - for (int i = 0; i < files.size(); i++) { - memdelete(files[i]); } for (int i = 0; i < subdirs.size(); i++) { - memdelete(subdirs[i]); } } void EditorFileSystem::_scan_filesystem() { - ERR_FAIL_COND(!scanning || new_filesystem); //read .fscache @@ -212,7 +192,6 @@ void EditorFileSystem::_scan_filesystem() { if (f) { //read the disk cache while (!f->eof_reached()) { - String l = f->get_line().strip_edges(); if (first) { if (first_scan) { @@ -282,7 +261,6 @@ void EditorFileSystem::_scan_filesystem() { FileAccessRef f2 = FileAccess::open(update_cache, FileAccess::READ); String l = f2->get_line().strip_edges(); while (l != String()) { - file_cache.erase(l); //erase cache for this, so it gets updated l = f2->get_line().strip_edges(); } @@ -319,7 +297,6 @@ void EditorFileSystem::_scan_filesystem() { } void EditorFileSystem::_save_filesystem_cache() { - group_file_cache.clear(); String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME); @@ -334,13 +311,11 @@ void EditorFileSystem::_save_filesystem_cache() { } void EditorFileSystem::_thread_func(void *_userdata) { - EditorFileSystem *sd = (EditorFileSystem *)_userdata; sd->_scan_filesystem(); } bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_imported_files) { - if (!reimport_on_missing_imported_files && p_only_imported_files) return false; @@ -378,7 +353,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo String dest_md5 = ""; while (true) { - assign = Variant(); next_tag.fields.clear(); next_tag.name = String(); @@ -460,7 +434,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo //check source md5 matching if (!p_only_imported_files) { - if (source_file != String() && source_file != p_path) { return true; //file was moved, reimport } @@ -486,7 +459,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo } bool EditorFileSystem::_update_scan_actions() { - sources_changed.clear(); bool fs_changed = false; @@ -495,18 +467,14 @@ bool EditorFileSystem::_update_scan_actions() { Vector<String> reloads; for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) { - ItemAction &ia = E->get(); switch (ia.action) { case ItemAction::ACTION_NONE: { - } break; case ItemAction::ACTION_DIR_ADD: { - int idx = 0; for (int i = 0; i < ia.dir->subdirs.size(); i++) { - if (ia.new_dir->name < ia.dir->subdirs[i]->name) break; idx++; @@ -520,17 +488,14 @@ bool EditorFileSystem::_update_scan_actions() { fs_changed = true; } break; case ItemAction::ACTION_DIR_REMOVE: { - ERR_CONTINUE(!ia.dir->parent); ia.dir->parent->subdirs.erase(ia.dir); memdelete(ia.dir); fs_changed = true; } break; case ItemAction::ACTION_FILE_ADD: { - int idx = 0; for (int i = 0; i < ia.dir->files.size(); i++) { - if (ia.new_file->file < ia.dir->files[i]->file) break; idx++; @@ -545,7 +510,6 @@ bool EditorFileSystem::_update_scan_actions() { } break; case ItemAction::ACTION_FILE_REMOVE: { - int idx = ia.dir->find_file_index(ia.file); ERR_CONTINUE(idx == -1); _delete_internal_files(ia.dir->files[idx]->file); @@ -556,7 +520,6 @@ bool EditorFileSystem::_update_scan_actions() { } break; case ItemAction::ACTION_FILE_TEST_REIMPORT: { - int idx = ia.dir->find_file_index(ia.file); ERR_CONTINUE(idx == -1); String full_path = ia.dir->get_file_path(idx); @@ -573,7 +536,6 @@ bool EditorFileSystem::_update_scan_actions() { fs_changed = true; } break; case ItemAction::ACTION_FILE_RELOAD: { - int idx = ia.dir->find_file_index(ia.file); ERR_CONTINUE(idx == -1); String full_path = ia.dir->get_file_path(idx); @@ -604,7 +566,6 @@ bool EditorFileSystem::_update_scan_actions() { } void EditorFileSystem::scan() { - if (false /*&& bool(Globals::get_singleton()->get("debug/disable_scan"))*/) return; @@ -630,7 +591,6 @@ void EditorFileSystem::scan() { _queue_update_script_classes(); first_scan = false; } else { - ERR_FAIL_COND(thread); set_process(true); Thread::Settings s; @@ -644,14 +604,12 @@ void EditorFileSystem::scan() { } void EditorFileSystem::ScanProgress::update(int p_current, int p_total) const { - float ratio = low + ((hi - low) / p_total) * p_current; progress->step(ratio * 1000); EditorFileSystem::singleton->scan_total = ratio; } EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_current, int p_total) const { - ScanProgress sp = *this; float slice = (sp.hi - sp.low) / p_total; sp.low += slice * p_current; @@ -660,7 +618,6 @@ EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_cur } void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) { - List<String> dirs; List<String> files; @@ -670,7 +627,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess da->list_dir_begin(); while (true) { - String f = da->get_next(); if (f == "") break; @@ -679,7 +635,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess continue; if (da->current_is_dir()) { - if (f.begins_with(".")) // Ignore special and . / .. continue; @@ -691,7 +646,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess dirs.push_back(f); } else { - files.push_back(f); } } @@ -705,15 +659,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess int idx = 0; for (List<String>::Element *E = dirs.front(); E; E = E->next(), idx++) { - if (da->change_dir(E->get()) == OK) { - String d = da->get_current_dir(); if (d == cd || !d.begins_with(cd)) { da->change_dir(cd); //avoid recursion } else { - EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); efd->parent = p_dir; @@ -723,7 +674,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess int idx2 = 0; for (int i = 0; i < p_dir->subdirs.size(); i++) { - if (efd->name < p_dir->subdirs[i]->name) break; idx2++; @@ -744,7 +694,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } for (List<String>::Element *E = files.front(); E; E = E->next(), idx++) { - String ext = E->get().get_extension().to_lower(); if (!valid_extensions.has(ext)) { continue; //invalid @@ -759,7 +708,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess uint64_t mt = FileAccess::get_modified_time(path); if (import_extensions.has(ext)) { - //is imported uint64_t import_mt = 0; if (FileAccess::exists(path + ".import")) { @@ -767,7 +715,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && !_test_for_reimport(path, true)) { - fi->type = fc->type; fi->deps = fc->deps; fi->modified_time = fc->modification_time; @@ -795,7 +742,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } } else { - fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path); fi->import_group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(path); fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path); @@ -810,7 +756,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess scan_actions.push_back(ia); } } else { - if (fc && fc->modification_time == mt) { //not imported, so just update type if changed fi->type = fc->type; @@ -838,14 +783,12 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ScanProgress &p_progress) { - uint64_t current_mtime = FileAccess::get_modified_time(p_dir->get_path()); bool updated_dir = false; String cd = p_dir->get_path(); if (current_mtime != p_dir->modified_time || using_fat32_or_exfat) { - updated_dir = true; p_dir->modified_time = current_mtime; //ooooops, dir changed, see what's going on @@ -853,12 +796,10 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const //first mark everything as veryfied for (int i = 0; i < p_dir->files.size(); i++) { - p_dir->files[i]->verified = false; } for (int i = 0; i < p_dir->subdirs.size(); i++) { - p_dir->get_subdir(i)->verified = false; } @@ -869,7 +810,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const da->change_dir(cd); da->list_dir_begin(); while (true) { - String f = da->get_next(); if (f == "") break; @@ -878,13 +818,11 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const continue; if (da->current_is_dir()) { - if (f.begins_with(".")) // Ignore special and . / .. continue; int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this continue; if (FileAccess::exists(cd.plus_file(f).plus_file(".gdignore"))) // skip if another project inside this @@ -958,7 +896,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } for (int i = 0; i < p_dir->files.size(); i++) { - if (updated_dir && !p_dir->files[i]->verified) { //this file was removed, add action to remove it ItemAction ia; @@ -983,7 +920,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } else if (!FileAccess::exists(path + ".import")) { reimport = true; //no .import file, obviously reimport } else { - uint64_t import_mt = FileAccess::get_modified_time(path + ".import"); if (import_mt != p_dir->files[i]->import_modified_time) { reimport = true; @@ -993,7 +929,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } if (reimport) { - ItemAction ia; ia.action = ItemAction::ACTION_FILE_TEST_REIMPORT; ia.dir = p_dir; @@ -1005,7 +940,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const uint64_t mt = FileAccess::get_modified_time(path); if (mt != p_dir->files[i]->modified_time) { - p_dir->files[i]->modified_time = mt; //save new time, but test for reload ItemAction ia; @@ -1018,7 +952,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } for (int i = 0; i < p_dir->subdirs.size(); i++) { - if (updated_dir && !p_dir->subdirs[i]->verified) { //this directory was removed, add action to remove it ItemAction ia; @@ -1045,7 +978,6 @@ void EditorFileSystem::_delete_internal_files(String p_file) { } void EditorFileSystem::_thread_func_sources(void *_userdata) { - EditorFileSystem *efs = (EditorFileSystem *)_userdata; if (efs->filesystem) { EditorProgressBG pr("sources", TTR("ScanSources"), 1000); @@ -1059,12 +991,10 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) { } void EditorFileSystem::get_changed_sources(List<String> *r_changed) { - *r_changed = sources_changed; } void EditorFileSystem::scan_changes() { - if (first_scan || // Prevent a premature changes scan from inhibiting the first full scan scanning || scanning_changes || thread) { scan_changes_pending = true; @@ -1095,7 +1025,6 @@ void EditorFileSystem::scan_changes() { scanning_changes_done = true; emit_signal("sources_changed", sources_changed.size() > 0); } else { - ERR_FAIL_COND(thread_sources); set_process(true); scan_total = 0; @@ -1106,11 +1035,8 @@ void EditorFileSystem::scan_changes() { } void EditorFileSystem::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - call_deferred("scan"); //this should happen after every editor node entered the tree } break; @@ -1139,13 +1065,9 @@ void EditorFileSystem::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { - if (use_threads) { - if (scanning_changes) { - if (scanning_changes_done) { - scanning_changes = false; set_process(false); @@ -1160,7 +1082,6 @@ void EditorFileSystem::_notification(int p_what) { first_scan = false; } } else if (!scanning) { - set_process(false); if (filesystem) @@ -1187,34 +1108,28 @@ void EditorFileSystem::_notification(int p_what) { } bool EditorFileSystem::is_scanning() const { - return scanning || scanning_changes; } float EditorFileSystem::get_scanning_progress() const { - return scan_total; } EditorFileSystemDirectory *EditorFileSystem::get_filesystem() { - return filesystem; } void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file) { - if (!p_dir) return; //none p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time)); for (int i = 0; i < p_dir->files.size(); i++) { - if (p_dir->files[i]->import_group_file != String()) { group_file_cache.insert(p_dir->files[i]->import_group_file); } String s = p_dir->files[i]->file + "::" + p_dir->files[i]->type + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path; s += "::"; for (int j = 0; j < p_dir->files[i]->deps.size(); j++) { - if (j > 0) s += "<>"; s += p_dir->files[i]->deps[j]; @@ -1224,7 +1139,6 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, } for (int i = 0; i < p_dir->subdirs.size(); i++) { - _save_filesystem_cache(p_dir->subdirs[i], p_file); } } @@ -1252,13 +1166,11 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector EditorFileSystemDirectory *fs = filesystem; for (int i = 0; i < path.size(); i++) { - if (path[i].begins_with(".")) return false; int idx = -1; for (int j = 0; j < fs->get_subdir_count(); j++) { - if (fs->get_subdir(j)->get_name() == path[i]) { idx = j; break; @@ -1274,7 +1186,6 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector int idx2 = 0; for (int j = 0; j < fs->get_subdir_count(); j++) { - if (efsd->name < fs->get_subdir(j)->get_name()) break; idx2++; @@ -1286,14 +1197,12 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector fs->subdirs.insert(idx2, efsd); fs = efsd; } else { - fs = fs->get_subdir(idx); } } int cpos = -1; for (int i = 0; i < fs->files.size(); i++) { - if (fs->files[i]->file == file) { cpos = i; break; @@ -1307,12 +1216,10 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector } String EditorFileSystem::get_file_type(const String &p_file) const { - EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { - return ""; } @@ -1320,14 +1227,12 @@ 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 nullptr; EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { - return nullptr; } @@ -1338,7 +1243,6 @@ EditorFileSystemDirectory *EditorFileSystem::find_file(const String &p_file, int } EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p_path) { - if (!filesystem || scanning) return nullptr; @@ -1363,10 +1267,8 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p EditorFileSystemDirectory *fs = filesystem; for (int i = 0; i < path.size(); i++) { - int idx = -1; for (int j = 0; j < fs->get_subdir_count(); j++) { - if (fs->get_subdir(j)->get_name() == path[i]) { idx = j; break; @@ -1376,7 +1278,6 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p if (idx == -1) { return nullptr; } else { - fs = fs->get_subdir(idx); } } @@ -1395,7 +1296,6 @@ void EditorFileSystem::_save_late_updated_files() { } Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { - List<String> deps; ResourceLoader::get_dependencies(p_path, &deps); @@ -1408,7 +1308,6 @@ Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { } String EditorFileSystem::_get_global_script_class(const String &p_type, const String &p_path, String *r_extends, String *r_icon_path) const { - for (int i = 0; i < ScriptServer::get_language_count(); i++) { if (ScriptServer::get_language(i)->handles_global_class_type(p_type)) { String global_name; @@ -1450,7 +1349,6 @@ void EditorFileSystem::_scan_script_classes(EditorFileSystemDirectory *p_dir) { } void EditorFileSystem::update_script_classes() { - if (!update_script_classes_queued) return; @@ -1482,12 +1380,10 @@ void EditorFileSystem::_queue_update_script_classes() { } void EditorFileSystem::update_file(const String &p_file) { - EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (!_find_file(p_file, &fs, cpos)) { - if (!fs) return; } @@ -1508,7 +1404,6 @@ void EditorFileSystem::update_file(const String &p_file) { String type = ResourceLoader::get_resource_type(p_file); if (cpos == -1) { - //the file did not exist, it was added late_added_files.insert(p_file); //remember that it was added. This mean it will be scanned and imported on editor restart @@ -1528,12 +1423,10 @@ void EditorFileSystem::update_file(const String &p_file) { if (idx == fs->files.size()) { fs->files.push_back(fi); } else { - fs->files.insert(idx, fi); } cpos = idx; } else { - //the file exists and it was updated, and was not added in this step. //this means we must force upon next restart to scan it again, to get proper type and dependencies late_update_files.insert(p_file); @@ -1555,13 +1448,11 @@ void EditorFileSystem::update_file(const String &p_file) { } Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector<String> &p_files) { - String importer_name; Map<String, Map<StringName, Variant>> source_file_options; Map<String, String> base_paths; for (int i = 0; i < p_files.size(); i++) { - Ref<ConfigFile> config; config.instance(); Error err = config->load(p_files[i] + ".import"); @@ -1585,7 +1476,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector importer->get_import_options(&options); //set default values for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - source_file_options[p_files[i]][E->get().option.name] = E->get().default_value; } @@ -1611,7 +1501,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector //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()) { - const String &file = E->key(); String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file); FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE); @@ -1661,7 +1550,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector importer->get_import_options(&options); //set default values for (List<ResourceImporter::ImportOption>::Element *F = options.front(); F; F = F->next()) { - String base = F->get().option.name; Variant v = F->get().default_value; if (source_file_options[file].has(base)) { @@ -1699,11 +1587,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly if (ResourceCache::has(file)) { - Resource *r = ResourceCache::get(file); if (r->get_import_path() != String()) { - String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(file); r->set_import_path(dst_path); r->set_import_last_modified_time(0); @@ -1717,7 +1603,6 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector } void EditorFileSystem::_reimport_file(const String &p_file) { - EditorFileSystemDirectory *fs = nullptr; int cpos = -1; bool found = _find_file(p_file, &fs, cpos); @@ -1816,13 +1701,11 @@ void EditorFileSystem::_reimport_file(const String &p_file) { Vector<String> dest_paths; if (err == OK) { - if (importer->get_save_extension() == "") { //no path } else if (import_variants.size()) { //import with variants for (List<String>::Element *E = import_variants.front(); E; E = E->next()) { - String path = base_path.c_escape() + "." + E->get() + "." + importer->get_save_extension(); f->store_line("path." + E->get() + "=\"" + path + "\""); @@ -1835,7 +1718,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) { } } else { - f->store_line("valid=false"); } @@ -1876,7 +1758,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) { //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { - String base = E->get().option.name; String value; VariantWriter::write_to_string(params[base], value); @@ -1907,11 +1788,9 @@ void EditorFileSystem::_reimport_file(const String &p_file) { //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly if (ResourceCache::has(p_file)) { - Resource *r = ResourceCache::get(p_file); if (r->get_import_path() != String()) { - String dst_path = ResourceFormatImporter::get_singleton()->get_internal_resource_path(p_file); r->set_import_path(dst_path); r->set_import_last_modified_time(0); @@ -1922,7 +1801,6 @@ void EditorFileSystem::_reimport_file(const String &p_file) { } 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(); for (int i = 0; i < fc; i++) { @@ -1940,7 +1818,6 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map<Str } void EditorFileSystem::reimport_files(const Vector<String> &p_files) { - { //check that .import folder exists DirAccess *da = DirAccess::open("res://"); if (da->change_dir(".import") != OK) { @@ -1960,7 +1837,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { Set<String> groups_to_reimport; for (int i = 0; i < p_files.size(); i++) { - String group_file = ResourceFormatImporter::get_singleton()->get_import_group_file(p_files[i]); if (group_file_cache.has(p_files[i])) { @@ -1983,7 +1859,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { EditorFileSystemDirectory *fs = nullptr; int cpos = -1; if (_find_file(p_files[i], &fs, cpos)) { - fs->files.write[cpos]->import_group_file = group_file; } } @@ -2001,7 +1876,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_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()) { - Error err = _reimport_group(E->key(), E->get()); if (err == OK) { _reimport_file(E->key()); @@ -2019,7 +1893,6 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { } Error EditorFileSystem::_resource_import(const String &p_path) { - Vector<String> files; files.push_back(p_path); @@ -2034,13 +1907,10 @@ bool EditorFileSystem::is_group_file(const String &p_path) const { } void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const String &p_group_file, const String &p_new_location) { - int fc = efd->files.size(); EditorFileSystemDirectory::FileInfo *const *files = efd->files.ptrw(); for (int i = 0; i < fc; i++) { - if (files[i]->import_group_file == p_group_file) { - files[i]->import_group_file = p_new_location; Ref<ConfigFile> config; @@ -2051,7 +1921,6 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S continue; } if (config->has_section_key("remap", "group_file")) { - config->set_value("remap", "group_file", p_new_location); } @@ -2076,7 +1945,6 @@ void EditorFileSystem::_move_group_files(EditorFileSystemDirectory *efd, const S } void EditorFileSystem::move_group_file(const String &p_path, const String &p_new_path) { - if (get_filesystem()) { _move_group_files(get_filesystem(), p_path, p_new_path); if (group_file_cache.has(p_path)) { @@ -2087,7 +1955,6 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new } void EditorFileSystem::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_filesystem"), &EditorFileSystem::get_filesystem); ClassDB::bind_method(D_METHOD("is_scanning"), &EditorFileSystem::is_scanning); ClassDB::bind_method(D_METHOD("get_scanning_progress"), &EditorFileSystem::get_scanning_progress); @@ -2105,27 +1972,23 @@ void EditorFileSystem::_bind_methods() { } void EditorFileSystem::_update_extensions() { - valid_extensions.clear(); import_extensions.clear(); List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("", &extensionsl); for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - valid_extensions.insert(E->get()); } extensionsl.clear(); ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl); for (List<String>::Element *E = extensionsl.front(); E; E = E->next()) { - import_extensions.insert(E->get()); } } EditorFileSystem::EditorFileSystem() { - ResourceLoader::import = _resource_import; reimport_on_missing_imported_files = GLOBAL_DEF("editor/reimport_missing_imported_files", true); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 55a2ed3d09..da27a63c64 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -40,7 +40,6 @@ class FileAccess; struct EditorProgressBG; class EditorFileSystemDirectory : public Object { - GDCLASS(EditorFileSystemDirectory, Object); String name; @@ -104,13 +103,11 @@ public: }; class EditorFileSystem : public Node { - GDCLASS(EditorFileSystem, Node); _THREAD_SAFE_CLASS_ struct ItemAction { - enum Action { ACTION_NONE, ACTION_DIR_ADD, @@ -163,7 +160,6 @@ class EditorFileSystem : public Node { /* Used for reading the filesystem cache file */ struct FileCache { - String type; uint64_t modification_time; uint64_t import_modification_time; @@ -178,7 +174,6 @@ class EditorFileSystem : public Node { HashMap<String, FileCache> file_cache; struct ScanProgress { - float low; float hi; mutable EditorProgressBG *progress; diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 507a77e641..270495ff55 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -35,7 +35,6 @@ #include "editor_settings.h" Vector<String> EditorFolding::_get_unfolds(const Object *p_object) { - Vector<String> sections; sections.resize(p_object->editor_get_section_folding().size()); if (sections.size()) { @@ -61,7 +60,6 @@ void EditorFolding::save_resource_folding(const RES &p_resource, const String &p } void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfolds) { - int uc = p_unfolds.size(); const String *r = p_unfolds.ptr(); p_object->editor_clear_section_folding(); @@ -71,7 +69,6 @@ void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfol } void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) { - Ref<ConfigFile> config; config.instance(); @@ -117,7 +114,6 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p if (E->get().type == Variant::OBJECT) { RES res = p_node->get(E->get().name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { - Vector<String> res_unfolds = _get_unfolds(res.ptr()); resource_folds.push_back(res->get_path()); resource_folds.push_back(res_unfolds); @@ -132,7 +128,6 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p } } void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) { - ERR_FAIL_NULL(p_scene); FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); @@ -156,7 +151,6 @@ void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path config->save(file); } void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { - Ref<ConfigFile> config; config.instance(); @@ -218,14 +212,12 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { } bool EditorFolding::has_folding_data(const String &p_path) { - String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); return FileAccess::exists(file); } void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { - List<PropertyInfo> plist; p_object->get_property_list(&plist); String group_base; @@ -234,7 +226,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { Set<String> unfold_group; for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_CATEGORY) { group = ""; group_base = ""; @@ -249,7 +240,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { //can unfold if (E->get().usage & PROPERTY_USAGE_EDITOR) { - if (group != "") { //group if (group_base == String() || E->get().name.begins_with(group_base)) { bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); @@ -271,7 +261,6 @@ void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { if (E->get().type == Variant::OBJECT) { RES res = p_object->get(E->get().name); if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { - resources.insert(res); _do_object_unfolds(res.ptr(), resources); } @@ -301,7 +290,6 @@ void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resou } void EditorFolding::unfold_scene(Node *p_scene) { - Set<RES> resources; _do_node_unfolds(p_scene, p_scene, resources); } diff --git a/editor/editor_folding.h b/editor/editor_folding.h index 5220907fe7..13f07b99b0 100644 --- a/editor/editor_folding.h +++ b/editor/editor_folding.h @@ -34,7 +34,6 @@ #include "scene/main/node.h" class EditorFolding { - Vector<String> _get_unfolds(const Object *p_object); void _set_unfolds(Object *p_object, const Vector<String> &p_unfolds); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 6c5e8e17e4..31eead83de 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -43,7 +43,6 @@ DocData *EditorHelp::doc = nullptr; void EditorHelp::_init_colors() { - title_color = get_theme_color("accent_color", "Editor"); text_color = get_theme_color("default_color", "RichTextLabel"); headline_color = get_theme_color("headline_color", "EditorHelp"); @@ -58,21 +57,18 @@ void EditorHelp::_init_colors() { } void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) { - if (!is_visible_in_tree()) return; Ref<InputEventKey> k = p_ev; if (k.is_valid() && k->get_control() && k->get_keycode() == KEY_F) { - search->grab_focus(); search->select_all(); } } void EditorHelp::_search(bool p_search_previous) { - if (p_search_previous) find_bar->search_prev(); else @@ -80,12 +76,10 @@ void EditorHelp::_search(bool p_search_previous) { } void EditorHelp::_class_list_select(const String &p_select) { - _goto_desc(p_select); } void EditorHelp::_class_desc_select(const String &p_select) { - if (p_select.begins_with("$")) { //enum String select = p_select.substr(1, p_select.length()); String class_name; @@ -182,7 +176,6 @@ void EditorHelp::_class_desc_resized() { } void EditorHelp::_add_type(const String &p_type, const String &p_enum) { - String t = p_type; if (t.empty()) t = "void"; @@ -224,7 +217,6 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { } String EditorHelp::_fix_constant(const String &p_constant) const { - if (p_constant.strip_edges() == "4294967295") { return "0xFFFFFFFF"; } @@ -241,7 +233,6 @@ String EditorHelp::_fix_constant(const String &p_constant) const { } void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) { - method_line[p_method.name] = class_desc->get_line_count() - 2; //gets overridden if description const bool is_vararg = p_method.qualifiers.find("vararg") != -1; @@ -286,7 +277,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->add_text(": "); _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration); if (p_method.arguments[j].default_value != "") { - class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); @@ -312,7 +302,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview class_desc->add_text(")"); class_desc->pop(); if (p_method.qualifiers != "") { - class_desc->push_color(qualifier_color); class_desc->add_text(" "); _add_text(p_method.qualifiers); @@ -324,7 +313,6 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview } Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { - if (!doc->class_list.has(p_class)) return ERR_DOES_NOT_EXIST; @@ -378,7 +366,6 @@ void EditorHelp::_update_doc() { // Ascendents if (cd.inherits != "") { - class_desc->push_color(title_color); class_desc->push_font(doc_font); class_desc->add_text(TTR("Inherits:") + " "); @@ -402,14 +389,11 @@ void EditorHelp::_update_doc() { // Descendents if (ClassDB::class_exists(cd.name)) { - bool found = false; bool prev = false; for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { - if (E->get().inherits == cd.name) { - if (!found) { class_desc->push_color(title_color); class_desc->push_font(doc_font); @@ -419,7 +403,6 @@ void EditorHelp::_update_doc() { } if (prev) { - class_desc->add_text(" , "); } @@ -439,7 +422,6 @@ void EditorHelp::_update_doc() { // Brief description if (cd.brief_description != "") { - class_desc->push_color(text_color); class_desc->push_font(doc_bold_font); class_desc->push_indent(1); @@ -454,7 +436,6 @@ void EditorHelp::_update_doc() { // Class description if (cd.description != "") { - section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2)); description_line = class_desc->get_line_count() - 2; class_desc->push_color(title_color); @@ -514,7 +495,6 @@ void EditorHelp::_update_doc() { bool property_descr = false; if (cd.properties.size()) { - section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -614,7 +594,6 @@ void EditorHelp::_update_doc() { } if (methods.size()) { - if (sort_methods) methods.sort(); @@ -688,7 +667,6 @@ void EditorHelp::_update_doc() { // Theme properties if (cd.theme_properties.size()) { - section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -701,7 +679,6 @@ void EditorHelp::_update_doc() { class_desc->set_table_column_expand(1, true); for (int i = 0; i < cd.theme_properties.size(); i++) { - theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description class_desc->push_cell(); @@ -751,7 +728,6 @@ void EditorHelp::_update_doc() { // Signals if (cd.signals.size()) { - if (sort_methods) { cd.signals.sort(); } @@ -769,7 +745,6 @@ void EditorHelp::_update_doc() { class_desc->push_indent(1); for (int i = 0; i < cd.signals.size(); i++) { - signal_line[cd.signals[i].name] = class_desc->get_line_count() - 2; //gets overridden if description class_desc->push_font(doc_code_font); // monofont class_desc->push_color(headline_color); @@ -787,7 +762,6 @@ void EditorHelp::_update_doc() { class_desc->add_text(": "); _add_type(cd.signals[i].arguments[j].type); if (cd.signals[i].arguments[j].default_value != "") { - class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); @@ -802,7 +776,6 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->pop(); // end monofont if (cd.signals[i].description != "") { - class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); @@ -821,12 +794,10 @@ void EditorHelp::_update_doc() { // Constants and enums if (cd.constants.size()) { - Map<String, Vector<DocData::ConstantDoc>> enums; Vector<DocData::ConstantDoc> constants; for (int i = 0; i < cd.constants.size(); i++) { - if (cd.constants[i].enumeration != String()) { if (!enums.has(cd.constants[i].enumeration)) { enums[cd.constants[i].enumeration] = Vector<DocData::ConstantDoc>(); @@ -834,14 +805,12 @@ void EditorHelp::_update_doc() { enums[cd.constants[i].enumeration].push_back(cd.constants[i]); } else { - constants.push_back(cd.constants[i]); } } // Enums if (enums.size()) { - section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -853,7 +822,6 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (Map<String, Vector<DocData::ConstantDoc>>::Element *E = enums.front(); E; E = E->next()) { - enum_line[E->key()] = class_desc->get_line_count() - 2; class_desc->push_color(title_color); @@ -927,7 +895,6 @@ void EditorHelp::_update_doc() { // Constants if (constants.size()) { - section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -939,7 +906,6 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (int i = 0; i < constants.size(); i++) { - constant_line[constants[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); @@ -986,7 +952,6 @@ void EditorHelp::_update_doc() { // Property descriptions if (property_descr) { - section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -998,7 +963,6 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (int i = 0; i < cd.properties.size(); i++) { - if (cd.properties[i].overridden) continue; @@ -1038,7 +1002,6 @@ void EditorHelp::_update_doc() { class_desc->pop(); // cell if (cd.properties[i].setter != "") { - class_desc->push_cell(); class_desc->pop(); // cell @@ -1056,7 +1019,6 @@ void EditorHelp::_update_doc() { } if (cd.properties[i].getter != "") { - class_desc->push_cell(); class_desc->pop(); // cell @@ -1101,7 +1063,6 @@ void EditorHelp::_update_doc() { // Method descriptions if (method_descr) { - section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); @@ -1123,7 +1084,6 @@ void EditorHelp::_update_doc() { } for (int i = 0; i < methods_filtered.size(); i++) { - class_desc->push_font(doc_code_font); _add_method(methods_filtered[i], false); class_desc->pop(); @@ -1165,7 +1125,6 @@ void EditorHelp::_request_help(const String &p_string) { } void EditorHelp::_help_callback(const String &p_topic) { - String what = p_topic.get_slice(":", 0); String clss = p_topic.get_slice(":", 1); String name; @@ -1217,7 +1176,6 @@ void EditorHelp::_help_callback(const String &p_topic) { } static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { - DocData *doc = EditorHelp::get_doc_data(); String base_path; @@ -1244,7 +1202,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { int pos = 0; while (pos < bbcode.length()) { - int brk_pos = bbcode.find("[", pos); if (brk_pos < 0) @@ -1263,7 +1220,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { int brk_end = bbcode.find("]", brk_pos + 1); if (brk_end == -1) { - String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); if (!code_tag) text = text.replace("\n", "\n\n"); @@ -1278,7 +1234,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); if (!tag_ok) { - p_rt->add_text("["); pos = brk_pos + 1; continue; @@ -1295,12 +1250,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { code_tag = false; } else if (code_tag) { - p_rt->add_text("["); pos = brk_pos + 1; } else if (tag.begins_with("method ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ")) { - int tag_end = tag.find(" "); String link_tag = tag.substr(0, tag_end); @@ -1314,7 +1267,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; } else if (doc->class_list.has(tag)) { - p_rt->push_color(link_color); p_rt->push_meta("#" + tag); p_rt->add_text(tag); @@ -1323,19 +1275,16 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; } else if (tag == "b") { - //use bold font p_rt->push_font(doc_bold_font); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "i") { - //use italics font p_rt->push_color(font_color_hl); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag == "codeblock") { - //use monospace font p_rt->push_font(doc_code_font); p_rt->push_color(code_color); @@ -1343,7 +1292,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "kbd") { - //use keyboard font with custom color p_rt->push_font(doc_kbd_font); p_rt->push_color(kbd_color); @@ -1351,31 +1299,26 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { - //align to center p_rt->push_align(RichTextLabel::ALIGN_CENTER); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { - //force a line break p_rt->add_newline(); pos = brk_end + 1; } else if (tag == "u") { - //use underline p_rt->push_underline(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "s") { - //use strikethrough p_rt->push_strikethrough(); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); @@ -1385,13 +1328,11 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag.begins_with("url=")) { - String url = tag.substr(4, tag.length()); p_rt->push_meta(url); pos = brk_end + 1; tag_stack.push_front("url"); } else if (tag == "img") { - int end = bbcode.find("[", brk_end); if (end == -1) end = bbcode.length(); @@ -1404,7 +1345,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { pos = end; tag_stack.push_front(tag); } else if (tag.begins_with("color=")) { - String col = tag.substr(6, tag.length()); Color color; @@ -1450,7 +1390,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front("color"); } else if (tag.begins_with("font=")) { - String fnt = tag.substr(5, tag.length()); Ref<Font> font = ResourceLoader::load(base_path.plus_file(fnt), "Font"); @@ -1464,7 +1403,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front("font"); } else { - p_rt->add_text("["); //ignore pos = brk_pos + 1; } @@ -1476,7 +1414,6 @@ void EditorHelp::_add_text(const String &p_bbcode) { } void EditorHelp::generate_doc() { - doc = memnew(DocData); doc->generate(true); DocData compdoc; @@ -1485,11 +1422,9 @@ void EditorHelp::generate_doc() { } void EditorHelp::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - _update_doc(); } break; case NOTIFICATION_THEME_CHANGED: { @@ -1503,12 +1438,10 @@ void EditorHelp::_notification(int p_what) { } void EditorHelp::go_to_help(const String &p_help) { - _help_callback(p_help); } void EditorHelp::go_to_class(const String &p_class, int p_scroll) { - _goto_desc(p_class, p_scroll); } @@ -1527,12 +1460,10 @@ void EditorHelp::scroll_to_section(int p_section_index) { } void EditorHelp::popup_search() { - find_bar->popup_search(); } String EditorHelp::get_class() { - return edited_class; } @@ -1541,16 +1472,13 @@ void EditorHelp::search_again(bool p_search_previous) { } int EditorHelp::get_scroll() const { - return class_desc->get_v_scroll()->get_value(); } void EditorHelp::set_scroll(int p_scroll) { - class_desc->get_v_scroll()->set_value(p_scroll); } void EditorHelp::_bind_methods() { - ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select); ClassDB::bind_method("_request_help", &EditorHelp::_request_help); ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input); @@ -1561,7 +1489,6 @@ void EditorHelp::_bind_methods() { } EditorHelp::EditorHelp() { - set_custom_minimum_size(Size2(150 * EDSCALE, 0)); EDITOR_DEF("text_editor/help/sort_functions_alphabetically", true); @@ -1593,14 +1520,12 @@ EditorHelp::~EditorHelp() { } void EditorHelpBit::_go_to_help(String p_what) { - EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); ScriptEditor::get_singleton()->goto_help(p_what); emit_signal("request_hide"); } void EditorHelpBit::_meta_clicked(String p_select) { - if (p_select.begins_with("$")) { //enum String select = p_select.substr(1, p_select.length()); @@ -1613,11 +1538,9 @@ void EditorHelpBit::_meta_clicked(String p_select) { _go_to_help("class_enum:" + class_name + ":" + select); return; } else if (p_select.begins_with("#")) { - _go_to_help("class_name:" + p_select.substr(1, p_select.length())); return; } else if (p_select.begins_with("@")) { - String m = p_select.substr(1, p_select.length()); if (m.find(".") != -1) @@ -1626,13 +1549,11 @@ void EditorHelpBit::_meta_clicked(String p_select) { } void EditorHelpBit::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_text", "text"), &EditorHelpBit::set_text); ADD_SIGNAL(MethodInfo("request_hide")); } void EditorHelpBit::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: { rich_text->clear(); @@ -1640,7 +1561,6 @@ void EditorHelpBit::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - rich_text->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); } break; default: @@ -1649,14 +1569,12 @@ void EditorHelpBit::_notification(int p_what) { } void EditorHelpBit::set_text(const String &p_text) { - text = p_text; rich_text->clear(); _add_text_to_rt(text, rich_text); } EditorHelpBit::EditorHelpBit() { - rich_text = memnew(RichTextLabel); add_child(rich_text); rich_text->connect("meta_clicked", callable_mp(this, &EditorHelpBit::_meta_clicked)); @@ -1666,7 +1584,6 @@ EditorHelpBit::EditorHelpBit() { } FindBar::FindBar() { - search_text = memnew(LineEdit); add_child(search_text); search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0)); @@ -1701,7 +1618,6 @@ FindBar::FindBar() { } void FindBar::popup_search() { - show(); bool grabbed_focus = false; if (!search_text->has_focus()) { @@ -1719,11 +1635,9 @@ void FindBar::popup_search() { } void FindBar::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - find_prev->set_icon(get_theme_icon("MoveUp", "EditorIcons")); find_next->set_icon(get_theme_icon("MoveDown", "EditorIcons")); hide_button->set_normal_texture(get_theme_icon("Close", "EditorIcons")); @@ -1733,36 +1647,30 @@ void FindBar::_notification(int p_what) { 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: { - set_process_unhandled_input(is_visible_in_tree()); } break; } } void FindBar::_bind_methods() { - ClassDB::bind_method("_unhandled_input", &FindBar::_unhandled_input); ADD_SIGNAL(MethodInfo("search")); } void FindBar::set_rich_text_label(RichTextLabel *p_rich_text_label) { - rich_text_label = p_rich_text_label; } bool FindBar::search_next() { - return _search(); } bool FindBar::search_prev() { - return _search(true); } bool FindBar::_search(bool p_search_previous) { - String stext = search_text->get_text(); bool keep = prev_search == stext; @@ -1784,7 +1692,6 @@ bool FindBar::_search(bool p_search_previous) { } void FindBar::_update_results_count() { - results_count = 0; String searched = search_text->get_text(); @@ -1806,7 +1713,6 @@ void FindBar::_update_results_count() { } void FindBar::_update_matches_label() { - if (search_text->get_text().empty() || results_count == -1) { matches_label->hide(); } else { @@ -1818,7 +1724,6 @@ void FindBar::_update_matches_label() { } void FindBar::_hide_bar() { - if (search_text->has_focus()) rich_text_label->grab_focus(); @@ -1826,22 +1731,16 @@ void FindBar::_hide_bar() { } void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (k->is_pressed() && (rich_text_label->has_focus() || is_a_parent_of(get_focus_owner()))) { - bool accepted = true; switch (k->get_keycode()) { - case KEY_ESCAPE: { - _hide_bar(); } break; default: { - accepted = false; } break; } @@ -1854,12 +1753,10 @@ void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) { } void FindBar::_search_text_changed(const String &p_text) { - search_next(); } void FindBar::_search_text_entered(const String &p_text) { - if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { search_prev(); } else { diff --git a/editor/editor_help.h b/editor/editor_help.h index 2e053e674f..4d42c1d38a 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -88,7 +88,6 @@ public: }; class EditorHelp : public VBoxContainer { - GDCLASS(EditorHelp, VBoxContainer); enum Page { @@ -193,7 +192,6 @@ public: }; class EditorHelpBit : public MarginContainer { - GDCLASS(EditorHelpBit, MarginContainer); RichTextLabel *rich_text; diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 1a865de23d..936288b176 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -36,7 +36,6 @@ #include "editor_scale.h" void EditorHelpSearch::_update_icons() { - search_box->set_right_icon(results_tree->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon("Search", "EditorIcons")); @@ -48,7 +47,6 @@ void EditorHelpSearch::_update_icons() { } void EditorHelpSearch::_update_results() { - String term = search_box->get_text(); int search_flags = filter_combo->get_selected_id(); @@ -62,7 +60,6 @@ void EditorHelpSearch::_update_results() { } void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) { - // Redirect up and down navigational key events to the results list. Ref<InputEventKey> key = p_event; if (key.is_valid()) { @@ -79,17 +76,14 @@ void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) { } void EditorHelpSearch::_search_box_text_changed(const String &p_text) { - _update_results(); } void EditorHelpSearch::_filter_combo_item_selected(int p_option) { - _update_results(); } void EditorHelpSearch::_confirmed() { - TreeItem *item = results_tree->get_selected(); if (!item) return; @@ -103,7 +97,6 @@ void EditorHelpSearch::_confirmed() { } void EditorHelpSearch::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { @@ -113,17 +106,14 @@ void EditorHelpSearch::_notification(int p_what) { } } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - _update_icons(); } break; case NOTIFICATION_ENTER_TREE: { - connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed)); _update_icons(); } break; case NOTIFICATION_PROCESS: { - // Update background search. if (search.is_valid()) { if (search->work()) { @@ -148,17 +138,14 @@ void EditorHelpSearch::_notification(int p_what) { } void EditorHelpSearch::_bind_methods() { - ADD_SIGNAL(MethodInfo("go_to_help")); } void EditorHelpSearch::popup_dialog() { - popup_dialog(search_box->get_text()); } void EditorHelpSearch::popup_dialog(const String &p_term) { - // Restore valid window bounds or pop up at default size. Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "search_help", Rect2()); if (saved_size != Rect2()) @@ -182,7 +169,6 @@ void EditorHelpSearch::popup_dialog(const String &p_term) { } EditorHelpSearch::EditorHelpSearch() { - old_search = false; set_hide_on_ok(false); @@ -254,7 +240,6 @@ EditorHelpSearch::EditorHelpSearch() { } bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const StringName &p_class) { - Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); if (profile.is_null()) { return false; @@ -262,7 +247,6 @@ bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const Strin StringName class_name = p_class; while (class_name != StringName()) { - if (!ClassDB::class_exists(class_name)) { return false; } @@ -277,7 +261,6 @@ bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const Strin } bool EditorHelpSearch::Runner::_slice() { - bool phase_done = false; switch (phase) { case PHASE_MATCH_CLASSES_INIT: @@ -314,7 +297,6 @@ bool EditorHelpSearch::Runner::_slice() { } bool EditorHelpSearch::Runner::_phase_match_classes_init() { - iterator_doc = EditorHelp::get_doc_data()->class_list.front(); matches.clear(); matched_item = nullptr; @@ -323,10 +305,8 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() { } bool EditorHelpSearch::Runner::_phase_match_classes() { - DocData::ClassDoc &class_doc = iterator_doc->value(); if (!_is_class_disabled_by_feature_profile(class_doc.name)) { - matches[class_doc.name] = ClassMatch(); ClassMatch &match = matches[class_doc.name]; @@ -376,7 +356,6 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { } bool EditorHelpSearch::Runner::_phase_class_items_init() { - iterator_match = matches.front(); results_tree->clear(); @@ -387,7 +366,6 @@ bool EditorHelpSearch::Runner::_phase_class_items_init() { } bool EditorHelpSearch::Runner::_phase_class_items() { - ClassMatch &match = iterator_match->value(); if (search_flags & SEARCH_SHOW_HIERARCHY) { @@ -403,14 +381,12 @@ bool EditorHelpSearch::Runner::_phase_class_items() { } bool EditorHelpSearch::Runner::_phase_member_items_init() { - iterator_match = matches.front(); return true; } bool EditorHelpSearch::Runner::_phase_member_items() { - ClassMatch &match = iterator_match->value(); TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; @@ -430,14 +406,12 @@ bool EditorHelpSearch::Runner::_phase_member_items() { } bool EditorHelpSearch::Runner::_phase_select_match() { - if (matched_item) matched_item->select(0); return true; } bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const { - if (search_flags & SEARCH_CASE_SENSITIVE) return p_term.is_subsequence_of(p_string); else @@ -445,7 +419,6 @@ bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String } void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) { - if (!matched_item) { if (search_flags & SEARCH_CASE_SENSITIVE) { if (p_text.casecmp_to(term) == 0) @@ -458,7 +431,6 @@ void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_tex } TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_match) { - if (class_items.has(p_match.doc->name)) return class_items[p_match.doc->name]; @@ -479,7 +451,6 @@ 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_theme_icon(p_doc->name, "EditorIcons")) icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons"); @@ -505,7 +476,6 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const } TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { - String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; for (int i = 0; i < p_doc->arguments.size(); i++) { const DocData::ArgumentDoc &arg = p_doc->arguments[i]; @@ -520,7 +490,6 @@ TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, cons } TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { - String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; for (int i = 0; i < p_doc->arguments.size(); i++) { const DocData::ArgumentDoc &arg = p_doc->arguments[i]; @@ -535,13 +504,11 @@ TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, cons } TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) { - String tooltip = p_class_doc->name + "." + p_doc->name; return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, TTRC("Constant"), "constant", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) { - String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; tooltip += "\n " + p_class_doc->name + "." + p_doc->setter + "(value) setter"; tooltip += "\n " + p_class_doc->name + "." + p_doc->getter + "() getter"; @@ -549,13 +516,11 @@ TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, co } TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) { - String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, TTRC("Theme Property"), "theme_item", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_type, const String &p_metatype, const String &p_tooltip) { - Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { @@ -585,7 +550,6 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons } bool EditorHelpSearch::Runner::work(uint64_t slot) { - // Return true when the search has been completed, otherwise false. const uint64_t until = OS::get_singleton()->get_ticks_usec() + slot; while (!_slice()) diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 9f58c7244f..f7dbc5c3ad 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -84,7 +84,6 @@ public: }; class EditorHelpSearch::Runner : public Reference { - enum Phase { PHASE_MATCH_CLASSES_INIT, PHASE_MATCH_CLASSES, diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 6adc640651..f7d92050e1 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -39,13 +39,11 @@ #include "scene/resources/packed_scene.h" Size2 EditorProperty::get_minimum_size() const { - Size2 ms; Ref<Font> font = get_theme_font("font", "Tree"); ms.height = font->get_height(); for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -88,7 +86,6 @@ Size2 EditorProperty::get_minimum_size() const { } void EditorProperty::emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field, bool p_changing) { - Variant args[4] = { p_property, p_value, p_field, p_changing }; const Variant *argptrs[4] = { &args[0], &args[1], &args[2], &args[3] }; @@ -96,9 +93,7 @@ void EditorProperty::emit_changed(const StringName &p_property, const Variant &p } void EditorProperty::_notification(int p_what) { - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Size2 size = get_size(); Rect2 rect; Rect2 bottom_rect; @@ -114,7 +109,6 @@ void EditorProperty::_notification(int p_what) { //compute room needed for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -138,7 +132,6 @@ void EditorProperty::_notification(int p_what) { } if (bottom_editor) { - int m = 0; //get_constant("item_margin", "Tree"); bottom_rect = Rect2(m, rect.size.height + get_theme_constant("vseparation", "Tree"), size.width - m, bottom_editor->get_combined_minimum_size().height); @@ -175,7 +168,6 @@ void EditorProperty::_notification(int p_what) { //set children for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -348,14 +340,12 @@ bool EditorProperty::is_read_only() const { } bool EditorPropertyRevert::may_node_be_in_instance(Node *p_node) { - Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); bool might_be = false; Node *node = p_node; while (node) { - if (node->get_scene_instance_state().is_valid()) { might_be = true; break; @@ -375,7 +365,6 @@ bool EditorPropertyRevert::may_node_be_in_instance(Node *p_node) { } bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, const StringName &p_prop, Variant &value) { - Node *node = p_node; Node *orig = node; @@ -384,7 +373,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co bool found = false; while (node) { - Ref<SceneState> ss; if (node == edited_scene) { @@ -395,7 +383,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co } if (ss.is_valid()) { - NodePath np = node->get_path_to(orig); int node_idx = ss->find_node_by_path(np); if (node_idx >= 0) { @@ -403,7 +390,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co Variant lvar; lvar = ss->get_property_value(node_idx, p_prop, lfound); if (lfound) { - found = true; value = lvar; } @@ -429,7 +415,6 @@ bool EditorPropertyRevert::get_instanced_node_original_property(Node *p_node, co } bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Variant &p_current, const Variant &p_orig) { - // this is a pretty difficult function, because a property may not be saved but may have // the flag to not save if one or if zero @@ -443,7 +428,6 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian bool found_state = false; while (node) { - Ref<SceneState> ss; if (node == edited_scene) { @@ -478,7 +462,6 @@ bool EditorPropertyRevert::is_node_property_different(Node *p_node, const Varian } bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringName &p_property) { - bool has_revert = false; Node *node = Object::cast_to<Node>(p_object); @@ -524,7 +507,6 @@ bool EditorPropertyRevert::can_property_revert(Object *p_object, const StringNam } void EditorProperty::update_reload_status() { - if (property == StringName()) return; //no property, so nothing to do @@ -551,30 +533,25 @@ bool EditorProperty::use_keying_next() const { return false; } void EditorProperty::set_checkable(bool p_checkable) { - checkable = p_checkable; update(); queue_sort(); } bool EditorProperty::is_checkable() const { - return checkable; } void EditorProperty::set_checked(bool p_checked) { - checked = p_checked; update(); } bool EditorProperty::is_checked() const { - return checked; } void EditorProperty::set_draw_red(bool p_draw_red) { - draw_red = p_draw_red; update(); } @@ -600,12 +577,10 @@ bool EditorProperty::is_keying() const { } bool EditorProperty::is_draw_red() const { - return draw_red; } void EditorProperty::_focusable_focused(int p_index) { - if (!selectable) return; bool already_selected = selected; @@ -618,13 +593,11 @@ void EditorProperty::_focusable_focused(int p_index) { } void EditorProperty::add_focusable(Control *p_control) { - p_control->connect("focus_entered", callable_mp(this, &EditorProperty::_focusable_focused), varray(focusables.size())); focusables.push_back(p_control); } void EditorProperty::select(int p_focusable) { - bool already_selected = selected; if (p_focusable >= 0) { @@ -651,14 +624,12 @@ bool EditorProperty::is_selected() const { } void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { - if (property == StringName()) return; Ref<InputEventMouse> me = p_event; if (me.is_valid()) { - bool button_left = me->get_button_mask() & BUTTON_MASK_LEFT; bool new_keying_hover = keying_rect.has_point(me->get_position()) && !button_left; @@ -689,7 +660,6 @@ void EditorProperty::_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) { - if (!selected && selectable) { selected = true; emit_signal("selected", property, -1); @@ -721,12 +691,10 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { } if (revert_rect.has_point(mb->get_position())) { - Variant vorig; Node *node = Object::cast_to<Node>(object); if (node && EditorPropertyRevert::may_node_be_in_instance(node) && EditorPropertyRevert::get_instanced_node_original_property(node, property, vorig)) { - emit_changed(property, vorig.duplicate(true)); update_property(); return; @@ -767,15 +735,12 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) { } void EditorProperty::set_label_reference(Control *p_control) { - label_reference = p_control; } void EditorProperty::set_bottom_editor(Control *p_control) { - bottom_editor = p_control; } Variant EditorProperty::get_drag_data(const Point2 &p_point) { - if (property == StringName()) return Variant(); @@ -792,12 +757,10 @@ Variant EditorProperty::get_drag_data(const Point2 &p_point) { } void EditorProperty::set_use_folding(bool p_use_folding) { - use_folding = p_use_folding; } bool EditorProperty::is_using_folding() const { - return use_folding; } @@ -820,7 +783,6 @@ void EditorProperty::set_name_split_ratio(float p_ratio) { } float EditorProperty::get_name_split_ratio() const { - return split_ratio; } @@ -830,7 +792,6 @@ void EditorProperty::set_object_and_property(Object *p_object, const StringName } Control *EditorProperty::make_custom_tooltip(const String &p_text) const { - tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); //help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); @@ -859,7 +820,6 @@ String EditorProperty::get_tooltip_text() const { } void EditorProperty::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_label", "text"), &EditorProperty::set_label); ClassDB::bind_method(D_METHOD("get_label"), &EditorProperty::get_label); @@ -916,7 +876,6 @@ void EditorProperty::_bind_methods() { } EditorProperty::EditorProperty() { - draw_top_bg = true; object = nullptr; split_ratio = 0.5; @@ -943,14 +902,12 @@ EditorProperty::EditorProperty() { //////////////////////////////////////////////// void EditorInspectorPlugin::add_custom_control(Control *control) { - AddedEditor ae; ae.property_editor = control; added_editors.push_back(ae); } void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Control *p_prop) { - ERR_FAIL_COND(Object::cast_to<EditorProperty>(p_prop) == nullptr); AddedEditor ae; @@ -960,7 +917,6 @@ void EditorInspectorPlugin::add_property_editor(const String &p_for_property, Co } void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const String &p_label, const Vector<String> &p_properties, Control *p_prop) { - AddedEditor ae; ae.properties = p_properties; ae.property_editor = p_prop; @@ -969,28 +925,24 @@ void EditorInspectorPlugin::add_property_editor_for_multiple_properties(const St } bool EditorInspectorPlugin::can_handle(Object *p_object) { - if (get_script_instance()) { return get_script_instance()->call("can_handle", p_object); } return false; } void EditorInspectorPlugin::parse_begin(Object *p_object) { - if (get_script_instance()) { get_script_instance()->call("parse_begin", p_object); } } void EditorInspectorPlugin::parse_category(Object *p_object, const String &p_parse_category) { - if (get_script_instance()) { get_script_instance()->call("parse_category", p_object, p_parse_category); } } bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { - if (get_script_instance()) { Variant arg[6] = { p_object, p_type, p_path, p_hint, p_hint_text, p_usage @@ -1005,14 +957,12 @@ bool EditorInspectorPlugin::parse_property(Object *p_object, Variant::Type p_typ return false; } void EditorInspectorPlugin::parse_end() { - if (get_script_instance()) { get_script_instance()->call("parse_end"); } } void EditorInspectorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_custom_control", "control"), &EditorInspectorPlugin::add_custom_control); ClassDB::bind_method(D_METHOD("add_property_editor", "property", "editor"), &EditorInspectorPlugin::add_property_editor); ClassDB::bind_method(D_METHOD("add_property_editor_for_multiple_properties", "label", "properties", "editor"), &EditorInspectorPlugin::add_property_editor_for_multiple_properties); @@ -1047,9 +997,7 @@ void EditorInspectorPlugin::_bind_methods() { //////////////////////////////////////////////// void EditorInspectorCategory::_notification(int p_what) { - if (p_what == NOTIFICATION_DRAW) { - draw_rect(Rect2(Vector2(), get_size()), bg_color); Ref<Font> font = get_theme_font("font", "Tree"); @@ -1073,7 +1021,6 @@ void EditorInspectorCategory::_notification(int p_what) { } Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const { - tooltip_text = p_text; EditorHelpBit *help_bit = memnew(EditorHelpBit); help_bit->add_theme_style_override("panel", get_theme_stylebox("panel", "TooltipPanel")); @@ -1097,7 +1044,6 @@ Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) cons } Size2 EditorInspectorCategory::get_minimum_size() const { - Ref<Font> font = get_theme_font("font", "Tree"); Size2 ms; @@ -1116,7 +1062,6 @@ void EditorInspectorCategory::_bind_methods() { } String EditorInspectorCategory::get_tooltip_text() const { - return tooltip_text; } @@ -1127,7 +1072,6 @@ EditorInspectorCategory::EditorInspectorCategory() { //////////////////////////////////////////////// void EditorInspectorSection::_test_unfold() { - if (!vbox_added) { add_child(vbox); vbox_added = true; @@ -1135,9 +1079,7 @@ void EditorInspectorSection::_test_unfold() { } void EditorInspectorSection::_notification(int p_what) { - if (p_what == NOTIFICATION_SORT_CHILDREN) { - Ref<Font> font = get_theme_font("font", "Tree"); Ref<Texture2D> arrow; @@ -1163,7 +1105,6 @@ void EditorInspectorSection::_notification(int p_what) { //set children for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -1179,7 +1120,6 @@ void EditorInspectorSection::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> arrow; if (foldable) { @@ -1211,10 +1151,8 @@ void EditorInspectorSection::_notification(int p_what) { } Size2 EditorInspectorSection::get_minimum_size() const { - Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -1235,7 +1173,6 @@ Size2 EditorInspectorSection::get_minimum_size() const { } void EditorInspectorSection::setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable) { - section = p_section; label = p_label; object = p_object; @@ -1258,13 +1195,11 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe } void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) { - if (!foldable) return; Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Ref<Font> font = get_theme_font("font", "Tree"); if (mb->get_position().y > font->get_height()) { //clicked outside return; @@ -1287,7 +1222,6 @@ VBoxContainer *EditorInspectorSection::get_vbox() { } void EditorInspectorSection::unfold() { - if (!foldable) return; @@ -1311,7 +1245,6 @@ void EditorInspectorSection::fold() { } void EditorInspectorSection::_bind_methods() { - ClassDB::bind_method(D_METHOD("setup", "section", "label", "object", "bg_color", "foldable"), &EditorInspectorSection::setup); ClassDB::bind_method(D_METHOD("get_vbox"), &EditorInspectorSection::get_vbox); ClassDB::bind_method(D_METHOD("unfold"), &EditorInspectorSection::unfold); @@ -1327,7 +1260,6 @@ EditorInspectorSection::EditorInspectorSection() { } EditorInspectorSection::~EditorInspectorSection() { - if (!vbox_added) { memdelete(vbox); } @@ -1340,9 +1272,7 @@ Ref<EditorInspectorPlugin> EditorInspector::inspector_plugins[MAX_PLUGINS]; int EditorInspector::inspector_plugin_count = 0; EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { - for (int i = inspector_plugin_count - 1; i >= 0; i--) { - inspector_plugins[i]->parse_property(p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide); if (inspector_plugins[i]->added_editors.size()) { for (int j = 1; j < inspector_plugins[i]->added_editors.size(); j++) { //only keep first one @@ -1351,7 +1281,6 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V EditorProperty *prop = Object::cast_to<EditorProperty>(inspector_plugins[i]->added_editors[0].property_editor); if (prop) { - inspector_plugins[i]->added_editors.clear(); return prop; } else { @@ -1364,7 +1293,6 @@ EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, V } void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { - ERR_FAIL_COND(inspector_plugin_count == MAX_PLUGINS); for (int i = 0; i < inspector_plugin_count; i++) { @@ -1375,7 +1303,6 @@ void EditorInspector::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_p } void EditorInspector::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) { - ERR_FAIL_COND(inspector_plugin_count == MAX_PLUGINS); int idx = -1; @@ -1409,19 +1336,15 @@ void EditorInspector::set_undo_redo(UndoRedo *p_undo_redo) { } String EditorInspector::get_selected_path() const { - return property_selected; } void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<EditorInspectorPlugin> ped) { - for (List<EditorInspectorPlugin::AddedEditor>::Element *F = ped->added_editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); current_vbox->add_child(F->get().property_editor); if (ep) { - ep->object = object; ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); ep->connect("property_keyed", callable_mp(this, &EditorInspector::_property_keyed)); @@ -1434,7 +1357,6 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit ep->connect("object_id_selected", callable_mp(this, &EditorInspector::_object_id_selected), varray(), CONNECT_DEFERRED); if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { //since it's one, associate: ep->property = F->get().properties[0]; @@ -1465,7 +1387,6 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit } bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName &p_property) { - Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); if (profile.is_null()) { return false; @@ -1474,7 +1395,6 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName StringName class_name = object->get_class(); while (class_name != StringName()) { - if (profile->is_class_property_disabled(class_name, p_property)) { return true; } @@ -1489,7 +1409,6 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName } void EditorInspector::update_tree() { - //to update properly if all is refreshed StringName current_selected = property_selected; int current_focusable = -1; @@ -1565,20 +1484,17 @@ void EditorInspector::update_tree() { } for (List<PropertyInfo>::Element *I = plist.front(); I; I = I->next()) { - PropertyInfo &p = I->get(); //make sure the property can be edited 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 = ""; @@ -1587,7 +1503,6 @@ void EditorInspector::update_tree() { continue; } else if (p.usage & PROPERTY_USAGE_CATEGORY) { - group = ""; group_base = ""; subgroup = ""; @@ -1623,7 +1538,6 @@ void EditorInspector::update_tree() { if (use_doc_hints) { StringName type2 = p.name; if (!class_descr_cache.has(type2)) { - String descr; DocData *dd = EditorHelp::get_doc_data(); Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(type2); @@ -1704,7 +1618,6 @@ void EditorInspector::update_tree() { String path = basename.left(basename.find_last("/")); if (use_filter && filter != "") { - String cat = path; if (capitalize_paths) @@ -1722,7 +1635,6 @@ void EditorInspector::update_tree() { VBoxContainer *current_vbox = main_vbox; { - String acc_path = ""; int level = 1; for (int i = 0; i < path.get_slice_count("/"); i++) { @@ -1773,7 +1685,6 @@ void EditorInspector::update_tree() { String doc_hint; if (use_doc_hints) { - StringName classname = object->get_class_name(); if (object_class != String()) { classname = object_class; @@ -1833,7 +1744,6 @@ void EditorInspector::update_tree() { ped->added_editors.clear(); for (List<EditorInspectorPlugin::AddedEditor>::Element *F = editors.front(); F; F = F->next()) { - EditorProperty *ep = Object::cast_to<EditorProperty>(F->get().property_editor); if (ep) { @@ -1841,7 +1751,6 @@ void EditorInspector::update_tree() { ep->object = object; if (F->get().properties.size()) { - if (F->get().properties.size() == 1) { //since it's one, associate: ep->property = F->get().properties[0]; @@ -1877,7 +1786,6 @@ void EditorInspector::update_tree() { current_vbox->add_child(F->get().property_editor); if (ep) { - ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed)); if (p.usage & PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED) { ep->connect("property_changed", callable_mp(this, &EditorInspector::_property_changed_update_all), varray(), CONNECT_DEFERRED); @@ -1929,7 +1837,6 @@ void EditorInspector::update_property(const String &p_prop) { } void EditorInspector::_clear() { - while (main_vbox->get_child_count()) { memdelete(main_vbox->get_child(0)); } @@ -1942,7 +1849,6 @@ void EditorInspector::_clear() { } void EditorInspector::refresh() { - if (refresh_countdown > 0 || changing) return; refresh_countdown = EditorSettings::get_singleton()->get("docks/property_editor/auto_refresh_interval"); @@ -1956,7 +1862,6 @@ void EditorInspector::edit(Object *p_object) { if (object == p_object) return; if (object) { - _clear(); object->remove_change_receptor(this); } @@ -1985,7 +1890,6 @@ void EditorInspector::set_read_only(bool p_read_only) { } bool EditorInspector::is_capitalize_paths_enabled() const { - return capitalize_paths; } void EditorInspector::set_enable_capitalize_paths(bool p_capitalize) { @@ -2021,7 +1925,6 @@ void EditorInspector::register_text_enter(Node *p_line_edit) { } void EditorInspector::_filter_changed(const String &p_text) { - _clear(); update_tree(); } @@ -2036,7 +1939,6 @@ bool EditorInspector::is_using_folding() { } void EditorInspector::collapse_all_folding() { - for (List<EditorInspectorSection *>::Element *E = sections.front(); E; E = E->next()) { E->get()->fold(); } @@ -2072,7 +1974,6 @@ void EditorInspector::set_use_wide_editors(bool p_enable) { } void EditorInspector::set_sub_inspector(bool p_enable) { - sub_inspector = p_enable; if (!is_inside_tree()) return; @@ -2089,7 +1990,6 @@ void EditorInspector::set_use_deletable_properties(bool p_enabled) { } void EditorInspector::_edit_request_change(Object *p_object, const String &p_property) { - if (object != p_object) //may be undoing/redoing for a non edited object, so ignore return; @@ -2104,7 +2004,6 @@ void EditorInspector::_edit_request_change(Object *p_object, const String &p_pro } void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field) { - if (autoclear && editor_property_map.has(p_name)) { for (List<EditorProperty *>::Element *E = editor_property_map[p_name].front(); E; E = E->next()) { if (E->get()->is_checkable()) { @@ -2114,7 +2013,6 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } if (!undo_redo || bool(object->call("_dont_undo_redo"))) { - object->set(p_name, p_value); if (p_refresh_all) _edit_request_change(object, ""); @@ -2124,12 +2022,10 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo emit_signal(_prop_edited, p_name); } else if (Object::cast_to<MultiNodeEdit>(object)) { - Object::cast_to<MultiNodeEdit>(object)->set_property_field(p_name, p_value, p_changed_field); _edit_request_change(object, p_name); emit_signal(_prop_edited, p_name); } else { - undo_redo->create_action(TTR("Set") + " " + p_name, UndoRedo::MERGE_ENDS); undo_redo->add_do_property(object, p_name, p_value); undo_redo->add_undo_property(object, p_name, object->get(p_name)); @@ -2138,14 +2034,12 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo undo_redo->add_do_method(this, "_edit_request_change", object, ""); undo_redo->add_undo_method(this, "_edit_request_change", object, ""); } else { - undo_redo->add_do_method(this, "_edit_request_change", object, p_name); undo_redo->add_undo_method(this, "_edit_request_change", object, p_name); } Resource *r = Object::cast_to<Resource>(object); if (r) { - if (String(p_name) == "resource_local_to_scene") { bool prev = object->get(p_name); bool next = p_value; @@ -2170,7 +2064,6 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo } void EditorInspector::_property_changed(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) { - // The "changing" variable must be true for properties that trigger events as typing occurs, // like "text_changed" signal. E.g. text property of Label, Button, RichTextLabel, etc. if (p_changing) @@ -2191,7 +2084,6 @@ void EditorInspector::_property_changed_update_all(const String &p_path, const V } void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array p_values) { - ERR_FAIL_COND(p_paths.size() == 0 || p_values.size() == 0); ERR_FAIL_COND(p_paths.size() != p_values.size()); String names; @@ -2213,7 +2105,6 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array } void EditorInspector::_property_keyed(const String &p_path, bool p_advance) { - if (!object) return; @@ -2221,7 +2112,6 @@ void EditorInspector::_property_keyed(const String &p_path, bool p_advance) { } void EditorInspector::_property_deleted(const String &p_path) { - print_line("deleted pressed?"); if (!object) return; @@ -2230,7 +2120,6 @@ void EditorInspector::_property_deleted(const String &p_path) { } void EditorInspector::_property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance) { - if (!object) return; @@ -2238,17 +2127,14 @@ void EditorInspector::_property_keyed_with_value(const String &p_path, const Var } void EditorInspector::_property_checked(const String &p_path, bool p_checked) { - if (!object) return; //property checked if (autoclear) { - if (!p_checked) { object->set(p_path, Variant()); } else { - Variant to_create; List<PropertyInfo> pinfo; object->get_property_list(&pinfo); @@ -2275,7 +2161,6 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) { } void EditorInspector::_property_selected(const String &p_path, int p_focusable) { - property_selected = p_path; property_focusable = p_focusable; //deselect the others @@ -2292,7 +2177,6 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) } void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) { - emit_signal("object_id_selected", p_id); } @@ -2301,20 +2185,17 @@ void EditorInspector::_resource_selected(const String &p_path, RES p_resource) { } void EditorInspector::_node_removed(Node *p_node) { - if (p_node == object) { edit(nullptr); } } void EditorInspector::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed)); } if (p_what == NOTIFICATION_ENTER_TREE) { - if (sub_inspector) { add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor")); } else { @@ -2326,7 +2207,6 @@ void EditorInspector::_notification(int p_what) { 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)); } @@ -2334,7 +2214,6 @@ void EditorInspector::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - if (update_scroll_request >= 0) { get_v_scrollbar()->call_deferred("set_value", update_scroll_request); update_scroll_request = -1; @@ -2354,13 +2233,11 @@ void EditorInspector::_notification(int p_what) { changing++; if (update_tree_pending) { - update_tree(); update_tree_pending = false; pending.clear(); } else { - while (pending.size()) { StringName prop = pending.front()->get(); if (editor_property_map.has(prop)) { @@ -2377,7 +2254,6 @@ void EditorInspector::_notification(int p_what) { } if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - if (sub_inspector) { add_theme_style_override("bg", get_theme_stylebox("sub_inspector_bg", "Editor")); } else if (is_inside_tree()) { @@ -2394,7 +2270,6 @@ void EditorInspector::_changed_callback(Object *p_changed, const char *p_prop) { } void EditorInspector::_vscroll_changed(double p_offset) { - if (update_scroll_request >= 0) //waiting, do nothing return; @@ -2420,12 +2295,10 @@ String EditorInspector::get_object_class() const { } void EditorInspector::_feature_profile_changed() { - update_tree(); } void EditorInspector::_bind_methods() { - ClassDB::bind_method("_edit_request_change", &EditorInspector::_edit_request_change); ClassDB::bind_method("refresh", &EditorInspector::refresh); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index c8c1ecc49a..90d995e36d 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -47,7 +47,6 @@ public: }; class EditorProperty : public Container { - GDCLASS(EditorProperty, Container); private: diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index dbd043c494..4f48c5091b 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -41,21 +41,18 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid()) { - if (!k->is_pressed()) return; switch (k->get_keycode()) { case KEY_KP_ENTER: case KEY_ENTER: { - if (get_hide_on_ok()) hide(); ok_pressed(); set_input_as_handled(); } break; case KEY_ESCAPE: { - hide(); set_input_as_handled(); } break; @@ -64,27 +61,21 @@ void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { } void EditorLayoutsDialog::_bind_methods() { - ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name"))); } void EditorLayoutsDialog::ok_pressed() { - if (layout_names->is_anything_selected()) { - Vector<int> const selected_items = layout_names->get_selected_items(); for (int i = 0; i < selected_items.size(); ++i) { - emit_signal("name_confirmed", layout_names->get_item_text(selected_items[i])); } } else if (name->is_visible() && name->get_text() != "") { - emit_signal("name_confirmed", name->get_text()); } } void EditorLayoutsDialog::_post_popup() { - ConfirmationDialog::_post_popup(); name->clear(); layout_names->clear(); @@ -93,7 +84,6 @@ void EditorLayoutsDialog::_post_popup() { config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { - return; } @@ -101,13 +91,11 @@ void EditorLayoutsDialog::_post_popup() { config.ptr()->get_sections(&layouts); for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - layout_names->add_item(**E); } } EditorLayoutsDialog::EditorLayoutsDialog() { - makevb = memnew(VBoxContainer); add_child(makevb); makevb->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 5); @@ -133,6 +121,5 @@ EditorLayoutsDialog::EditorLayoutsDialog() { } void EditorLayoutsDialog::set_name_line_enabled(bool p_enabled) { - name->set_visible(p_enabled); } diff --git a/editor/editor_layouts_dialog.h b/editor/editor_layouts_dialog.h index d18c2bce17..39f0f4163d 100644 --- a/editor/editor_layouts_dialog.h +++ b/editor/editor_layouts_dialog.h @@ -37,7 +37,6 @@ class LineEdit; class ItemList; class EditorLayoutsDialog : public ConfirmationDialog { - GDCLASS(EditorLayoutsDialog, ConfirmationDialog); LineEdit *name; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 78aed96363..7adde6f114 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -38,7 +38,6 @@ #include "scene/resources/dynamic_font.h" void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) { - EditorLog *self = (EditorLog *)p_self; if (self->current != Thread::get_caller_id()) return; @@ -58,9 +57,7 @@ void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_f } void EditorLog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - //button->set_icon(get_icon("Console","EditorIcons")); log->add_theme_font_override("normal_font", get_theme_font("output_source", "EditorFonts")); log->add_theme_color_override("selection_color", get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.4)); @@ -76,13 +73,11 @@ void EditorLog::_notification(int p_what) { } void EditorLog::_clear_request() { - log->clear(); tool_button->set_icon(Ref<Texture2D>()); } void EditorLog::_copy_request() { - log->selection_copy(); } @@ -95,7 +90,6 @@ void EditorLog::copy() { } void EditorLog::add_message(const String &p_msg, MessageType p_type) { - log->add_newline(); bool restore = p_type != MSG_TYPE_STD; @@ -133,19 +127,16 @@ void EditorLog::set_tool_button(ToolButton *p_tool_button) { } void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) { - EditorLog *self = (EditorLog *)p_self; self->add_message(p_name, EditorLog::MSG_TYPE_EDITOR); } void EditorLog::_bind_methods() { - ADD_SIGNAL(MethodInfo("clear_request")); ADD_SIGNAL(MethodInfo("copy_request")); } EditorLog::EditorLog() { - VBoxContainer *vb = this; HBoxContainer *hb = memnew(HBoxContainer); @@ -189,7 +180,6 @@ EditorLog::EditorLog() { } void EditorLog::deinit() { - remove_error_handler(&eh); } diff --git a/editor/editor_log.h b/editor/editor_log.h index e3980690b2..1c9a2d4062 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -44,7 +44,6 @@ #include "scene/gui/tool_button.h" class EditorLog : public VBoxContainer { - GDCLASS(EditorLog, VBoxContainer); Button *clearbutton; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c38f705c1b..b975d555af 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -180,7 +180,6 @@ EditorNode *EditorNode::singleton = nullptr; void EditorNode::_update_scene_tabs() { - bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button"); if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { @@ -190,7 +189,6 @@ void EditorNode::_update_scene_tabs() { scene_tabs->clear_tabs(); 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); Ref<Texture2D> icon; if (type_node) { @@ -239,21 +237,17 @@ void EditorNode::_update_scene_tabs() { } void EditorNode::_version_control_menu_option(int p_idx) { - switch (vcs_actions_menu->get_item_id(p_idx)) { case RUN_VCS_SETTINGS: { - VersionControlEditorPlugin::get_singleton()->popup_vcs_set_up_dialog(gui_base); } break; case RUN_VCS_SHUT_DOWN: { - VersionControlEditorPlugin::get_singleton()->shut_down(); } break; } } void EditorNode::_update_title() { - String appname = ProjectSettings::get_singleton()->get("application/config/name"); String title = appname.empty() ? String(VERSION_FULL_NAME) : String(VERSION_NAME + String(" - ") + appname); String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String(); @@ -266,10 +260,8 @@ void EditorNode::_update_title() { } void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && !k->is_echo()) { - EditorPlugin *old_editor = editor_plugin_screen; if (ED_IS_SHORTCUT("editor/next_tab", p_event)) { @@ -309,14 +301,12 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorNode::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_PROCESS: { if (opening_prev && !confirmation->is_visible()) opening_prev = false; if (unsaved_cache != (saved_version != editor_data.get_undo_redo().get_version())) { - unsaved_cache = (saved_version != editor_data.get_undo_redo().get_version()); _update_title(); } @@ -331,7 +321,6 @@ void EditorNode::_notification(int p_what) { uint32_t tick = OS::get_singleton()->get_ticks_msec(); if (frame != update_spinner_step_frame && (tick - update_spinner_step_msec) > (1000 / 8)) { - update_spinner_step++; if (update_spinner_step >= 8) update_spinner_step = 0; @@ -408,7 +397,6 @@ void EditorNode::_notification(int p_what) { } break; case NOTIFICATION_READY: { - { _initializing_addons = true; Vector<String> addons; @@ -438,7 +426,6 @@ void EditorNode::_notification(int p_what) { } break; 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"))); @@ -446,18 +433,15 @@ void EditorNode::_notification(int p_what) { } break; 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 NOTIFICATION_WM_ABOUT: { - show_about(); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - _menu_option_confirm(FILE_QUIT, false); } break; @@ -495,7 +479,6 @@ void EditorNode::_notification(int p_what) { // update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { - ToolButton *tb = singleton->main_editor_buttons[i]; EditorPlugin *p_editor = singleton->editor_table[i]; Ref<Texture2D> icon = p_editor->get_icon(); @@ -568,12 +551,10 @@ 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; int rc = p_resources.size(); for (int i = 0; i < rc; i++) { - Ref<Resource> res(ResourceCache::get(p_resources.get(i))); if (res.is_null()) { continue; @@ -602,14 +583,11 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } void EditorNode::_fs_changed() { - for (Set<FileDialog *>::Element *E = file_dialogs.front(); E; E = E->next()) { - E->get()->invalidate(); } for (Set<EditorFileDialog *>::Element *E = editor_file_dialogs.front(); E; E = E->next()) { - E->get()->invalidate(); } @@ -679,7 +657,6 @@ void EditorNode::_fs_changed() { } void EditorNode::_resources_reimported(const Vector<String> &p_resources) { - List<String> scenes; //will load later int current_tab = scene_tabs->get_current_tab(); @@ -709,7 +686,6 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) { } void EditorNode::_sources_changed(bool p_exist) { - if (waiting_for_first_scan) { waiting_for_first_scan = false; @@ -735,13 +711,11 @@ void EditorNode::_vp_resized() { } void EditorNode::_node_renamed() { - if (get_inspector()) get_inspector()->update_tree(); } void EditorNode::_editor_select_next() { - int editor = _get_current_main_editor(); do { @@ -756,7 +730,6 @@ void EditorNode::_editor_select_next() { } void EditorNode::_editor_select_prev() { - int editor = _get_current_main_editor(); do { @@ -771,7 +744,6 @@ void EditorNode::_editor_select_prev() { } Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) { - dependency_errors.clear(); Error err; @@ -779,11 +751,9 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN); if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) { - //current_option = -1; Vector<String> errors; for (Set<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) { - errors.push_back(E->get()); } dependency_error->show(DependencyErrorDialog::MODE_RESOURCE, p_resource, errors); @@ -797,12 +767,10 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d } void EditorNode::edit_node(Node *p_node) { - push_item(p_node); } void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) { - editor_data.apply_changes_in_editors(); int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) @@ -826,7 +794,6 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St } void EditorNode::save_resource(const Ref<Resource> &p_resource) { - if (p_resource->get_path().is_resource_file()) { save_resource_in_path(p_resource, p_resource->get_path()); } else { @@ -835,7 +802,6 @@ void EditorNode::save_resource(const Ref<Resource> &p_resource) { } void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path) { - { String path = p_resource->get_path(); int srpos = path.find("::"); @@ -859,7 +825,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String List<String> preferred; for (int i = 0; i < extensions.size(); i++) { - if (p_resource->is_class("Script") && (extensions[i] == "tres" || extensions[i] == "res" || extensions[i] == "xml")) { //this serves no purpose and confused people continue; @@ -869,7 +834,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } if (p_at_path != String()) { - file->set_current_dir(p_at_path); if (p_resource->get_path().is_resource_file()) { file->set_current_file(p_resource->get_path().get_file()); @@ -881,7 +845,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } } } else if (p_resource->get_path() != "") { - file->set_current_path(p_resource->get_path()); if (extensions.size()) { String ext = p_resource->get_path().get_extension().to_lower(); @@ -890,7 +853,6 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } } } else if (preferred.size()) { - String existing; if (extensions.size()) { existing = "new_" + p_resource->get_class().to_lower() + "." + preferred.front()->get().to_lower(); @@ -902,31 +864,23 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String } void EditorNode::_menu_option(int p_option) { - _menu_option_confirm(p_option, false); } void EditorNode::_menu_confirm_current() { - _menu_option_confirm(current_option, true); } void EditorNode::_dialog_display_save_error(String p_file, Error p_error) { - if (p_error) { - switch (p_error) { - case ERR_FILE_CANT_WRITE: { - show_accept(TTR("Can't open file for writing:") + " " + p_file.get_extension(), TTR("OK")); } break; case ERR_FILE_UNRECOGNIZED: { - show_accept(TTR("Requested file format unknown:") + " " + p_file.get_extension(), TTR("OK")); } break; default: { - show_accept(TTR("Error while saving."), TTR("OK")); } break; } @@ -934,29 +888,21 @@ void EditorNode::_dialog_display_save_error(String p_file, Error p_error) { } void EditorNode::_dialog_display_load_error(String p_file, Error p_error) { - if (p_error) { - switch (p_error) { - case ERR_CANT_OPEN: { - show_accept(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file()), TTR("OK")); } break; case ERR_PARSE_ERROR: { - show_accept(vformat(TTR("Error while parsing '%s'."), p_file.get_file()), TTR("OK")); } break; case ERR_FILE_CORRUPT: { - show_accept(vformat(TTR("Unexpected end of file '%s'."), p_file.get_file()), TTR("OK")); } break; case ERR_FILE_NOT_FOUND: { - show_accept(vformat(TTR("Missing '%s' or its dependencies."), p_file.get_file()), TTR("OK")); } break; default: { - show_accept(vformat(TTR("Error while loading '%s'."), p_file.get_file()), TTR("OK")); } break; } @@ -964,7 +910,6 @@ void EditorNode::_dialog_display_load_error(String p_file, Error p_error) { } void EditorNode::_get_scene_metadata(const String &p_file) { - Node *scene = editor_data.get_edited_scene_root(); if (!scene) @@ -984,7 +929,6 @@ void EditorNode::_get_scene_metadata(const String &p_file) { Dictionary md; for (List<String>::Element *E = esl.front(); E; E = E->next()) { - Variant st = cf->get_value("editor_states", E->get()); if (st.get_type() != Variant::NIL) { md[E->get()] = st; @@ -995,7 +939,6 @@ void EditorNode::_get_scene_metadata(const String &p_file) { } void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { - Node *scene = editor_data.get_edited_scene_root(p_idx); if (!scene) @@ -1021,7 +964,6 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { md.get_key_list(&keys); for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - cf->set_value("editor_states", E->get(), md[E->get()]); } @@ -1030,12 +972,10 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { } bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags) { - if (p_res.is_null()) return false; if (processed.has(p_res)) { - return processed[p_res]; } @@ -1052,25 +992,21 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, i processed[p_res] = false; //because it's a file return false; } else { - processed[p_res] = changed; return changed; } } bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags) { - bool ret_changed = false; List<PropertyInfo> pi; obj->get_property_list(&pi); for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; switch (E->get().type) { case Variant::OBJECT: { - RES res = obj->get(E->get().name); if (_find_and_save_resource(res, processed, flags)) @@ -1078,11 +1014,9 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::ARRAY: { - Array varray = obj->get(E->get().name); int len = varray.size(); for (int i = 0; i < len; i++) { - const Variant &v = varray.get(i); RES res = v; if (_find_and_save_resource(res, processed, flags)) @@ -1091,12 +1025,10 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } break; case Variant::DICTIONARY: { - Dictionary d = obj->get(E->get().name); List<Variant> keys; d.get_key_list(&keys); for (List<Variant>::Element *F = keys.front(); F; F = F->next()) { - Variant v = d[F->get()]; RES res = v; if (_find_and_save_resource(res, processed, flags)) @@ -1112,11 +1044,9 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj, Map<RES, bool> } void EditorNode::_save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags) { - _find_and_save_edited_subresources(scene, processed, flags); for (int i = 0; i < scene->get_child_count(); i++) { - Node *n = scene->get_child(i); if (n->get_owner() != editor_data.get_edited_scene_root()) continue; @@ -1125,7 +1055,6 @@ void EditorNode::_save_edited_subresources(Node *scene, Map<RES, bool> &processe } void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { - if (p_node->is_class("Viewport") || (p_node != editor_data.get_edited_scene_root() && p_node->get_owner() != editor_data.get_edited_scene_root())) return; @@ -1139,7 +1068,6 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { } 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() != nullptr) { @@ -1167,7 +1095,6 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } if (img.is_valid()) { - img = img->duplicate(); save.step(TTR("Creating Thumbnail"), 2); @@ -1219,7 +1146,6 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_node) { - for (int i = 0; i < p_node->get_child_count(); i++) { Node *child = p_node->get_child(i); if (child->get_filename() == p_filename) { @@ -1235,7 +1161,6 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod } 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); return true; @@ -1276,7 +1201,6 @@ int EditorNode::_save_external_resources() { List<Ref<Resource>> cached; ResourceCache::get_cached_resources(&cached); for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - Ref<Resource> res = E->get(); if (!res->get_path().is_resource_file()) continue; @@ -1299,11 +1223,9 @@ int EditorNode::_save_external_resources() { } void EditorNode::_save_scene(String p_file, int idx) { - Node *scene = editor_data.get_edited_scene_root(idx); if (!scene) { - show_accept(TTR("This operation can't be done without a tree root."), TTR("OK")); return; } @@ -1336,7 +1258,6 @@ void EditorNode::_save_scene(String p_file, int idx) { Error err = sdata->pack(scene); if (err != OK) { - show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK")); return; } @@ -1372,19 +1293,16 @@ void EditorNode::_save_scene(String p_file, int idx) { _update_title(); _update_scene_tabs(); } else { - _dialog_display_save_error(p_file, err); } } void EditorNode::save_all_scenes() { - _menu_option_confirm(RUN_STOP, true); _save_all_scenes(); } void EditorNode::save_scene_list(Vector<String> p_scene_filenames) { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *scene = editor_data.get_edited_scene_root(i); @@ -1395,7 +1313,6 @@ void EditorNode::save_scene_list(Vector<String> p_scene_filenames) { } void EditorNode::restart_editor() { - exiting = true; String to_reopen; @@ -1417,7 +1334,6 @@ void EditorNode::restart_editor() { } void EditorNode::_save_all_scenes() { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *scene = editor_data.get_edited_scene_root(i); if (scene && scene->get_filename() != "") { @@ -1432,16 +1348,13 @@ void EditorNode::_save_all_scenes() { } void EditorNode::_mark_unsaved_scenes() { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { - Node *node = editor_data.get_edited_scene_root(i); if (!node) continue; String path = node->get_filename(); if (!(path == String() || FileAccess::exists(path))) { - if (i == editor_data.get_edited_scene()) set_current_version(-1); else @@ -1454,10 +1367,8 @@ void EditorNode::_mark_unsaved_scenes() { } void EditorNode::_dialog_action(String p_file) { - switch (current_option) { case FILE_NEW_INHERITED_SCENE: { - Node *scene = editor_data.get_edited_scene_root(); // If the previous scene is rootless, just close it in favor of the new one. if (!scene) @@ -1466,11 +1377,9 @@ void EditorNode::_dialog_action(String p_file) { load_scene(p_file, false, true); } break; case FILE_OPEN_SCENE: { - load_scene(p_file); } break; case SETTINGS_PICK_MAIN_SCENE: { - ProjectSettings::get_singleton()->set("application/run/main_scene", p_file); ProjectSettings::get_singleton()->save(); //would be nice to show the project manager opened with the highlighted field.. @@ -1487,7 +1396,6 @@ void EditorNode::_dialog_action(String p_file) { case SCENE_TAB_CLOSE: case FILE_SAVE_SCENE: case FILE_SAVE_AS_SCENE: { - int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing; if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { @@ -1515,7 +1423,6 @@ void EditorNode::_dialog_action(String p_file) { case FILE_SAVE_AND_RUN: { if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { - _save_default_environment(); _save_scene_with_preview(p_file); _run(false, p_file); @@ -1523,7 +1430,6 @@ void EditorNode::_dialog_action(String p_file) { } break; case FILE_EXPORT_MESH_LIBRARY: { - Ref<MeshLibrary> ml; if (file_export_lib_merge->is_pressed() && FileAccess::exists(p_file)) { ml = ResourceLoader::load(p_file, "MeshLibrary"); @@ -1548,7 +1454,6 @@ void EditorNode::_dialog_action(String p_file) { } break; case FILE_EXPORT_TILESET: { - Ref<TileSet> tileset; if (FileAccess::exists(p_file) && file_export_lib_merge->is_pressed()) { tileset = ResourceLoader::load(p_file, "TileSet"); @@ -1566,7 +1471,6 @@ void EditorNode::_dialog_action(String p_file) { Error err = ResourceSaver::save(p_file, tileset); if (err) { - show_accept(TTR("Error saving TileSet!"), TTR("OK")); return; } @@ -1574,7 +1478,6 @@ void EditorNode::_dialog_action(String p_file) { case RESOURCE_SAVE: case RESOURCE_SAVE_AS: { - ERR_FAIL_COND(saving_resource.is_null()); save_resource_in_path(saving_resource, p_file); saving_resource = Ref<Resource>(); @@ -1584,7 +1487,6 @@ void EditorNode::_dialog_action(String p_file) { current_obj->_change_notify(); } break; case SETTINGS_LAYOUT_SAVE: { - if (p_file.empty()) return; @@ -1612,7 +1514,6 @@ void EditorNode::_dialog_action(String p_file) { } break; case SETTINGS_LAYOUT_DELETE: { - if (p_file.empty()) return; @@ -1653,7 +1554,6 @@ void EditorNode::_dialog_action(String p_file) { } bool EditorNode::item_has_editor(Object *p_object) { - if (_is_class_editor_disabled_by_feature_profile(p_object->get_class())) { return false; } @@ -1666,7 +1566,6 @@ void EditorNode::edit_item_resource(RES p_resource) { } bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName &p_class) { - Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); if (profile.is_null()) { return false; @@ -1675,7 +1574,6 @@ bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName & StringName class_name = p_class; while (class_name != StringName()) { - if (profile->is_class_disabled(class_name)) { return true; } @@ -1689,7 +1587,6 @@ bool EditorNode::_is_class_editor_disabled_by_feature_profile(const StringName & } void EditorNode::edit_item(Object *p_object) { - Vector<EditorPlugin *> sub_plugins; if (p_object) { @@ -1700,7 +1597,6 @@ void EditorNode::edit_item(Object *p_object) { } if (!sub_plugins.empty()) { - bool same = true; if (sub_plugins.size() == editor_plugins_over->get_plugins_list().size()) { for (int i = 0; i < sub_plugins.size(); i++) { @@ -1723,7 +1619,6 @@ 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(nullptr); node_dock->set_node(nullptr); @@ -1734,7 +1629,6 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in ObjectID id = p_object->get_instance_id(); if (id != editor_history.get_current()) { - if (p_inspector_only) { editor_history.add_object_inspector_only(id); } else if (p_property == "") @@ -1747,7 +1641,6 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in } void EditorNode::_save_default_environment() { - Ref<Environment> fallback = get_tree()->get_root()->get_world_3d()->get_fallback_environment(); if (fallback.is_valid() && fallback->get_path().is_resource_file()) { @@ -1758,7 +1651,6 @@ void EditorNode::_save_default_environment() { } void EditorNode::hide_top_editors() { - _display_top_editors(false); editor_plugins_over->clear(); @@ -1777,7 +1669,6 @@ void EditorNode::_set_editing_top_editors(Object *p_current_object) { } static bool overrides_external_editor(Object *p_object) { - Script *script = Object::cast_to<Script>(p_object); if (!script) @@ -1787,7 +1678,6 @@ 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) : nullptr; bool inspector_only = editor_history.is_current_inspector_only(); @@ -1795,7 +1685,6 @@ void EditorNode::_edit_current() { this->current = current_obj; if (!current_obj) { - scene_tree_dock->set_selected(nullptr); get_inspector()->edit(nullptr); node_dock->set_node(nullptr); @@ -1816,7 +1705,6 @@ void EditorNode::_edit_current() { String editable_warning; //none by default if (is_resource) { - Resource *current_res = Object::cast_to<Resource>(current_obj); ERR_FAIL_COND(!current_res); get_inspector()->edit(current_res); @@ -1841,7 +1729,6 @@ void EditorNode::_edit_current() { } } } else if (is_node) { - Node *current_node = Object::cast_to<Node>(current_obj); ERR_FAIL_COND(!current_node); @@ -1864,7 +1751,6 @@ void EditorNode::_edit_current() { } } else { - Node *selected_node = nullptr; if (current_obj->is_class("EditorDebuggerRemoteObject")) { @@ -1917,7 +1803,6 @@ void EditorNode::_edit_current() { /* Take care of PLUGIN EDITOR */ if (!inspector_only) { - EditorPlugin *main_plugin = editor_data.get_editor(current_obj); for (int i = 0; i < editor_table.size(); i++) { @@ -1927,7 +1812,6 @@ void EditorNode::_edit_current() { } if (main_plugin) { - // special case if use of external editor is true if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) @@ -1938,7 +1822,6 @@ void EditorNode::_edit_current() { // update screen main_plugin if (!changing_scene) { - if (editor_plugin_screen) editor_plugin_screen->make_visible(false); editor_plugin_screen = main_plugin; @@ -1952,13 +1835,11 @@ void EditorNode::_edit_current() { } for (int i = 0; i < editor_table.size(); i++) { - main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin); } } } else { - editor_plugin_screen->edit(current_obj); } } @@ -1976,7 +1857,6 @@ void EditorNode::_edit_current() { _set_editing_top_editors(current_obj); _display_top_editors(true); } else if (!editor_plugins_over->get_plugins_list().empty()) { - hide_top_editors(); } } @@ -1986,7 +1866,6 @@ void EditorNode::_edit_current() { } void EditorNode::_run(bool p_current, const String &p_custom) { - if (editor_run.get_status() == EditorRun::STATUS_PLAY) { play_button->set_pressed(!_playing_edited); play_scene_button->set_pressed(_playing_edited); @@ -2006,7 +1885,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { bool skip_breakpoints; if (p_current || (editor_data.get_edited_scene_root() && p_custom == editor_data.get_edited_scene_root()->get_filename())) { - Node *scene = editor_data.get_edited_scene_root(); if (!scene) { @@ -2026,7 +1904,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } if (run_filename == "") { - //evidently, run the scene if (!ensure_main_scene(false)) { return; @@ -2034,15 +1911,12 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } if (bool(EDITOR_GET("run/auto_save/save_before_running"))) { - if (unsaved_cache) { - Node *scene = editor_data.get_edited_scene_root(); if (scene) { //only autosave if there is a scene obviously if (scene->get_filename() == "") { - show_accept(TTR("Current scene was never saved, please save it prior to running."), TTR("OK")); return; } @@ -2074,7 +1948,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { EditorDebuggerNode::get_singleton()->start(); Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints); if (error != OK) { - EditorDebuggerNode::get_singleton()->stop(); show_accept(TTR("Could not start subprocess!"), TTR("OK")); return; @@ -2098,7 +1971,6 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) { - bool autosave = EDITOR_GET("run/auto_save/save_before_running"); if (autosave) { _menu_option_confirm(FILE_SAVE_ALL_SCENES, false); @@ -2116,25 +1988,21 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) { } void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { - if (!p_confirmed) //this may be a hack.. current_option = (MenuOptions)p_option; switch (p_option) { case FILE_NEW_SCENE: { - new_scene(); } break; case FILE_NEW_INHERITED_SCENE: case FILE_OPEN_SCENE: { - file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); for (int i = 0; i < extensions.size(); i++) { - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } @@ -2147,25 +2015,21 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_QUICK_OPEN: { - quick_open->popup_dialog("Resource", true); quick_open->set_title(TTR("Quick Open...")); } break; case FILE_QUICK_OPEN_SCENE: { - quick_open->popup_dialog("PackedScene", true); quick_open->set_title(TTR("Quick Open Scene...")); } break; case FILE_QUICK_OPEN_SCRIPT: { - quick_open->popup_dialog("Script", true); quick_open->set_title(TTR("Quick Open Script...")); } break; case FILE_OPEN_PREV: { - if (previous_scenes.empty()) break; opening_prev = true; @@ -2194,7 +2058,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_CLOSE_ALL_AND_QUIT: case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE: { - if (!p_confirmed) { tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false); @@ -2218,12 +2081,10 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } case SCENE_TAB_CLOSE: case FILE_SAVE_SCENE: { - int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing; Node *scene = editor_data.get_edited_scene_root(scene_idx); if (scene && scene->get_filename() != "") { - if (scene_idx != editor_data.get_edited_scene()) _save_scene_with_preview(scene->get_filename(), scene_idx); else @@ -2243,7 +2104,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { Node *scene = editor_data.get_edited_scene_root(scene_idx); if (!scene) { - int saved = _save_external_resources(); String err_text; if (saved > 0) { @@ -2263,7 +2123,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { ResourceSaver::get_recognized_extensions(sd, &extensions); file->clear_filters(); for (int i = 0; i < extensions.size(); i++) { - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } @@ -2276,7 +2135,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } } else { - String existing; if (extensions.size()) { String root_name(scene->get_name()); @@ -2290,7 +2148,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_SAVE_ALL_SCENES: { - _save_all_scenes(); } break; case FILE_SAVE_BEFORE_RUN: { @@ -2307,14 +2164,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_EXPORT_PROJECT: { - project_export->popup_export(); } break; case FILE_EXPORT_MESH_LIBRARY: { - if (!editor_data.get_edited_scene_root()) { - show_accept(TTR("This operation can't be done without a scene."), TTR("OK")); break; } @@ -2332,7 +2186,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_EXPORT_TILESET: { - //Make sure that the scene has a root before trying to convert to tileset if (!editor_data.get_edited_scene_root()) { show_accept(TTR("This operation can't be done without a root node."), TTR("OK")); @@ -2353,9 +2206,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_IMPORT_SUBSCENE: { - if (!editor_data.get_edited_scene_root()) { - show_accept(TTR("This operation can't be done without a selected node."), TTR("OK")); break; } @@ -2365,9 +2216,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_EXTERNAL_OPEN_SCENE: { - if (unsaved_cache && !p_confirmed) { - confirmation->get_ok()->set_text(TTR("Open")); confirmation->set_text(TTR("Current scene not saved. Open anyway?")); confirmation->popup_centered(); @@ -2384,7 +2233,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case EDIT_UNDO: { - if (Input::get_singleton()->get_mouse_button_mask() & 0x7) { log->add_message("Can't undo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR); } else { @@ -2398,7 +2246,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } break; case EDIT_REDO: { - if (Input::get_singleton()->get_mouse_button_mask() & 0x7) { log->add_message("Can't redo while mouse buttons are pressed.", EditorLog::MSG_TYPE_EDITOR); } else { @@ -2412,7 +2259,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case EDIT_RELOAD_SAVED_SCENE: { - Node *scene = get_edited_scene(); if (!scene) @@ -2462,7 +2308,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case RUN_STOP: { - if (editor_run.get_status() == EditorRun::STATUS_STOP) break; @@ -2497,22 +2342,18 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case RUN_PLAY_SCENE: { - _save_default_environment(); _menu_option_confirm(RUN_STOP, true); _run(true); } break; case RUN_SCENE_SETTINGS: { - run_settings_dialog->popup_run_settings(); } break; case RUN_SETTINGS: { - project_settings->popup_project_settings(); } break; case FILE_INSTALL_ANDROID_SOURCE: { - if (p_confirmed) { export_template_manager->install_android_template(); } else { @@ -2533,14 +2374,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_QUIT: case RUN_PROJECT_MANAGER: { - if (!p_confirmed) { bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit"); if (_next_unsaved_scene(!save_each) == -1) { - bool confirm = EDITOR_GET("interface/editor/quit_confirmation"); if (confirm) { - 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(); @@ -2549,12 +2387,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { break; } } else { - if (save_each) { - _menu_option_confirm(p_option == FILE_QUIT ? FILE_CLOSE_ALL_AND_QUIT : FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER, false); } else { - String unsaved_scenes; int i = _next_unsaved_scene(true, 0); while (i != -1) { @@ -2578,65 +2413,52 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { _discard_changes(); } break; case SETTINGS_UPDATE_CONTINUOUSLY: { - EditorSettings::get_singleton()->set("interface/editor/update_continuously", true); _update_update_spinner(); show_accept(TTR("This option is deprecated. Situations where refresh must be forced are now considered a bug. Please report."), TTR("OK")); } break; case SETTINGS_UPDATE_WHEN_CHANGED: { - EditorSettings::get_singleton()->set("interface/editor/update_continuously", false); _update_update_spinner(); } break; case SETTINGS_UPDATE_SPINNER_HIDE: { - EditorSettings::get_singleton()->set("interface/editor/show_update_spinner", false); _update_update_spinner(); } break; case SETTINGS_PREFERENCES: { - settings_config_dialog->popup_edit_settings(); } break; case SETTINGS_EDITOR_DATA_FOLDER: { - OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_data_dir()); } break; case SETTINGS_EDITOR_CONFIG_FOLDER: { - OS::get_singleton()->shell_open(String("file://") + EditorSettings::get_singleton()->get_settings_dir()); } break; case SETTINGS_MANAGE_EXPORT_TEMPLATES: { - export_template_manager->popup_manager(); } break; case SETTINGS_MANAGE_FEATURE_PROFILES: { - feature_profile_manager->popup_centered_clamped(Size2(900, 800) * EDSCALE, 0.8); } break; case SETTINGS_TOGGLE_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 = 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: { - screenshot_timer->start(); } break; case SETTINGS_PICK_MAIN_SCENE: { - file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); file->clear_filters(); for (int i = 0; i < extensions.size(); i++) { - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } @@ -2671,7 +2493,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case SET_VIDEO_DRIVER_SAVE_AND_RESTART: { - ProjectSettings::get_singleton()->set("rendering/quality/driver/driver_name", video_driver_request); ProjectSettings::get_singleton()->save(); @@ -2695,7 +2516,6 @@ void EditorNode::_screenshot(bool p_use_utc) { } void EditorNode::_save_screenshot(NodePath p_path) { - 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(); @@ -2729,9 +2549,7 @@ void EditorNode::_tool_menu_option(int p_idx) { } int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) { - for (int i = p_start; i < editor_data.get_edited_scene_count(); i++) { - if (!editor_data.get_edited_scene_root(i)) continue; int current = editor_data.get_edited_scene(); @@ -2758,9 +2576,7 @@ void EditorNode::_exit_editor() { } void EditorNode::_discard_changes(const String &p_str) { - switch (current_option) { - case FILE_CLOSE_ALL_AND_QUIT: case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE: @@ -2768,7 +2584,6 @@ void EditorNode::_discard_changes(const String &p_str) { case FILE_CLOSE_RIGHT: case FILE_CLOSE_ALL: case SCENE_TAB_CLOSE: { - Node *scene = editor_data.get_edited_scene_root(tab_closing); if (scene != nullptr) { String scene_filename = scene->get_filename(); @@ -2802,13 +2617,11 @@ void EditorNode::_discard_changes(const String &p_str) { } } break; case FILE_QUIT: { - _menu_option_confirm(RUN_STOP, true); _exit_editor(); } break; case RUN_PROJECT_MANAGER: { - _menu_option_confirm(RUN_STOP, true); _exit_editor(); String exec = OS::get_singleton()->get_executable_path(); @@ -2826,7 +2639,6 @@ void EditorNode::_discard_changes(const String &p_str) { } void EditorNode::_update_file_menu_opened() { - Ref<ShortCut> close_scene_sc = ED_GET_SHORTCUT("editor/close_scene"); close_scene_sc->set_name(TTR("Close Scene")); Ref<ShortCut> reopen_closed_scene_sc = ED_GET_SHORTCUT("editor/reopen_closed_scene"); @@ -2841,12 +2653,10 @@ void EditorNode::_update_file_menu_closed() { } Control *EditorNode::get_viewport() { - return viewport; } void EditorNode::_editor_select(int p_which) { - static bool selecting = false; if (selecting || changing_scene) return; @@ -2906,9 +2716,7 @@ void EditorNode::select_editor_by_name(const String &p_name) { } void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { - if (p_editor->has_main_screen()) { - ToolButton *tb = memnew(ToolButton); tb->set_toggle_mode(true); tb->connect("pressed", callable_mp(singleton, &EditorNode::_editor_select), varray(singleton->main_editor_buttons.size())); @@ -2935,13 +2743,9 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed } void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) { - if (p_editor->has_main_screen()) { - for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { - if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) { - if (singleton->main_editor_buttons[i]->is_pressed()) { singleton->_editor_select(EDITOR_SCRIPT); } @@ -2966,7 +2770,6 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan } void EditorNode::_update_addon_config() { - if (_initializing_addons) return; @@ -2986,12 +2789,10 @@ void EditorNode::_update_addon_config() { } void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) { - ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon)); ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon)); if (!p_enabled) { - EditorPlugin *addon = plugin_addons[p_addon]; remove_editor_plugin(addon, p_config_changed); memdelete(addon); //bye @@ -3068,7 +2869,6 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, } bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const { - return plugin_addons.has(p_addon); } @@ -3098,7 +2898,6 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) { } void EditorNode::_remove_scene(int index, bool p_change_tab) { - if (editor_data.get_edited_scene() == index) { //Scene to remove is current scene _remove_edited_scene(p_change_tab); @@ -3109,7 +2908,6 @@ void EditorNode::_remove_scene(int index, bool p_change_tab) { } void EditorNode::set_edited_scene(Node *p_scene) { - if (get_editor_data().get_edited_scene_root()) { if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root) scene_root->remove_child(get_editor_data().get_edited_scene_root()); @@ -3129,7 +2927,6 @@ void EditorNode::set_edited_scene(Node *p_scene) { } int EditorNode::_get_current_main_editor() { - for (int i = 0; i < editor_table.size(); i++) { if (editor_table[i] == editor_plugin_screen) return i; @@ -3139,7 +2936,6 @@ int EditorNode::_get_current_main_editor() { } Dictionary EditorNode::_get_main_scene_state() { - Dictionary state; state["main_tab"] = _get_current_main_editor(); state["scene_tree_offset"] = scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_value(); @@ -3150,7 +2946,6 @@ 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 != nullptr) return; //not for this scene @@ -3202,7 +2997,6 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { } void EditorNode::set_current_version(uint64_t p_version) { - saved_version = p_version; editor_data.set_edited_scene_version(p_version); } @@ -3212,12 +3006,10 @@ bool EditorNode::is_changing_scene() const { } void EditorNode::_clear_undo_history() { - get_undo_redo()->clear_history(false); } void EditorNode::set_current_scene(int p_idx) { - //Save the folding in case the scene gets reloaded. if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx)) editor_folding.save_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); @@ -3263,7 +3055,6 @@ void EditorNode::set_current_scene(int p_idx) { } bool EditorNode::is_scene_open(const String &p_path) { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { if (editor_data.get_scene_path(i) == p_path) return true; @@ -3285,16 +3076,13 @@ int EditorNode::new_scene() { } Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_clear_errors, bool p_force_open_imported) { - if (!is_inside_tree()) { defer_load_scene = p_scene; return OK; } if (!p_set_inherited) { - for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { - if (editor_data.get_scene_path(i) == p_scene) { _scene_tab_changed(i); return OK; @@ -3316,7 +3104,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b String lpath = ProjectSettings::get_singleton()->localize_path(p_scene); if (!lpath.begins_with("res://")) { - show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("OK")); opening_prev = false; return ERR_FILE_NOT_FOUND; @@ -3336,7 +3123,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b Error err; Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", true, &err); if (!sdata.is_valid()) { - _dialog_display_load_error(lpath, err); opening_prev = false; @@ -3348,11 +3134,9 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b } if (!p_ignore_broken_deps && dependency_errors.has(lpath)) { - current_option = -1; Vector<String> errors; for (Set<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) { - errors.push_back(E->get()); } dependency_error->show(DependencyErrorDialog::MODE_SCENE, lpath, errors); @@ -3368,7 +3152,6 @@ 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()) { - String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E->key()) + "\n"; for (Set<String>::Element *F = E->get().front(); F; F = F->next()) { txt += "\t" + F->get() + "\n"; @@ -3392,7 +3175,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b Node *new_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN); if (!new_scene) { - sdata.unref(); _dialog_display_load_error(lpath, ERR_FILE_NOT_FOUND); opening_prev = false; @@ -3443,7 +3225,6 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b } void EditorNode::open_request(const String &p_path) { - if (!opening_prev) { List<String>::Element *prev_scene = previous_scenes.find(p_path); if (prev_scene != nullptr) { @@ -3455,12 +3236,10 @@ void EditorNode::open_request(const String &p_path) { } void EditorNode::request_instance_scene(const String &p_path) { - scene_tree_dock->instance(p_path); } void EditorNode::request_instance_scenes(const Vector<String> &p_files) { - scene_tree_dock->instance_scenes(p_files); } @@ -3469,42 +3248,34 @@ ImportDock *EditorNode::get_import_dock() { } FileSystemDock *EditorNode::get_filesystem_dock() { - return filesystem_dock; } SceneTreeDock *EditorNode::get_scene_tree_dock() { - return scene_tree_dock; } InspectorDock *EditorNode::get_inspector_dock() { - return inspector_dock; } void EditorNode::_inherit_request(String p_file) { - current_option = FILE_NEW_INHERITED_SCENE; _dialog_action(p_file); } void EditorNode::_instance_request(const Vector<String> &p_files) { - request_instance_scenes(p_files); } void EditorNode::_close_messages() { - old_split_ofs = center_split->get_split_offset(); center_split->set_split_offset(0); } void EditorNode::_show_messages() { - center_split->set_split_offset(old_split_ofs); } void EditorNode::_add_to_recent_scenes(const String &p_scene) { - Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); if (rc.find(p_scene) != -1) rc.erase(p_scene); @@ -3517,18 +3288,14 @@ void EditorNode::_add_to_recent_scenes(const String &p_scene) { } void EditorNode::_open_recent_scene(int p_idx) { - if (p_idx == recent_scenes->get_item_count() - 1) { - EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array()); call_deferred("_update_recent_scenes"); } else { - Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); ERR_FAIL_INDEX(p_idx, rc.size()); if (load_scene(rc[p_idx]) != OK) { - rc.remove(p_idx); EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc); _update_recent_scenes(); @@ -3537,13 +3304,11 @@ void EditorNode::_open_recent_scene(int p_idx) { } void EditorNode::_update_recent_scenes() { - Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array()); recent_scenes->clear(); String path; for (int i = 0; i < rc.size(); i++) { - path = rc[i]; recent_scenes->add_item(path.replace("res://", ""), i); } @@ -3554,7 +3319,6 @@ void EditorNode::_update_recent_scenes() { } void EditorNode::_quick_opened() { - Vector<String> files = quick_open->get_selected_files(); for (int i = 0; i < files.size(); i++) { @@ -3569,12 +3333,10 @@ void EditorNode::_quick_opened() { } void EditorNode::_quick_run() { - _run(false, quick_run->get_selected()); } void EditorNode::notify_all_debug_sessions_exited() { - _menu_option_confirm(RUN_STOP, false); stop_button->set_pressed(false); editor_run.stop(); @@ -3585,7 +3347,6 @@ void EditorNode::add_io_error(const String &p_error) { } void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { - EditorNode *en = (EditorNode *)p_ud; en->load_errors->add_image(en->gui_base->get_theme_icon("Error", "EditorIcons")); en->load_errors->add_text(p_text + "\n"); @@ -3593,13 +3354,11 @@ void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { } bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const { - if (p_node->get_filename() == p_path) { return true; } for (int i = 0; i < p_node->get_child_count(); i++) { - if (_find_scene_in_use(p_node->get_child(i), p_path)) { return true; } @@ -3609,7 +3368,6 @@ bool EditorNode::_find_scene_in_use(Node *p_node, const String &p_path) const { } bool EditorNode::is_scene_in_use(const String &p_path) { - Node *es = get_edited_scene(); if (es) return _find_scene_in_use(es, p_path); @@ -3617,7 +3375,6 @@ bool EditorNode::is_scene_in_use(const String &p_path) { } void EditorNode::register_editor_types() { - ResourceLoader::set_timestamp_on_load(true); ResourceSaver::set_timestamp_on_save(true); @@ -3654,12 +3411,10 @@ void EditorNode::register_editor_types() { } void EditorNode::unregister_editor_types() { - _init_callbacks.clear(); } void EditorNode::stop_child_process(OS::ProcessID p_pid) { - if (has_child_process(p_pid)) { editor_run.stop_child_process(p_pid); if (!editor_run.get_child_process_count()) // All children stopped. Closing. @@ -3841,7 +3596,6 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } void EditorNode::progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { - if (singleton->cmdline_export_mode) { print_line(p_task + ": begin: " + p_label + " steps: " + itos(p_steps)); } else { @@ -3850,18 +3604,15 @@ void EditorNode::progress_add_task(const String &p_task, const String &p_label, } bool EditorNode::progress_task_step(const String &p_task, const String &p_state, int p_step, bool p_force_refresh) { - if (singleton->cmdline_export_mode) { print_line("\t" + p_task + ": step " + itos(p_step) + ": " + p_state); return false; } else { - return singleton->progress_dialog->task_step(p_task, p_state, p_step, p_force_refresh); } } void EditorNode::progress_end_task(const String &p_task) { - if (singleton->cmdline_export_mode) { print_line(p_task + ": end"); } else { @@ -3870,29 +3621,23 @@ void EditorNode::progress_end_task(const String &p_task) { } void EditorNode::progress_add_task_bg(const String &p_task, const String &p_label, int p_steps) { - singleton->progress_hb->add_task(p_task, p_label, p_steps); } void EditorNode::progress_task_step_bg(const String &p_task, int p_step) { - singleton->progress_hb->task_step(p_task, p_step); } void EditorNode::progress_end_task_bg(const String &p_task) { - singleton->progress_hb->end_task(p_task); } Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { - EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem_path(p_path.get_base_dir()); if (efsd) { - String file = p_path.get_file(); for (int i = 0; i < efsd->get_file_count(); i++) { if (efsd->get_file(i) == file) { - String type = efsd->get_file_type(i); if (singleton->icon_type_cache.has(type)) { @@ -3908,12 +3653,10 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { } void EditorNode::_build_icon_type_cache() { - List<StringName> tl; StringName ei = "EditorIcons"; theme_base->get_theme()->get_icon_list(ei, &tl); for (List<StringName>::Element *E = tl.front(); E; E = E->next()) { - if (!ClassDB::class_exists(E->get())) continue; icon_type_cache[E->get()] = theme_base->get_theme()->get_icon(E->get(), ei); @@ -3921,29 +3664,24 @@ void EditorNode::_build_icon_type_cache() { } void EditorNode::_file_dialog_register(FileDialog *p_dialog) { - singleton->file_dialogs.insert(p_dialog); } void EditorNode::_file_dialog_unregister(FileDialog *p_dialog) { - singleton->file_dialogs.erase(p_dialog); } void EditorNode::_editor_file_dialog_register(EditorFileDialog *p_dialog) { - singleton->editor_file_dialogs.insert(p_dialog); } void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog) { - singleton->editor_file_dialogs.erase(p_dialog); } Vector<EditorNodeInitCallback> EditorNode::_init_callbacks; Error EditorNode::export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only) { - export_defer.preset = p_preset; export_defer.path = p_path; export_defer.debug = p_debug; @@ -3960,7 +3698,6 @@ void EditorNode::show_accept(const String &p_text, const String &p_title) { } 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); @@ -3971,7 +3708,6 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { } void EditorNode::_copy_warning(const String &p_str) { - DisplayServer::get_singleton()->clipboard_set(warning->get_text()); } @@ -4036,7 +3772,6 @@ void EditorNode::_dock_make_float() { } 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(); @@ -4060,11 +3795,9 @@ void EditorNode::_update_dock_containers() { } void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { - Ref<InputEventMouse> me = p_input; if (me.is_valid()) { - Vector2 point = me->get_position(); int nrect = -1; @@ -4094,7 +3827,6 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { dock_slot[dock_popup_selected]->hide(); } else { - dock_slot[dock_popup_selected]->set_current_tab(0); } @@ -4113,18 +3845,15 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { } void EditorNode::_dock_popup_exit() { - dock_select_rect_over = -1; dock_select->update(); } void EditorNode::_dock_pre_popup(int p_which) { - dock_popup_selected = p_which; } void EditorNode::_dock_move_left() { - if (dock_popup_selected < 0 || dock_popup_selected >= DOCK_SLOT_MAX) return; Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab()); @@ -4139,7 +3868,6 @@ void EditorNode::_dock_move_left() { } void EditorNode::_dock_move_right() { - Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab()); Control *next = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() + 1); if (!current || !next) @@ -4174,18 +3902,15 @@ void EditorNode::_dock_select_draw() { dock_tab_move_right->set_disabled(true); if (dock_popup_selected != -1 && dock_slot[dock_popup_selected]->get_tab_count()) { - dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() == 0); dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() >= dock_slot[dock_popup_selected]->get_tab_count() - 1); } for (int i = 0; i < DOCK_SLOT_MAX; i++) { - Vector2 ofs; switch (i) { case DOCK_SLOT_LEFT_UL: { - } break; case DOCK_SLOT_LEFT_BL: { ofs.y += s.y; @@ -4226,7 +3951,6 @@ void EditorNode::_dock_select_draw() { } else if (dock_slot[i]->get_child_count() == 0) { dock_select->draw_rect(r, unused); } else { - dock_select->draw_rect(r, used); } @@ -4241,7 +3965,6 @@ void EditorNode::_dock_select_draw() { } void EditorNode::_save_docks() { - if (waiting_for_first_scan) { return; //scanning, do not touch docks } @@ -4256,7 +3979,6 @@ void EditorNode::_save_docks() { } void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) { - for (int i = 0; i < DOCK_SLOT_MAX; i++) { String names; for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) { @@ -4276,14 +3998,12 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p p_layout->set_value(p_section, "dock_filesystem_file_list_display_mode", filesystem_dock->get_file_list_display_mode()); for (int i = 0; i < vsplits.size(); i++) { - if (vsplits[i]->is_visible_in_tree()) { p_layout->set_value(p_section, "dock_split_" + itos(i + 1), vsplits[i]->get_split_offset()); } } for (int i = 0; i < hsplits.size(); i++) { - p_layout->set_value(p_section, "dock_hsplit_" + itos(i + 1), hsplits[i]->get_split_offset()); } } @@ -4301,17 +4021,14 @@ void EditorNode::_save_open_scenes_to_config(Ref<ConfigFile> p_layout, const Str } void EditorNode::save_layout() { - dock_drag_timer->start(); } void EditorNode::_dock_split_dragged(int ofs) { - dock_drag_timer->start(); } void EditorNode::_load_docks() { - Ref<ConfigFile> config; config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); @@ -4330,9 +4047,7 @@ void EditorNode::_load_docks() { } void EditorNode::_update_dock_slots_visibility() { - if (!docks_visible) { - for (int i = 0; i < DOCK_SLOT_MAX; i++) { dock_slot[i]->hide(); } @@ -4345,7 +4060,6 @@ void EditorNode::_update_dock_slots_visibility() { bottom_panel->hide(); } else { for (int i = 0; i < DOCK_SLOT_MAX; i++) { - int tabs_visible = 0; for (int j = 0; j < dock_slot[i]->get_tab_count(); j++) { if (!dock_slot[i]->get_tab_hidden(j)) { @@ -4367,7 +4081,6 @@ void EditorNode::_update_dock_slots_visibility() { } for (int i = 0; i < DOCK_SLOT_MAX; i++) { - if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) { dock_slot[i]->set_current_tab(0); } @@ -4382,11 +4095,9 @@ void EditorNode::_update_dock_slots_visibility() { } void EditorNode::_dock_tab_changed(int p_tab) { - // update visibility but don't set current tab if (!docks_visible) { - for (int i = 0; i < DOCK_SLOT_MAX; i++) { dock_slot[i]->hide(); } @@ -4399,7 +4110,6 @@ void EditorNode::_dock_tab_changed(int p_tab) { bottom_panel->hide(); } else { for (int i = 0; i < DOCK_SLOT_MAX; i++) { - if (dock_slot[i]->get_tab_count()) dock_slot[i]->show(); else @@ -4423,16 +4133,13 @@ void EditorNode::_dock_tab_changed(int p_tab) { } void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section) { - for (int i = 0; i < DOCK_SLOT_MAX; i++) { - if (!p_layout->has_section_key(p_section, "dock_" + itos(i + 1))) continue; Vector<String> names = String(p_layout->get_value(p_section, "dock_" + itos(i + 1))).split(","); for (int j = 0; j < names.size(); j++) { - String name = names[j]; //find it, in a horribly inefficient way int atidx = -1; @@ -4480,7 +4187,6 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String } for (int i = 0; i < vsplits.size(); i++) { - if (!p_layout->has_section_key(p_section, "dock_split_" + itos(i + 1))) continue; @@ -4509,7 +4215,6 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String right_hsplit->hide(); for (int i = 0; i < DOCK_SLOT_MAX; i++) { - if (dock_slot[i]->is_visible() && dock_slot[i]->get_tab_count()) { dock_slot[i]->set_current_tab(0); } @@ -4558,7 +4263,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { String main_scene = GLOBAL_DEF("application/run/main_scene", ""); if (main_scene == "") { - 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(); @@ -4566,7 +4270,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { } if (!FileAccess::exists(main_scene)) { - 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(); @@ -4574,7 +4277,6 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { } if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") { - 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(); @@ -4602,7 +4304,6 @@ void EditorNode::set_current_tab(int p_tab) { } void EditorNode::_update_layouts_menu() { - editor_layouts->clear(); overridden_default_layout = -1; @@ -4623,7 +4324,6 @@ void EditorNode::_update_layouts_menu() { config.ptr()->get_sections(&layouts); for (List<String>::Element *E = layouts.front(); E; E = E->next()) { - String layout = E->get(); if (layout == TTR("Default")) { @@ -4636,11 +4336,8 @@ void EditorNode::_update_layouts_menu() { } void EditorNode::_layout_menu_option(int p_id) { - switch (p_id) { - case SETTINGS_LAYOUT_SAVE: { - current_option = p_id; layout_dialog->set_title(TTR("Save Layout")); layout_dialog->get_ok()->set_text(TTR("Save")); @@ -4648,7 +4345,6 @@ void EditorNode::_layout_menu_option(int p_id) { layout_dialog->set_name_line_enabled(true); } break; case SETTINGS_LAYOUT_DELETE: { - current_option = p_id; layout_dialog->set_title(TTR("Delete Layout")); layout_dialog->get_ok()->set_text(TTR("Delete")); @@ -4656,12 +4352,10 @@ void EditorNode::_layout_menu_option(int p_id) { layout_dialog->set_name_line_enabled(false); } break; case SETTINGS_LAYOUT_DEFAULT: { - _load_docks_from_config(default_layout, "docks"); _save_docks(); } break; default: { - Ref<ConfigFile> config; config.instance(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); @@ -4676,7 +4370,6 @@ void EditorNode::_layout_menu_option(int p_id) { } void EditorNode::_scene_tab_script_edited(int p_tab) { - Ref<Script> script = editor_data.get_scene_root_script(p_tab); if (script.is_valid()) inspector_dock->edit_resource(script); @@ -4730,7 +4423,6 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseButton> mb = p_input; if (mb.is_valid()) { - if (scene_tabs->get_hovered_tab() >= 0) { if (mb->get_button_index() == BUTTON_MIDDLE && mb->is_pressed()) { _scene_tab_closed(scene_tabs->get_hovered_tab()); @@ -4741,7 +4433,6 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) { } } if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - // context menu scene_tabs_context_menu->clear(); scene_tabs_context_menu->set_size(Size2(1, 1)); @@ -4815,7 +4506,6 @@ void EditorNode::_scene_tab_changed(int p_tab) { } ToolButton *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) { - ToolButton *tb = memnew(ToolButton); tb->connect("toggled", callable_mp(this, &EditorNode::_bottom_panel_switch), varray(bottom_panel_items.size())); tb->set_text(p_text); @@ -4836,7 +4526,6 @@ ToolButton *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) { } bool EditorNode::are_bottom_panels_hidden() const { - for (int i = 0; i < bottom_panel_items.size(); i++) { if (bottom_panel_items[i].button->is_pressed()) return false; @@ -4846,9 +4535,7 @@ bool EditorNode::are_bottom_panels_hidden() const { } void EditorNode::hide_bottom_panel() { - for (int i = 0; i < bottom_panel_items.size(); i++) { - if (bottom_panel_items[i].control->is_visible()) { _bottom_panel_switch(false, i); break; @@ -4857,9 +4544,7 @@ void EditorNode::hide_bottom_panel() { } void EditorNode::make_bottom_panel_item_visible(Control *p_item) { - for (int i = 0; i < bottom_panel_items.size(); i++) { - if (bottom_panel_items[i].control == p_item) { _bottom_panel_switch(true, i); break; @@ -4868,9 +4553,7 @@ void EditorNode::make_bottom_panel_item_visible(Control *p_item) { } void EditorNode::raise_bottom_panel_item(Control *p_item) { - for (int i = 0; i < bottom_panel_items.size(); i++) { - if (bottom_panel_items[i].control == p_item) { bottom_panel_items[i].button->raise(); SWAP(bottom_panel_items.write[i], bottom_panel_items.write[bottom_panel_items.size() - 1]); @@ -4885,9 +4568,7 @@ void EditorNode::raise_bottom_panel_item(Control *p_item) { } void EditorNode::remove_bottom_panel_item(Control *p_item) { - for (int i = 0; i < bottom_panel_items.size(); i++) { - if (bottom_panel_items[i].control == p_item) { if (p_item->is_visible_in_tree()) { _bottom_panel_switch(false, i); @@ -4907,7 +4588,6 @@ void EditorNode::remove_bottom_panel_item(Control *p_item) { } void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { - ERR_FAIL_INDEX(p_idx, bottom_panel_items.size()); if (bottom_panel_items[p_idx].control->is_visible() == p_enable) { @@ -4916,7 +4596,6 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { if (p_enable) { for (int i = 0; i < bottom_panel_items.size(); i++) { - bottom_panel_items[i].button->set_pressed(i == p_idx); bottom_panel_items[i].control->set_visible(i == p_idx); } @@ -4955,7 +4634,6 @@ bool EditorNode::get_docks_visible() const { } void EditorNode::_toggle_distraction_free_mode() { - if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) { int screen = -1; for (int i = 0; i < editor_table.size(); i++) { @@ -4978,7 +4656,6 @@ void EditorNode::_toggle_distraction_free_mode() { } void EditorNode::set_distraction_free_mode(bool p_enter) { - distraction_free->set_pressed(p_enter); if (p_enter) { @@ -5001,7 +4678,6 @@ void EditorNode::add_control_to_dock(DockSlot p_slot, Control *p_control) { } void EditorNode::remove_control_from_dock(Control *p_control) { - Control *dock = nullptr; for (int i = 0; i < DOCK_SLOT_MAX; i++) { if (p_control->get_parent() == dock_slot[i]) { @@ -5017,7 +4693,6 @@ void EditorNode::remove_control_from_dock(Control *p_control) { } Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { - Control *drag_control = memnew(Control); TextureRect *drag_preview = memnew(TextureRect); Label *label = memnew(Label); @@ -5166,7 +4841,6 @@ void EditorNode::_global_menu_new_window(const Variant &p_tag) { } void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) { - String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_selected_path()); _add_dropped_files_recursive(p_files, to_path); @@ -5175,17 +4849,14 @@ void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) { } void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, String to_path) { - DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Vector<String> just_copy = String("ttf,otf").split(","); for (int i = 0; i < p_files.size(); i++) { - String from = p_files[i]; String to = to_path.plus_file(from.get_file()); if (dir->dir_exists(from)) { - Vector<String> sub_files; DirAccessRef sub_dir = DirAccess::open(from); @@ -5218,19 +4889,16 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str } void EditorNode::_file_access_close_error_notify(const String &p_str) { - add_io_error("Unable to write to file '" + p_str + "', file in use, locked or lacking permissions."); } 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; ResourceCache::get_cached_resources(&cached); List<Ref<Resource>> to_clear; //clear internal resources from previous scene from being used for (List<Ref<Resource>>::Element *E = cached.front(); E; E = E->next()) { - if (E->get()->get_path().begins_with(p_path + "::")) { //subresources of existing scene to_clear.push_back(E->get()); } @@ -5244,7 +4912,6 @@ void EditorNode::reload_scene(const String &p_path) { int scene_idx = -1; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { - if (editor_data.get_scene_path(i) == p_path) { scene_idx = i; break; @@ -5283,7 +4950,6 @@ void EditorNode::reload_scene(const String &p_path) { int EditorNode::plugin_init_callback_count = 0; void EditorNode::add_plugin_init_callback(EditorPluginInitializeCallback p_callback) { - ERR_FAIL_COND(plugin_init_callback_count == MAX_INIT_CALLBACKS); plugin_init_callbacks[plugin_init_callback_count++] = p_callback; @@ -5294,7 +4960,6 @@ EditorPluginInitializeCallback EditorNode::plugin_init_callbacks[EditorNode::MAX int EditorNode::build_callback_count = 0; void EditorNode::add_build_callback(EditorBuildCallback p_callback) { - ERR_FAIL_COND(build_callback_count == MAX_INIT_CALLBACKS); build_callbacks[build_callback_count++] = p_callback; @@ -5303,7 +4968,6 @@ void EditorNode::add_build_callback(EditorBuildCallback p_callback) { EditorBuildCallback EditorNode::build_callbacks[EditorNode::MAX_BUILD_CALLBACKS]; bool EditorNode::call_build() { - bool builds_successful = true; for (int i = 0; i < build_callback_count && builds_successful; i++) { @@ -5322,13 +4986,11 @@ bool EditorNode::call_build() { } void EditorNode::_inherit_imported(const String &p_action) { - open_imported->hide(); load_scene(open_import_request, true, true); } void EditorNode::_open_imported() { - load_scene(open_import_request, true, false, true, true); } @@ -5348,7 +5010,6 @@ bool EditorNode::is_editor_dimmed() const { } void EditorNode::open_export_template_manager() { - export_template_manager->popup_manager(); } @@ -5361,7 +5022,6 @@ void EditorNode::remove_resource_conversion_plugin(const Ref<EditorResourceConve } Vector<Ref<EditorResourceConversionPlugin>> EditorNode::find_resource_conversion_plugin(const Ref<Resource> &p_for_resource) { - Vector<Ref<EditorResourceConversionPlugin>> ret; for (int i = 0; i < resource_conversion_plugins.size(); i++) { @@ -5374,12 +5034,10 @@ Vector<Ref<EditorResourceConversionPlugin>> EditorNode::find_resource_conversion } void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) { - top_split->set_visible(!p_pressed); } 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_theme_color_override("font_color", Color::hex(0x5586a4ff)); @@ -5389,7 +5047,6 @@ void EditorNode::_update_video_driver_color() { } 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()); @@ -5413,18 +5070,15 @@ void EditorNode::_resource_saved(RES p_resource, const String &p_path) { } void EditorNode::_resource_loaded(RES p_resource, const String &p_path) { - singleton->editor_folding.load_resource_folding(p_resource, p_path); } void EditorNode::_feature_profile_changed() { - Ref<EditorFeatureProfile> profile = feature_profile_manager->get_current_profile(); TabContainer *import_tabs = cast_to<TabContainer>(import_dock->get_parent()); TabContainer *node_tabs = cast_to<TabContainer>(node_dock->get_parent()); TabContainer *fs_tabs = cast_to<TabContainer>(filesystem_dock->get_parent()); if (profile.is_valid()) { - import_tabs->set_tab_hidden(import_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_IMPORT_DOCK)); node_tabs->set_tab_hidden(node_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_NODE_DOCK)); fs_tabs->set_tab_hidden(filesystem_dock->get_index(), profile->is_feature_disabled(EditorFeatureProfile::FEATURE_FILESYSTEM_DOCK)); @@ -5439,7 +5093,6 @@ void EditorNode::_feature_profile_changed() { _editor_select(EDITOR_2D); } } else { - import_tabs->set_tab_hidden(import_dock->get_index(), false); node_tabs->set_tab_hidden(node_dock->get_index(), false); fs_tabs->set_tab_hidden(filesystem_dock->get_index(), false); @@ -5456,7 +5109,6 @@ void EditorNode::_feature_profile_changed() { } void EditorNode::_bind_methods() { - ClassDB::bind_method("_editor_select", &EditorNode::_editor_select); ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed); ClassDB::bind_method("edit_node", &EditorNode::edit_node); @@ -5500,7 +5152,6 @@ void EditorNode::_bind_methods() { } static Node *_resource_get_edited_scene() { - return EditorNode::get_singleton()->get_edited_scene(); } @@ -5510,7 +5161,6 @@ 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, nullptr, &eta->output, &eta->exitcode, true, &eta->execute_output_mutex); print_verbose("Thread exit status: " + itos(eta->exitcode)); @@ -5522,7 +5172,6 @@ static void _execute_thread(void *p_ud) { } int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { - execute_output_dialog->set_title(p_title); execute_output_dialog->get_ok()->set_disabled(true); execute_outputs->clear(); @@ -5571,7 +5220,6 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p } EditorNode::EditorNode() { - Input::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; @@ -5591,7 +5239,6 @@ EditorNode::EditorNode() { Input *id = Input::get_singleton(); if (id) { - bool found_touchscreen = false; for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) { if (DisplayServer::get_singleton()->screen_is_touchscreen(i)) { @@ -6863,7 +6510,6 @@ EditorNode::EditorNode() { } EditorNode::~EditorNode() { - EditorInspector::cleanup_plugins(); remove_print_handler(&print_handler); @@ -6882,21 +6528,18 @@ EditorNode::~EditorNode() { */ void EditorPluginList::make_visible(bool p_visible) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->make_visible(p_visible); } } void EditorPluginList::edit(Object *p_object) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->edit(p_object); } } bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) { - bool discard = false; for (int i = 0; i < plugins_list.size(); i++) { @@ -6925,28 +6568,24 @@ bool EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<I } void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->forward_canvas_draw_over_viewport(p_overlay); } } void EditorPluginList::forward_canvas_force_draw_over_viewport(Control *p_overlay) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->forward_canvas_force_draw_over_viewport(p_overlay); } } void EditorPluginList::forward_spatial_draw_over_viewport(Control *p_overlay) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->forward_spatial_draw_over_viewport(p_overlay); } } void EditorPluginList::forward_spatial_force_draw_over_viewport(Control *p_overlay) { - for (int i = 0; i < plugins_list.size(); i++) { plugins_list[i]->forward_spatial_force_draw_over_viewport(p_overlay); } diff --git a/editor/editor_node.h b/editor/editor_node.h index b39a3bbfd0..a0f4d7db7c 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -89,7 +89,6 @@ class Window; class SubViewport; class EditorNode : public Node { - GDCLASS(EditorNode, Node); public: @@ -868,7 +867,6 @@ public: }; struct EditorProgress { - String task; bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); } EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false) { @@ -909,7 +907,6 @@ public: }; struct EditorProgressBG { - String task; void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); } EditorProgressBG(const String &p_task, const String &p_label, int p_amount) { diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 804ad62bbb..8d71dc6ca0 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -34,14 +34,12 @@ #include "editor_scale.h" void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { - if (p_depth > 8) return; List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) continue; if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) @@ -66,7 +64,6 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) { } void EditorPath::_about_to_show() { - Object *obj = ObjectDB::get_instance(history->get_path_object(history->get_path_size() - 1)); if (!obj) return; @@ -83,9 +80,7 @@ void EditorPath::_about_to_show() { } void EditorPath::update_path() { - for (int i = 0; i < history->get_path_size(); i++) { - Object *obj = ObjectDB::get_instance(history->get_path_object(i)); if (!obj) continue; @@ -97,7 +92,6 @@ void EditorPath::update_path() { if (i == history->get_path_size() - 1) { String name; if (Object::cast_to<Resource>(obj)) { - Resource *r = Object::cast_to<Resource>(obj); if (r->get_path().is_resource_file()) name = r->get_path().get_file(); @@ -122,7 +116,6 @@ void EditorPath::update_path() { } void EditorPath::_id_pressed(int p_idx) { - ERR_FAIL_INDEX(p_idx, objects.size()); Object *obj = ObjectDB::get_instance(objects[p_idx]); @@ -133,7 +126,6 @@ void EditorPath::_id_pressed(int p_idx) { } void EditorPath::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_THEME_CHANGED: { update_path(); @@ -145,7 +137,6 @@ void EditorPath::_bind_methods() { } EditorPath::EditorPath(EditorHistory *p_history) { - history = p_history; set_clip_text(true); set_text_align(ALIGN_LEFT); diff --git a/editor/editor_path.h b/editor/editor_path.h index b0ffc487ac..01ba25ab69 100644 --- a/editor/editor_path.h +++ b/editor/editor_path.h @@ -35,7 +35,6 @@ #include "scene/gui/menu_button.h" class EditorPath : public MenuButton { - GDCLASS(EditorPath, MenuButton); EditorHistory *history; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 8689cad45b..7bffdc5744 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -44,7 +44,6 @@ #include "servers/rendering_server.h" Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) { - Vector<Ref<Mesh>> meshes; for (int i = 0; i < p_meshes.size(); i++) { @@ -61,7 +60,6 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ } 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 = RS::get_singleton()->scenario_create(); @@ -89,7 +87,6 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh Vector<Ref<Texture2D>> textures; for (int i = 0; i < p_meshes.size(); i++) { - Ref<Mesh> mesh = p_meshes[i]; if (!mesh.is_valid()) { textures.push_back(Ref<Texture2D>()); @@ -156,17 +153,14 @@ void EditorInterface::set_main_screen_editor(const String &p_name) { } Control *EditorInterface::get_editor_viewport() { - return EditorNode::get_singleton()->get_viewport(); } void EditorInterface::edit_resource(const Ref<Resource> &p_resource) { - EditorNode::get_singleton()->edit_resource(p_resource); } void EditorInterface::open_scene_from_path(const String &scene_path) { - if (EditorNode::get_singleton()->is_changing_scene()) { return; } @@ -175,7 +169,6 @@ void EditorInterface::open_scene_from_path(const String &scene_path) { } void EditorInterface::reload_scene_from_path(const String &scene_path) { - if (EditorNode::get_singleton()->is_changing_scene()) { return; } @@ -188,7 +181,6 @@ Node *EditorInterface::get_edited_scene_root() { } Array EditorInterface::get_open_scenes() const { - Array ret; Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes(); @@ -218,7 +210,6 @@ String EditorInterface::get_current_path() const { } void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property) { - EditorNode::get_singleton()->push_item(p_obj, p_for_property); } @@ -243,7 +234,6 @@ EditorResourcePreview *EditorInterface::get_resource_previewer() { } Control *EditorInterface::get_base_control() { - return EditorNode::get_singleton()->get_gui_base(); } @@ -270,7 +260,6 @@ Error EditorInterface::save_scene() { } void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) { - EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview); } @@ -281,7 +270,6 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) { EditorInterface *EditorInterface::singleton = nullptr; void EditorInterface::_bind_methods() { - ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property"), &EditorInterface::inspect_object, DEFVAL(String())); ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection); ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings); @@ -319,12 +307,10 @@ EditorInterface::EditorInterface() { /////////////////////////////////////////// void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) { - EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon); } void EditorPlugin::remove_custom_type(const String &p_type) { - EditorNode::get_editor_data().remove_custom_type(p_type); } @@ -342,19 +328,16 @@ ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const } void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control); } void EditorPlugin::remove_control_from_docks(Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->remove_control_from_dock(p_control); } void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) { - ERR_FAIL_NULL(p_control); EditorNode::get_singleton()->remove_bottom_panel_item(p_control); } @@ -363,69 +346,56 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C ERR_FAIL_NULL(p_control); switch (p_location) { - case CONTAINER_TOOLBAR: { - EditorNode::get_menu_hb()->add_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_MENU: { - Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: { - 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: { - 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: { - Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { - CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control); } break; case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: { - CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0); } break; case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { - CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control); CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1); } break; case CONTAINER_CANVAS_EDITOR_BOTTOM: { - CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control); } break; case CONTAINER_PROPERTY_EDITOR_BOTTOM: { - EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control); } break; case CONTAINER_PROJECT_SETTING_TAB_LEFT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0); } break; case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control); ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1); @@ -437,52 +407,42 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati ERR_FAIL_NULL(p_control); switch (p_location) { - case CONTAINER_TOOLBAR: { - EditorNode::get_menu_hb()->remove_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_MENU: { - Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: { - Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control); } break; case CONTAINER_SPATIAL_EDITOR_BOTTOM: { - Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_MENU: { - CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control); } break; case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: { - CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control); } break; case CONTAINER_CANVAS_EDITOR_BOTTOM: { - CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control); } break; case CONTAINER_PROPERTY_EDITOR_BOTTOM: { - EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control); } break; case CONTAINER_PROJECT_SETTING_TAB_LEFT: case CONTAINER_PROJECT_SETTING_TAB_RIGHT: { - ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control); } break; @@ -521,7 +481,6 @@ void EditorPlugin::notify_scene_changed(const Node *scn_root) { } void EditorPlugin::notify_main_screen_changed(const String &screen_name) { - if (screen_name == last_main_screen_name) return; @@ -538,7 +497,6 @@ void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) { } bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { - if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) { return get_script_instance()->call("forward_canvas_gui_input", p_event); } @@ -546,14 +504,12 @@ bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { } void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) { - if (get_script_instance() && get_script_instance()->has_method("forward_canvas_draw_over_viewport")) { get_script_instance()->call("forward_canvas_draw_over_viewport", p_overlay); } } void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) { - if (get_script_instance() && get_script_instance()->has_method("forward_canvas_force_draw_over_viewport")) { get_script_instance()->call("forward_canvas_force_draw_over_viewport", p_overlay); } @@ -561,7 +517,6 @@ 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 (Node3DEditor::get_singleton()->is_visible()) { int count = 0; for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) { @@ -580,7 +535,6 @@ int EditorPlugin::update_overlays() const { } 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); } @@ -589,20 +543,17 @@ bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<Input } void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) { - if (get_script_instance() && get_script_instance()->has_method("forward_spatial_draw_over_viewport")) { get_script_instance()->call("forward_spatial_draw_over_viewport", p_overlay); } } void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) { - if (get_script_instance() && get_script_instance()->has_method("forward_spatial_force_draw_over_viewport")) { get_script_instance()->call("forward_spatial_force_draw_over_viewport", p_overlay); } } String EditorPlugin::get_name() const { - if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) { return get_script_instance()->call("get_plugin_name"); } @@ -610,7 +561,6 @@ String EditorPlugin::get_name() const { return String(); } const Ref<Texture2D> EditorPlugin::get_icon() const { - if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) { return get_script_instance()->call("get_plugin_icon"); } @@ -618,7 +568,6 @@ const Ref<Texture2D> EditorPlugin::get_icon() const { return Ref<Texture2D>(); } bool EditorPlugin::has_main_screen() const { - if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) { return get_script_instance()->call("has_main_screen"); } @@ -626,14 +575,12 @@ bool EditorPlugin::has_main_screen() const { return false; } void EditorPlugin::make_visible(bool p_visible) { - if (get_script_instance() && get_script_instance()->has_method("make_visible")) { get_script_instance()->call("make_visible", p_visible); } } void EditorPlugin::edit(Object *p_object) { - if (get_script_instance() && get_script_instance()->has_method("edit")) { if (p_object->is_class("Resource")) { get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object))); @@ -644,7 +591,6 @@ void EditorPlugin::edit(Object *p_object) { } bool EditorPlugin::handles(Object *p_object) const { - if (get_script_instance() && get_script_instance()->has_method("handles")) { return get_script_instance()->call("handles", p_object); } @@ -652,7 +598,6 @@ bool EditorPlugin::handles(Object *p_object) const { return false; } Dictionary EditorPlugin::get_state() const { - if (get_script_instance() && get_script_instance()->has_method("get_state")) { return get_script_instance()->call("get_state"); } @@ -661,14 +606,12 @@ Dictionary EditorPlugin::get_state() const { } void EditorPlugin::set_state(const Dictionary &p_state) { - if (get_script_instance() && get_script_instance()->has_method("set_state")) { get_script_instance()->call("set_state", p_state); } } void EditorPlugin::clear() { - if (get_script_instance() && get_script_instance()->has_method("clear")) { get_script_instance()->call("clear"); } @@ -676,7 +619,6 @@ void EditorPlugin::clear() { // if editor references external resources/scenes, save them void EditorPlugin::save_external_data() { - if (get_script_instance() && get_script_instance()->has_method("save_external_data")) { get_script_instance()->call("save_external_data"); } @@ -684,14 +626,12 @@ void EditorPlugin::save_external_data() { // if changes are pending in editor, apply them void EditorPlugin::apply_changes() { - if (get_script_instance() && get_script_instance()->has_method("apply_changes")) { get_script_instance()->call("apply_changes"); } } void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) { - if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) { PackedStringArray arr = get_script_instance()->call("get_breakpoints"); for (int i = 0; i < arr.size(); i++) @@ -699,7 +639,6 @@ void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) { } } bool EditorPlugin::get_remove_list(List<Node *> *p_list) { - return false; } @@ -777,21 +716,18 @@ void EditorPlugin::disable_plugin() { } void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { - if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { get_script_instance()->call("set_window_layout", p_layout); } } void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) { - if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) { get_script_instance()->call("get_window_layout", p_layout); } } bool EditorPlugin::build() { - if (get_script_instance() && get_script_instance()->has_method("build")) { return get_script_instance()->call("build"); } @@ -800,17 +736,14 @@ bool EditorPlugin::build() { } void EditorPlugin::queue_save_layout() const { - EditorNode::get_singleton()->save_layout(); } void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) { - EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item); } void EditorPlugin::hide_bottom_panel() { - EditorNode::get_singleton()->hide_bottom_panel(); } @@ -823,7 +756,6 @@ ScriptCreateDialog *EditorPlugin::get_script_create_dialog() { } void EditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container); ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel); ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index a939d58752..2792c8bf19 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -110,7 +110,6 @@ public: }; class EditorPlugin : public Node { - GDCLASS(EditorPlugin, Node); friend class EditorData; UndoRedo *undo_redo = nullptr; @@ -252,7 +251,6 @@ VARIANT_ENUM_CAST(EditorPlugin::DockSlot); typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *); class EditorPlugins { - enum { MAX_CREATE_FUNCS = 64 }; @@ -278,7 +276,6 @@ public: } static void add_create_func(EditorPluginCreateFunc p_func) { - ERR_FAIL_COND(creation_func_count >= MAX_CREATE_FUNCS); creation_funcs[creation_func_count++] = p_func; } diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 62a76786ae..764d1af451 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -39,7 +39,6 @@ #include "scene/gui/margin_container.h" void EditorPluginSettings::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_FOCUS_IN) { update_plugins(); } else if (p_what == Node::NOTIFICATION_READY) { @@ -49,7 +48,6 @@ void EditorPluginSettings::_notification(int p_what) { } void EditorPluginSettings::update_plugins() { - plugin_list->clear(); DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); @@ -70,12 +68,10 @@ void EditorPluginSettings::update_plugins() { Vector<String> plugins; while (d != String()) { - bool dir = da->current_is_dir(); String path = "res://addons/" + d + "/plugin.cfg"; if (dir && FileAccess::exists(path)) { - plugins.push_back(d); } @@ -88,7 +84,6 @@ void EditorPluginSettings::update_plugins() { plugins.sort(); for (int i = 0; i < plugins.size(); i++) { - Ref<ConfigFile> cf; cf.instance(); String path = "res://addons/" + plugins[i] + "/plugin.cfg"; @@ -151,7 +146,6 @@ void EditorPluginSettings::update_plugins() { } void EditorPluginSettings::_plugin_activity_changed() { - if (updating) return; @@ -193,7 +187,6 @@ void EditorPluginSettings::_bind_methods() { } EditorPluginSettings::EditorPluginSettings() { - plugin_config_dialog = memnew(PluginConfigDialog); plugin_config_dialog->config(""); add_child(plugin_config_dialog); diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index 63a8395805..ceb00eb12f 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -38,7 +38,6 @@ #include "scene/gui/dialogs.h" class EditorPluginSettings : public VBoxContainer { - GDCLASS(EditorPluginSettings, VBoxContainer); enum { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c5772e0ea7..9bb20122c6 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -112,7 +112,6 @@ void EditorPropertyMultilineText::_text_changed() { } void EditorPropertyMultilineText::_open_big_text() { - if (!big_text_dialog) { big_text = memnew(TextEdit); big_text->connect("text_changed", callable_mp(this, &EditorPropertyMultilineText::_big_text_changed)); @@ -172,9 +171,7 @@ EditorPropertyMultilineText::EditorPropertyMultilineText() { ///////////////////// TEXT ENUM ///////////////////////// void EditorPropertyTextEnum::_option_selected(int p_which) { - if (string_name) { - emit_changed(get_edited_property(), StringName(options->get_item_text(p_which))); } else { emit_changed(get_edited_property(), options->get_item_text(p_which)); @@ -182,7 +179,6 @@ void EditorPropertyTextEnum::_option_selected(int p_which) { } void EditorPropertyTextEnum::update_property() { - String which = get_edited_object()->get(get_edited_property()); for (int i = 0; i < options->get_item_count(); i++) { String t = options->get_item_text(i); @@ -216,12 +212,10 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() { ///////////////////// PATH ///////////////////////// void EditorPropertyPath::_path_selected(const String &p_path) { - emit_changed(get_edited_property(), p_path); update_property(); } void EditorPropertyPath::_path_pressed() { - if (!dialog) { dialog = memnew(EditorFileDialog); dialog->connect("file_selected", callable_mp(this, &EditorPropertyPath::_path_selected)); @@ -257,33 +251,28 @@ void EditorPropertyPath::_path_pressed() { } void EditorPropertyPath::update_property() { - String full_path = get_edited_object()->get(get_edited_property()); path->set_text(full_path); path->set_tooltip(full_path); } void EditorPropertyPath::setup(const Vector<String> &p_extensions, bool p_folder, bool p_global) { - extensions = p_extensions; folder = p_folder; global = p_global; } void EditorPropertyPath::set_save_mode() { - save_mode = true; } void EditorPropertyPath::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { path_edit->set_icon(get_theme_icon("Folder", "EditorIcons")); } } void EditorPropertyPath::_path_focus_exited() { - _path_selected(path->get_text()); } @@ -313,7 +302,6 @@ EditorPropertyPath::EditorPropertyPath() { ///////////////////// CLASS NAME ///////////////////////// void EditorPropertyClassName::setup(const String &p_base_type, const String &p_selected_type) { - base_type = p_base_type; dialog->set_base_type(base_type); selected_type = p_selected_type; @@ -321,7 +309,6 @@ void EditorPropertyClassName::setup(const String &p_base_type, const String &p_s } void EditorPropertyClassName::update_property() { - String s = get_edited_object()->get(get_edited_property()); property->set_text(s); selected_type = s; @@ -356,13 +343,11 @@ EditorPropertyClassName::EditorPropertyClassName() { ///////////////////// MEMBER ///////////////////////// void EditorPropertyMember::_property_selected(const String &p_selected) { - emit_changed(get_edited_property(), p_selected); update_property(); } void EditorPropertyMember::_property_select() { - if (!selector) { selector = memnew(PropertySelector); selector->connect("selected", callable_mp(this, &EditorPropertyMember::_property_selected)); @@ -372,7 +357,6 @@ void EditorPropertyMember::_property_select() { String current = get_edited_object()->get(get_edited_property()); if (hint == MEMBER_METHOD_OF_VARIANT_TYPE) { - Variant::Type type = Variant::NIL; for (int i = 0; i < Variant::VARIANT_MAX; i++) { if (hint_text == Variant::get_type_name(Variant::Type(i))) { @@ -383,24 +367,20 @@ void EditorPropertyMember::_property_select() { selector->select_method_from_basic_type(type, current); } else if (hint == MEMBER_METHOD_OF_BASE_TYPE) { - selector->select_method_from_base_type(hint_text, current); } else if (hint == MEMBER_METHOD_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (instance) selector->select_method_from_instance(instance, current); } else if (hint == MEMBER_METHOD_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (Object::cast_to<Script>(obj)) { selector->select_method_from_script(Object::cast_to<Script>(obj), current); } } else if (hint == MEMBER_PROPERTY_OF_VARIANT_TYPE) { - Variant::Type type = Variant::NIL; String tname = hint_text; if (tname.find(".") != -1) @@ -415,17 +395,14 @@ void EditorPropertyMember::_property_select() { selector->select_property_from_basic_type(type, current); } else if (hint == MEMBER_PROPERTY_OF_BASE_TYPE) { - selector->select_property_from_base_type(hint_text, current); } else if (hint == MEMBER_PROPERTY_OF_INSTANCE) { - Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (instance) selector->select_property_from_instance(instance, current); } else if (hint == MEMBER_PROPERTY_OF_SCRIPT) { - Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); if (Object::cast_to<Script>(obj)) { selector->select_property_from_script(Object::cast_to<Script>(obj), current); @@ -439,7 +416,6 @@ void EditorPropertyMember::setup(Type p_hint, const String &p_hint_text) { } void EditorPropertyMember::update_property() { - String full_path = get_edited_object()->get(get_edited_property()); property->set_text(full_path); } @@ -458,7 +434,6 @@ EditorPropertyMember::EditorPropertyMember() { ///////////////////// CHECK ///////////////////////// void EditorPropertyCheck::_checkbox_pressed() { - emit_changed(get_edited_property(), checkbox->is_pressed()); } @@ -482,13 +457,11 @@ EditorPropertyCheck::EditorPropertyCheck() { ///////////////////// ENUM ///////////////////////// void EditorPropertyEnum::_option_selected(int p_which) { - int64_t val = options->get_item_metadata(p_which); emit_changed(get_edited_property(), val); } void EditorPropertyEnum::update_property() { - int64_t which = get_edited_object()->get(get_edited_property()); for (int i = 0; i < options->get_item_count(); i++) { @@ -500,7 +473,6 @@ void EditorPropertyEnum::update_property() { } void EditorPropertyEnum::setup(const Vector<String> &p_options) { - int64_t current_val = 0; for (int i = 0; i < p_options.size(); i++) { Vector<String> text_split = p_options[i].split(":"); @@ -531,7 +503,6 @@ EditorPropertyEnum::EditorPropertyEnum() { ///////////////////// FLAGS ///////////////////////// void EditorPropertyFlags::_flag_toggled() { - uint32_t value = 0; for (int i = 0; i < flags.size(); i++) { if (flags[i]->is_pressed()) { @@ -545,14 +516,12 @@ void EditorPropertyFlags::_flag_toggled() { } void EditorPropertyFlags::update_property() { - uint32_t value = get_edited_object()->get(get_edited_property()); for (int i = 0; i < flags.size(); i++) { uint32_t val = 1; val <<= flag_indices[i]; if (value & val) { - flags[i]->set_pressed(true); } else { flags[i]->set_pressed(false); @@ -587,7 +556,6 @@ void EditorPropertyFlags::_bind_methods() { } EditorPropertyFlags::EditorPropertyFlags() { - vbox = memnew(VBoxContainer); add_child(vbox); } @@ -636,7 +604,6 @@ public: void _notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Rect2 rect; rect.size = get_size(); flag_rects.clear(); @@ -648,14 +615,12 @@ public: Color color = get_theme_color("highlight_color", "Editor"); for (int i = 0; i < 2; i++) { - Point2 ofs(4, vofs); if (i == 1) ofs.y += bsize + 1; ofs += rect.position; for (int j = 0; j < 10; j++) { - Point2 o = ofs + Point2(j * (bsize + 1), 0); if (j >= 5) o.x += 1; @@ -677,7 +642,6 @@ public: } static void _bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &EditorPropertyLayersGrid::_gui_input); ADD_SIGNAL(MethodInfo("flag_changed", PropertyInfo(Variant::INT, "flag"))); } @@ -687,19 +651,16 @@ public: } }; void EditorPropertyLayers::_grid_changed(uint32_t p_grid) { - emit_changed(get_edited_property(), p_grid); } void EditorPropertyLayers::update_property() { - uint32_t value = get_edited_object()->get(get_edited_property()); grid->set_flag(value); } void EditorPropertyLayers::setup(LayerType p_layer_type) { - String basename; switch (p_layer_type) { case LAYER_RENDER_2D: @@ -738,7 +699,6 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) { } void EditorPropertyLayers::_button_pressed() { - layers->clear(); for (int i = 0; i < 20; i++) { if (i == 5 || i == 10 || i == 15) { @@ -771,7 +731,6 @@ void EditorPropertyLayers::_bind_methods() { } EditorPropertyLayers::EditorPropertyLayers() { - HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); grid = memnew(EditorPropertyLayersGrid); @@ -835,7 +794,6 @@ EditorPropertyInteger::EditorPropertyInteger() { ///////////////////// OBJECT ID ///////////////////////// void EditorPropertyObjectID::_edit_pressed() { - emit_signal("object_id_selected", get_edited_property(), get_edited_object()->get(get_edited_property())); } @@ -890,7 +848,6 @@ void EditorPropertyFloat::_bind_methods() { } void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser) { - spin->set_min(p_min); spin->set_max(p_max); spin->set_step(p_step); @@ -912,7 +869,6 @@ EditorPropertyFloat::EditorPropertyFloat() { ///////////////////// EASING ///////////////////////// void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { - const Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid()) { if (mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) { @@ -938,7 +894,6 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { const Ref<InputEventMouseMotion> mm = p_ev; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - float rel = mm->get_relative().x; if (rel == 0) return; @@ -966,7 +921,6 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { } void EditorPropertyEasing::_draw_easing() { - RID ci = easing_draw->get_canvas_item(); Size2 s = easing_draw->get_size(); @@ -987,7 +941,6 @@ void EditorPropertyEasing::_draw_easing() { Vector<Point2> lines; for (int i = 1; i <= points; i++) { - float ifl = i / float(points); float iflp = (i - 1) / float(points); @@ -1047,13 +1000,11 @@ void EditorPropertyEasing::_spin_focus_exited() { } void EditorPropertyEasing::setup(bool p_full, bool p_flip) { - flip = p_flip; full = p_full; } void EditorPropertyEasing::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_ENTER_TREE: { @@ -1075,7 +1026,6 @@ void EditorPropertyEasing::_bind_methods() { } EditorPropertyEasing::EditorPropertyEasing() { - easing_draw = memnew(Control); easing_draw->connect("draw", callable_mp(this, &EditorPropertyEasing::_draw_easing)); easing_draw->connect("gui_input", callable_mp(this, &EditorPropertyEasing::_drag_easing)); @@ -1128,7 +1078,6 @@ void EditorPropertyVector2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 2; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1213,7 +1162,6 @@ void EditorPropertyRect2::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 4; i++) { - Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1235,7 +1183,6 @@ void EditorPropertyRect2::setup(double p_min, double p_max, double p_step, bool } EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) { - bool horizontal = !p_force_wide && bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing")); BoxContainer *bc; @@ -1296,7 +1243,6 @@ void EditorPropertyVector3::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1377,7 +1323,6 @@ void EditorPropertyVector2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 2; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1462,7 +1407,6 @@ void EditorPropertyRect2i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 4; i++) { - Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1484,7 +1428,6 @@ void EditorPropertyRect2i::setup(int p_min, int p_max, bool p_no_slider) { } EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { - bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing"); BoxContainer *bc; @@ -1545,7 +1488,6 @@ void EditorPropertyVector3i::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1628,7 +1570,6 @@ void EditorPropertyPlane::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1650,7 +1591,6 @@ void EditorPropertyPlane::setup(double p_min, double p_max, double p_step, bool } EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) { - bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing"); BoxContainer *bc; @@ -1713,7 +1653,6 @@ void EditorPropertyQuat::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 3; i++) { - Color c = base; c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1800,7 +1739,6 @@ void EditorPropertyAABB::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 6; i++) { - Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1874,7 +1812,6 @@ void EditorPropertyTransform2D::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 6; i++) { - Color c = base; c.set_hsv(float(i % 2) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -1953,7 +1890,6 @@ void EditorPropertyBasis::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 9; i++) { - Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -2038,7 +1974,6 @@ void EditorPropertyTransform::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Color base = get_theme_color("accent_color", "Editor"); for (int i = 0; i < 12; i++) { - Color c = base; c.set_hsv(float(i % 3) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v()); spin[i]->set_custom_label_color(true, c); @@ -2081,12 +2016,10 @@ EditorPropertyTransform::EditorPropertyTransform() { ////////////// COLOR PICKER ////////////////////// void EditorPropertyColor::_color_changed(const Color &p_color) { - emit_changed(get_edited_property(), p_color, "", true); } void EditorPropertyColor::_popup_closed() { - emit_changed(get_edited_property(), picker->get_pick_color(), "", false); } @@ -2103,7 +2036,6 @@ void EditorPropertyColor::_bind_methods() { } void EditorPropertyColor::update_property() { - picker->set_pick_color(get_edited_object()->get(get_edited_property())); const Color color = picker->get_pick_color(); @@ -2129,7 +2061,6 @@ void EditorPropertyColor::setup(bool p_show_alpha) { } EditorPropertyColor::EditorPropertyColor() { - picker = memnew(ColorPickerButton); add_child(picker); picker->set_flat(true); @@ -2141,7 +2072,6 @@ EditorPropertyColor::EditorPropertyColor() { ////////////// NODE PATH ////////////////////// void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { - NodePath path = p_path; Node *base_node = nullptr; @@ -2188,13 +2118,11 @@ void EditorPropertyNodePath::_node_assign() { } void EditorPropertyNodePath::_node_clear() { - emit_changed(get_edited_property(), NodePath()); update_property(); } void EditorPropertyNodePath::update_property() { - NodePath p = get_edited_object()->get(get_edited_property()); assign->set_tooltip(p); @@ -2235,14 +2163,12 @@ void EditorPropertyNodePath::update_property() { } void EditorPropertyNodePath::setup(const NodePath &p_base_hint, Vector<StringName> p_valid_types, bool p_use_path_from_scene_root) { - base_hint = p_base_hint; valid_types = p_valid_types; use_path_from_scene_root = p_use_path_from_scene_root; } void EditorPropertyNodePath::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); clear->set_icon(t); @@ -2253,7 +2179,6 @@ void EditorPropertyNodePath::_bind_methods() { } EditorPropertyNodePath::EditorPropertyNodePath() { - HBoxContainer *hbc = memnew(HBoxContainer); add_child(hbc); assign = memnew(Button); @@ -2292,7 +2217,6 @@ EditorPropertyRID::EditorPropertyRID() { ////////////// RESOURCE ////////////////////// void EditorPropertyResource::_file_selected(const String &p_path) { - RES res = ResourceLoader::load(p_path); ERR_FAIL_COND_MSG(res.is_null(), "Cannot load resource from path '" + p_path + "'."); @@ -2325,11 +2249,9 @@ void EditorPropertyResource::_file_selected(const String &p_path) { } void EditorPropertyResource::_menu_option(int p_which) { - // scene_tree->popup_centered_ratio(); switch (p_which) { case OBJ_MENU_LOAD: { - if (!file) { file = memnew(EditorFileDialog); file->connect("file_selected", callable_mp(this, &EditorPropertyResource::_file_selected)); @@ -2340,7 +2262,6 @@ void EditorPropertyResource::_menu_option(int p_which) { List<String> extensions; for (int i = 0; i < type.get_slice_count(","); i++) { - ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions); } @@ -2351,7 +2272,6 @@ void EditorPropertyResource::_menu_option(int p_which) { file->clear_filters(); for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } @@ -2359,23 +2279,19 @@ void EditorPropertyResource::_menu_option(int p_which) { } break; case OBJ_MENU_EDIT: { - RES res = get_edited_object()->get(get_edited_property()); if (!res.is_null()) { - emit_signal("resource_selected", get_edited_property(), res); } } break; case OBJ_MENU_CLEAR: { - emit_changed(get_edited_property(), RES()); update_property(); } break; case OBJ_MENU_MAKE_UNIQUE: { - RES res_orig = get_edited_object()->get(get_edited_property()); if (res_orig.is_null()) return; @@ -2385,11 +2301,9 @@ void EditorPropertyResource::_menu_option(int p_which) { List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - Pair<String, Variant> p; PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { - p.first = pi.name; p.second = res_orig->get(pi.name); } @@ -2406,7 +2320,6 @@ 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()) { - Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); } @@ -2430,21 +2343,18 @@ void EditorPropertyResource::_menu_option(int p_which) { } break; case OBJ_MENU_PASTE: { - RES res = EditorSettings::get_singleton()->get_resource_clipboard(); emit_changed(get_edited_property(), res); update_property(); } break; case OBJ_MENU_NEW_SCRIPT: { - if (Object::cast_to<Node>(get_edited_object())) { EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), false); } } break; case OBJ_MENU_EXTEND_SCRIPT: { - if (Object::cast_to<Node>(get_edited_object())) { EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(get_edited_object()), true); } @@ -2460,11 +2370,9 @@ void EditorPropertyResource::_menu_option(int p_which) { tab_container->set_current_tab(file_system_dock->get_index()); } break; default: { - RES res = get_edited_object()->get(get_edited_property()); if (p_which >= CONVERT_BASE_ID) { - int to_type = p_which - CONVERT_BASE_ID; Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); @@ -2482,7 +2390,6 @@ void EditorPropertyResource::_menu_option(int p_which) { String intype = inheritors_array[p_which - TYPE_BASE_ID]; if (intype == "ViewportTexture") { - Resource *r = Object::cast_to<Resource>(get_edited_object()); if (r && r->get_path().is_resource_file()) { EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene.")); @@ -2544,7 +2451,6 @@ void EditorPropertyResource::_menu_option(int p_which) { } void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj) { - RES p = get_edited_object()->get(get_edited_property()); if (p.is_valid() && p->get_instance_id() == p_obj) { String type = p->get_class_name(); @@ -2572,7 +2478,6 @@ void EditorPropertyResource::_resource_preview(const String &p_path, const Ref<T } void EditorPropertyResource::_update_menu_items() { - //////////////////// UPDATE MENU ////////////////////////// RES res = get_edited_object()->get(get_edited_property()); @@ -2592,7 +2497,6 @@ void EditorPropertyResource::_update_menu_items() { } for (int i = 0; i < base_type.get_slice_count(","); i++) { - String base = base_type.get_slice(",", i); Set<String> valid_inheritors; @@ -2658,7 +2562,6 @@ void EditorPropertyResource::_update_menu_items() { menu->add_icon_item(get_theme_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); if (!res.is_null()) { - 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); @@ -2687,18 +2590,15 @@ void EditorPropertyResource::_update_menu_items() { menu->add_separator(); if (!res.is_null()) { - menu->add_item(TTR("Copy"), OBJ_MENU_COPY); } if (paste_valid) { - menu->add_item(TTR("Paste"), OBJ_MENU_PASTE); } } if (!res.is_null()) { - Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(res); if (conversions.size()) { menu->add_separator(); @@ -2707,10 +2607,8 @@ void EditorPropertyResource::_update_menu_items() { String what = conversions[i]->converts_to(); Ref<Texture2D> icon; if (has_theme_icon(what, "EditorIcons")) { - icon = get_theme_icon(what, "EditorIcons"); } else { - icon = get_theme_icon(what, "Resource"); } @@ -2720,7 +2618,6 @@ void EditorPropertyResource::_update_menu_items() { } void EditorPropertyResource::_update_menu() { - _update_menu_items(); Rect2 gt = edit->get_screen_rect(); @@ -2732,17 +2629,14 @@ void EditorPropertyResource::_update_menu() { } void EditorPropertyResource::_sub_inspector_property_keyed(const String &p_property, const Variant &p_value, bool) { - emit_signal("property_keyed_with_value", String(get_edited_property()) + ":" + p_property, p_value, false); } void EditorPropertyResource::_sub_inspector_resource_selected(const RES &p_resource, const String &p_property) { - emit_signal("resource_selected", String(get_edited_property()) + ":" + p_property, p_resource); } void EditorPropertyResource::_sub_inspector_object_id_selected(int p_id) { - emit_signal("object_id_selected", get_edited_property(), p_id); } @@ -2768,7 +2662,6 @@ void EditorPropertyResource::_open_editor_pressed() { } void EditorPropertyResource::_fold_other_editors(Object *p_self) { - if (this == p_self) { return; } @@ -2800,17 +2693,14 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) { } void EditorPropertyResource::update_property() { - RES res = get_edited_object()->get(get_edited_property()); if (use_sub_inspector) { - if (res.is_valid() != assign->is_toggle_mode()) { assign->set_toggle_mode(res.is_valid()); } if (res.is_valid() && get_edited_object()->editor_is_section_unfolded(get_edited_property())) { - if (!sub_inspector) { sub_inspector = memnew(EditorInspector); sub_inspector->set_enable_v_scroll(false); @@ -2876,7 +2766,6 @@ void EditorPropertyResource::update_property() { assign->set_icon(Ref<Texture2D>()); assign->set_text(TTR("[empty]")); } else { - assign->set_icon(EditorNode::get_singleton()->get_object_icon(res.operator->(), "Object")); if (res->get_name() != String()) { @@ -2907,12 +2796,10 @@ void EditorPropertyResource::_resource_selected() { } if (use_sub_inspector) { - bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property()); get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold); update_property(); } else { - emit_signal("resource_selected", get_edited_property(), res); } } @@ -2922,14 +2809,12 @@ 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_theme_icon("select_arrow", "Tree"); edit->set_icon(t); } if (p_what == NOTIFICATION_DRAG_BEGIN) { - if (is_visible_in_tree()) { if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; @@ -2947,7 +2832,6 @@ void EditorPropertyResource::_notification(int p_what) { } void EditorPropertyResource::_viewport_selected(const NodePath &p_path) { - Node *to_node = get_node(p_path); if (!Object::cast_to<Viewport>(to_node)) { EditorNode::get_singleton()->show_warning(TTR("Selected node is not a Viewport!")); @@ -2970,14 +2854,12 @@ void EditorPropertyResource::collapse_all_folding() { } void EditorPropertyResource::expand_all_folding() { - if (sub_inspector) { sub_inspector->expand_all_folding(); } } void EditorPropertyResource::_button_draw() { - if (dropping) { Color color = get_theme_color("accent_color", "Editor"); assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false); @@ -2985,10 +2867,8 @@ void EditorPropertyResource::_button_draw() { } Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - RES res = get_edited_object()->get(get_edited_property()); if (res.is_valid()) { - return EditorNode::get_singleton()->drag_resource(res, p_from); } @@ -2996,7 +2876,6 @@ Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control } bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const { - String allowed_type = base_type; Dictionary drag_data = p_drag_data; @@ -3011,7 +2890,6 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const } if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; if (files.size() == 1) { @@ -3019,7 +2897,6 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "") { - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { String at = allowed_type.get_slice(",", i).strip_edges(); if (ClassDB::is_parent_class(ftype, at)) { @@ -3034,11 +2911,9 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const } bool EditorPropertyResource::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - return _is_drop_valid(p_data); } void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - ERR_FAIL_COND(!_is_drop_valid(p_data)); Dictionary drag_data = p_data; @@ -3052,7 +2927,6 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant & } if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; if (files.size() == 1) { @@ -3072,7 +2946,6 @@ void EditorPropertyResource::set_use_sub_inspector(bool p_enable) { } void EditorPropertyResource::_bind_methods() { - ClassDB::bind_method(D_METHOD("_resource_preview"), &EditorPropertyResource::_resource_preview); ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &EditorPropertyResource::get_drag_data_fw); ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &EditorPropertyResource::can_drop_data_fw); @@ -3082,7 +2955,6 @@ void EditorPropertyResource::_bind_methods() { } EditorPropertyResource::EditorPropertyResource() { - opened_editor = false; sub_inspector = nullptr; sub_inspector_vbox = nullptr; @@ -3139,11 +3011,9 @@ void EditorInspectorDefaultPlugin::parse_begin(Object *p_object) { } bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { - float default_float_step = EDITOR_GET("interface/inspector/default_float_step"); switch (p_type) { - // atomic types case Variant::NIL: { EditorPropertyNil *editor = memnew(EditorPropertyNil); @@ -3154,7 +3024,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ add_property_editor(p_path, editor); } break; case Variant::INT: { - if (p_hint == PROPERTY_HINT_ENUM) { EditorPropertyEnum *editor = memnew(EditorPropertyEnum); Vector<String> options = p_hint_text.split(","); @@ -3168,7 +3037,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ add_property_editor(p_path, editor); } else if (p_hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_2D_RENDER || p_hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || p_hint == PROPERTY_HINT_LAYERS_3D_RENDER) { - EditorPropertyLayers::LayerType lt = EditorPropertyLayers::LAYER_RENDER_2D; switch (p_hint) { case PROPERTY_HINT_LAYERS_2D_RENDER: @@ -3190,7 +3058,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ editor->setup(lt); add_property_editor(p_path, editor); } else if (p_hint == PROPERTY_HINT_OBJECT_ID) { - EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); editor->setup(p_hint_text); add_property_editor(p_path, editor); @@ -3227,7 +3094,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ } } break; case Variant::FLOAT: { - if (p_hint == PROPERTY_HINT_EXP_EASING) { EditorPropertyEasing *editor = memnew(EditorPropertyEasing); bool full = true; @@ -3280,7 +3146,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ } } break; case Variant::STRING: { - if (p_hint == PROPERTY_HINT_ENUM) { EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum); Vector<String> options = p_hint_text.split(","); @@ -3294,7 +3159,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ editor->setup("Object", p_hint_text); add_property_editor(p_path, editor); } else if (p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_FILE || p_hint == PROPERTY_HINT_SAVE_FILE || p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE) { - Vector<String> extensions = p_hint_text.split(","); bool global = p_hint == PROPERTY_HINT_GLOBAL_DIR || p_hint == PROPERTY_HINT_GLOBAL_FILE; bool folder = p_hint == PROPERTY_HINT_DIR || p_hint == PROPERTY_HINT_GLOBAL_DIR; @@ -3313,7 +3177,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ p_hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE || p_hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE || p_hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) { - EditorPropertyMember *editor = memnew(EditorPropertyMember); EditorPropertyMember::Type type = EditorPropertyMember::MEMBER_METHOD_OF_BASE_TYPE; @@ -3346,7 +3209,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ add_property_editor(p_path, editor); } else { - EditorPropertyText *editor = memnew(EditorPropertyText); if (p_hint == PROPERTY_HINT_PLACEHOLDER_TEXT) { editor->set_placeholder(p_hint_text); @@ -3567,7 +3429,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ add_property_editor(p_path, editor); } break; case Variant::STRING_NAME: { - if (p_hint == PROPERTY_HINT_ENUM) { EditorPropertyTextEnum *editor = memnew(EditorPropertyTextEnum); Vector<String> options = p_hint_text.split(","); @@ -3583,7 +3444,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ } } break; case Variant::NODE_PATH: { - EditorPropertyNodePath *editor = memnew(EditorPropertyNodePath); if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) { editor->setup(p_hint_text, Vector<StringName>(), (p_usage & PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT)); @@ -3611,7 +3471,6 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ for (int j = 0; j < p_hint_text.get_slice_count(","); j++) { String inherits = p_hint_text.get_slicec(',', j); if (ClassDB::is_parent_class(inherits, type)) { - editor->set_use_sub_inspector(false); } } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 49cffb015f..cf2104bc08 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -35,7 +35,6 @@ #include "editor_properties.h" bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; if (pn.begins_with("indices")) { @@ -48,11 +47,9 @@ bool EditorPropertyArrayObject::_set(const StringName &p_name, const Variant &p_ } bool EditorPropertyArrayObject::_get(const StringName &p_name, Variant &r_ret) const { - String pn = p_name; if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); bool valid; r_ret = array.get(idx, &valid); @@ -80,17 +77,14 @@ EditorPropertyArrayObject::EditorPropertyArrayObject() { /////////////////// bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Variant &p_value) { - String pn = p_name; if (pn == "new_item_key") { - new_item_key = p_value; return true; } if (pn == "new_item_value") { - new_item_value = p_value; return true; } @@ -106,23 +100,19 @@ bool EditorPropertyDictionaryObject::_set(const StringName &p_name, const Varian } bool EditorPropertyDictionaryObject::_get(const StringName &p_name, Variant &r_ret) const { - String pn = p_name; if (pn == "new_item_key") { - r_ret = new_item_key; return true; } if (pn == "new_item_value") { - r_ret = new_item_value; return true; } if (pn.begins_with("indices")) { - int idx = pn.get_slicec('/', 1).to_int(); Variant key = dict.get_key_at_index(idx); r_ret = dict[key]; @@ -166,7 +156,6 @@ EditorPropertyDictionaryObject::EditorPropertyDictionaryObject() { ///////////////////// ARRAY /////////////////////////// void EditorPropertyArray::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { - if (p_property.begins_with("indices")) { int idx = p_property.get_slice("/", 1).to_int(); Variant array = object->get_array(); @@ -181,7 +170,6 @@ void EditorPropertyArray::_property_changed(const String &p_property, Variant p_ } 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_screen_rect(); @@ -191,7 +179,6 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) { } void EditorPropertyArray::_change_type_menu(int p_index) { - if (p_index == Variant::VARIANT_MAX) { _remove_pressed(changing_type_idx); return; @@ -218,7 +205,6 @@ void EditorPropertyArray::_object_id_selected(const StringName &p_property, Obje } void EditorPropertyArray::update_property() { - Variant array = get_edited_object()->get(get_edited_property()); String arrtype = ""; @@ -278,11 +264,9 @@ void EditorPropertyArray::update_property() { } if (unfolded) { - updating = true; if (!vbox) { - vbox = memnew(VBoxContainer); add_child(vbox); set_bottom_editor(vbox); @@ -371,13 +355,11 @@ void EditorPropertyArray::update_property() { bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL; if (is_untyped_array) { - Button *edit = memnew(Button); 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_theme_icon("Remove", "EditorIcons")); remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed), varray(i + offset)); @@ -399,7 +381,6 @@ void EditorPropertyArray::update_property() { } void EditorPropertyArray::_remove_pressed(int p_index) { - Variant array = object->get_array(); array.call("remove", p_index); @@ -425,7 +406,6 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { Dictionary drag_data = p_drag_data; if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; for (int i = 0; i < files.size(); i++) { @@ -449,7 +429,6 @@ bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const { } bool EditorPropertyArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - return _is_drop_valid(p_data); } @@ -459,7 +438,6 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d Dictionary drag_data = p_data; if (drag_data.has("type") && String(drag_data["type"]) == "files") { - Vector<String> files = drag_data["files"]; Variant array = object->get_array(); @@ -493,7 +471,6 @@ void EditorPropertyArray::drop_data_fw(const Point2 &p_point, const Variant &p_d void EditorPropertyArray::_notification(int p_what) { if (p_what == NOTIFICATION_DRAG_BEGIN) { - if (is_visible_in_tree()) { if (_is_drop_valid(get_viewport()->gui_get_drag_data())) { dropping = true; @@ -511,7 +488,6 @@ void EditorPropertyArray::_notification(int p_what) { } void EditorPropertyArray::_edit_pressed() { - Variant array = get_edited_object()->get(get_edited_property()); if (!array.is_array()) { Callable::CallError ce; @@ -566,7 +542,6 @@ void EditorPropertyArray::_length_changed(double p_page) { } void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint_string) { - array_type = p_array_type; if (array_type == Variant::ARRAY && !p_hint_string.empty()) { @@ -591,7 +566,6 @@ void EditorPropertyArray::_bind_methods() { } EditorPropertyArray::EditorPropertyArray() { - object.instance(); page_idx = 0; page_len = 10; @@ -631,12 +605,9 @@ EditorPropertyArray::EditorPropertyArray() { ///////////////////// DICTIONARY /////////////////////////// void EditorPropertyDictionary::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { - if (p_property == "new_item_key") { - object->set_new_item_key(p_value); } else if (p_property == "new_item_value") { - object->set_new_item_value(p_value); } else if (p_property.begins_with("indices")) { int idx = p_property.get_slice("/", 1).to_int(); @@ -652,7 +623,6 @@ void EditorPropertyDictionary::_property_changed(const String &p_property, Varia } void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) { - Button *button = Object::cast_to<Button>(p_button); Rect2 rect = button->get_screen_rect(); @@ -663,7 +633,6 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) { } void EditorPropertyDictionary::_add_key_value() { - // Do not allow nil as valid key. I experienced errors with this if (object->get_new_item_key().get_type() == Variant::NIL) { return; @@ -683,7 +652,6 @@ void EditorPropertyDictionary::_add_key_value() { } void EditorPropertyDictionary::_change_type_menu(int p_index) { - if (changing_type_idx < 0) { Variant value; Callable::CallError ce; @@ -700,7 +668,6 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { Dictionary dict = object->get_dict(); if (p_index < Variant::VARIANT_MAX) { - Variant value; Callable::CallError ce; value = Variant::construct(Variant::Type(p_index), nullptr, 0, ce); @@ -719,7 +686,6 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { } void EditorPropertyDictionary::update_property() { - Variant updated_val = get_edited_object()->get(get_edited_property()); if (updated_val.get_type() == Variant::NIL) { @@ -743,11 +709,9 @@ void EditorPropertyDictionary::update_property() { } if (unfolded) { - updating = true; if (!vbox) { - vbox = memnew(VBoxContainer); add_child(vbox); set_bottom_editor(vbox); @@ -814,7 +778,6 @@ void EditorPropertyDictionary::update_property() { // atomic types case Variant::BOOL: { - prop = memnew(EditorPropertyCheck); } break; @@ -825,83 +788,71 @@ void EditorPropertyDictionary::update_property() { } break; case Variant::FLOAT: { - EditorPropertyFloat *editor = memnew(EditorPropertyFloat); editor->setup(-100000, 100000, 0.001, true, false, true, true); prop = editor; } break; case Variant::STRING: { - prop = memnew(EditorPropertyText); } break; // math types case Variant::VECTOR2: { - EditorPropertyVector2 *editor = memnew(EditorPropertyVector2); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::VECTOR2I: { - EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i); editor->setup(-100000, 100000, true); prop = editor; } break; case Variant::RECT2: { - EditorPropertyRect2 *editor = memnew(EditorPropertyRect2); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::RECT2I: { - EditorPropertyRect2i *editor = memnew(EditorPropertyRect2i); editor->setup(-100000, 100000, true); prop = editor; } break; case Variant::VECTOR3: { - EditorPropertyVector3 *editor = memnew(EditorPropertyVector3); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::VECTOR3I: { - EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i); editor->setup(-100000, 100000, true); prop = editor; } break; case Variant::TRANSFORM2D: { - EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::PLANE: { - EditorPropertyPlane *editor = memnew(EditorPropertyPlane); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::QUAT: { - EditorPropertyQuat *editor = memnew(EditorPropertyQuat); editor->setup(-100000, 100000, 0.001, true); prop = editor; } break; case Variant::AABB: { - EditorPropertyAABB *editor = memnew(EditorPropertyAABB); editor->setup(-100000, 100000, 0.001, true); prop = editor; @@ -940,15 +891,12 @@ void EditorPropertyDictionary::update_property() { } break; case Variant::OBJECT: { - if (Object::cast_to<EncodedObjectAsID>(value)) { - EditorPropertyObjectID *editor = memnew(EditorPropertyObjectID); editor->setup("Object"); prop = editor; } else { - EditorPropertyResource *editor = memnew(EditorPropertyResource); editor->setup("Resource"); prop = editor; @@ -967,55 +915,46 @@ void EditorPropertyDictionary::update_property() { // arrays case Variant::PACKED_BYTE_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_BYTE_ARRAY); prop = editor; } break; case Variant::PACKED_INT32_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_INT32_ARRAY); prop = editor; } break; case Variant::PACKED_FLOAT32_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_FLOAT32_ARRAY); prop = editor; } break; case Variant::PACKED_INT64_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_INT64_ARRAY); prop = editor; } break; case Variant::PACKED_FLOAT64_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_FLOAT64_ARRAY); prop = editor; } break; case Variant::PACKED_STRING_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_STRING_ARRAY); prop = editor; } break; case Variant::PACKED_VECTOR2_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_VECTOR2_ARRAY); prop = editor; } break; case Variant::PACKED_VECTOR3_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_VECTOR3_ARRAY); prop = editor; } break; case Variant::PACKED_COLOR_ARRAY: { - EditorPropertyArray *editor = memnew(EditorPropertyArray); editor->setup(Variant::PACKED_COLOR_ARRAY); prop = editor; @@ -1100,7 +1039,6 @@ void EditorPropertyDictionary::_notification(int p_what) { } void EditorPropertyDictionary::_edit_pressed() { - Variant prop_val = get_edited_object()->get(get_edited_property()); if (prop_val.get_type() == Variant::NIL) { Callable::CallError ce; @@ -1123,7 +1061,6 @@ void EditorPropertyDictionary::_bind_methods() { } EditorPropertyDictionary::EditorPropertyDictionary() { - object.instance(); page_idx = 0; page_len = 10; diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index d6f3c976f9..7eed9b4fa7 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -37,7 +37,6 @@ #include "scene/gui/button.h" class EditorPropertyArrayObject : public Reference { - GDCLASS(EditorPropertyArrayObject, Reference); Variant array; @@ -54,7 +53,6 @@ public: }; class EditorPropertyDictionaryObject : public Reference { - GDCLASS(EditorPropertyDictionaryObject, Reference); Variant new_item_key; diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 2a4300f833..d389a076b7 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -42,7 +42,6 @@ #include "editor_settings.h" bool EditorResourcePreviewGenerator::handles(const String &p_type) const { - if (get_script_instance() && get_script_instance()->has_method("handles")) { return get_script_instance()->call("handles", p_type); } @@ -50,7 +49,6 @@ bool EditorResourcePreviewGenerator::handles(const String &p_type) const { } Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const Size2 &p_size) const { - if (get_script_instance() && get_script_instance()->has_method("generate")) { return get_script_instance()->call("generate", p_from, p_size); } @@ -58,7 +56,6 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate(const RES &p_from, const } Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String &p_path, const Size2 &p_size) const { - if (get_script_instance() && get_script_instance()->has_method("generate_from_path")) { return get_script_instance()->call("generate_from_path", p_path, p_size); } @@ -70,7 +67,6 @@ Ref<Texture2D> EditorResourcePreviewGenerator::generate_from_path(const String & } bool EditorResourcePreviewGenerator::generate_small_preview_automatically() const { - if (get_script_instance() && get_script_instance()->has_method("generate_small_preview_automatically")) { return get_script_instance()->call("generate_small_preview_automatically"); } @@ -79,7 +75,6 @@ bool EditorResourcePreviewGenerator::generate_small_preview_automatically() cons } bool EditorResourcePreviewGenerator::can_generate_small_preview() const { - if (get_script_instance() && get_script_instance()->has_method("can_generate_small_preview")) { return get_script_instance()->call("can_generate_small_preview"); } @@ -88,7 +83,6 @@ bool EditorResourcePreviewGenerator::can_generate_small_preview() const { } void EditorResourcePreviewGenerator::_bind_methods() { - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::STRING, "type"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate", PropertyInfo(Variant::OBJECT, "from", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::VECTOR2, "size"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(CLASS_INFO(Texture2D), "generate_from_path", PropertyInfo(Variant::STRING, "path", PROPERTY_HINT_FILE), PropertyInfo(Variant::VECTOR2, "size"))); @@ -102,13 +96,11 @@ EditorResourcePreviewGenerator::EditorResourcePreviewGenerator() { EditorResourcePreview *EditorResourcePreview::singleton = nullptr; void EditorResourcePreview::_thread_func(void *ud) { - EditorResourcePreview *erp = (EditorResourcePreview *)ud; erp->_thread(); } void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_small_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { - String path = p_str; { MutexLock lock(preview_mutex); @@ -214,15 +206,12 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } void EditorResourcePreview::_thread() { - exited = false; while (!exit) { - preview_sem.wait(); preview_mutex.lock(); if (queue.size()) { - QueueItem item = queue.front()->get(); queue.pop_front(); @@ -237,7 +226,6 @@ void EditorResourcePreview::_thread() { preview_mutex.unlock(); } else { - preview_mutex.unlock(); Ref<ImageTexture> texture; @@ -247,14 +235,12 @@ void EditorResourcePreview::_thread() { thumbnail_size *= EDSCALE; if (item.resource.is_valid()) { - _generate_preview(texture, small_texture, item, String()); //adding hash to the end of path (should be ID:<objid>:<hash>) because of 5 argument limit to call_deferred _preview_ready(item.path + ":" + itos(item.resource->hash_edited_version()), texture, small_texture, item.id, item.function, item.userdata); } else { - String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -264,11 +250,9 @@ void EditorResourcePreview::_thread() { String file = cache_base + ".txt"; FileAccess *f = FileAccess::open(file, FileAccess::READ); if (!f) { - // No cache found, generate _generate_preview(texture, small_texture, item, cache_base); } else { - uint64_t modtime = FileAccess::get_modified_time(item.path); int tsize = f->get_line().to_int64(); bool has_small_texture = f->get_line().to_int(); @@ -277,17 +261,14 @@ void EditorResourcePreview::_thread() { bool cache_valid = true; if (tsize != thumbnail_size) { - cache_valid = false; memdelete(f); } else if (last_modtime != modtime) { - String last_md5 = f->get_line(); String md5 = FileAccess::get_md5(item.path); memdelete(f); if (last_md5 != md5) { - cache_valid = false; } else { @@ -311,7 +292,6 @@ void EditorResourcePreview::_thread() { } if (cache_valid) { - Ref<Image> img; img.instance(); Ref<Image> small_img; @@ -320,7 +300,6 @@ void EditorResourcePreview::_thread() { if (img->load(cache_base + ".png") != OK) { cache_valid = false; } else { - texture.instance(); texture->create_from_image(img); @@ -336,7 +315,6 @@ void EditorResourcePreview::_thread() { } if (!cache_valid) { - _generate_preview(texture, small_texture, item, cache_base); } } @@ -352,7 +330,6 @@ void EditorResourcePreview::_thread() { } void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p_res, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) { - ERR_FAIL_NULL(p_receiver); ERR_FAIL_COND(!p_res.is_valid()); @@ -362,7 +339,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p String path_id = "ID:" + itos(p_res->get_instance_id()); if (cache.has(path_id) && cache[path_id].last_hash == p_res->hash_edited_version()) { - cache[path_id].order = order++; p_receiver->call(p_receiver_func, path_id, cache[path_id].preview, cache[path_id].small_preview, p_userdata); return; @@ -383,7 +359,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p } void EditorResourcePreview::queue_resource_preview(const String &p_path, Object *p_receiver, const StringName &p_receiver_func, const Variant &p_userdata) { - ERR_FAIL_NULL(p_receiver); { MutexLock lock(preview_mutex); @@ -406,22 +381,18 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object } void EditorResourcePreview::add_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) { - preview_generators.push_back(p_generator); } void EditorResourcePreview::remove_preview_generator(const Ref<EditorResourcePreviewGenerator> &p_generator) { - preview_generators.erase(p_generator); } EditorResourcePreview *EditorResourcePreview::get_singleton() { - return singleton; } void EditorResourcePreview::_bind_methods() { - ClassDB::bind_method("_preview_ready", &EditorResourcePreview::_preview_ready); ClassDB::bind_method(D_METHOD("queue_resource_preview", "path", "receiver", "receiver_func", "userdata"), &EditorResourcePreview::queue_resource_preview); @@ -434,13 +405,11 @@ void EditorResourcePreview::_bind_methods() { } void EditorResourcePreview::check_for_invalidation(const String &p_path) { - bool call_invalidated = false; { MutexLock lock(preview_mutex); if (cache.has(p_path)) { - uint64_t modified_time = FileAccess::get_modified_time(p_path); if (modified_time != cache[p_path].modified_time) { cache.erase(p_path); @@ -482,6 +451,5 @@ EditorResourcePreview::EditorResourcePreview() { } EditorResourcePreview::~EditorResourcePreview() { - stop(); } diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index dc5a3b9c93..2f4bc65de9 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -37,7 +37,6 @@ #include "scene/resources/texture.h" class EditorResourcePreviewGenerator : public Reference { - GDCLASS(EditorResourcePreviewGenerator, Reference); protected: @@ -55,7 +54,6 @@ public: }; class EditorResourcePreview : public Node { - GDCLASS(EditorResourcePreview, Node); static EditorResourcePreview *singleton; diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 01156d9809..00befb89f2 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -35,12 +35,10 @@ #include "servers/display_server.h" EditorRun::Status EditorRun::get_status() const { - return status; } Error EditorRun::run(const String &p_scene, const String &p_custom_args, const List<String> &p_breakpoints, const bool &p_skip_breakpoints) { - List<String> args; String resource_path = ProjectSettings::get_singleton()->get_resource_path(); @@ -106,7 +104,6 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L test_size.x = ProjectSettings::get_singleton()->get("display/window/size/test_width"); test_size.y = ProjectSettings::get_singleton()->get("display/window/size/test_height"); if (test_size.x > 0 && test_size.y > 0) { - desired_size = test_size; } @@ -155,11 +152,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } if (p_breakpoints.size()) { - args.push_back("--breakpoints"); String bpoints; for (const List<String>::Element *E = p_breakpoints.front(); E; E = E->next()) { - bpoints += E->get().replace(" ", "%20"); if (E->next()) bpoints += ","; @@ -187,7 +182,6 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L printf("Running: %ls", exec.c_str()); for (List<String>::Element *E = args.front(); E; E = E->next()) { - printf(" %ls", E->get().c_str()); }; printf("\n"); @@ -221,9 +215,7 @@ void EditorRun::stop_child_process(OS::ProcessID p_pid) { } void EditorRun::stop() { - if (status != STATUS_STOP && pids.size() > 0) { - for (List<OS::ProcessID>::Element *E = pids.front(); E; E = E->next()) { OS::get_singleton()->kill(E->get()); } @@ -233,6 +225,5 @@ void EditorRun::stop() { } EditorRun::EditorRun() { - status = STATUS_STOP; } diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index d4450acea2..16b8d6d110 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -35,11 +35,8 @@ #include "editor_scale.h" void EditorRunNative::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { - Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i); if (eep.is_null()) continue; @@ -49,7 +46,6 @@ void EditorRunNative::_notification(int p_what) { im = im->duplicate(); im->clear_mipmaps(); if (!im->empty()) { - im->resize(16 * EDSCALE, 16 * EDSCALE); Ref<ImageTexture> small_icon; small_icon.instance(); @@ -66,13 +62,10 @@ void EditorRunNative::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - bool changed = EditorExport::get_singleton()->poll_export_platforms() || first; if (changed) { - for (Map<int, MenuButton *>::Element *E = menus.front(); E; E = E->next()) { - Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key()); MenuButton *mb = E->get(); int dc = eep->get_options_count(); @@ -98,7 +91,6 @@ void EditorRunNative::_notification(int p_what) { } void EditorRunNative::_run_native(int p_idx, int p_platform) { - if (!EditorNode::get_singleton()->ensure_main_scene(true)) { resume_idx = p_idx; resume_platform = p_platform; @@ -120,7 +112,6 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) { Ref<EditorExportPreset> preset; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { - Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i); if (ep->is_runnable() && ep->get_platform() == eep) { preset = ep; @@ -159,12 +150,10 @@ void EditorRunNative::resume_run_native() { } void EditorRunNative::_bind_methods() { - ADD_SIGNAL(MethodInfo("native_run", PropertyInfo(Variant::OBJECT, "preset", PROPERTY_HINT_RESOURCE_TYPE, "EditorExportPreset"))); } bool EditorRunNative::is_deploy_debug_remote_enabled() const { - return EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_deploy_remote_debug", false); } diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h index 5f2236b88c..df6714cb53 100644 --- a/editor/editor_run_native.h +++ b/editor/editor_run_native.h @@ -35,7 +35,6 @@ #include "scene/gui/menu_button.h" class EditorRunNative : public HBoxContainer { - GDCLASS(EditorRunNative, HBoxContainer); Map<int, MenuButton *> menus; diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp index c03fd4f6f5..e2446e92be 100644 --- a/editor/editor_run_script.cpp +++ b/editor/editor_run_script.cpp @@ -33,7 +33,6 @@ #include "editor_node.h" void EditorScript::add_root_node(Node *p_node) { - if (!editor) { EditorNode::add_io_error("EditorScript::add_root_node: " + TTR("Write your logic in the _run() method.")); return; @@ -48,12 +47,10 @@ void EditorScript::add_root_node(Node *p_node) { } EditorInterface *EditorScript::get_editor_interface() { - return EditorInterface::get_singleton(); } Node *EditorScript::get_scene() { - if (!editor) { EditorNode::add_io_error("EditorScript::get_scene: " + TTR("Write your logic in the _run() method.")); return nullptr; @@ -63,7 +60,6 @@ Node *EditorScript::get_scene() { } void EditorScript::_run() { - Ref<Script> s = get_script(); ERR_FAIL_COND(!s.is_valid()); if (!get_script_instance()) { @@ -75,18 +71,15 @@ void EditorScript::_run() { ce.error = Callable::CallError::CALL_OK; 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?")); } } void EditorScript::set_editor(EditorNode *p_editor) { - editor = p_editor; } void EditorScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node); ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene); ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorScript::get_editor_interface); @@ -94,6 +87,5 @@ void EditorScript::_bind_methods() { } EditorScript::EditorScript() { - editor = nullptr; } diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h index edf75b9e73..261e2a7e41 100644 --- a/editor/editor_run_script.h +++ b/editor/editor_run_script.h @@ -35,7 +35,6 @@ #include "editor_plugin.h" class EditorNode; class EditorScript : public Reference { - GDCLASS(EditorScript, Reference); EditorNode *editor; diff --git a/editor/editor_scale.cpp b/editor/editor_scale.cpp index 358241cbcc..6a26cc6401 100644 --- a/editor/editor_scale.cpp +++ b/editor/editor_scale.cpp @@ -35,10 +35,8 @@ static float scale = 1.0; void editor_set_scale(float p_scale) { - scale = p_scale; } float editor_get_scale() { - return scale; } diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 3bb7072eac..c5e0c091e8 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -33,7 +33,6 @@ #include "editor_scale.h" class SectionedInspectorFilter : public Object { - GDCLASS(SectionedInspectorFilter, Object); Object *edited; @@ -41,7 +40,6 @@ class SectionedInspectorFilter : public Object { bool allow_sub; bool _set(const StringName &p_name, const Variant &p_value) { - if (!edited) return false; @@ -56,7 +54,6 @@ class SectionedInspectorFilter : public Object { } bool _get(const StringName &p_name, Variant &r_ret) const { - if (!edited) return false; @@ -71,14 +68,12 @@ class SectionedInspectorFilter : public Object { return valid; } void _get_property_list(List<PropertyInfo> *p_list) const { - if (!edited) return; List<PropertyInfo> pinfo; edited->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); int sp = pi.name.find("/"); @@ -99,25 +94,21 @@ class SectionedInspectorFilter : public Object { } bool property_can_revert(const String &p_name) { - return edited->call("property_can_revert", section + "/" + p_name); } Variant property_get_revert(const String &p_name) { - return edited->call("property_get_revert", section + "/" + p_name); } protected: static void _bind_methods() { - ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert); ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert); } public: void set_section(const String &p_section, bool p_allow_sub) { - section = p_section; allow_sub = p_allow_sub; _change_notify(); @@ -134,12 +125,10 @@ public: }; void SectionedInspector::_bind_methods() { - ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list); } void SectionedInspector::_section_selected() { - if (!sections->get_selected()) return; @@ -149,14 +138,12 @@ void SectionedInspector::_section_selected() { } void SectionedInspector::set_current_section(const String &p_section) { - if (section_map.has(p_section)) { section_map[p_section]->select(0); } } String SectionedInspector::get_current_section() const { - if (sections->get_selected()) return sections->get_selected()->get_metadata(0); else @@ -164,7 +151,6 @@ String SectionedInspector::get_current_section() const { } String SectionedInspector::get_full_item_path(const String &p_item) { - String base = get_current_section(); if (base != "") @@ -174,7 +160,6 @@ String SectionedInspector::get_full_item_path(const String &p_item) { } void SectionedInspector::edit(Object *p_object) { - if (!p_object) { obj = ObjectID(); sections->clear(); @@ -190,7 +175,6 @@ void SectionedInspector::edit(Object *p_object) { inspector->set_object_class(p_object->get_class()); if (obj != id) { - obj = id; update_category_list(); @@ -206,13 +190,11 @@ void SectionedInspector::edit(Object *p_object) { selected_category = first_item->get_metadata(0); } } else { - update_category_list(); } } void SectionedInspector::update_category_list() { - sections->clear(); Object *o = ObjectDB::get_instance(obj); @@ -233,7 +215,6 @@ void SectionedInspector::update_category_list() { filter = search_box->get_text(); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - PropertyInfo pi = E->get(); if (pi.usage & PROPERTY_USAGE_CATEGORY) @@ -257,7 +238,6 @@ void SectionedInspector::update_category_list() { int sc = MIN(2, sectionarr.size() - 1); for (int i = 0; i < sc; i++) { - TreeItem *parent = section_map[metasection]; parent->set_custom_bg_color(0, get_theme_color("prop_subsection", "Editor")); @@ -290,19 +270,16 @@ void SectionedInspector::update_category_list() { } void SectionedInspector::register_search_box(LineEdit *p_box) { - search_box = p_box; inspector->register_text_enter(p_box); search_box->connect("text_changed", callable_mp(this, &SectionedInspector::_search_changed)); } void SectionedInspector::_search_changed(const String &p_what) { - update_category_list(); } EditorInspector *SectionedInspector::get_inspector() { - return inspector; } @@ -334,6 +311,5 @@ SectionedInspector::SectionedInspector() : } SectionedInspector::~SectionedInspector() { - memdelete(filter); } diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index f01e6e250e..dfc521302a 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -38,7 +38,6 @@ class SectionedInspectorFilter; class SectionedInspector : public HSplitContainer { - GDCLASS(SectionedInspector, HSplitContainer); ObjectID obj; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5e34913cf0..bbb4881d14 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -58,7 +58,6 @@ Ref<EditorSettings> EditorSettings::singleton = nullptr; // Properties bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { - _THREAD_SAFE_METHOD_ bool changed = _set_only(p_name, p_value); @@ -69,15 +68,12 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { } bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) { - _THREAD_SAFE_METHOD_ if (p_name.operator String() == "shortcuts") { - Array arr = p_value; ERR_FAIL_COND_V(arr.size() && arr.size() & 1, true); for (int i = 0; i < arr.size(); i += 2) { - String name = arr[i]; Ref<InputEvent> shortcut = arr[i + 1]; @@ -120,14 +116,11 @@ bool EditorSettings::_set_only(const StringName &p_name, const Variant &p_value) } bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { - _THREAD_SAFE_METHOD_ if (p_name.operator String() == "shortcuts") { - Array arr; for (const Map<String, Ref<ShortCut>>::Element *E = shortcuts.front(); E; E = E->next()) { - Ref<ShortCut> sc = E->get(); if (optimize_save) { @@ -163,7 +156,6 @@ void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_val } struct _EVCSort { - String name; Variant::Type type; int order; @@ -174,14 +166,12 @@ struct _EVCSort { }; void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { - _THREAD_SAFE_METHOD_ const String *k = nullptr; Set<_EVCSort> vclist; while ((k = props.next(k))) { - const VariantContainer *v = props.getptr(*k); if (v->hide_from_editor) @@ -203,7 +193,6 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { } for (Set<_EVCSort>::Element *E = vclist.front(); E; E = E->next()) { - int pinfo = 0; if (E->get().save || !optimize_save) { pinfo |= PROPERTY_USAGE_STORAGE; @@ -231,7 +220,6 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { } void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { - ERR_FAIL_COND(!p_info.has("name")); ERR_FAIL_COND(!p_info.has("type")); @@ -251,7 +239,6 @@ void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { // Default configs bool EditorSettings::has_default_value(const String &p_setting) const { - _THREAD_SAFE_METHOD_ if (!props.has(p_setting)) @@ -260,7 +247,6 @@ bool EditorSettings::has_default_value(const String &p_setting) const { } void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { - _THREAD_SAFE_METHOD_ /* Languages */ @@ -280,7 +266,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { EditorTranslationList *etl = _editor_translations; while (etl->data) { - const String &locale = etl->lang; // Skip locales which we can't render properly (see above comment). @@ -640,24 +625,19 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["project_manager/sorting_order"] = PropertyInfo(Variant::INT, "project_manager/sorting_order", PROPERTY_HINT_ENUM, "Name,Path,Last Edited"); if (p_extra_config.is_valid()) { - if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) { - Vector<String> list = p_extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - String name = list[i].replace("/", "::"); set("projects/" + name, list[i]); }; }; if (p_extra_config->has_section("presets")) { - List<String> keys; p_extra_config->get_section_keys("presets", &keys); for (List<String>::Element *E = keys.front(); E; E = E->next()) { - String key = E->get(); Variant val = p_extra_config->get_value("presets", key); set(key, val); @@ -667,7 +647,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { } void EditorSettings::_load_default_text_editor_theme() { - bool dark_theme = is_dark_theme(); _initial_set("text_editor/highlighting/symbol_color", Color(0.73, 0.87, 1.0)); @@ -751,7 +730,6 @@ static Dictionary _get_builtin_script_templates() { } static void _create_script_templates(const String &p_path) { - Dictionary templates = _get_builtin_script_templates(); List<Variant> keys; templates.get_key_list(&keys); @@ -775,12 +753,10 @@ static void _create_script_templates(const String &p_path) { // PUBLIC METHODS EditorSettings *EditorSettings::get_singleton() { - return singleton.ptr(); } void EditorSettings::create() { - if (singleton.ptr()) return; //pointless @@ -815,7 +791,6 @@ void EditorSettings::create() { memdelete(d); if (self_contained) { - // editor is self contained, all in same folder data_path = exe_path; data_dir = data_path.plus_file("editor_data"); @@ -824,7 +799,6 @@ void EditorSettings::create() { cache_path = exe_path; cache_dir = data_dir.plus_file("cache"); } else { - // Typically XDG_DATA_HOME or %APPDATA% data_path = OS::get_singleton()->get_data_path(); data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name()); @@ -845,7 +819,6 @@ void EditorSettings::create() { String config_file_path; if (data_path != "" && config_path != "" && cache_path != "") { - // Validate/create data dir and subdirectories dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); @@ -967,7 +940,6 @@ fail: if (extra_config->has_section("init_projects")) { Vector<String> list = extra_config->get_value("init_projects", "list"); for (int i = 0; i < list.size(); i++) { - list.write[i] = exe_path.plus_file(list[i]); }; extra_config->set_value("init_projects", "list", list); @@ -986,7 +958,6 @@ fail: } void EditorSettings::setup_language() { - String lang = get("interface/editor/editor_language"); if (lang == "en") return; // Default, nothing to do. @@ -1039,7 +1010,6 @@ void EditorSettings::setup_language() { } void EditorSettings::setup_network() { - List<IP_Address> local_ip; IP::get_singleton()->get_local_addresses(&local_ip); String hint; @@ -1048,7 +1018,6 @@ void EditorSettings::setup_network() { // Check that current remote_host is a valid interface address and populate hints. for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) { - String ip = E->get(); // link-local IPv6 addresses don't work, skipping them @@ -1072,7 +1041,6 @@ void EditorSettings::setup_network() { } void EditorSettings::save() { - //_THREAD_SAFE_METHOD_ if (!singleton.ptr()) @@ -1093,7 +1061,6 @@ void EditorSettings::save() { } void EditorSettings::destroy() { - if (!singleton.ptr()) return; save(); @@ -1101,7 +1068,6 @@ void EditorSettings::destroy() { } void EditorSettings::set_optimize_save(bool p_optimize) { - optimize_save = p_optimize; } @@ -1118,14 +1084,12 @@ Variant EditorSettings::get_setting(const String &p_setting) const { } bool EditorSettings::has_setting(const String &p_setting) const { - _THREAD_SAFE_METHOD_ return props.has(p_setting); } void EditorSettings::erase(const String &p_setting) { - _THREAD_SAFE_METHOD_ props.erase(p_setting); @@ -1147,7 +1111,6 @@ void EditorSettings::set_restart_if_changed(const StringName &p_setting, bool p_ } void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) { - _THREAD_SAFE_METHOD_ if (!props.has(p_setting)) @@ -1160,7 +1123,6 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed) { - Variant ret = p_default; if (EditorSettings::get_singleton()->has_setting(p_setting)) { ret = EditorSettings::get_singleton()->get(p_setting); @@ -1177,13 +1139,11 @@ Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_re } Variant _EDITOR_GET(const String &p_setting) { - ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has_setting(p_setting), Variant()); return EditorSettings::get_singleton()->get(p_setting); } bool EditorSettings::property_can_revert(const String &p_setting) { - if (!props.has(p_setting)) return false; @@ -1194,7 +1154,6 @@ bool EditorSettings::property_can_revert(const String &p_setting) { } Variant EditorSettings::property_get_revert(const String &p_setting) { - if (!props.has(p_setting) || !props[p_setting].has_default_value) return Variant(); @@ -1202,7 +1161,6 @@ Variant EditorSettings::property_get_revert(const String &p_setting) { } void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { - _THREAD_SAFE_METHOD_ hints[p_hint.name] = p_hint; @@ -1211,51 +1169,42 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { // Data directories String EditorSettings::get_data_dir() const { - return data_dir; } String EditorSettings::get_templates_dir() const { - return get_data_dir().plus_file("templates"); } // Config directories String EditorSettings::get_settings_dir() const { - return settings_dir; } String EditorSettings::get_project_settings_dir() const { - return get_settings_dir().plus_file("projects").plus_file(project_config_dir); } String EditorSettings::get_text_editor_themes_dir() const { - return get_settings_dir().plus_file("text_editor_themes"); } String EditorSettings::get_script_templates_dir() const { - return get_settings_dir().plus_file("script_templates"); } String EditorSettings::get_project_script_templates_dir() const { - return ProjectSettings::get_singleton()->get("editor/script_templates_search_path"); } // Cache directory String EditorSettings::get_cache_dir() const { - return cache_dir; } String EditorSettings::get_feature_profiles_dir() const { - return get_settings_dir().plus_file("feature_profiles"); } @@ -1283,7 +1232,6 @@ Variant EditorSettings::get_project_metadata(const String &p_section, const Stri } void EditorSettings::set_favorites(const Vector<String> &p_favorites) { - favorites = p_favorites; FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::WRITE); if (f) { @@ -1294,12 +1242,10 @@ void EditorSettings::set_favorites(const Vector<String> &p_favorites) { } Vector<String> EditorSettings::get_favorites() const { - return favorites; } void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { - recent_dirs = p_recent_dirs; FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::WRITE); if (f) { @@ -1310,12 +1256,10 @@ void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { } Vector<String> EditorSettings::get_recent_dirs() const { - return recent_dirs; } void EditorSettings::load_favorites() { - FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorites"), FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); @@ -1398,7 +1342,6 @@ void EditorSettings::load_text_editor_theme() { // don't load if it's not already there! if (has_setting("text_editor/highlighting/" + key)) { - // make sure it is actually a color if (val.is_valid_html_color() && key.find("color") >= 0) { props["text_editor/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam @@ -1410,7 +1353,6 @@ void EditorSettings::load_text_editor_theme() { } bool EditorSettings::import_text_editor_theme(String p_file) { - if (!p_file.ends_with(".tet")) { return false; } else { @@ -1429,7 +1371,6 @@ bool EditorSettings::import_text_editor_theme(String p_file) { } bool EditorSettings::save_text_editor_theme() { - String p_file = get("text_editor/theme/color_theme"); if (_is_default_text_editor_theme(p_file.get_file().to_lower())) { @@ -1448,7 +1389,6 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { return false; } if (_save_text_editor_theme(p_file)) { - // switch to theme is saved in the theme directory list_text_editor_themes(); String theme_name = p_file.substr(0, p_file.length() - 4).get_file(); @@ -1468,7 +1408,6 @@ bool EditorSettings::is_default_text_editor_theme() { } Vector<String> EditorSettings::get_script_templates(const String &p_extension, const String &p_custom_path) { - Vector<String> templates; String template_dir = get_script_templates_dir(); if (!p_custom_path.empty()) { @@ -1491,19 +1430,16 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c } String EditorSettings::get_editor_layouts_config() const { - return get_settings_dir().plus_file("editor_layouts.cfg"); } // Shortcuts void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) { - shortcuts[p_name] = p_shortcut; } 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); ERR_FAIL_COND_V_MSG(!E, false, "Unknown Shortcut: " + p_name + "."); @@ -1511,7 +1447,6 @@ 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); if (!E) return Ref<ShortCut>(); @@ -1520,15 +1455,12 @@ 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()) { - r_shortcuts->push_back(E->key()); } } Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) { - if (!EditorSettings::get_singleton()) { return nullptr; } @@ -1546,7 +1478,6 @@ struct ShortCutMapping { }; Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p_keycode) { - #ifdef OSX_ENABLED // Use Cmd+Backspace as a general replacement for Delete shortcuts on macOS if (p_keycode == KEY_DELETE) { @@ -1577,7 +1508,6 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path); if (sc.is_valid()) { - sc->set_name(p_name); //keep name (the ones that come from disk have no name) sc->set_meta("original", ie); //to compare against changes return sc; @@ -1593,7 +1523,6 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p } void EditorSettings::notify_changes() { - _THREAD_SAFE_METHOD_ SceneTree *sml = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()); @@ -1611,7 +1540,6 @@ void EditorSettings::notify_changes() { } void EditorSettings::_bind_methods() { - ClassDB::bind_method(D_METHOD("has_setting", "name"), &EditorSettings::has_setting); ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &EditorSettings::set_setting); ClassDB::bind_method(D_METHOD("get_setting", "name"), &EditorSettings::get_setting); @@ -1638,7 +1566,6 @@ void EditorSettings::_bind_methods() { } EditorSettings::EditorSettings() { - last_order = 0; optimize_save = true; save_changed_setting = true; diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 8f1a3c8333..755d46f11b 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -42,7 +42,6 @@ class EditorPlugin; class EditorSettings : public Resource { - GDCLASS(EditorSettings, Resource); private: @@ -50,7 +49,6 @@ private: public: struct Plugin { - EditorPlugin *instance; String path; String name; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 2c70e16610..e19fcfd55c 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -47,16 +47,13 @@ String EditorSpinSlider::get_text_value() const { } void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { - if (read_only) return; Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { - if (updown_offset != -1 && mb->get_position().x > updown_offset) { //there is an updown, so use it. if (mb->get_position().y < get_size().height / 2) { @@ -66,7 +63,6 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } return; } else { - grabbing_spinner_attempt = true; grabbing_spinner_dist_cache = 0; pre_grab_value = get_value(); @@ -74,11 +70,8 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { grabbing_spinner_mouse_pos = Input::get_singleton()->get_mouse_position(); } } else { - if (grabbing_spinner_attempt) { - if (grabbing_spinner) { - Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); Input::get_singleton()->warp_mouse_position(grabbing_spinner_mouse_pos); update(); @@ -91,7 +84,6 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } } } else if (mb->get_button_index() == BUTTON_WHEEL_UP || mb->get_button_index() == BUTTON_WHEEL_DOWN) { - if (grabber->is_visible()) call_deferred("update"); } @@ -99,9 +91,7 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (grabbing_spinner_attempt) { - double diff_x = mm->get_relative().x; if (mm->get_shift() && grabbing_spinner) { diff_x *= 0.1; @@ -150,12 +140,10 @@ void EditorSpinSlider::_gui_input(const Ref<InputEvent> &p_event) { } void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (grabbing_grabber) { if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_WHEEL_UP) { set_value(get_value() + get_step()); mousewheel_over_grabber = true; @@ -167,9 +155,7 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { } if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) { - if (mb->is_pressed()) { - grabbing_grabber = true; if (!mousewheel_over_grabber) { grabbing_ratio = get_as_ratio(); @@ -193,7 +179,6 @@ void EditorSpinSlider::_grabber_gui_input(const Ref<InputEvent> &p_event) { } void EditorSpinSlider::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_FOCUS_OUT || p_what == NOTIFICATION_WM_FOCUS_IN || p_what == NOTIFICATION_EXIT_TREE) { @@ -218,7 +203,6 @@ void EditorSpinSlider::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - updown_offset = -1; Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); @@ -324,12 +308,10 @@ void EditorSpinSlider::_notification(int p_what) { } if (p_what == NOTIFICATION_MOUSE_ENTER) { - mouse_over_spin = true; update(); } if (p_what == NOTIFICATION_MOUSE_EXIT) { - mouse_over_spin = false; update(); } @@ -342,7 +324,6 @@ void EditorSpinSlider::_notification(int p_what) { } Size2 EditorSpinSlider::get_minimum_size() const { - Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit"); Ref<Font> font = get_theme_font("font", "LineEdit"); @@ -399,7 +380,6 @@ void EditorSpinSlider::_value_input_closed() { //focus_exited signal void EditorSpinSlider::_value_focus_exited() { - // discontinue because the focus_exit was caused by right-click context menu if (value_input->get_menu()->is_visible()) return; @@ -429,7 +409,6 @@ void EditorSpinSlider::_grabber_mouse_exited() { } void EditorSpinSlider::set_read_only(bool p_enable) { - read_only = p_enable; update(); } @@ -439,7 +418,6 @@ bool EditorSpinSlider::is_read_only() const { } void EditorSpinSlider::set_flat(bool p_enable) { - flat = p_enable; update(); } @@ -483,7 +461,6 @@ void EditorSpinSlider::_bind_methods() { } EditorSpinSlider::EditorSpinSlider() { - flat = false; grabbing_spinner_attempt = false; grabbing_spinner = false; diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index 1205e0b37c..2170fd6380 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -35,13 +35,11 @@ #include "scene/resources/packed_scene.h" void EditorSubScene::_path_selected(const String &p_path) { - path->set_text(p_path); _path_changed(p_path); } void EditorSubScene::_path_changed(const String &p_path) { - tree->clear(); if (scene) { @@ -65,13 +63,11 @@ void EditorSubScene::_path_changed(const String &p_path) { } void EditorSubScene::_path_browse() { - file_dialog->popup_centered_ratio(); } void EditorSubScene::_notification(int p_what) { if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - if (is_visible() && scene == nullptr) { _path_browse(); } @@ -79,7 +75,6 @@ void EditorSubScene::_notification(int p_what) { } void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) { - TreeItem *it = tree->create_item(p_parent); it->set_metadata(0, p_node); it->set_text(0, p_node->get_name()); @@ -88,7 +83,6 @@ void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) { it->set_icon(0, EditorNode::get_singleton()->get_object_icon(p_node, "Node")); for (int i = 0; i < p_node->get_child_count(); i++) { - Node *c = p_node->get_child(i); if (c->get_owner() != scene) continue; @@ -165,13 +159,10 @@ void EditorSubScene::ok_pressed() { } void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) { - if (p_node == scene) { - scene->set_filename(""); p_to_reown->push_back(p_node); } else if (p_node->get_owner() == scene) { - p_to_reown->push_back(p_node); } @@ -214,18 +205,15 @@ void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { } void EditorSubScene::clear() { - path->set_text(""); _path_changed(""); } void EditorSubScene::_bind_methods() { - ADD_SIGNAL(MethodInfo("subscene_selected")); } EditorSubScene::EditorSubScene() { - scene = nullptr; is_root = false; @@ -262,7 +250,6 @@ EditorSubScene::EditorSubScene() { ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file_dialog->add_filter("*." + E->get()); } diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h index 5c3b4377d4..cd88805254 100644 --- a/editor/editor_sub_scene.h +++ b/editor/editor_sub_scene.h @@ -36,7 +36,6 @@ #include "scene/gui/tree.h" class EditorSubScene : public ConfirmationDialog { - GDCLASS(EditorSubScene, ConfirmationDialog); List<Node *> selection; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 0ef173f074..ace106cd3e 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -86,7 +86,6 @@ static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, } Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) { - Ref<ImageTexture> icon = memnew(ImageTexture); Ref<Image> img = memnew(Image); @@ -106,7 +105,6 @@ Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float #endif void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = true, int p_thumb_size = 32, bool p_only_thumbs = false) { - #ifdef MODULE_SVG_ENABLED // The default icon theme is designed to be used for a dark theme. // This dictionary stores color codes to convert to other colors @@ -255,7 +253,6 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = } Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { - Ref<Theme> theme = Ref<Theme>(memnew(Theme)); const float default_contrast = 0.25; diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 6f3a8d9ea7..4b13a5dd89 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -33,7 +33,6 @@ EditorVCSInterface *EditorVCSInterface::singleton = nullptr; void EditorVCSInterface::_bind_methods() { - // Proxy end points that act as fallbacks to unavailability of a function in the VCS addon ClassDB::bind_method(D_METHOD("_initialize", "project_root_path"), &EditorVCSInterface::_initialize); ClassDB::bind_method(D_METHOD("_is_vcs_initialized"), &EditorVCSInterface::_is_vcs_initialized); @@ -62,18 +61,15 @@ void EditorVCSInterface::_bind_methods() { } bool EditorVCSInterface::_initialize(String p_project_root_path) { - WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed."); return true; } bool EditorVCSInterface::_is_vcs_initialized() { - return false; } Dictionary EditorVCSInterface::_get_modified_files_data() { - return Dictionary(); } @@ -87,96 +83,76 @@ void EditorVCSInterface::_commit(String p_msg) { } Array EditorVCSInterface::_get_file_diff(String p_file_path) { - return Array(); } bool EditorVCSInterface::_shut_down() { - return false; } String EditorVCSInterface::_get_project_name() { - return String(); } String EditorVCSInterface::_get_vcs_name() { - return ""; } bool EditorVCSInterface::initialize(String p_project_root_path) { - is_initialized = call("_initialize", p_project_root_path); return is_initialized; } bool EditorVCSInterface::is_vcs_initialized() { - return call("_is_vcs_initialized"); } Dictionary EditorVCSInterface::get_modified_files_data() { - return call("_get_modified_files_data"); } void EditorVCSInterface::stage_file(String p_file_path) { - if (is_addon_ready()) { - call("_stage_file", p_file_path); } } void EditorVCSInterface::unstage_file(String p_file_path) { - if (is_addon_ready()) { - call("_unstage_file", p_file_path); } } bool EditorVCSInterface::is_addon_ready() { - return is_initialized; } void EditorVCSInterface::commit(String p_msg) { - if (is_addon_ready()) { - call("_commit", p_msg); } } Array EditorVCSInterface::get_file_diff(String p_file_path) { - if (is_addon_ready()) { - return call("_get_file_diff", p_file_path); } return Array(); } bool EditorVCSInterface::shut_down() { - return call("_shut_down"); } String EditorVCSInterface::get_project_name() { - return call("_get_project_name"); } String EditorVCSInterface::get_vcs_name() { - return call("_get_vcs_name"); } EditorVCSInterface::EditorVCSInterface() { - is_initialized = false; } @@ -184,11 +160,9 @@ EditorVCSInterface::~EditorVCSInterface() { } EditorVCSInterface *EditorVCSInterface::get_singleton() { - return singleton; } void EditorVCSInterface::set_singleton(EditorVCSInterface *p_singleton) { - singleton = p_singleton; } diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index 85d5e30367..ee9e51441d 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -36,7 +36,6 @@ #include "scene/gui/panel_container.h" class EditorVCSInterface : public Object { - GDCLASS(EditorVCSInterface, Object) bool is_initialized; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index f52e340a26..61860d2376 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -42,7 +42,6 @@ #include "scene/gui/link_button.h" void ExportTemplateManager::_update_template_list() { - while (current_hb->get_child_count()) { memdelete(current_hb->get_child(0)); } @@ -57,7 +56,6 @@ void ExportTemplateManager::_update_template_list() { Set<String> templates; d->list_dir_begin(); if (err == OK) { - String c = d->get_next(); while (c != String()) { if (d->current_is_dir() && !c.begins_with(".")) { @@ -118,7 +116,6 @@ void ExportTemplateManager::_update_template_list() { } for (Set<String>::Element *E = templates.back(); E; E = E->prev()) { - HBoxContainer *hbc = memnew(HBoxContainer); Label *version = memnew(Label); version->set_modulate(current->get_theme_color("disabled_font_color", "Editor")); @@ -141,7 +138,6 @@ void ExportTemplateManager::_update_template_list() { } void ExportTemplateManager::_download_template(const String &p_version) { - while (template_list->get_child_count()) { memdelete(template_list->get_child(0)); } @@ -155,14 +151,12 @@ 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(); to_remove = p_version; } void ExportTemplateManager::_uninstall_template_confirm() { - DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir(); Error err = da->change_dir(templates_dir); @@ -181,7 +175,6 @@ void ExportTemplateManager::_uninstall_template_confirm() { } bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) { - // 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 = nullptr; @@ -189,7 +182,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); if (!pkg) { - EditorNode::get_singleton()->show_warning(TTR("Can't open export templates zip.")); return false; } @@ -200,7 +192,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ String contents_dir; while (ret == UNZ_OK) { - unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); @@ -208,7 +199,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ String file = fname; if (file.ends_with("version.txt")) { - Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -266,7 +256,6 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ fc = 0; while (ret == UNZ_OK) { - //get filename unz_file_info info; char fname[16384]; @@ -340,18 +329,15 @@ bool ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_ } void ExportTemplateManager::popup_manager() { - _update_template_list(); popup_centered(Size2(400, 400) * EDSCALE); } void ExportTemplateManager::ok_pressed() { - template_open->popup_centered_ratio(); } void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) { - if (p_status != HTTPRequest::RESULT_SUCCESS || p_code != 200) { EditorNode::get_singleton()->show_warning(TTR("Error getting the list of mirrors.")); return; @@ -397,9 +383,7 @@ void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_ } } void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) { - switch (p_status) { - case HTTPRequest::RESULT_CANT_RESOLVE: { template_list_state->set_text(TTR("Can't resolve.")); } break; @@ -445,7 +429,6 @@ 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)) { OS::get_singleton()->shell_open(p_url); return; @@ -482,14 +465,12 @@ 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(); if (update_countdown > 0) { @@ -552,13 +533,11 @@ void ExportTemplateManager::_notification(int p_what) { } bool ExportTemplateManager::can_install_android_template() { - const String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG); return FileAccess::exists(templates_dir.plus_file("android_source.zip")); } Error ExportTemplateManager::install_android_template() { - // To support custom Android builds, we install the Java source code and buildsystem // from android_source.zip to the project's res://android folder. @@ -615,7 +594,6 @@ Error ExportTemplateManager::install_android_template() { Set<String> dirs_tested; int idx = 0; while (ret == UNZ_OK) { - // Get file path. unz_file_info info; char fpath[16384]; @@ -667,7 +645,6 @@ void ExportTemplateManager::_bind_methods() { } ExportTemplateManager::ExportTemplateManager() { - VBoxContainer *main_vb = memnew(VBoxContainer); add_child(main_vb); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index fb44c145b2..7e05bc5d88 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -40,7 +40,6 @@ #define DEBUG_TIME(m_what) void EditorFileServer::_close_client(ClientData *cd) { - cd->connection->disconnect_from_host(); { MutexLock lock(cd->efs->wait_mutex); @@ -54,7 +53,6 @@ void EditorFileServer::_close_client(ClientData *cd) { } void EditorFileServer::_subthread_start(void *s) { - ClientData *cd = (ClientData *)s; cd->connection->set_no_delay(true); @@ -68,11 +66,9 @@ void EditorFileServer::_subthread_start(void *s) { int passlen = decode_uint32(buf4); if (passlen > 512) { - _close_client(cd); ERR_FAIL_COND(passlen > 512); } else if (passlen > 0) { - Vector<char> passutf8; passutf8.resize(passlen + 1); err = cd->connection->get_data((uint8_t *)passutf8.ptr(), passlen); @@ -106,7 +102,6 @@ void EditorFileServer::_subthread_start(void *s) { cd->connection->put_data(buf4, 4); while (!cd->quit) { - //wait for ID err = cd->connection->get_data(buf4, 4); DEBUG_TIME("get_data") @@ -126,11 +121,9 @@ void EditorFileServer::_subthread_start(void *s) { int cmd = decode_uint32(buf4); switch (cmd) { - case FileAccessNetwork::COMMAND_FILE_EXISTS: case FileAccessNetwork::COMMAND_GET_MODTIME: case FileAccessNetwork::COMMAND_OPEN_FILE: { - DEBUG_TIME("open_file") err = cd->connection->get_data(buf4, 4); if (err != OK) { @@ -161,14 +154,12 @@ void EditorFileServer::_subthread_start(void *s) { } if (!s2.begins_with("res://")) { - _close_client(cd); ERR_FAIL_COND(!s2.begins_with("res://")); } ERR_CONTINUE(cd->files.has(id)); if (cmd == FileAccessNetwork::COMMAND_FILE_EXISTS) { - encode_uint32(id, buf4); cd->connection->put_data(buf4, 4); encode_uint32(FileAccessNetwork::RESPONSE_FILE_EXISTS, buf4); @@ -180,7 +171,6 @@ void EditorFileServer::_subthread_start(void *s) { } if (cmd == FileAccessNetwork::COMMAND_GET_MODTIME) { - encode_uint32(id, buf4); cd->connection->put_data(buf4, 4); encode_uint32(FileAccessNetwork::RESPONSE_GET_MODTIME, buf4); @@ -218,7 +208,6 @@ void EditorFileServer::_subthread_start(void *s) { } break; case FileAccessNetwork::COMMAND_READ_BLOCK: { - err = cd->connection->get_data(buf4, 8); if (err != OK) { _close_client(cd); @@ -259,7 +248,6 @@ void EditorFileServer::_subthread_start(void *s) { } break; case FileAccessNetwork::COMMAND_CLOSE: { - print_verbose("CLOSED"); ERR_CONTINUE(!cd->files.has(id)); memdelete(cd->files[id]); @@ -272,10 +260,8 @@ void EditorFileServer::_subthread_start(void *s) { } void EditorFileServer::_thread_start(void *s) { - EditorFileServer *self = (EditorFileServer *)s; while (!self->quit) { - if (self->cmd == CMD_ACTIVATE) { self->server->listen(self->port); self->active = true; @@ -312,7 +298,6 @@ void EditorFileServer::_thread_start(void *s) { } void EditorFileServer::start() { - stop(); port = EDITOR_DEF("filesystem/file_server/port", 6010); password = EDITOR_DEF("filesystem/file_server/password", ""); @@ -320,17 +305,14 @@ void EditorFileServer::start() { } bool EditorFileServer::is_active() const { - return active; } void EditorFileServer::stop() { - cmd = CMD_STOP; } EditorFileServer::EditorFileServer() { - server.instance(); quit = false; active = false; @@ -342,7 +324,6 @@ EditorFileServer::EditorFileServer() { } EditorFileServer::~EditorFileServer() { - quit = true; Thread::wait_to_finish(thread); memdelete(thread); diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index cc3cb44566..9645fbf39e 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -38,7 +38,6 @@ #include "core/os/thread.h" class EditorFileServer : public Object { - GDCLASS(EditorFileServer, Object); enum Command { @@ -48,7 +47,6 @@ class EditorFileServer : public Object { }; struct ClientData { - Thread *thread; Ref<StreamPeerTCP> connection; Map<int, FileAccess *> files; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 236ae16ccf..a6ba624b64 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -93,7 +93,6 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory if (display_mode == DISPLAY_MODE_TREE_ONLY) { String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene"); for (int i = 0; i < p_dir->get_file_count(); i++) { - String file_type = p_dir->get_file_type(i); if (_is_file_type_disabled_by_feature_profile(file_type)) { @@ -554,7 +553,6 @@ bool FileSystemDock::_is_file_type_disabled_by_feature_profile(const StringName StringName class_name = p_class; while (class_name != StringName()) { - if (profile->is_class_disabled(class_name)) { return true; } @@ -576,7 +574,6 @@ void FileSystemDock::_search(EditorFileSystemDirectory *p_path, List<FileInfo> * String file = p_path->get_file(i); if (file.to_lower().find(searched_string) != -1) { - FileInfo fi; fi.name = file; fi.type = p_path->get_file_type(i); @@ -860,9 +857,7 @@ void FileSystemDock::_file_list_activate_file(int p_idx) { void FileSystemDock::_preview_invalidated(const String &p_path) { if (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && searched_string.length() == 0 && file_list_vb->is_visible_in_tree()) { - for (int i = 0; i < files->get_item_count(); i++) { - if (files->get_item_metadata(i) == p_path) { // Re-request preview. Array udata; @@ -1728,7 +1723,6 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected } break; case FILE_INFO: { - } break; case FILE_REIMPORT: { @@ -1905,7 +1899,6 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da Dictionary drag_data = p_data; if (drag_data.has("favorite")) { - if (String(drag_data["favorite"]) != "all") { return false; } @@ -1976,7 +1969,6 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, Vector<String> dirs = EditorSettings::get_singleton()->get_favorites(); if (drag_data.has("favorite")) { - if (String(drag_data["favorite"]) != "all") { return; } @@ -2350,7 +2342,6 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { } void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { - Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed() && !key->is_echo()) { if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) { @@ -2366,7 +2357,6 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { } void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { - Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed() && !key->is_echo()) { if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) { @@ -2451,7 +2441,6 @@ void FileSystemDock::_feature_profile_changed() { } void FileSystemDock::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree); ClassDB::bind_method(D_METHOD("_file_list_thumbnail_done"), &FileSystemDock::_file_list_thumbnail_done); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index d73180c831..b2a8f7dba4 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -59,7 +59,6 @@ static bool is_text_char(CharType c) { } static bool find_next(const String &line, String pattern, int from, bool match_case, bool whole_words, int &out_begin, int &out_end) { - int end = from; while (true) { @@ -163,9 +162,7 @@ void FindInFiles::_process() { } void FindInFiles::_iterate() { - if (_folders_stack.size() != 0) { - // Scan folders first so we can build a list of files and have progress info later PackedStringArray &folders_to_scan = _folders_stack.write[_folders_stack.size() - 1]; @@ -196,7 +193,6 @@ void FindInFiles::_iterate() { } } else if (_files_to_scan.size() != 0) { - // Then scan files String fpath = _files_to_scan[_files_to_scan.size() - 1]; @@ -220,7 +216,6 @@ float FindInFiles::get_progress() const { } void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { - DirAccessRef dir = DirAccess::open(path); if (!dir) { print_verbose("Cannot open directory! " + path); @@ -254,7 +249,6 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) { } void FindInFiles::_scan_file(String fpath) { - FileAccessRef f = FileAccess::open(fpath, FileAccess::READ); if (!f) { print_verbose(String("Cannot open file ") + fpath); @@ -264,7 +258,6 @@ void FindInFiles::_scan_file(String fpath) { int line_number = 0; while (!f->eof_reached()) { - // line number starts at 1 ++line_number; @@ -282,7 +275,6 @@ void FindInFiles::_scan_file(String fpath) { } void FindInFiles::_bind_methods() { - ADD_SIGNAL(MethodInfo(SIGNAL_RESULT_FOUND, PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "line_number"), @@ -298,7 +290,6 @@ const char *FindInFilesDialog::SIGNAL_FIND_REQUESTED = "find_requested"; const char *FindInFilesDialog::SIGNAL_REPLACE_REQUESTED = "replace_requested"; FindInFilesDialog::FindInFilesDialog() { - set_min_size(Size2(500 * EDSCALE, 0)); set_title(TTR("Find in Files")); @@ -408,7 +399,6 @@ void FindInFilesDialog::set_replace_text(String text) { } void FindInFilesDialog::set_find_in_files_mode(FindInFilesMode p_mode) { - if (_mode == p_mode) return; @@ -464,7 +454,6 @@ 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"); @@ -506,7 +495,6 @@ void FindInFilesDialog::custom_action(const String &p_action) { } void FindInFilesDialog::_on_search_text_modified(String text) { - ERR_FAIL_COND(!_find_button); ERR_FAIL_COND(!_replace_button); @@ -546,7 +534,6 @@ void FindInFilesDialog::_on_folder_selected(String path) { } void FindInFilesDialog::_bind_methods() { - ADD_SIGNAL(MethodInfo(SIGNAL_FIND_REQUESTED)); ADD_SIGNAL(MethodInfo(SIGNAL_REPLACE_REQUESTED)); } @@ -556,7 +543,6 @@ const char *FindInFilesPanel::SIGNAL_RESULT_SELECTED = "result_selected"; const char *FindInFilesPanel::SIGNAL_FILES_MODIFIED = "files_modified"; FindInFilesPanel::FindInFilesPanel() { - _finder = memnew(FindInFiles); _finder->connect(FindInFiles::SIGNAL_RESULT_FOUND, callable_mp(this, &FindInFilesPanel::_on_result_found)); _finder->connect(FindInFiles::SIGNAL_FINISHED, callable_mp(this, &FindInFilesPanel::_on_finished)); @@ -641,7 +627,6 @@ FindInFilesPanel::FindInFilesPanel() { } void FindInFilesPanel::set_with_replace(bool with_replace) { - _with_replace = with_replace; _replace_container->set_visible(with_replace); @@ -670,7 +655,6 @@ void FindInFilesPanel::clear() { } void FindInFilesPanel::start_search() { - clear(); _status_label->set_text(TTR("Searching...")); @@ -687,7 +671,6 @@ void FindInFilesPanel::start_search() { } void FindInFilesPanel::stop_search() { - _finder->stop(); _status_label->set_text(""); @@ -704,7 +687,6 @@ void FindInFilesPanel::_notification(int p_what) { } void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin, int end, String text) { - TreeItem *file_item; Map<String, TreeItem *>::Element *E = _file_items.find(fpath); @@ -756,7 +738,6 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin } void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { - TreeItem *item = Object::cast_to<TreeItem>(item_obj); if (!item) return; @@ -777,7 +758,6 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) { } void FindInFilesPanel::_on_item_edited() { - TreeItem *item = _results_display->get_selected(); if (item->is_checked(0)) { @@ -792,7 +772,6 @@ void FindInFilesPanel::_on_item_edited() { } void FindInFilesPanel::_on_finished() { - _status_label->set_text(TTR("Search complete")); update_replace_buttons(); set_progress_visible(false); @@ -809,7 +788,6 @@ void FindInFilesPanel::_on_cancel_button_clicked() { } void FindInFilesPanel::_on_result_selected() { - TreeItem *item = _results_display->get_selected(); Map<TreeItem *, Result>::Element *E = _result_items.find(item); @@ -828,19 +806,16 @@ void FindInFilesPanel::_on_replace_text_changed(String text) { } void FindInFilesPanel::_on_replace_all_clicked() { - String replace_text = get_replace_text(); PackedStringArray modified_files; for (Map<String, TreeItem *>::Element *E = _file_items.front(); E; E = E->next()) { - TreeItem *file_item = E->value(); String fpath = file_item->get_metadata(0); Vector<Result> locations; for (TreeItem *item = file_item->get_children(); item; item = item->get_next()) { - if (!item->is_checked(0)) continue; @@ -866,13 +841,11 @@ void FindInFilesPanel::_on_replace_all_clicked() { class ConservativeGetLine { public: String get_line(FileAccess *f) { - _line_buffer.clear(); CharType c = f->get_8(); while (!f->eof_reached()) { - if (c == '\n') { _line_buffer.push_back(c); _line_buffer.push_back(0); @@ -898,7 +871,6 @@ private: }; void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result> &locations, String new_text) { - // If the file is already open, I assume the editor will reload it. // If there are unsaved changes, the user will be asked on focus, // however that means either losing changes or losing replaces. @@ -917,7 +889,6 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result> int offset = 0; for (int i = 0; i < locations.size(); ++i) { - int repl_line_number = locations[i].line_number; while (current_line < repl_line_number) { @@ -963,7 +934,6 @@ String FindInFilesPanel::get_replace_text() { } void FindInFilesPanel::update_replace_buttons() { - bool disabled = _finder->is_searching(); _replace_all_button->set_disabled(disabled); @@ -974,7 +944,6 @@ void FindInFilesPanel::set_progress_visible(bool visible) { } void FindInFilesPanel::_bind_methods() { - ClassDB::bind_method("_on_result_found", &FindInFilesPanel::_on_result_found); ClassDB::bind_method("_on_finished", &FindInFilesPanel::_on_finished); ClassDB::bind_method("_draw_result_text", &FindInFilesPanel::draw_result_text); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index 7e5d2e87d6..692b41e921 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -536,7 +536,6 @@ GroupDialog::GroupDialog() { //////////////////////////////////////////////////////////////////////////////// void GroupsEditor::_add_group(const String &p_group) { - if (!node) return; @@ -564,7 +563,6 @@ void GroupsEditor::_add_group(const String &p_group) { } void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) { - if (!node) return; @@ -589,14 +587,12 @@ void GroupsEditor::_remove_group(Object *p_item, int p_column, int p_id) { } struct _GroupInfoComparator { - bool operator()(const Node::GroupInfo &p_a, const Node::GroupInfo &p_b) const { return p_a.name.operator String() < p_b.name.operator String(); } }; void GroupsEditor::update_tree() { - tree->clear(); if (!node) @@ -609,7 +605,6 @@ void GroupsEditor::update_tree() { TreeItem *root = tree->create_item(); for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next()) { - Node::GroupInfo gi = E->get(); if (!gi.persistent) continue; @@ -618,11 +613,9 @@ void GroupsEditor::update_tree() { bool can_be_deleted = true; while (n) { - Ref<SceneState> ss = (n == EditorNode::get_singleton()->get_edited_scene()) ? n->get_scene_inherited_state() : n->get_scene_instance_state(); if (ss.is_valid()) { - int path = ss->find_node_by_path(n->get_path_to(node)); if (path != -1) { if (ss->is_node_in_group(path, gi.name)) { @@ -645,13 +638,11 @@ void GroupsEditor::update_tree() { } void GroupsEditor::set_current(Node *p_node) { - node = p_node; update_tree(); } void GroupsEditor::_show_group_dialog() { - group_dialog->edit(); group_dialog->set_undo_redo(undo_redo); } @@ -661,7 +652,6 @@ void GroupsEditor::_bind_methods() { } GroupsEditor::GroupsEditor() { - node = nullptr; VBoxContainer *vbc = this; diff --git a/editor/groups_editor.h b/editor/groups_editor.h index 40c7b3c75a..911c82e7f0 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -42,7 +42,6 @@ #include "scene/gui/tree.h" class GroupDialog : public AcceptDialog { - GDCLASS(GroupDialog, AcceptDialog); ConfirmationDialog *error; @@ -104,7 +103,6 @@ public: }; class GroupsEditor : public VBoxContainer { - GDCLASS(GroupsEditor, VBoxContainer); Node *node; diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index 9e49fa9066..e82e1bb098 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -45,14 +45,12 @@ /* HELPERS */ String Collada::Effect::get_texture_path(const String &p_source, Collada &state) const { - const String &image = p_source; ERR_FAIL_COND_V(!state.state.image_map.has(image), ""); return state.state.image_map[image].path; } Transform Collada::get_root_transform() const { - Transform unit_scale_transform; #ifndef COLLADA_IMPORT_SCALE_SCENE unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale)); @@ -67,7 +65,6 @@ void Collada::Vertex::fix_unit_scale(Collada &state) { } static String _uri_to_id(const String &p_uri) { - if (p_uri.begins_with("#")) return p_uri.substr(1, p_uri.size() - 1); else @@ -77,13 +74,11 @@ static String _uri_to_id(const String &p_uri) { /** HELPER FUNCTIONS **/ Transform Collada::fix_transform(const Transform &p_transform) { - Transform tr = p_transform; #ifndef NO_UP_AXIS_SWAP if (state.up_axis != Vector3::AXIS_Y) { - for (int i = 0; i < 3; i++) SWAP(tr.basis[1][i], tr.basis[state.up_axis][i]); for (int i = 0; i < 3; i++) @@ -105,7 +100,6 @@ Transform Collada::fix_transform(const Transform &p_transform) { } static Transform _read_transform_from_array(const Vector<float> &array, int ofs = 0) { - Transform tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. tr.basis.elements[0][0] = array[0 + ofs]; @@ -126,39 +120,30 @@ static Transform _read_transform_from_array(const Vector<float> &array, int ofs /* STRUCTURES */ Transform Collada::Node::compute_transform(Collada &state) const { - Transform xform; for (int i = 0; i < xform_list.size(); i++) { - Transform xform_step; const XForm &xf = xform_list[i]; switch (xf.op) { - case XForm::OP_ROTATE: { if (xf.data.size() >= 4) { - xform_step.rotate(Vector3(xf.data[0], xf.data[1], xf.data[2]), Math::deg2rad(xf.data[3])); } } break; case XForm::OP_SCALE: { - if (xf.data.size() >= 3) { - xform_step.scale(Vector3(xf.data[0], xf.data[1], xf.data[2])); } } break; case XForm::OP_TRANSLATE: { - if (xf.data.size() >= 3) { - xform_step.origin = Vector3(xf.data[0], xf.data[1], xf.data[2]); } } break; case XForm::OP_MATRIX: { - if (xf.data.size() >= 16) { xform_step = _read_transform_from_array(xf.data, 0); } @@ -178,12 +163,10 @@ Transform Collada::Node::compute_transform(Collada &state) const { } Transform Collada::Node::get_transform() const { - return default_transform; } Transform Collada::Node::get_global_transform() const { - if (parent) return parent->get_global_transform() * default_transform; else @@ -191,12 +174,10 @@ Transform Collada::Node::get_global_transform() const { } Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { - ERR_FAIL_COND_V(keys.size() == 0, Vector<float>()); int i = 0; for (i = 0; i < keys.size(); i++) { - if (keys[i].time > p_time) break; } @@ -207,10 +188,8 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { return keys[keys.size() - 1].data; switch (keys[i].interp_type) { - case INTERP_BEZIER: //wait for bezier case INTERP_LINEAR: { - float c = (p_time - keys[i - 1].time) / (keys[i].time - keys[i - 1].time); if (keys[i].data.size() == 16) { @@ -243,11 +222,9 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { return ret; } else { - Vector<float> dest; dest.resize(keys[i].data.size()); for (int j = 0; j < dest.size(); j++) { - dest.write[j] = keys[i].data[j] * c + keys[i - 1].data[j] * (1.0 - c); } return dest; @@ -260,15 +237,11 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { } void Collada::_parse_asset(XMLParser &parser) { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "up_axis") { - parser.read(); if (parser.get_node_data() == "X_UP") state.up_axis = Vector3::AXIS_X; @@ -279,7 +252,6 @@ void Collada::_parse_asset(XMLParser &parser) { COLLADA_PRINT("up axis: " + parser.get_node_data()); } else if (name == "unit") { - state.unit_scale = parser.get_attribute_value("meter").to_double(); COLLADA_PRINT("unit scale: " + rtos(state.unit_scale)); } @@ -290,7 +262,6 @@ void Collada::_parse_asset(XMLParser &parser) { } void Collada::_parse_image(XMLParser &parser) { - String id = parser.get_attribute_value("id"); if (!(state.import_flags & IMPORT_FLAG_SCENE)) { @@ -309,15 +280,11 @@ void Collada::_parse_image(XMLParser &parser) { image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().plus_file(path.percent_decode())); } } else { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "init_from") { - parser.read(); String path = parser.get_node_data().strip_edges().percent_decode(); @@ -333,7 +300,6 @@ void Collada::_parse_image(XMLParser &parser) { image.path = path; } else if (name == "data") { - ERR_PRINT("COLLADA Embedded image data not supported!"); } else if (name == "extra" && !parser.is_empty()) @@ -348,7 +314,6 @@ void Collada::_parse_image(XMLParser &parser) { } void Collada::_parse_material(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -365,11 +330,8 @@ void Collada::_parse_material(XMLParser &parser) { /* <1.4 */ ERR_PRINT("Collada Materials < 1.4 are not supported (yet)"); } else { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT && parser.get_node_name() == "instance_effect") { - material.instance_effect = _uri_to_id(parser.get_attribute_value("url")); } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "material") break; //end of <asset> @@ -381,7 +343,6 @@ void Collada::_parse_material(XMLParser &parser) { //! reads floats from inside of xml element until end of xml element Vector<float> Collada::_read_float_array(XMLParser &parser) { - if (parser.is_empty()) return Vector<float>(); @@ -409,7 +370,6 @@ Vector<float> Collada::_read_float_array(XMLParser &parser) { } Vector<String> Collada::_read_string_array(XMLParser &parser) { - if (parser.is_empty()) return Vector<String>(); @@ -430,7 +390,6 @@ Vector<String> Collada::_read_string_array(XMLParser &parser) { } Transform Collada::_read_transform(XMLParser &parser) { - if (parser.is_empty()) return Transform(); @@ -458,7 +417,6 @@ Transform Collada::_read_transform(XMLParser &parser) { } String Collada::_read_empty_draw_type(XMLParser &parser) { - String empty_draw_type = ""; if (parser.is_empty()) @@ -474,7 +432,6 @@ String Collada::_read_empty_draw_type(XMLParser &parser) { } Variant Collada::_parse_param(XMLParser &parser) { - if (parser.is_empty()) return Variant(); @@ -483,50 +440,36 @@ Variant Collada::_parse_param(XMLParser &parser) { while (parser.read() == OK) { if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "float") { - parser.read(); if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data().to_double(); } } else if (parser.get_node_name() == "float2") { - Vector<float> v2 = _read_float_array(parser); if (v2.size() >= 2) { - data = Vector2(v2[0], v2[1]); } } else if (parser.get_node_name() == "float3") { - Vector<float> v3 = _read_float_array(parser); if (v3.size() >= 3) { - data = Vector3(v3[0], v3[1], v3[2]); } } else if (parser.get_node_name() == "float4") { - Vector<float> v4 = _read_float_array(parser); if (v4.size() >= 4) { - data = Color(v4[0], v4[1], v4[2], v4[3]); } } else if (parser.get_node_name() == "sampler2D") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "source") { - parser.read(); if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data(); } } @@ -534,17 +477,12 @@ Variant Collada::_parse_param(XMLParser &parser) { break; } } else if (parser.get_node_name() == "surface") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "init_from") { - parser.read(); if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data(); } } @@ -562,7 +500,6 @@ Variant Collada::_parse_param(XMLParser &parser) { } void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &id) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -570,15 +507,12 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - // first come the tags we descend, but ignore the top-levels COLLADA_PRINT("node name: " + parser.get_node_name()); if (!parser.is_empty() && (parser.get_node_name() == "profile_COMMON" || parser.get_node_name() == "technique" || parser.get_node_name() == "extra")) { - _parse_effect_material(parser, effect, id); // try again } else if (parser.get_node_name() == "newparam") { @@ -591,31 +525,23 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & parser.get_node_name() == "lambert" || parser.get_node_name() == "phong" || parser.get_node_name() == "blinn") { - COLLADA_PRINT("shade model: " + parser.get_node_name()); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String what = parser.get_node_name(); if (what == "emission" || what == "diffuse" || what == "specular" || what == "reflective") { - // color or texture types while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "color") { - Vector<float> colorarr = _read_float_array(parser); COLLADA_PRINT("colorarr size: " + rtos(colorarr.size())); if (colorarr.size() >= 3) { - // alpha strangely not alright? maybe it needs to be multiplied by value as a channel intensity Color color(colorarr[0], colorarr[1], colorarr[2], 1.0); if (what == "diffuse") @@ -629,7 +555,6 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & } } else if (parser.get_node_name() == "texture") { - String sampler = parser.get_attribute_value("texture"); if (!effect.params.has(sampler)) { ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data()); @@ -685,14 +610,10 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & parser.read(); effect.unshaded = parser.get_node_data().to_int(); } else if (parser.get_node_name() == "bump") { - // color or texture types while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "texture") { - String sampler = parser.get_attribute_value("texture"); if (!effect.params.has(sampler)) { ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data()); @@ -731,7 +652,6 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & } void Collada::_parse_effect(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -751,7 +671,6 @@ void Collada::_parse_effect(XMLParser &parser) { } void Collada::_parse_camera(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -764,47 +683,36 @@ void Collada::_parse_camera(XMLParser &parser) { CameraData &camera = state.camera_data_map[id]; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "perspective") { - camera.mode = CameraData::MODE_PERSPECTIVE; } else if (name == "orthographic") { - camera.mode = CameraData::MODE_ORTHOGONAL; } else if (name == "xfov") { - parser.read(); camera.perspective.x_fov = parser.get_node_data().to_double(); } else if (name == "yfov") { - parser.read(); camera.perspective.y_fov = parser.get_node_data().to_double(); } else if (name == "xmag") { - parser.read(); camera.orthogonal.x_mag = parser.get_node_data().to_double(); } else if (name == "ymag") { - parser.read(); camera.orthogonal.y_mag = parser.get_node_data().to_double(); } else if (name == "aspect_ratio") { - parser.read(); camera.aspect = parser.get_node_data().to_double(); } else if (name == "znear") { - parser.read(); camera.z_near = parser.get_node_data().to_double(); } else if (name == "zfar") { - parser.read(); camera.z_far = parser.get_node_data().to_double(); } @@ -817,7 +725,6 @@ void Collada::_parse_camera(XMLParser &parser) { } void Collada::_parse_light(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -830,25 +737,18 @@ void Collada::_parse_light(XMLParser &parser) { LightData &light = state.light_data_map[id]; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "ambient") { - light.mode = LightData::MODE_AMBIENT; } else if (name == "directional") { - light.mode = LightData::MODE_DIRECTIONAL; } else if (name == "point") { - light.mode = LightData::MODE_OMNI; } else if (name == "spot") { - light.mode = LightData::MODE_SPOT; } else if (name == "color") { - parser.read(); Vector<float> colorarr = _read_float_array(parser); COLLADA_PRINT("colorarr size: " + rtos(colorarr.size())); @@ -860,24 +760,19 @@ void Collada::_parse_light(XMLParser &parser) { } } else if (name == "constant_attenuation") { - parser.read(); light.constant_att = parser.get_node_data().to_double(); } else if (name == "linear_attenuation") { - parser.read(); light.linear_att = parser.get_node_data().to_double(); } else if (name == "quadratic_attenuation") { - parser.read(); light.quad_att = parser.get_node_data().to_double(); } else if (name == "falloff_angle") { - parser.read(); light.spot_angle = parser.get_node_data().to_double(); } else if (name == "falloff_exponent") { - parser.read(); light.spot_exp = parser.get_node_data().to_double(); } @@ -890,7 +785,6 @@ void Collada::_parse_light(XMLParser &parser) { } void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_name) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -914,13 +808,10 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "source") { - String id = parser.get_attribute_value("id"); curvedata.sources[id] = CurveData::Source(); current_source = id; @@ -929,14 +820,12 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } else if (section == "float_array" || section == "array") { // create a new array and read it. if (curvedata.sources.has(current_source)) { - curvedata.sources[current_source].array = _read_float_array(parser); COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values."); } } else if (section == "Name_array") { // create a new array and read it. if (curvedata.sources.has(current_source)) { - curvedata.sources[current_source].sarray = _read_string_array(parser); COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values."); } @@ -950,13 +839,9 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam COLLADA_PRINT("section: " + current_source + " stride " + itos(curvedata.sources[current_source].stride)); } } else if (section == "control_vertices") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -969,7 +854,6 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } } else if (!parser.is_empty()) { - parser.skip_section(); } } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "spline") @@ -978,7 +862,6 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name) { - if (!(state.import_flags & IMPORT_FLAG_SCENE)) { if (!parser.is_empty()) parser.skip_section(); @@ -1002,13 +885,10 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "source") { - String id = parser.get_attribute_value("id"); meshdata.sources[id] = MeshData::Source(); current_source = id; @@ -1017,7 +897,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } else if (section == "float_array" || section == "array") { // create a new array and read it. if (meshdata.sources.has(current_source)) { - meshdata.sources[current_source].array = _read_float_array(parser); COLLADA_PRINT("section: " + current_source + " read " + itos(meshdata.sources[current_source].array.size()) + " values."); } @@ -1030,16 +909,12 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name COLLADA_PRINT("section: " + current_source + " stride " + itos(meshdata.sources[current_source].stride)); } } else if (section == "vertices") { - MeshData::Vertices vert; String id = parser.get_attribute_value("id"); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -1054,7 +929,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name meshdata.vertices[id] = vert; } else if (section == "triangles" || section == "polylist" || section == "polygons") { - bool polygons = (section == "polygons"); if (polygons) { WARN_PRINT("Primitive type \"polygons\" is not well supported (concave shapes may fail). To ensure that the geometry is properly imported, please re-export using \"triangles\" or \"polylist\"."); @@ -1068,11 +942,8 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name int last_ref = 0; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -1098,7 +969,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name Vector<float> values = _read_float_array(parser); if (polygons) { - ERR_CONTINUE(prim.vertex_size == 0); prim.polygons.push_back(values.size() / prim.vertex_size); int from = prim.indices.size(); @@ -1125,7 +995,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name meshdata.primitives.push_back(prim); } else if (parser.get_node_name() == "double_sided") { - parser.read(); meshdata.found_double_sided = true; meshdata.double_sided = parser.get_node_data().to_int(); @@ -1133,7 +1002,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } else if (parser.get_node_name() == "polygons") { ERR_PRINT("Primitive type \"polygons\" not supported, re-export using \"polylist\" or \"triangles\"."); } else if (!parser.is_empty()) { - parser.skip_section(); } } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "mesh") @@ -1142,7 +1010,6 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { - state.skin_controller_data_map[p_id] = SkinControllerData(); SkinControllerData &skindata = state.skin_controller_data_map[p_id]; @@ -1151,13 +1018,10 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { String current_source; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "bind_shape_matrix") { - skindata.bind_shape = _read_transform(parser); #ifdef COLLADA_IMPORT_SCALE_SCENE skindata.bind_shape.origin *= state.unit_scale; @@ -1166,7 +1030,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { COLLADA_PRINT("skeleton bind shape transform: " + skindata.bind_shape); } else if (section == "source") { - String id = parser.get_attribute_value("id"); skindata.sources[id] = SkinControllerData::Source(); current_source = id; @@ -1175,7 +1038,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } else if (section == "float_array" || section == "array") { // create a new array and read it. if (skindata.sources.has(current_source)) { - skindata.sources[current_source].array = _read_float_array(parser); COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values."); } @@ -1185,7 +1047,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { if (section == "IDREF_array") skindata.use_idrefs = true; if (skindata.sources.has(current_source)) { - skindata.sources[current_source].sarray = _read_string_array(parser); if (section == "IDREF_array") { Vector<String> sa = skindata.sources[current_source].sarray; @@ -1199,7 +1060,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } else if (section == "accessor") { // child of source (below a technique tag) if (skindata.sources.has(current_source)) { - int stride = 1; if (parser.has_attribute("stride")) stride = parser.get_attribute_value("stride").to_int(); @@ -1209,15 +1069,11 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } } else if (section == "joints") { - SkinControllerData::Joints joint; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -1232,17 +1088,13 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { skindata.joints = joint; } else if (section == "vertex_weights") { - SkinControllerData::Weights weights; weights.count = parser.get_attribute_value("count").to_int(); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -1300,7 +1152,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { ERR_FAIL_COND(joint_source.sarray.size() != ibm_source.array.size() / 16); for (int i = 0; i < joint_source.sarray.size(); i++) { - String name = joint_source.sarray[i]; Transform xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices xform.affine_invert(); // inverse for rest, because it's an inverse @@ -1312,7 +1163,6 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { - state.morph_controller_data_map[p_id] = MorphControllerData(); MorphControllerData &morphdata = state.morph_controller_data_map[p_id]; @@ -1321,13 +1171,10 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { String current_source; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "source") { - String id = parser.get_attribute_value("id"); morphdata.sources[id] = MorphControllerData::Source(); current_source = id; @@ -1336,7 +1183,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } else if (section == "float_array" || section == "array") { // create a new array and read it. if (morphdata.sources.has(current_source)) { - morphdata.sources[current_source].array = _read_float_array(parser); COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values."); } @@ -1348,7 +1194,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { morphdata.use_idrefs=true; */ if (morphdata.sources.has(current_source)) { - morphdata.sources[current_source].sarray = _read_string_array(parser); /* if (section=="IDREF_array") { @@ -1363,7 +1208,6 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } else if (section == "accessor") { // child of source (below a technique tag) if (morphdata.sources.has(current_source)) { - int stride = 1; if (parser.has_attribute("stride")) stride = parser.get_attribute_value("stride").to_int(); @@ -1373,13 +1217,9 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } else if (section == "targets") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_attribute_value("semantic"); String source = _uri_to_id(parser.get_attribute_value("source")); @@ -1401,13 +1241,11 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } if (morphdata.targets.has("MORPH_WEIGHT")) { - state.morph_name_map[morphdata.targets["MORPH_WEIGHT"]] = p_id; } } void Collada::_parse_controller(XMLParser &parser) { - String id = parser.get_attribute_value("id"); if (parser.is_empty()) { @@ -1415,9 +1253,7 @@ void Collada::_parse_controller(XMLParser &parser) { } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "skin") { @@ -1431,7 +1267,6 @@ void Collada::_parse_controller(XMLParser &parser) { } Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { - String type = parser.get_node_name(); NodeGeometry *geom = memnew(NodeGeometry); geom->controller = type == "instance_controller"; @@ -1441,11 +1276,8 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { return geom; // try to find also many materials and skeletons! while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "instance_material") { - String symbol = parser.get_attribute_value("symbol"); String target = _uri_to_id(parser.get_attribute_value("target")); @@ -1454,7 +1286,6 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { geom->material_map[symbol] = mat; COLLADA_PRINT("uses material: '" + target + "' on primitive'" + symbol + "'"); } else if (parser.get_node_name() == "skeleton") { - parser.read(); String uri = _uri_to_id(parser.get_node_data()); if (uri != "") { @@ -1467,7 +1298,6 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { } if (geom->controller) { - if (geom->skeletons.empty()) { //XSI style @@ -1487,7 +1317,6 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { } Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) { - NodeCamera *cam = memnew(NodeCamera); cam->camera = _uri_to_id(parser.get_attribute_value_safe("url")); @@ -1498,7 +1327,6 @@ Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) { return cam; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_camera") break; } @@ -1507,7 +1335,6 @@ Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) { } Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) { - NodeLight *cam = memnew(NodeLight); cam->light = _uri_to_id(parser.get_attribute_value_safe("url")); @@ -1518,7 +1345,6 @@ Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) { return cam; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_light") break; } @@ -1527,13 +1353,11 @@ Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) { } Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { - String instance_type = parser.get_node_name(); if (instance_type == "instance_geometry" || instance_type == "instance_controller") { return _parse_visual_instance_geometry(parser); } else if (instance_type == "instance_camera") { - return _parse_visual_instance_camera(parser); } else if (instance_type == "instance_light") { return _parse_visual_instance_light(parser); @@ -1543,7 +1367,6 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { return nullptr; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == instance_type) break; } @@ -1552,7 +1375,6 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { } Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { - String name; String id = parser.get_attribute_value_safe("id"); @@ -1560,7 +1382,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { bool found_name = false; if (id == "") { - id = "%NODEID%" + itos(Math::rand()); } else { @@ -1576,7 +1397,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { name = parser.has_attribute("name") ? parser.get_attribute_value_safe("name") : parser.get_attribute_value_safe("id"); if (name == "") { - name = id; } else { found_name = true; @@ -1604,9 +1424,7 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "translate") { @@ -1678,13 +1496,10 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } else if (section == "empty_draw_type") { empty_draw_type = _read_empty_draw_type(parser); } else if (section == "technique" || section == "extra") { - } else if (section != "node") { //usually what defines the type of node if (section.begins_with("instance_")) { - if (!node) { - node = _parse_visual_node_instance_data(parser); } else { @@ -1693,7 +1508,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } } else { - /* Found a child node!! what to do..*/ Node *child = _parse_visual_scene_node(parser); @@ -1705,7 +1519,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } if (!node) { - node = memnew(Node); //generic node, nothing of relevance found } @@ -1734,7 +1547,6 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } void Collada::_parse_visual_scene(XMLParser &parser) { - String id = parser.get_attribute_value("id"); if (parser.is_empty()) { @@ -1748,9 +1560,7 @@ void Collada::_parse_visual_scene(XMLParser &parser) { vscene.name = parser.get_attribute_value("name"); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); if (section == "node") { @@ -1765,7 +1575,6 @@ void Collada::_parse_visual_scene(XMLParser &parser) { } void Collada::_parse_animation(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) { if (!parser.is_empty()) parser.skip_section(); @@ -1790,38 +1599,30 @@ void Collada::_parse_animation(XMLParser &parser) { Vector<String> channel_targets; while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "source") { - current_source = parser.get_attribute_value("id"); source_param_names[current_source] = Vector<String>(); source_param_types[current_source] = Vector<String>(); } else if (name == "float_array") { - if (current_source != "") { float_sources[current_source] = _read_float_array(parser); } } else if (name == "Name_array") { - if (current_source != "") { string_sources[current_source] = _read_string_array(parser); } } else if (name == "accessor") { - if (current_source != "" && parser.has_attribute("stride")) { source_strides[current_source] = parser.get_attribute_value("stride").to_int(); } } else if (name == "sampler") { - current_sampler = parser.get_attribute_value("id"); samplers[current_sampler] = Map<String, String>(); } else if (name == "param") { - if (parser.has_attribute("name")) source_param_names[current_source].push_back(parser.get_attribute_value("name")); else @@ -1833,14 +1634,11 @@ void Collada::_parse_animation(XMLParser &parser) { source_param_types[current_source].push_back(""); } else if (name == "input") { - if (current_sampler != "") { - samplers[current_sampler][parser.get_attribute_value("semantic")] = parser.get_attribute_value("source"); } } else if (name == "channel") { - channel_sources.push_back(parser.get_attribute_value("source")); channel_targets.push_back(parser.get_attribute_value("target")); } @@ -1850,7 +1648,6 @@ void Collada::_parse_animation(XMLParser &parser) { } for (int i = 0; i < channel_sources.size(); i++) { - String source = _uri_to_id(channel_sources[i]); String target = channel_targets[i]; ERR_CONTINUE(!samplers.has(source)); @@ -1870,7 +1667,6 @@ void Collada::_parse_animation(XMLParser &parser) { Vector<String> &names = source_param_names[output_id]; for (int l = 0; l < names.size(); l++) { - String name = names[l]; Vector<float> &time_keys = float_sources[input_id]; @@ -1908,7 +1704,6 @@ void Collada::_parse_animation(XMLParser &parser) { } if (sampler.has("INTERPOLATION")) { - String interp_id = _uri_to_id(sampler["INTERPOLATION"]); ERR_CONTINUE(!string_sources.has(interp_id)); Vector<String> &interps = string_sources[interp_id]; @@ -1976,7 +1771,6 @@ void Collada::_parse_animation(XMLParser &parser) { } void Collada::_parse_animation_clip(XMLParser &parser) { - if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) { if (!parser.is_empty()) parser.skip_section(); @@ -1996,12 +1790,9 @@ void Collada::_parse_animation_clip(XMLParser &parser) { clip.end = parser.get_attribute_value("end").to_double(); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "instance_animation") { - String url = _uri_to_id(parser.get_attribute_value("url")); clip.tracks.push_back(url); } @@ -2014,22 +1805,17 @@ void Collada::_parse_animation_clip(XMLParser &parser) { } void Collada::_parse_scene(XMLParser &parser) { - if (parser.is_empty()) { return; } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); if (name == "instance_visual_scene") { - state.root_visual_scene = _uri_to_id(parser.get_attribute_value("url")); } else if (name == "instance_physics_scene") { - state.root_physics_scene = _uri_to_id(parser.get_attribute_value("url")); } @@ -2039,40 +1825,29 @@ void Collada::_parse_scene(XMLParser &parser) { } void Collada::_parse_library(XMLParser &parser) { - if (parser.is_empty()) { return; } while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); COLLADA_PRINT("library name is: " + name); if (name == "image") { - _parse_image(parser); } else if (name == "material") { - _parse_material(parser); } else if (name == "effect") { - _parse_effect(parser); } else if (name == "camera") { - _parse_camera(parser); } else if (name == "light") { - _parse_light(parser); } else if (name == "geometry") { - String id = parser.get_attribute_value("id"); String name2 = parser.get_attribute_value_safe("name"); while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "mesh") { state.mesh_name_map[id] = (name2 != "") ? name2 : id; _parse_mesh_geometry(parser, id, name2); @@ -2086,16 +1861,12 @@ void Collada::_parse_library(XMLParser &parser) { } } else if (name == "controller") { - _parse_controller(parser); } else if (name == "animation") { - _parse_animation(parser); } else if (name == "animation_clip") { - _parse_animation_clip(parser); } else if (name == "visual_scene") { - COLLADA_PRINT("visual scene"); _parse_visual_scene(parser); } else if (!parser.is_empty()) @@ -2107,27 +1878,21 @@ void Collada::_parse_library(XMLParser &parser) { } void Collada::_joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner) { - if (p_node->type == Node::TYPE_JOINT) { - NodeJoint *nj = static_cast<NodeJoint *>(p_node); nj->owner = p_owner; for (int i = 0; i < nj->children.size(); i++) { - _joint_set_owner(nj->children.write[i], p_owner); } } } void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton) { - Node *node = *p_node; if (node->type == Node::TYPE_JOINT) { - if (!p_skeleton) { - // ohohohoohoo it's a joint node, time to work! NodeSkeleton *sk = memnew(NodeSkeleton); *p_node = sk; @@ -2149,9 +1914,7 @@ void Collada::_create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton } bool Collada::_remove_node(Node *p_parent, Node *p_node) { - for (int i = 0; i < p_parent->children.size(); i++) { - if (p_parent->children[i] == p_node) { p_parent->children.remove(i); return true; @@ -2164,10 +1927,8 @@ bool Collada::_remove_node(Node *p_parent, Node *p_node) { } void Collada::_remove_node(VisualScene *p_vscene, Node *p_node) { - for (int i = 0; i < p_vscene->root_nodes.size(); i++) { if (p_vscene->root_nodes[i] == p_node) { - p_vscene->root_nodes.remove(i); return; } @@ -2179,17 +1940,13 @@ void Collada::_remove_node(VisualScene *p_vscene, Node *p_node) { } void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { - if (p_node->type == Node::TYPE_GEOMETRY) { - NodeGeometry *gnode = static_cast<NodeGeometry *>(p_node); if (gnode->controller) { - // recount skeletons used Set<NodeSkeleton *> skeletons; for (int i = 0; i < gnode->skeletons.size(); i++) { - String nodeid = gnode->skeletons[i]; ERR_CONTINUE(!state.scene_map.has(nodeid)); //weird, it should have it... @@ -2206,17 +1963,14 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { } if (skeletons.size() > 1) { - //do the merger!! Set<NodeSkeleton *>::Element *E = skeletons.front(); NodeSkeleton *base = E->get(); for (E = E->next(); E; E = E->next()) { - NodeSkeleton *merged = E->get(); _remove_node(p_vscene, merged); for (int i = 0; i < merged->children.size(); i++) { - _joint_set_owner(merged->children[i], base); base->children.push_back(merged->children[i]); merged->children[i]->parent = base; @@ -2235,15 +1989,12 @@ void Collada::_merge_skeletons(VisualScene *p_vscene, Node *p_node) { } void Collada::_merge_skeletons2(VisualScene *p_vscene) { - for (Map<String, SkinControllerData>::Element *E = state.skin_controller_data_map.front(); E; E = E->next()) { - SkinControllerData &cd = E->get(); NodeSkeleton *skeleton = nullptr; for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { - String name; if (!state.sid_to_node_map.has(F->key())) { @@ -2260,7 +2011,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { NodeSkeleton *sk = nullptr; while (node && !sk) { - if (node->type == Node::TYPE_SKELETON) { sk = static_cast<NodeSkeleton *>(node); } @@ -2278,7 +2028,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { //whoa.. wtf, merge. _remove_node(p_vscene, sk); for (int i = 0; i < sk->children.size(); i++) { - _joint_set_owner(sk->children[i], skeleton); skeleton->children.push_back(sk->children[i]); sk->children[i]->parent = skeleton; @@ -2292,7 +2041,6 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { } bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { - Node *node = p_node; if (node->type == Node::TYPE_SKELETON && node->parent && node->parent->type == Node::TYPE_NODE && node->parent->children.size() == 1) { @@ -2312,7 +2060,6 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { Node *gp = parent->parent; bool found = false; for (int i = 0; i < gp->children.size(); i++) { - if (gp->children[i] == parent) { gp->children.write[i] = node; found = true; @@ -2323,13 +2070,10 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { ERR_PRINT("BUG"); } } else { - bool found = false; for (int i = 0; i < p_vscene->root_nodes.size(); i++) { - if (p_vscene->root_nodes[i] == parent) { - p_vscene->root_nodes.write[i] = node; found = true; break; @@ -2346,7 +2090,6 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { } for (int i = 0; i < node->children.size(); i++) { - if (_optimize_skeletons(p_vscene, node->children[i])) return false; //stop processing, go up } @@ -2355,18 +2098,15 @@ bool Collada::_optimize_skeletons(VisualScene *p_vscene, Node *p_node) { } bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, List<Node *> *p_mgeom) { - // Bind Shape Matrix scales the bones and makes them gigantic, so the matrix then shrinks the model? // Solution: apply the Bind Shape Matrix to the VERTICES, and if the object comes scaled, it seems to be left alone! if (p_node->type == Node::TYPE_GEOMETRY) { - NodeGeometry *ng = static_cast<NodeGeometry *>(p_node); if (ng->ignore_anim) return false; //already made child of skeleton and processeg if (ng->controller && ng->skeletons.size()) { - String nodeid = ng->skeletons[0]; ERR_FAIL_COND_V(!state.scene_map.has(nodeid), false); //weird, it should have it... @@ -2401,7 +2141,6 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L //make rests relative to the skeleton (they seem to be always relative to world) for (Map<String, Transform>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) { - E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative } @@ -2419,7 +2158,6 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L } for (int i = 0; i < p_node->children.size(); i++) { - if (_move_geometry_to_skeletons(p_vscene, p_node->children[i], p_mgeom)) { p_node->children.remove(i); i--; @@ -2430,23 +2168,17 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L } void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) { - if (p_node->type == Node::TYPE_GEOMETRY) { - NodeGeometry *nj = static_cast<NodeGeometry *>(p_node); if (nj->controller) { - String base = nj->source; while (base != "" && !state.mesh_data_map.has(base)) { - if (state.skin_controller_data_map.has(base)) { - SkinControllerData &sk = state.skin_controller_data_map[base]; base = sk.base; } else if (state.morph_controller_data_map.has(base)) { - state.morph_ownership_map[base] = nj->id; break; } else { @@ -2457,15 +2189,12 @@ void Collada::_find_morph_nodes(VisualScene *p_vscene, Node *p_node) { } for (int i = 0; i < p_node->children.size(); i++) { - _find_morph_nodes(p_vscene, p_node->children[i]); } } void Collada::_optimize() { - for (Map<String, VisualScene>::Element *E = state.visual_scene_map.front(); E; E = E->next()) { - VisualScene &vs = E->get(); for (int i = 0; i < vs.root_nodes.size(); i++) { _create_skeletons(&vs.root_nodes.write[i]); @@ -2482,7 +2211,6 @@ void Collada::_optimize() { } for (int i = 0; i < vs.root_nodes.size(); i++) { - List<Node *> mgeom; if (_move_geometry_to_skeletons(&vs, vs.root_nodes[i], &mgeom)) { vs.root_nodes.remove(i); @@ -2490,7 +2218,6 @@ void Collada::_optimize() { } while (!mgeom.empty()) { - Node *n = mgeom.front()->get(); n->parent->children.push_back(n); mgeom.pop_front(); @@ -2504,9 +2231,7 @@ void Collada::_optimize() { } int Collada::get_uv_channel(String p_name) { - if (!channel_map.has(p_name)) { - ERR_FAIL_COND_V(channel_map.size() == 2, 0); channel_map[p_name] = channel_map.size(); @@ -2516,7 +2241,6 @@ int Collada::get_uv_channel(String p_name) { } Error Collada::load(const String &p_path, int p_flags) { - Ref<XMLParser> parserr = memnew(XMLParser); XMLParser &parser = *parserr.ptr(); Error err = parser.open(p_path); @@ -2526,9 +2250,7 @@ Error Collada::load(const String &p_path, int p_flags) { state.import_flags = p_flags; /* Skip headers */ while ((err = parser.read()) == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "COLLADA") { break; } else if (!parser.is_empty()) @@ -2550,7 +2272,6 @@ Error Collada::load(const String &p_path, int p_flags) { } while ((err = parser.read()) == OK) { - /* Read all the main sections.. */ if (parser.get_node_type() != XMLParser::NODE_ELEMENT) @@ -2564,10 +2285,8 @@ Error Collada::load(const String &p_path, int p_flags) { _parse_asset(parser); } else if (section.begins_with("library_")) { - _parse_library(parser); } else if (section == "scene") { - _parse_scene(parser); } else if (!parser.is_empty()) { parser.skip_section(); // unknown section, likely headers diff --git a/editor/import/collada.h b/editor/import/collada.h index 187a8092da..02c3277911 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -44,23 +44,19 @@ public: }; struct Image { - String path; }; struct Material { - String name; String instance_effect; }; struct Effect { - String name; Map<String, Variant> params; struct Channel { - int uv_idx = 0; String texture; Color color; @@ -81,7 +77,6 @@ public: }; struct CameraData { - enum Mode { MODE_PERSPECTIVE, MODE_ORTHOGONAL @@ -108,7 +103,6 @@ public: }; struct LightData { - enum Mode { MODE_AMBIENT, MODE_DIRECTIONAL, @@ -131,10 +125,8 @@ public: }; struct MeshData { - String name; struct Source { - Vector<float> array; int stride; }; @@ -142,16 +134,13 @@ public: Map<String, Source> sources; struct Vertices { - Map<String, String> sources; }; Map<String, Vertices> vertices; struct Primitives { - struct SourceRef { - String source; int offset; }; @@ -173,12 +162,10 @@ public: }; struct CurveData { - String name; bool closed = false; struct Source { - Vector<String> sarray; Vector<float> array; int stride; @@ -192,14 +179,12 @@ public: }; struct SkinControllerData { - String base; bool use_idrefs = false; Transform bind_shape; struct Source { - Vector<String> sarray; //maybe for names Vector<float> array; int stride = 1; @@ -209,14 +194,11 @@ public: Map<String, Source> sources; struct Joints { - Map<String, String> sources; } joints; struct Weights { - struct SourceRef { - String source; int offset; }; @@ -234,12 +216,10 @@ public: }; struct MorphControllerData { - String mesh; String mode; struct Source { - int stride = 1; Vector<String> sarray; //maybe for names Vector<float> array; @@ -253,7 +233,6 @@ public: }; struct Vertex { - int idx = 0; Vector3 vertex; Vector3 normal; @@ -271,7 +250,6 @@ public: Vector<Weight> weights; void fix_weights() { - weights.sort(); if (weights.size() > 4) { //cap to 4 and make weights add up 1 @@ -288,17 +266,13 @@ public: void fix_unit_scale(Collada &state); bool operator<(const Vertex &p_vert) const { - if (uid == p_vert.uid) { if (vertex == p_vert.vertex) { if (normal == p_vert.normal) { if (uv == p_vert.uv) { if (uv2 == p_vert.uv2) { - if (!weights.empty() || !p_vert.weights.empty()) { - if (weights.size() == p_vert.weights.size()) { - for (int i = 0; i < weights.size(); i++) { if (weights[i].bone_idx != p_vert.weights[i].bone_idx) return weights[i].bone_idx < p_vert.weights[i].bone_idx; @@ -328,7 +302,6 @@ public: }; struct Node { - enum Type { TYPE_NODE, @@ -340,7 +313,6 @@ public: }; struct XForm { - enum Op { OP_ROTATE, OP_SCALE, @@ -381,12 +353,10 @@ public: }; struct NodeSkeleton : public Node { - NodeSkeleton() { type = TYPE_SKELETON; } }; struct NodeJoint : public Node { - NodeSkeleton *owner = nullptr; String sid; NodeJoint() { @@ -395,7 +365,6 @@ public: }; struct NodeGeometry : public Node { - bool controller; String source; @@ -410,21 +379,18 @@ public: }; struct NodeCamera : public Node { - String camera; NodeCamera() { type = TYPE_CAMERA; } }; struct NodeLight : public Node { - String light; NodeLight() { type = TYPE_LIGHT; } }; struct VisualScene { - String name; Vector<Node *> root_nodes; @@ -435,7 +401,6 @@ public: }; struct AnimationClip { - String name; float begin = 0; float end = 1; @@ -445,7 +410,6 @@ public: }; struct AnimationTrack { - String id; String target; String param; @@ -458,7 +422,6 @@ public: }; struct Key { - enum Type { TYPE_FLOAT, TYPE_MATRIX @@ -485,7 +448,6 @@ public: /****************/ struct State { - int import_flags = 0; float unit_scale = 1.0; @@ -493,7 +455,6 @@ public: bool z_up; struct Version { - int major, minor, rev; bool operator<(const Version &p_ver) const { return (major == p_ver.major) ? ((minor == p_ver.minor) ? (rev < p_ver.rev) : minor < p_ver.minor) : major < p_ver.major; } diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 697ddfba96..0f3faf4189 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -45,7 +45,6 @@ #include "scene/resources/surface_tool.h" struct ColladaImport { - Collada collada; Node3D *scene; @@ -101,7 +100,6 @@ struct ColladaImport { void _pre_process_lights(Collada::Node *p_node); ColladaImport() { - found_ambient = false; found_directional = false; force_make_tangents = false; @@ -111,7 +109,6 @@ struct ColladaImport { }; 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; @@ -130,7 +127,6 @@ Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p skeleton_bone_map[p_skeleton][joint->sid] = r_bone; if (collada.state.bone_rest_map.has(joint->sid)) { - p_skeleton->set_bone_rest(r_bone, collada.fix_transform(collada.state.bone_rest_map[joint->sid])); //should map this bone to something for animation? } else { @@ -139,7 +135,6 @@ Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p int id = r_bone++; for (int i = 0; i < p_node->children.size(); i++) { - Error err = _populate_skeleton(p_skeleton, p_node->children[i], r_bone, id); if (err) return err; @@ -149,12 +144,9 @@ Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p } void ColladaImport::_pre_process_lights(Collada::Node *p_node) { - if (p_node->type == Collada::Node::TYPE_LIGHT) { - Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node); if (collada.state.light_data_map.has(light->light)) { - Collada::LightData &ld = collada.state.light_data_map[light->light]; if (ld.mode == Collada::LightData::MODE_AMBIENT) { found_ambient = true; @@ -171,13 +163,10 @@ void ColladaImport::_pre_process_lights(Collada::Node *p_node) { } Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { - if (p_node->type == Collada::Node::TYPE_SKELETON) { - Skeleton3D *sk = memnew(Skeleton3D); int bone = 0; for (int i = 0; i < p_node->children.size(); i++) { - _populate_skeleton(sk, p_node->children[i], bone, -1); } sk->localize_rests(); //after creating skeleton, rests must be localized...! @@ -185,7 +174,6 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { } for (int i = 0; i < p_node->children.size(); i++) { - Error err = _create_scene_skeletons(p_node->children[i]); if (err) return err; @@ -194,29 +182,22 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { } Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { - Node3D *node = nullptr; switch (p_node->type) { - case Collada::Node::TYPE_NODE: { - node = memnew(Node3D); } break; case Collada::Node::TYPE_JOINT: { - return OK; // do nothing } break; case Collada::Node::TYPE_LIGHT: { - //node = memnew( Light) Collada::NodeLight *light = static_cast<Collada::NodeLight *>(p_node); if (collada.state.light_data_map.has(light->light)) { - Collada::LightData &ld = collada.state.light_data_map[light->light]; if (ld.mode == Collada::LightData::MODE_AMBIENT) { - if (found_directional) return OK; //do nothing not needed @@ -230,7 +211,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { node = l; } else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) { - //well, it's an ambient light.. Light3D *l = memnew(DirectionalLight3D); /* @@ -242,7 +222,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { */ node = l; } else { - Light3D *l; if (ld.mode == Collada::LightData::MODE_OMNI) @@ -261,43 +240,33 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } } else { - node = memnew(Node3D); } } break; case Collada::Node::TYPE_CAMERA: { - Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node); Camera3D *camera = memnew(Camera3D); if (collada.state.camera_data_map.has(cam->camera)) { - const Collada::CameraData &cd = collada.state.camera_data_map[cam->camera]; switch (cd.mode) { - case Collada::CameraData::MODE_ORTHOGONAL: { - if (cd.orthogonal.y_mag) { - 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(Camera3D::KEEP_WIDTH); camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far); } } break; case Collada::CameraData::MODE_PERSPECTIVE: { - if (cd.perspective.y_fov) { - camera->set_perspective(cd.perspective.y_fov, cd.z_near, cd.z_far); } else if (!cd.perspective.y_fov && cd.perspective.x_fov) { - camera->set_perspective(cd.perspective.x_fov / cd.aspect, cd.z_near, cd.z_far); } @@ -309,11 +278,9 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } break; case Collada::Node::TYPE_GEOMETRY: { - Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); if (collada.state.curve_data_map.has(ng->source)) { - node = memnew(Path3D); } else { //mesh since nothing else @@ -322,7 +289,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } } break; case Collada::Node::TYPE_SKELETON: { - ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE); Skeleton3D *sk = skeleton_map[p_node]; node = sk; @@ -347,7 +313,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } for (int i = 0; i < p_node->children.size(); i++) { - Error err = _create_scene(p_node->children[i], node); if (err) return err; @@ -356,7 +321,6 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { } Error ColladaImport::_create_material(const String &p_target) { - ERR_FAIL_COND_V(material_cache.has(p_target), ERR_ALREADY_EXISTS); ERR_FAIL_COND_V(!collada.state.material_map.has(p_target), ERR_INVALID_PARAMETER); Collada::Material &src_mat = collada.state.material_map[p_target]; @@ -373,16 +337,13 @@ Error ColladaImport::_create_material(const String &p_target) { // DIFFUSE if (effect.diffuse.texture != "") { - String texfile = effect.get_texture_path(effect.diffuse.texture, collada); if (texfile != "") { - if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture); material->set_albedo(Color(1, 1, 1, 1)); //material->set_parameter(StandardMaterial3D::PARAM_DIFFUSE,Color(1,1,1,1)); @@ -397,10 +358,8 @@ Error ColladaImport::_create_material(const String &p_target) { // SPECULAR if (effect.specular.texture != "") { - String texfile = effect.get_texture_path(effect.specular.texture, collada); if (texfile != "") { - if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -424,17 +383,14 @@ Error ColladaImport::_create_material(const String &p_target) { // EMISSION if (effect.emission.texture != "") { - String texfile = effect.get_texture_path(effect.emission.texture, collada); if (texfile != "") { - if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, texture); material->set_emission(Color(1, 1, 1, 1)); @@ -454,10 +410,8 @@ Error ColladaImport::_create_material(const String &p_target) { // NORMAL if (effect.bump.texture != "") { - String texfile = effect.get_texture_path(effect.bump.texture, collada); if (texfile != "") { - if (texfile.begins_with("/")) { texfile = texfile.replace_first("/", "res://"); } @@ -490,18 +444,15 @@ Error ColladaImport::_create_material(const String &p_target) { } 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; if (p_morph_data) { - //add morphie target ERR_FAIL_COND_V(!p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA); String mt = p_morph_data->targets["MORPH_TARGET"]; ERR_FAIL_COND_V(!p_morph_data->sources.has(mt), ERR_INVALID_DATA); int morph_targets = p_morph_data->sources[mt].sarray.size(); for (int i = 0; i < morph_targets; i++) { - String target = p_morph_data->sources[mt].sarray[i]; ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(target), ERR_INVALID_DATA); String name = collada.state.mesh_data_map[target].name; @@ -516,7 +467,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int surface = 0; for (int p_i = 0; p_i < meshdata.primitives.size(); p_i++) { - const Collada::MeshData::Primitives &p = meshdata.primitives[p_i]; /* VERTEX SOURCE */ @@ -540,7 +490,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int normal_ofs = 0; if (p.sources.has("NORMAL")) { - String normal_source_id = p.sources["NORMAL"].source; normal_ofs = p.sources["NORMAL"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(normal_source_id), ERR_INVALID_DATA); @@ -551,7 +500,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int binormal_ofs = 0; if (p.sources.has("TEXBINORMAL")) { - String binormal_source_id = p.sources["TEXBINORMAL"].source; binormal_ofs = p.sources["TEXBINORMAL"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(binormal_source_id), ERR_INVALID_DATA); @@ -562,7 +510,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int tangent_ofs = 0; if (p.sources.has("TEXTANGENT")) { - String tangent_source_id = p.sources["TEXTANGENT"].source; tangent_ofs = p.sources["TEXTANGENT"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(tangent_source_id), ERR_INVALID_DATA); @@ -573,7 +520,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int uv_ofs = 0; if (p.sources.has("TEXCOORD0")) { - String uv_source_id = p.sources["TEXCOORD0"].source; uv_ofs = p.sources["TEXCOORD0"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(uv_source_id), ERR_INVALID_DATA); @@ -584,7 +530,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int uv2_ofs = 0; if (p.sources.has("TEXCOORD1")) { - String uv2_source_id = p.sources["TEXCOORD1"].source; uv2_ofs = p.sources["TEXCOORD1"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(uv2_source_id), ERR_INVALID_DATA); @@ -595,7 +540,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int color_ofs = 0; if (p.sources.has("COLOR")) { - String color_source_id = p.sources["COLOR"].source; color_ofs = p.sources["COLOR"].offset; ERR_FAIL_COND_V(!meshdata.sources.has(color_source_id), ERR_INVALID_DATA); @@ -613,16 +557,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me bool has_weights = false; if (p_skin_controller) { - const Collada::SkinControllerData::Source *weight_src = nullptr; int weight_ofs = 0; if (p_skin_controller->weights.sources.has("WEIGHT")) { - String weight_id = p_skin_controller->weights.sources["WEIGHT"].source; weight_ofs = p_skin_controller->weights.sources["WEIGHT"].offset; if (p_skin_controller->sources.has(weight_id)) { - weight_src = &p_skin_controller->sources[weight_id]; } } @@ -630,7 +571,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int joint_ofs = 0; if (p_skin_controller->weights.sources.has("JOINT")) { - joint_ofs = p_skin_controller->weights.sources["JOINT"].offset; } @@ -639,13 +579,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int index_ofs = 0; int wstride = p_skin_controller->weights.sources.size(); for (int w_i = 0; w_i < p_skin_controller->weights.sets.size(); w_i++) { - int amount = p_skin_controller->weights.sets[w_i]; Vector<Collada::Vertex::Weight> weights; for (int a_i = 0; a_i < amount; a_i++) { - Collada::Vertex::Weight w; int read_from = index_ofs + a_i * wstride; @@ -715,10 +653,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int _prim_ofs = 0; int vertidx = 0; for (int p_j = 0; p_j < p.count; p_j++) { - int amount; if (p.polygons.size()) { - ERR_FAIL_INDEX_V(p_j, p.polygons.size(), ERR_INVALID_DATA); amount = p.polygons[p_j]; } else { @@ -730,7 +666,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me int prev2[2] = { 0, 0 }; for (int j = 0; j < amount; j++) { - int src = _prim_ofs; //_prim_ofs+=p.sources.size() @@ -750,13 +685,11 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me } if (normal_src) { - int normal_pos = (normal_src->stride ? normal_src->stride : 3) * p.indices[src + normal_ofs]; ERR_FAIL_INDEX_V(normal_pos, normal_src->array.size(), ERR_INVALID_DATA); vertex.normal = Vector3(normal_src->array[normal_pos + 0], normal_src->array[normal_pos + 1], normal_src->array[normal_pos + 2]); if (tangent_src && binormal_src) { - int binormal_pos = (binormal_src->stride ? binormal_src->stride : 3) * p.indices[src + binormal_ofs]; ERR_FAIL_INDEX_V(binormal_pos, binormal_src->array.size(), ERR_INVALID_DATA); Vector3 binormal = Vector3(binormal_src->array[binormal_pos + 0], binormal_src->array[binormal_pos + 1], binormal_src->array[binormal_pos + 2]); @@ -771,21 +704,18 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me } if (uv_src) { - int uv_pos = (uv_src->stride ? uv_src->stride : 2) * p.indices[src + uv_ofs]; ERR_FAIL_INDEX_V(uv_pos, uv_src->array.size(), ERR_INVALID_DATA); vertex.uv = Vector3(uv_src->array[uv_pos + 0], 1.0 - uv_src->array[uv_pos + 1], 0); } if (uv2_src) { - int uv2_pos = (uv2_src->stride ? uv2_src->stride : 2) * p.indices[src + uv2_ofs]; ERR_FAIL_INDEX_V(uv2_pos, uv2_src->array.size(), ERR_INVALID_DATA); vertex.uv2 = Vector3(uv2_src->array[uv2_pos + 0], 1.0 - uv2_src->array[uv2_pos + 1], 0); } if (color_src) { - int color_pos = (color_src->stride ? color_src->stride : 3) * p.indices[src + color_ofs]; // colors are RGB in collada.. ERR_FAIL_INDEX_V(color_pos, color_src->array.size(), ERR_INVALID_DATA); vertex.color = Color(color_src->array[color_pos + 0], color_src->array[color_pos + 1], color_src->array[color_pos + 2], (color_src->stride > 3) ? color_src->array[color_pos + 3] : 1.0); @@ -793,7 +723,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me #ifndef NO_UP_AXIS_SWAP if (collada.state.up_axis == Vector3::AXIS_Z) { - Vector3 bn = vertex.normal.cross(vertex.tangent.normal) * vertex.tangent.d; SWAP(vertex.vertex.z, vertex.vertex.y); @@ -815,10 +744,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me //COLLADA_PRINT("vertex: "+vertex.vertex); if (vertex_set.has(vertex)) { - index = vertex_set.find(vertex)->get().idx; } else { - index = vertex_set.size(); vertex.idx = index; vertex_set.insert(vertex); @@ -831,7 +758,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me if (j >= 2) { //insert indices in reverse order (collada uses CCW as frontface) if (local_xform_mirror) { - indices_list.push_back(prev2[0]); indices_list.push_back(prev2[1]); indices_list.push_back(index); @@ -852,16 +778,13 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me vertex_array.resize(vertex_set.size()); for (Set<Collada::Vertex>::Element *F = vertex_set.front(); F; F = F->next()) { - vertex_array.write[F->get().idx] = F->get(); } if (has_weights) { - //if skeleton, localize Transform local_xform = p_local_xform; for (int i = 0; i < vertex_array.size(); i++) { - vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex); vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized(); vertex_array.write[i].tangent.normal = local_xform.basis.xform(vertex_array[i].tangent.normal).normalized(); @@ -878,11 +801,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me /*****************/ { - Ref<StandardMaterial3D> material; { - if (p_material_map.has(p.material)) { String target = p_material_map[p.material].target; @@ -931,7 +852,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me bones.write[l] = vertex_array[k].weights[l].bone_idx; //sum += vertex_array[k].weights[l].weight; } else { - weights.write[l] = 0; bones.write[l] = 0; } @@ -954,7 +874,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me } if ((!binormal_src || !tangent_src) && normal_src && uv_src && force_make_tangents) { - surftool->generate_tangents(); } @@ -972,7 +891,6 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me //////////////////////////// for (int mi = 0; mi < p_morph_meshes.size(); mi++) { - Array a = p_morph_meshes[mi]->surface_get_arrays(surface); //add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not) @@ -1007,21 +925,16 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me } Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compression) { - if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) { - Node3D *node = node_map[p_node->id].node; Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); if (Object::cast_to<Path3D>(node)) { - Path3D *path = Object::cast_to<Path3D>(node); if (curve_cache.has(ng->source)) { - path->set_curve(curve_cache[ng->source]); } else { - Ref<Curve3D> c = memnew(Curve3D); const Collada::CurveData &cd = collada.state.curve_data_map[ng->source]; @@ -1053,14 +966,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres int pc = vertices.array.size() / 3; for (int i = 0; i < pc; i++) { - Vector3 pos(vertices.array[i * 3 + 0], vertices.array[i * 3 + 1], vertices.array[i * 3 + 2]); Vector3 in(in_tangents.array[i * 3 + 0], in_tangents.array[i * 3 + 1], in_tangents.array[i * 3 + 2]); Vector3 out(out_tangents.array[i * 3 + 0], out_tangents.array[i * 3 + 1], out_tangents.array[i * 3 + 2]); #ifndef NO_UP_AXIS_SWAP if (collada.state.up_axis == Vector3::AXIS_Z) { - SWAP(pos.y, pos.z); pos.z = -pos.z; SWAP(in.y, in.z); @@ -1084,7 +995,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } if (Object::cast_to<MeshInstance3D>(node)) { - Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node); MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node); @@ -1099,11 +1009,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres Vector<Ref<ArrayMesh>> morphs; if (ng2->controller) { - String ngsource = ng2->source; if (collada.state.skin_controller_data_map.has(ngsource)) { - ERR_FAIL_COND_V(!collada.state.skin_controller_data_map.has(ngsource), ERR_INVALID_DATA); skin = &collada.state.skin_controller_data_map[ngsource]; @@ -1147,7 +1055,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres bone_remap.resize(joint_src->sarray.size()); for (int i = 0; i < bone_remap.size(); i++) { - String str = joint_src->sarray[i]; ERR_FAIL_COND_V(!bone_remap_map.has(str), ERR_INVALID_DATA); bone_remap.write[i] = bone_remap_map[str]; @@ -1155,7 +1062,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } if (collada.state.morph_controller_data_map.has(ngsource)) { - //it's a morph!! morph = &collada.state.morph_controller_data_map[ngsource]; meshid = morph->mesh; @@ -1167,7 +1073,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres valid = true; Vector<String> names = morph->sources[target].sarray; for (int i = 0; i < names.size(); i++) { - String meshid2 = names[i]; if (collada.state.mesh_data_map.has(meshid2)) { Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); @@ -1211,19 +1116,16 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres mesh_cache[meshid] = mesh; } else { - WARN_PRINT("Collada: Will not import geometry: " + meshid); } } if (!mesh.is_null()) { - mi->set_mesh(mesh); if (!use_mesh_builtin_materials) { const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid]; for (int i = 0; i < meshdata.primitives.size(); i++) { - String matname = meshdata.primitives[i].material; if (ng2->material_map.has(matname)) { @@ -1248,7 +1150,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } for (int i = 0; i < p_node->children.size(); i++) { - Error err = _create_resources(p_node->children[i], p_use_compression); if (err) return err; @@ -1257,7 +1158,6 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents, bool p_use_compression) { - Error err = collada.load(p_path, p_flags); ERR_FAIL_COND_V_MSG(err, err, "Cannot load file '" + p_path + "'."); @@ -1269,13 +1169,11 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t //determine what's going on with the lights for (int i = 0; i < vs.root_nodes.size(); i++) { - _pre_process_lights(vs.root_nodes[i]); } //import scene for (int i = 0; i < vs.root_nodes.size(); i++) { - Error err2 = _create_scene_skeletons(vs.root_nodes[i]); if (err2 != OK) { memdelete(scene); @@ -1284,7 +1182,6 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t } for (int i = 0; i < vs.root_nodes.size(); i++) { - Error err2 = _create_scene(vs.root_nodes[i], scene); if (err2 != OK) { memdelete(scene); @@ -1305,48 +1202,36 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t } void ColladaImport::_fix_param_animation_tracks() { - for (Map<String, Collada::Node *>::Element *E = collada.state.scene_map.front(); E; E = E->next()) { - Collada::Node *n = E->get(); switch (n->type) { - case Collada::Node::TYPE_NODE: { // ? do nothing } break; case Collada::Node::TYPE_JOINT: { - } break; case Collada::Node::TYPE_SKELETON: { - } break; case Collada::Node::TYPE_LIGHT: { - } break; case Collada::Node::TYPE_CAMERA: { - } break; case Collada::Node::TYPE_GEOMETRY: { - Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(n); // test source(s) String source = ng->source; while (source != "") { - if (collada.state.skin_controller_data_map.has(source)) { - const Collada::SkinControllerData &skin = collada.state.skin_controller_data_map[source]; //nothing to animate here i think source = skin.base; } else if (collada.state.morph_controller_data_map.has(source)) { - const Collada::MorphControllerData &morph = collada.state.morph_controller_data_map[source]; if (morph.targets.has("MORPH_WEIGHT") && morph.targets.has("MORPH_TARGET")) { - String weights = morph.targets["MORPH_WEIGHT"]; String targets = morph.targets["MORPH_TARGET"]; //fails here @@ -1358,11 +1243,9 @@ void ColladaImport::_fix_param_animation_tracks() { ERR_FAIL_COND(weight_src.array.size() != target_src.sarray.size()); for (int i = 0; i < weight_src.array.size(); i++) { - String track_name = weights + "(" + itos(i) + ")"; String mesh_name = target_src.sarray[i]; if (collada.state.mesh_name_map.has(mesh_name) && collada.state.referenced_tracks.has(track_name)) { - const Vector<int> &rt = collada.state.referenced_tracks[track_name]; for (int rti = 0; rti < rt.size(); rti++) { @@ -1379,7 +1262,6 @@ void ColladaImport::_fix_param_animation_tracks() { } source = morph.mesh; } else { - source = ""; // for now nothing else supported } } @@ -1390,24 +1272,19 @@ void ColladaImport::_fix_param_animation_tracks() { } void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks) { - _fix_param_animation_tracks(); for (int i = 0; i < collada.state.animation_clips.size(); i++) { - for (int j = 0; j < collada.state.animation_clips[i].tracks.size(); j++) tracks_in_clips.insert(collada.state.animation_clips[i].tracks[j]); } for (int i = 0; i < collada.state.animation_tracks.size(); i++) { - const Collada::AnimationTrack &at = collada.state.animation_tracks[i]; String node; if (!node_map.has(at.target)) { - if (node_name_map.has(at.target)) { - node = node_name_map[at.target]; } else { WARN_PRINT("Collada: Couldn't find node: " + at.target); @@ -1418,11 +1295,9 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im } if (at.property) { - valid_animated_properties.push_back(i); } else { - node_map[node].anim_tracks.push_back(i); valid_animated_nodes.insert(node); } @@ -1434,7 +1309,6 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im } void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks) { - Ref<Animation> animation = Ref<Animation>(memnew(Animation)); if (p_clip == -1) { @@ -1444,7 +1318,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } for (Map<String, NodeMap>::Element *E = node_map.front(); E; E = E->next()) { - if (E->get().bone < 0) continue; bones_with_animation[E->key()] = false; @@ -1458,15 +1331,11 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Set<int> track_filter; if (p_clip == -1) { - for (int i = 0; i < collada.state.animation_clips.size(); i++) { - int tc = collada.state.animation_clips[i].tracks.size(); for (int j = 0; j < tc; j++) { - String n = collada.state.animation_clips[i].tracks[j]; if (collada.state.by_id_tracks.has(n)) { - const Vector<int> &ti = collada.state.by_id_tracks[n]; for (int k = 0; k < ti.size(); k++) { track_filter.insert(ti[k]); @@ -1475,13 +1344,10 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } } } else { - int tc = collada.state.animation_clips[p_clip].tracks.size(); for (int j = 0; j < tc; j++) { - String n = collada.state.animation_clips[p_clip].tracks[j]; if (collada.state.by_id_tracks.has(n)) { - const Vector<int> &ti = collada.state.by_id_tracks[n]; for (int k = 0; k < ti.size(); k++) { track_filter.insert(ti[k]); @@ -1503,7 +1369,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones anim_length = collada.state.animation_clips[p_clip].end; while (f < anim_length) { - base_snapshots.push_back(f); f += snapshot_interval; @@ -1518,11 +1383,9 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones bool tracks_found = false; for (Set<String>::Element *E = valid_animated_nodes.front(); E; E = E->next()) { - // take snapshots if (!collada.state.scene_map.has(E->get())) { - continue; } @@ -1539,7 +1402,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Collada::Node *cn = collada.state.scene_map[E->get()]; if (cn->ignore_anim) { - continue; } @@ -1559,18 +1421,14 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } for (int i = 0; i < snapshots.size(); i++) { - for (List<int>::Element *ET = nm.anim_tracks.front(); ET; ET = ET->next()) { //apply tracks if (p_clip == -1) { - if (track_filter.has(ET->get())) { - continue; } } else { - if (!track_filter.has(ET->get())) continue; } @@ -1581,9 +1439,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones int xform_idx = -1; for (int j = 0; j < cn->xform_list.size(); j++) { - if (cn->xform_list[j].id == at.param) { - xform_idx = j; break; } @@ -1623,10 +1479,8 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones //make bone transform relative to rest (in case of skeleton) Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node); if (sk) { - xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; } else { - ERR_PRINT("Collada: Invalid skeleton"); } } @@ -1652,10 +1506,8 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } if (p_make_tracks_in_all_bones) { - //some bones may lack animation, but since we don't store pose as a property, we must add keyframes! for (Map<String, bool>::Element *E = bones_with_animation.front(); E; E = E->next()) { - if (E->get()) continue; @@ -1695,15 +1547,12 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (p_import_value_tracks) { for (int i = 0; i < valid_animated_properties.size(); i++) { - int ti = valid_animated_properties[i]; if (p_clip == -1) { - if (track_filter.has(ti)) continue; } else { - if (!track_filter.has(ti)) continue; } @@ -1725,7 +1574,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->track_set_imported(track, true); //helps merging later for (int j = 0; j < at.keys.size(); j++) { - float time = at.keys[j].time; Variant value; Vector<float> data = at.keys[j].data; @@ -1748,7 +1596,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } if (tracks_found) { - animations.push_back(animation); } } @@ -1758,15 +1605,12 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones /*********************************************************************************/ uint32_t EditorSceneImporterCollada::get_import_flags() const { - return IMPORT_SCENE | IMPORT_ANIMATION; } void EditorSceneImporterCollada::get_extensions(List<String> *r_extensions) const { - r_extensions->push_back("dae"); } Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - ColladaImport state; uint32_t flags = Collada::IMPORT_FLAG_SCENE; if (p_flags & IMPORT_ANIMATION) @@ -1780,7 +1624,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ ERR_FAIL_COND_V_MSG(err != OK, nullptr, "Cannot load scene from file '" + p_path + "'."); if (state.missing_textures.size()) { - /* for(int i=0;i<state.missing_textures.size();i++) { EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]); @@ -1788,7 +1631,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ */ if (r_missing_deps) { - for (int i = 0; i < state.missing_textures.size(); i++) { //EditorNode::add_io_error("Texture Not Found: "+state.missing_textures[i]); r_missing_deps->push_back(state.missing_textures[i]); @@ -1797,7 +1639,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ } if (p_flags & IMPORT_ANIMATION) { - state.create_animations(p_flags & IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS, p_flags & EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS); AnimationPlayer *ap = memnew(AnimationPlayer); for (int i = 0; i < state.animations.size(); i++) { @@ -1808,7 +1649,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ name = state.animations[i]->get_name(); if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) { - if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { state.animations.write[i]->set_loop(true); } @@ -1824,7 +1664,6 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ } Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { - ColladaImport state; state.use_mesh_builtin_materials = false; @@ -1841,7 +1680,6 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path Ref<Animation> anim = state.animations[0]; String base = p_path.get_basename().to_lower(); if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) { - if (base.begins_with("loop") || base.ends_with("loop") || base.begins_with("cycle") || base.ends_with("cycle")) { anim->set_loop(true); } diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 932a064e76..57c694b698 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -34,7 +34,6 @@ #include "editor/import/resource_importer_scene.h" class EditorSceneImporterCollada : public EditorSceneImporter { - GDCLASS(EditorSceneImporterCollada, EditorSceneImporter); public: diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index aad378c94f..6d46d4d2e9 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -87,7 +87,6 @@ int EditorImportPlugin::get_import_order() const { } void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const { - ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_import_options"))); Array needed; needed.push_back("name"); @@ -131,7 +130,6 @@ bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map } Error EditorImportPlugin::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) { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("import")), ERR_UNAVAILABLE); Dictionary options; Array platform_variants, gen_files; @@ -153,7 +151,6 @@ Error EditorImportPlugin::import(const String &p_source_file, const String &p_sa } void EditorImportPlugin::_bind_methods() { - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_importer_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_visible_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_preset_count")); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 1a1e7171b9..c4bf9189f1 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -44,17 +44,14 @@ #include "scene/resources/surface_tool.h" uint32_t EditorSceneImporterGLTF::get_import_flags() const { - return IMPORT_SCENE | IMPORT_ANIMATION; } void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const { - r_extensions->push_back("gltf"); r_extensions->push_back("glb"); } Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &state) { - Error err; FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err); if (!f) { @@ -81,7 +78,6 @@ Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &stat } Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state) { - Error err; FileAccessRef f = FileAccess::open(p_path, FileAccess::READ, &err); if (!f) { @@ -163,7 +159,6 @@ String EditorSceneImporterGLTF::_sanitize_scene_name(const String &name) { } String EditorSceneImporterGLTF::_gen_unique_name(GLTFState &state, const String &p_name) { - const String s_name = _sanitize_scene_name(p_name); String name; @@ -204,7 +199,6 @@ String EditorSceneImporterGLTF::_sanitize_bone_name(const String &name) { } String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name) { - const String s_name = _sanitize_bone_name(p_name); String name; @@ -227,7 +221,6 @@ String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GL } Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { - ERR_FAIL_COND_V(!state.json.has("scenes"), ERR_FILE_CORRUPT); const Array &scenes = state.json["scenes"]; int loaded_scene = 0; @@ -257,11 +250,9 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { } Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { - ERR_FAIL_COND_V(!state.json.has("nodes"), ERR_FILE_CORRUPT); const Array &nodes = state.json["nodes"]; for (int i = 0; i < nodes.size(); i++) { - GLTFNode *node = memnew(GLTFNode); const Dictionary &n = nodes[i]; @@ -281,7 +272,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { node->xform = _arr_to_xform(n["matrix"]); } else { - if (n.has("translation")) { node->translation = _arr_to_vec3(n["translation"]); } @@ -308,7 +298,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { // build the hierarchy for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); node_i++) { - for (int j = 0; j < state.nodes[node_i]->children.size(); j++) { GLTFNodeIndex child_i = state.nodes[node_i]->children[j]; @@ -325,7 +314,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { } void EditorSceneImporterGLTF::_compute_node_heights(GLTFState &state) { - state.root_nodes.clear(); for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) { GLTFNode *node = state.nodes[node_i]; @@ -347,7 +335,6 @@ void EditorSceneImporterGLTF::_compute_node_heights(GLTFState &state) { } static Vector<uint8_t> _parse_base64_uri(const String &uri) { - int start = uri.find(","); ERR_FAIL_COND_V(start == -1, Vector<uint8_t>()); @@ -367,20 +354,17 @@ static Vector<uint8_t> _parse_base64_uri(const String &uri) { } Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_base_path) { - if (!state.json.has("buffers")) return OK; const Array &buffers = state.json["buffers"]; for (GLTFBufferIndex i = 0; i < buffers.size(); i++) { - if (i == 0 && state.glb_data.size()) { state.buffers.push_back(state.glb_data); } else { const Dictionary &buffer = buffers[i]; if (buffer.has("uri")) { - Vector<uint8_t> buffer_data; String uri = buffer["uri"]; @@ -388,7 +372,6 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_ //embedded data buffer_data = _parse_base64_uri(uri); } else { - uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows buffer_data = FileAccess::get_file_as_array(uri); ERR_FAIL_COND_V(buffer.size() == 0, ERR_PARSE_ERROR); @@ -408,11 +391,9 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_ } Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) { - ERR_FAIL_COND_V(!state.json.has("bufferViews"), ERR_FILE_CORRUPT); const Array &buffers = state.json["bufferViews"]; for (GLTFBufferViewIndex i = 0; i < buffers.size(); i++) { - const Dictionary &d = buffers[i]; GLTFBufferView buffer_view; @@ -444,7 +425,6 @@ Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) { } EditorSceneImporterGLTF::GLTFType EditorSceneImporterGLTF::_get_type_from_str(const String &p_string) { - if (p_string == "SCALAR") return TYPE_SCALAR; @@ -466,11 +446,9 @@ EditorSceneImporterGLTF::GLTFType EditorSceneImporterGLTF::_get_type_from_str(co } Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { - ERR_FAIL_COND_V(!state.json.has("accessors"), ERR_FILE_CORRUPT); const Array &accessors = state.json["accessors"]; for (GLTFAccessorIndex i = 0; i < accessors.size(); i++) { - const Dictionary &d = accessors[i]; GLTFAccessor accessor; @@ -536,7 +514,6 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { } String EditorSceneImporterGLTF::_get_component_type_name(const uint32_t p_component) { - switch (p_component) { case COMPONENT_TYPE_BYTE: return "Byte"; @@ -556,7 +533,6 @@ String EditorSceneImporterGLTF::_get_component_type_name(const uint32_t p_compon } String EditorSceneImporterGLTF::_get_type_name(const GLTFType p_component) { - static const char *names[] = { "float", "vec2", @@ -571,7 +547,6 @@ String EditorSceneImporterGLTF::_get_type_name(const GLTFType p_component) { } Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst, const GLTFBufferViewIndex p_buffer_view, const int skip_every, const int skip_bytes, const int element_size, const int count, const GLTFType type, const int component_count, const int component_type, const int component_size, const bool normalized, const int byte_offset, const bool for_vertex) { - const GLTFBufferView &bv = state.buffer_views[p_buffer_view]; int stride = bv.byte_stride ? bv.byte_stride : element_size; @@ -597,11 +572,9 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst //fill everything as doubles for (int i = 0; i < count; i++) { - const uint8_t *src = &bufptr[offset + i * stride]; for (int j = 0; j < component_count; j++) { - if (skip_every && j > 0 && (j % skip_every) == 0) { src += skip_bytes; } @@ -659,7 +632,6 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst } int EditorSceneImporterGLTF::_get_component_type_size(const int component_type) { - switch (component_type) { case COMPONENT_TYPE_BYTE: return 1; @@ -687,7 +659,6 @@ int EditorSceneImporterGLTF::_get_component_type_size(const int component_type) } Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - //spec, for reference: //https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment @@ -710,7 +681,6 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const switch (a.component_type) { case COMPONENT_TYPE_BYTE: case COMPONENT_TYPE_UNSIGNED_BYTE: { - if (a.type == TYPE_MAT2) { skip_every = 2; skip_bytes = 2; @@ -740,7 +710,6 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const double *dst = dst_buffer.ptrw(); if (a.buffer_view >= 0) { - ERR_FAIL_INDEX_V(a.buffer_view, state.buffer_views.size(), Vector<double>()); const Error err = _decode_buffer_view(state, dst, a.buffer_view, skip_every, skip_bytes, element_size, a.count, a.type, component_count, a.component_type, component_size, a.normalized, a.byte_offset, p_for_vertex); @@ -783,7 +752,6 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const } Vector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<int> ret; @@ -803,7 +771,6 @@ Vector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, } Vector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<float> ret; @@ -823,7 +790,6 @@ Vector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &sta } Vector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Vector2> ret; @@ -844,7 +810,6 @@ Vector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &sta } Vector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Vector3> ret; @@ -865,7 +830,6 @@ Vector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &sta } Vector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Color> ret; @@ -893,7 +857,6 @@ Vector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &stat } Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Quat> ret; @@ -912,7 +875,6 @@ Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, return ret; } Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Transform2D> ret; @@ -929,7 +891,6 @@ Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFSta } Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &state, const GLTFAccessorIndex p_accessor, bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Basis> ret; @@ -947,7 +908,6 @@ Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &stat } Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Transform> ret; @@ -966,13 +926,11 @@ Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState & } Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { - if (!state.json.has("meshes")) return OK; Array meshes = state.json["meshes"]; for (GLTFMeshIndex i = 0; i < meshes.size(); i++) { - print_verbose("glTF: Parsing mesh: " + itos(i)); Dictionary d = meshes[i]; @@ -985,7 +943,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { const Dictionary &extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary(); for (int j = 0; j < primitives.size(); j++) { - Dictionary p = primitives[j]; Array array; @@ -1123,7 +1080,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } for (int k = 0; k < targets.size(); k++) { - const Dictionary &t = targets[k]; Array array_copy; @@ -1141,7 +1097,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { const int size = src_varr.size(); ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR); { - const int max_idx = varr.size(); varr.resize(size); @@ -1188,7 +1143,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { Vector<float> tangents_v4; { - int max_idx = tangents_v3.size(); int size4 = src_tangents.size(); @@ -1199,7 +1153,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { const float *r4 = src_tangents.ptr(); for (int l = 0; l < size4 / 4; l++) { - if (l < max_idx) { w4[l * 4 + 0] = r3[l].x + r4[l * 4 + 0]; w4[l * 4 + 1] = r3[l].y + r4[l * 4 + 1]; @@ -1259,13 +1212,11 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_base_path) { - if (!state.json.has("images")) return OK; const Array &images = state.json["images"]; for (int i = 0; i < images.size(); i++) { - const Dictionary &d = images[i]; String mimetype; @@ -1287,7 +1238,6 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b data_ptr = data.ptr(); data_size = data.size(); } else { - uri = p_base_path.plus_file(uri).replace("\\", "/"); //fix for windows Ref<Texture2D> texture = ResourceLoader::load(uri); state.images.push_back(texture); @@ -1355,13 +1305,11 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) { - if (!state.json.has("textures")) return OK; const Array &textures = state.json["textures"]; for (GLTFTextureIndex i = 0; i < textures.size(); i++) { - const Dictionary &d = textures[i]; ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR); @@ -1384,13 +1332,11 @@ Ref<Texture2D> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLT } Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { - if (!state.json.has("materials")) return OK; const Array &materials = state.json["materials"]; for (GLTFMaterialIndex i = 0; i < materials.size(); i++) { - const Dictionary &d = materials[i]; Ref<StandardMaterial3D> material; @@ -1400,7 +1346,6 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (d.has("pbrMetallicRoughness")) { - const Dictionary &mr = d["pbrMetallicRoughness"]; if (mr.has("baseColorFactor")) { const Array &arr = mr["baseColorFactor"]; @@ -1534,7 +1479,6 @@ EditorSceneImporterGLTF::GLTFNodeIndex EditorSceneImporterGLTF::_find_highest_no } bool EditorSceneImporterGLTF::_capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, const GLTFNodeIndex node_index) { - bool found_joint = false; for (int i = 0; i < state.nodes[node_index]->children.size(); ++i) { @@ -1558,7 +1502,6 @@ bool EditorSceneImporterGLTF::_capture_nodes_in_skin(GLTFState &state, GLTFSkin } void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &state, GLTFSkin &skin) { - DisjointSet<GLTFNodeIndex> disjoint_set; for (int i = 0; i < skin.joints.size(); ++i) { @@ -1592,7 +1535,6 @@ void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &sta // Go up the tree till all of the multiple roots of the skin are at the same hierarchy level. // This sucks, but 99% of all game engines (not just Godot) would have this same issue. for (int i = 0; i < roots.size(); ++i) { - GLTFNodeIndex current_node = roots[i]; while (state.nodes[current_node]->height > maxHeight) { GLTFNodeIndex parent = state.nodes[current_node]->parent; @@ -1640,7 +1582,6 @@ void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &sta } Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) { - _capture_nodes_for_multirooted_skin(state, skin); // Grab all nodes that lay in between skin joints/nodes @@ -1686,7 +1627,6 @@ Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) { } Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) { - // This may seem duplicated from expand_skins, but this is really a sanity check! (so it kinda is) // In case additional interpolating logic is added to the skins, this will help ensure that you // do not cause it to self implode into a fiery blaze @@ -1752,7 +1692,6 @@ Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) { } Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { - if (!state.json.has("skins")) return OK; @@ -1760,7 +1699,6 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { // Create the base skins, and mark nodes that are joints for (int i = 0; i < skins.size(); i++) { - const Dictionary &d = skins[i]; GLTFSkin skin; @@ -1810,7 +1748,6 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { } Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) { - // Using a disjoint set, we are going to potentially combine all skins that are actually branches // of a main skeleton, or treat skins defining the same set of nodes as ONE skeleton. // This is another unclear issue caused by the current glTF specification. @@ -1888,7 +1825,6 @@ Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) { // Mark all the skins actual skeletons, after we have merged them for (GLTFSkeletonIndex skel_i = 0; skel_i < skeleton_owners.size(); ++skel_i) { - const GLTFNodeIndex skeleton_owner = skeleton_owners[skel_i]; GLTFSkeleton skeleton; @@ -1943,7 +1879,6 @@ Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) { } Error EditorSceneImporterGLTF::_reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints) { - DisjointSet<GLTFNodeIndex> subtree_set; // Populate the disjoint set with ONLY non joints that are in the skeleton hierarchy (non_joints vector) @@ -2058,7 +1993,6 @@ Error EditorSceneImporterGLTF::_reparent_to_fake_joint(GLTFState &state, GLTFSke } Error EditorSceneImporterGLTF::_determine_skeleton_roots(GLTFState &state, const GLTFSkeletonIndex skel_i) { - DisjointSet<GLTFNodeIndex> disjoint_set; for (GLTFNodeIndex i = 0; i < state.nodes.size(); ++i) { @@ -2113,7 +2047,6 @@ Error EditorSceneImporterGLTF::_determine_skeleton_roots(GLTFState &state, const Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) { for (GLTFSkeletonIndex skel_i = 0; skel_i < state.skeletons.size(); ++skel_i) { - GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i]; Skeleton3D *skeleton = memnew(Skeleton3D); @@ -2214,7 +2147,6 @@ Error EditorSceneImporterGLTF::_create_skins(GLTFState &state) { const bool has_ibms = !gltf_skin.inverse_binds.empty(); for (int joint_i = 0; joint_i < gltf_skin.joints_original.size(); ++joint_i) { - Transform xform; if (has_ibms) { xform = gltf_skin.inverse_binds[joint_i]; @@ -2253,7 +2185,6 @@ bool EditorSceneImporterGLTF::_skins_are_same(const Ref<Skin> &skin_a, const Ref } for (int i = 0; i < skin_a->get_bind_count(); ++i) { - if (skin_a->get_bind_bone(i) != skin_b->get_bind_bone(i)) { return false; } @@ -2284,21 +2215,18 @@ void EditorSceneImporterGLTF::_remove_duplicate_skins(GLTFState &state) { } Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { - if (!state.json.has("cameras")) return OK; const Array &cameras = state.json["cameras"]; for (GLTFCameraIndex i = 0; i < cameras.size(); i++) { - const Dictionary &d = cameras[i]; GLTFCamera camera; ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); const String &type = d["type"]; if (type == "orthographic") { - camera.perspective = false; if (d.has("orthographic")) { const Dictionary &og = d["orthographic"]; @@ -2310,7 +2238,6 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { } } else if (type == "perspective") { - camera.perspective = true; if (d.has("perspective")) { const Dictionary &ppt = d["perspective"]; @@ -2334,14 +2261,12 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { } Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { - if (!state.json.has("animations")) return OK; const Array &animations = state.json["animations"]; for (GLTFAnimationIndex i = 0; i < animations.size(); i++) { - const Dictionary &d = animations[i]; GLTFAnimation animation; @@ -2361,7 +2286,6 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { } for (int j = 0; j < channels.size(); j++) { - const Dictionary &c = channels[j]; if (!c.has("target")) continue; @@ -2471,7 +2395,6 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { } void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { - for (int i = 0; i < state.nodes.size(); i++) { GLTFNode *n = state.nodes[i]; @@ -2494,7 +2417,6 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { } 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]; @@ -2558,7 +2480,6 @@ Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene } 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]; Node3D *current_node = nullptr; @@ -2623,14 +2544,11 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene template <class T> struct EditorSceneImporterGLTFInterpolate { - T lerp(const T &a, const T &b, float c) const { - return a + (b - a) * c; } T catmull_rom(const T &p0, const T &p1, const T &p2, const T &p3, float t) { - const float t2 = t * t; const float t3 = t2 * t; @@ -2652,7 +2570,6 @@ struct EditorSceneImporterGLTFInterpolate { // thank you for existing, partial specialization template <> struct EditorSceneImporterGLTFInterpolate<Quat> { - Quat lerp(const Quat &a, const Quat &b, const float c) const { ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quat(), "The quaternion \"a\" must be normalized."); ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quat(), "The quaternion \"b\" must be normalized."); @@ -2677,7 +2594,6 @@ struct EditorSceneImporterGLTFInterpolate<Quat> { template <class T> T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { - //could use binary search, worth it? int idx = -1; for (int i = 0; i < p_times.size(); i++) { @@ -2690,7 +2606,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons switch (p_interp) { case GLTFAnimation::INTERP_LINEAR: { - if (idx == -1) { return p_values[0]; } else if (idx >= p_times.size() - 1) { @@ -2703,7 +2618,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons } break; case GLTFAnimation::INTERP_STEP: { - if (idx == -1) { return p_values[0]; } else if (idx >= p_times.size() - 1) { @@ -2714,7 +2628,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons } break; case GLTFAnimation::INTERP_CATMULLROMSPLINE: { - if (idx == -1) { return p_values[1]; } else if (idx >= p_times.size() - 1) { @@ -2727,7 +2640,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons } break; case GLTFAnimation::INTERP_CUBIC_SPLINE: { - if (idx == -1) { return p_values[1]; } else if (idx >= p_times.size() - 1) { @@ -2750,7 +2662,6 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons } void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps) { - const GLTFAnimation &anim = state.animations[index]; String name = anim.name; @@ -2770,7 +2681,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye float length = 0; for (Map<int, GLTFAnimation::Track>::Element *E = anim.tracks.front(); E; E = E->next()) { - const GLTFAnimation::Track &track = E->get(); //need to find the path NodePath node_path; @@ -2838,7 +2748,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye bool last = false; while (true) { - Vector3 pos = base_pos; Quat rot = base_rot; Vector3 scale = base_scale; @@ -2856,7 +2765,6 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye } if (node->skeleton >= 0) { - Transform xform; xform.basis.set_quat_scale(rot, scale); xform.origin = pos; @@ -2958,7 +2866,6 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D * } Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { - Node3D *root = memnew(Node3D); // scene_name is already unique @@ -2985,7 +2892,6 @@ Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_b } Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - GLTFState state; if (p_path.to_lower().ends_with("glb")) { @@ -3098,7 +3004,6 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla } Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return Ref<Animation>(); } diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 86d7e627a3..eee978ce16 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -40,7 +40,6 @@ class BoneAttachment3D; class MeshInstance3D; class EditorSceneImporterGLTF : public EditorSceneImporter { - GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter); typedef int GLTFAccessorIndex; @@ -92,7 +91,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { String _get_type_name(const GLTFType p_component); struct GLTFNode { - //matrices need to be transformed to this GLTFNodeIndex parent = -1; int height = -1; @@ -119,7 +117,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFBufferView { - GLTFBufferIndex buffer = -1; int byte_offset = 0; int byte_length = 0; @@ -131,7 +128,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFAccessor { - GLTFBufferViewIndex buffer_view = 0; int byte_offset = 0; int component_type = 0; @@ -214,7 +210,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFCamera { - bool perspective = true; float fov_size = 64; float zfar = 500; @@ -241,7 +236,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct Track { - Channel<Vector3> translation_track; Channel<Quat> rotation_track; Channel<Vector3> scale_track; @@ -254,7 +248,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFState { - Dictionary json; int major_version; int minor_version; diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp index 252af9050b..05a3bfc386 100644 --- a/editor/import/resource_importer_bitmask.cpp +++ b/editor/import/resource_importer_bitmask.cpp @@ -38,16 +38,13 @@ #include "scene/resources/texture.h" String ResourceImporterBitMap::get_importer_name() const { - return "bitmap"; } String ResourceImporterBitMap::get_visible_name() const { - return "BitMap"; } void ResourceImporterBitMap::get_recognized_extensions(List<String> *p_extensions) const { - ImageLoader::get_recognized_extensions(p_extensions); } String ResourceImporterBitMap::get_save_extension() const { @@ -55,12 +52,10 @@ String ResourceImporterBitMap::get_save_extension() const { } String ResourceImporterBitMap::get_resource_type() const { - return "BitMap"; } bool ResourceImporterBitMap::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } @@ -68,18 +63,15 @@ int ResourceImporterBitMap::get_preset_count() const { return 0; } String ResourceImporterBitMap::get_preset_name(int p_idx) const { - return String(); } void ResourceImporterBitMap::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "create_from", PROPERTY_HINT_ENUM, "Black & White,Alpha"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5)); } Error ResourceImporterBitMap::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) { - int create_from = p_options["create_from"]; float threshold = p_options["threshold"]; Ref<Image> image; @@ -97,7 +89,6 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String & for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { - bool bit; Color c = image->get_pixel(j, i); if (create_from == 0) { //b&W diff --git a/editor/import/resource_importer_csv.cpp b/editor/import/resource_importer_csv.cpp index 424f90bd54..e56cb1d3a1 100644 --- a/editor/import/resource_importer_csv.cpp +++ b/editor/import/resource_importer_csv.cpp @@ -34,16 +34,13 @@ #include "core/os/file_access.h" String ResourceImporterCSV::get_importer_name() const { - return "csv"; } String ResourceImporterCSV::get_visible_name() const { - return "CSV"; } void ResourceImporterCSV::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("csv"); } @@ -52,12 +49,10 @@ String ResourceImporterCSV::get_save_extension() const { } String ResourceImporterCSV::get_resource_type() const { - return "TextFile"; } bool ResourceImporterCSV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } @@ -65,7 +60,6 @@ int ResourceImporterCSV::get_preset_count() const { return 0; } String ResourceImporterCSV::get_preset_name(int p_idx) const { - return ""; } diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 9d72396449..09f2d691f0 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -36,16 +36,13 @@ #include "core/translation.h" String ResourceImporterCSVTranslation::get_importer_name() const { - return "csv_translation"; } String ResourceImporterCSVTranslation::get_visible_name() const { - return "CSV Translation"; } void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("csv"); } @@ -54,12 +51,10 @@ String ResourceImporterCSVTranslation::get_save_extension() const { } String ResourceImporterCSVTranslation::get_resource_type() const { - return "Translation"; } bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } @@ -67,18 +62,15 @@ int ResourceImporterCSVTranslation::get_preset_count() const { return 0; } String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const { - return ""; } void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0)); } Error ResourceImporterCSVTranslation::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) { - bool compress = p_options["compress"]; String delimiter; @@ -105,7 +97,6 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const Vector<Ref<Translation>> translations; for (int i = 1; i < line.size(); i++) { - String locale = line[i]; ERR_FAIL_COND_V_MSG(!TranslationServer::is_locale_valid(locale), ERR_PARSE_ERROR, "Error importing CSV translation: '" + locale + "' is not a valid locale."); @@ -119,10 +110,8 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const line = f->get_csv_line(delimiter); while (line.size() == locales.size() + 1) { - String key = line[0]; if (key != "") { - for (int i = 1; i < line.size(); i++) { translations.write[i - 1]->add_message(key, line[i].c_unescape()); } diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp index a1f5a79b00..927d911e94 100644 --- a/editor/import/resource_importer_image.cpp +++ b/editor/import/resource_importer_image.cpp @@ -36,16 +36,13 @@ #include "scene/resources/texture.h" String ResourceImporterImage::get_importer_name() const { - return "image"; } String ResourceImporterImage::get_visible_name() const { - return "Image"; } void ResourceImporterImage::get_recognized_extensions(List<String> *p_extensions) const { - ImageLoader::get_recognized_extensions(p_extensions); } @@ -54,12 +51,10 @@ String ResourceImporterImage::get_save_extension() const { } String ResourceImporterImage::get_resource_type() const { - return "Image"; } bool ResourceImporterImage::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } @@ -67,7 +62,6 @@ int ResourceImporterImage::get_preset_count() const { return 0; } String ResourceImporterImage::get_preset_name(int p_idx) const { - return String(); } @@ -75,7 +69,6 @@ void ResourceImporterImage::get_import_options(List<ImportOption> *r_options, in } Error ResourceImporterImage::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) { - FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'."); diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index c46cf4c1a8..18c6dc149b 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -40,7 +40,6 @@ #include "scene/resources/texture.h" String ResourceImporterLayeredTexture::get_importer_name() const { - switch (mode) { case MODE_CUBEMAP: { return "cubemap_texture"; @@ -60,7 +59,6 @@ String ResourceImporterLayeredTexture::get_importer_name() const { } String ResourceImporterLayeredTexture::get_visible_name() const { - switch (mode) { case MODE_CUBEMAP: { return "Cubemap"; @@ -79,7 +77,6 @@ String ResourceImporterLayeredTexture::get_visible_name() const { ERR_FAIL_V(""); } void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_extensions) const { - ImageLoader::get_recognized_extensions(p_extensions); } String ResourceImporterLayeredTexture::get_save_extension() const { @@ -102,7 +99,6 @@ String ResourceImporterLayeredTexture::get_save_extension() const { } String ResourceImporterLayeredTexture::get_resource_type() const { - switch (mode) { case MODE_CUBEMAP: { return "StreamCubemap"; @@ -121,7 +117,6 @@ String ResourceImporterLayeredTexture::get_resource_type() const { } bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - if (p_option == "compress/lossy_quality" && p_options.has("compress/mode")) { return int(p_options["compress/mode"]) == COMPRESS_LOSSY; } @@ -132,12 +127,10 @@ int ResourceImporterLayeredTexture::get_preset_count() const { return 0; } String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const { - return ""; } void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1)); @@ -160,9 +153,7 @@ void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_op } void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, const String &p_to_path, int p_compress_mode, float p_lossy, Image::CompressMode p_vram_compression, Image::CompressSource p_csource, Image::UsedChannels used_channels, bool p_mipmaps, bool p_force_po2) { - for (int i = 0; i < p_images.size(); i++) { - if (p_force_po2) { p_images.write[i]->resize_to_po2(); } @@ -199,7 +190,6 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons } Error ResourceImporterLayeredTexture::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) { - int compress_mode = p_options["compress/mode"]; float lossy = p_options["compress/lossy_quality"]; int hdr_compression = p_options["compress/hdr_compression"]; @@ -315,7 +305,6 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const bool can_compress_hdr = hdr_compression > 0; if (is_hdr && can_compress_hdr) { - if (used_channels == Image::USED_CHANNELS_LA || used_channels == Image::USED_CHANNELS_RGBA) { //can compress hdr, but hdr with alpha is not compressible @@ -337,9 +326,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const } if (can_compress_hdr) { - if (!can_bptc) { - //default to rgbe if (image->get_format() != Image::FORMAT_RGBE9995) { for (int i = 0; i < slices.size(); i++) { @@ -366,14 +353,12 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, lossy, Image::COMPRESS_ETC2, csource, used_channels, mipmaps, true); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_tex(slices, p_save_path + ".etc2." + extension, compress_mode, lossy, Image::COMPRESS_ETC2, csource, used_channels, mipmaps, true); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); @@ -408,7 +393,6 @@ const char *ResourceImporterLayeredTexture::compression_formats[] = { nullptr }; String ResourceImporterLayeredTexture::get_import_settings_string() const { - String s; int index = 0; @@ -425,7 +409,6 @@ String ResourceImporterLayeredTexture::get_import_settings_string() const { } bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_path) const { - //will become invalid if formats are missing to import Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); @@ -463,7 +446,6 @@ bool ResourceImporterLayeredTexture::are_import_settings_valid(const String &p_p ResourceImporterLayeredTexture *ResourceImporterLayeredTexture::singleton = nullptr; ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { - singleton = this; mode = MODE_CUBEMAP; } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 6a6eadfa5c..73150c8516 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -38,12 +38,10 @@ #include "scene/resources/surface_tool.h" 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) { - 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)); @@ -51,7 +49,6 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand String current_name; String base_path = p_path.get_base_dir(); while (true) { - String l = f->get_line().strip_edges(); if (l.begins_with("newmtl ")) { @@ -204,7 +201,6 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand } 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)); @@ -231,7 +227,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ String current_group; while (true) { - String l = f->get_line().strip_edges(); while (l.length() && l[l.length() - 1] == '\\') { String add = f->get_line().strip_edges(); @@ -283,12 +278,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_FILE_CORRUPT); for (int i = 2; i < v.size() - 1; i++) { - face[2] = v[i + 1].split("/"); ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_FILE_CORRUPT); for (int j = 0; j < 3; j++) { - int idx = j; if (idx < 2) { @@ -365,7 +358,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ } if (l.begins_with("o ") || f->eof_reached()) { - if (!p_single_mesh) { mesh->set_name(name); r_meshes.push_back(mesh); @@ -384,12 +376,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ } if (l.begins_with("usemtl ")) { - current_material = l.replace("usemtl", "").strip_edges(); } if (l.begins_with("g ")) { - current_group = l.substr(2, l.length()).strip_edges(); } @@ -411,7 +401,6 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ } if (p_single_mesh) { - r_meshes.push_back(mesh); } @@ -419,7 +408,6 @@ 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; 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); @@ -434,7 +422,6 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in Node3D *scene = memnew(Node3D); for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { - MeshInstance3D *mi = memnew(MeshInstance3D); mi->set_mesh(E->get()); mi->set_name(E->get()->get_name()); @@ -449,12 +436,10 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in return scene; } Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return Ref<Animation>(); } void EditorOBJImporter::get_extensions(List<String> *r_extensions) const { - r_extensions->push_back("obj"); } @@ -469,7 +454,6 @@ String ResourceImporterOBJ::get_visible_name() const { return "OBJ As Mesh"; } void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("obj"); } String ResourceImporterOBJ::get_save_extension() const { @@ -487,19 +471,16 @@ String ResourceImporterOBJ::get_preset_name(int p_idx) const { } void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1))); r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "offset_mesh"), Vector3(0, 0, 0))); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true)); } bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } 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; 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); diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 7485e60f7b..aec5de3dcc 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -34,7 +34,6 @@ #include "resource_importer_scene.h" class EditorOBJImporter : public EditorSceneImporter { - GDCLASS(EditorOBJImporter, EditorSceneImporter); public: diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 37941109a1..012e3e95a7 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -47,7 +47,6 @@ #include "scene/resources/world_margin_shape_3d.h" uint32_t EditorSceneImporter::get_import_flags() const { - if (get_script_instance()) { return get_script_instance()->call("_get_import_flags"); } @@ -55,7 +54,6 @@ uint32_t EditorSceneImporter::get_import_flags() const { ERR_FAIL_V(0); } void EditorSceneImporter::get_extensions(List<String> *r_extensions) const { - if (get_script_instance()) { Array arr = get_script_instance()->call("_get_extensions"); for (int i = 0; i < arr.size(); i++) { @@ -67,7 +65,6 @@ void EditorSceneImporter::get_extensions(List<String> *r_extensions) const { ERR_FAIL(); } Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - if (get_script_instance()) { return get_script_instance()->call("_import_scene", p_path, p_flags, p_bake_fps); } @@ -76,7 +73,6 @@ Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, } Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { - if (get_script_instance()) { return get_script_instance()->call("_import_animation", p_path, p_flags); } @@ -88,17 +84,14 @@ Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint3 //and you want to load the resulting file Node *EditorSceneImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return ResourceImporterScene::get_singleton()->import_scene_from_other_importer(this, p_path, p_flags, p_bake_fps); } Ref<Animation> EditorSceneImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { - return ResourceImporterScene::get_singleton()->import_animation_from_other_importer(this, p_path, p_flags, p_bake_fps); } void EditorSceneImporter::_bind_methods() { - ClassDB::bind_method(D_METHOD("import_scene_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_scene_from_other_importer); ClassDB::bind_method(D_METHOD("import_animation_from_other_importer", "path", "flags", "bake_fps"), &EditorSceneImporter::import_animation_from_other_importer); @@ -126,14 +119,12 @@ void EditorSceneImporter::_bind_methods() { ///////////////////////////////// void EditorScenePostImport::_bind_methods() { - BIND_VMETHOD(MethodInfo(Variant::OBJECT, "post_import", PropertyInfo(Variant::OBJECT, "scene"))); ClassDB::bind_method(D_METHOD("get_source_folder"), &EditorScenePostImport::get_source_folder); ClassDB::bind_method(D_METHOD("get_source_file"), &EditorScenePostImport::get_source_file); } Node *EditorScenePostImport::post_import(Node *p_scene) { - if (get_script_instance()) return get_script_instance()->call("post_import", p_scene); @@ -141,12 +132,10 @@ Node *EditorScenePostImport::post_import(Node *p_scene) { } String EditorScenePostImport::get_source_folder() const { - return source_folder; } String EditorScenePostImport::get_source_file() const { - return source_file; } @@ -159,17 +148,14 @@ EditorScenePostImport::EditorScenePostImport() { } String ResourceImporterScene::get_importer_name() const { - return "scene"; } String ResourceImporterScene::get_visible_name() const { - return "Scene"; } void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const { - for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { E->get()->get_extensions(p_extensions); } @@ -180,12 +166,10 @@ String ResourceImporterScene::get_save_extension() const { } String ResourceImporterScene::get_resource_type() const { - return "PackedScene"; } bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - if (p_option.begins_with("animation/")) { if (p_option != "animation/import" && !bool(p_options["animation/import"])) return false; @@ -219,7 +203,6 @@ int ResourceImporterScene::get_preset_count() const { return PRESET_MAX; } String ResourceImporterScene::get_preset_name(int p_idx) const { - switch (p_idx) { case PRESET_SINGLE_SCENE: return TTR("Import as Single Scene"); @@ -247,12 +230,10 @@ String ResourceImporterScene::get_preset_name(int p_idx) const { } static bool _teststr(const String &p_what, const String &p_str) { - String what = p_what; //remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) { - what = what.substr(0, what.length() - 1); } @@ -266,12 +247,10 @@ static bool _teststr(const String &p_what, const String &p_str) { } static String _fixstr(const String &p_what, const String &p_str) { - String what = p_what; //remove trailing spaces and numbers, some apps like blender add ".number" to duplicates so also compensate for this while (what.length() && ((what[what.length() - 1] >= '0' && what[what.length() - 1] <= '9') || what[what.length() - 1] <= 32 || what[what.length() - 1] == '.')) { - what = what.substr(0, what.length() - 1); } @@ -287,13 +266,10 @@ static String _fixstr(const String &p_what, const String &p_str) { } static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) { - if (!p_convex) { - Ref<Shape3D> shape = mesh->create_trimesh_shape(); r_shape_list.push_back(shape); } else { - Vector<Ref<Shape3D>> cd = mesh->convex_decompose(); if (cd.size()) { for (int i = 0; i < cd.size(); i++) { @@ -304,10 +280,8 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_l } 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++) { - Node *r = _fix_node(p_node->get_child(i), p_root, collision_map, p_light_bake_mode); if (!r) { i--; //was erased @@ -319,32 +293,26 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> bool isroot = p_node == p_root; if (!isroot && _teststr(name, "noimp")) { - memdelete(p_node); return nullptr; } if (Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> m = mi->get_mesh(); if (m.is_valid()) { - for (int i = 0; i < m->get_surface_count(); i++) { - Ref<StandardMaterial3D> mat = m->surface_get_material(i); if (!mat.is_valid()) continue; if (_teststr(mat->get_name(), "alpha")) { - mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); mat->set_name(_fixstr(mat->get_name(), "alpha")); } if (_teststr(mat->get_name(), "vcol")) { - mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); mat->set_name(_fixstr(mat->get_name(), "vcol")); @@ -353,7 +321,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (p_light_bake_mode != LIGHT_BAKE_DISABLED) { - mi->set_gi_mode(GeometryInstance3D::GI_MODE_BAKED); } } @@ -365,7 +332,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> List<StringName> anims; ap->get_animation_list(&anims); for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); ERR_CONTINUE(anim.is_null()); for (int i = 0; i < anim->get_track_count(); i++) { @@ -384,7 +350,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (_teststr(name, "colonly") || _teststr(name, "convcolonly")) { - if (isroot) return p_node; MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); @@ -413,7 +378,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> ERR_FAIL_COND_V(fixed_name == String(), nullptr); if (shapes.size()) { - StaticBody3D *col = memnew(StaticBody3D); col->set_transform(mi->get_transform()); col->set_name(fixed_name); @@ -423,7 +387,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> int idx = 0; for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -470,7 +433,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) { - if (isroot) return p_node; @@ -497,7 +459,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> int idx = 0; for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); rigid_body->add_child(cshape); @@ -509,7 +470,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mi->get_mesh(); @@ -547,7 +507,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> int idx = 0; for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -561,7 +520,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) { - if (isroot) return p_node; @@ -580,7 +538,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> memdelete(p_node); p_node = nmi; } else if (_teststr(name, "vehicle")) { - if (isroot) return p_node; @@ -600,7 +557,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = bv; } else if (_teststr(name, "wheel")) { - if (isroot) return p_node; @@ -620,14 +576,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = bv; } else if (Object::cast_to<MeshInstance3D>(p_node)) { - //last attempt, maybe collision inside the mesh data MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_null()) { - List<Ref<Shape3D>> shapes; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; @@ -649,7 +603,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> int idx = 0; for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -666,7 +619,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, bool p_bake_all) { - if (!scene->has_node(String("AnimationPlayer"))) return; @@ -681,7 +633,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo Ref<Animation> default_anim = anim->get_animation("default"); for (int i = 0; i < p_clips.size(); i += 4) { - String name = p_clips[i]; float from = p_clips[i + 1]; float to = p_clips[i + 2]; @@ -692,15 +643,12 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo Ref<Animation> new_anim = memnew(Animation); for (int j = 0; j < default_anim->get_track_count(); j++) { - List<float> keys; int kc = default_anim->track_get_key_count(j); int dtrack = -1; for (int k = 0; k < kc; k++) { - float kt = default_anim->track_get_key_time(j, k); if (kt >= from && kt < to) { - //found a key within range, so create track if (dtrack == -1) { new_anim->add_track(default_anim->track_get_type(j)); @@ -708,7 +656,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo new_anim->track_set_path(dtrack, default_anim->track_get_path(j)); if (kt > (from + 0.01) && k > 0) { - if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) { Quat q; Vector3 p; @@ -737,7 +684,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo } if (dtrack != -1 && kt >= to) { - if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) { Quat q; Vector3 p; @@ -757,7 +703,6 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo dtrack = new_anim->get_track_count() - 1; new_anim->track_set_path(dtrack, default_anim->track_get_path(j)); if (default_anim->track_get_type(j) == Animation::TYPE_TRANSFORM) { - Quat q; Vector3 p; Vector3 s; @@ -784,12 +729,10 @@ void ResourceImporterScene::_create_clips(Node *scene, const Array &p_clips, boo } void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String> &keep) { - Ref<Animation> a = anim; ERR_FAIL_COND(!a.is_valid()); for (int j = 0; j < a->get_track_count(); j++) { - String path = a->track_get_path(j); if (!keep.has(path)) { @@ -800,7 +743,6 @@ void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String> } void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { - if (!scene->has_node(String("AnimationPlayer"))) return; Node *n = scene->get_node(String("AnimationPlayer")); @@ -810,14 +752,12 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { Vector<String> strings = p_text.split("\n"); for (int i = 0; i < strings.size(); i++) { - strings.write[i] = strings[i].strip_edges(); } List<StringName> anim_names; anim->get_animation_list(&anim_names); for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - String name = E->get(); bool valid_for_this = false; bool valid = false; @@ -826,9 +766,7 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { Set<String> keep_local; for (int i = 0; i < strings.size(); i++) { - if (strings[i].begins_with("@")) { - valid_for_this = false; for (Set<String>::Element *F = keep_local.front(); F; F = F->next()) { keep.insert(F->get()); @@ -837,7 +775,6 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { Vector<String> filters = strings[i].substr(1, strings[i].length()).split(","); for (int j = 0; j < filters.size(); j++) { - String fname = filters[j].strip_edges(); if (fname == "") continue; @@ -861,13 +798,11 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { valid = true; } else if (valid_for_this) { - Ref<Animation> a = anim->get_animation(name); if (!a.is_valid()) continue; for (int j = 0; j < a->get_track_count(); j++) { - String path = a->track_get_path(j); String tname = strings[i]; @@ -906,7 +841,6 @@ void ResourceImporterScene::_filter_tracks(Node *scene, const String &p_text) { } void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle) { - if (!scene->has_node(String("AnimationPlayer"))) return; Node *n = scene->get_node(String("AnimationPlayer")); @@ -917,14 +851,12 @@ void ResourceImporterScene::_optimize_animations(Node *scene, float p_max_lin_er List<StringName> anim_names; anim->get_animation_list(&anim_names); for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - Ref<Animation> a = anim->get_animation(E->get()); a->optimize(p_max_lin_error, p_max_ang_error, Math::deg2rad(p_max_angle)); } } static String _make_extname(const String &p_str) { - String ext_name = p_str.replace(".", "_"); ext_name = ext_name.replace(":", "_"); ext_name = ext_name.replace("\"", "_"); @@ -940,14 +872,12 @@ static String _make_extname(const String &p_str) { } void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Transform> &meshes) { - List<PropertyInfo> pi; p_node->get_property_list(&pi); MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); if (mi) { - Ref<ArrayMesh> mesh = mi->get_mesh(); if (mesh.is_valid() && !meshes.has(mesh)) { @@ -962,13 +892,11 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans } } for (int i = 0; i < p_node->get_child_count(); i++) { - _find_meshes(p_node->get_child(i), 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; if (p_make_animations) { @@ -978,12 +906,10 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String List<StringName> anims; ap->get_animation_list(&anims); for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); ERR_CONTINUE(anim.is_null()); if (!p_animations.has(anim)) { - //mark what comes from the file first, this helps eventually keep user data for (int i = 0; i < anim->get_track_count(); i++) { anim->track_set_imported(i, true); @@ -1022,15 +948,11 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String p_node->get_property_list(&pi); for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (E->get().type == Variant::OBJECT) { - Ref<Material> mat = p_node->get(E->get().name); if (p_make_materials && mat.is_valid() && mat->get_name() != "") { - if (!p_materials.has(mat)) { - String ext_name; if (p_materials_as_text) { @@ -1043,28 +965,22 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String //if exists, use it p_materials[mat] = ResourceLoader::load(ext_name); } else { - ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH); p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache. } } if (p_materials[mat] != mat) { - p_node->set(E->get().name, p_materials[mat]); } } else { - Ref<ArrayMesh> mesh = p_node->get(E->get().name); if (mesh.is_valid()) { - bool mesh_just_added = false; if (p_make_meshes) { - if (!p_meshes.has(mesh)) { - //meshes are always overwritten, keeping them is not practical String ext_name; @@ -1082,9 +998,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String } if (p_make_materials) { - if (mesh_just_added || !p_meshes.has(mesh)) { - for (int i = 0; i < mesh->get_surface_count(); i++) { mat = mesh->surface_get_material(i); @@ -1106,19 +1020,16 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String //if exists, use it p_materials[mat] = ResourceLoader::load(ext_name); } else { - ResourceSaver::save(ext_name, mat, ResourceSaver::FLAG_CHANGE_PATH); p_materials[mat] = ResourceLoader::load(ext_name, "", true); // disable loading from the cache. } } if (p_materials[mat] != mat) { - mesh->surface_set_material(i, p_materials[mat]); //re-save the mesh since a material is now assigned if (p_make_meshes) { - String ext_name; if (p_meshes_as_text) { @@ -1144,13 +1055,11 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String } for (int i = 0; i < p_node->get_child_count(); i++) { - _make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_animations_as_text, p_keep_animations, p_make_materials, p_materials_as_text, p_keep_materials, p_make_meshes, p_meshes_as_text, p_animations, p_materials, p_meshes); } } 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"), "Node3D")); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root")); @@ -1203,7 +1112,6 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in } void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner) { - if (p_node != p_new_owner && p_node->get_owner() == p_scene) { p_node->set_owner(p_new_owner); } @@ -1215,21 +1123,17 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_ } Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) { - Ref<EditorSceneImporter> importer; String ext = p_path.get_extension().to_lower(); for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { - if (E->get().ptr() == p_exception) continue; List<String> extensions; E->get()->get_extensions(&extensions); for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); break; } @@ -1247,21 +1151,17 @@ Node *ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporte } Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneImporter *p_exception, const String &p_path, uint32_t p_flags, int p_bake_fps) { - Ref<EditorSceneImporter> importer; String ext = p_path.get_extension().to_lower(); for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { - if (E->get().ptr() == p_exception) continue; List<String> extensions; E->get()->get_extensions(&extensions); for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); break; } @@ -1277,7 +1177,6 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito } Error ResourceImporterScene::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) { - const String &src_path = p_source_file; Ref<EditorSceneImporter> importer; @@ -1287,14 +1186,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p progress.step(TTR("Importing Scene..."), 0); for (Set<Ref<EditorSceneImporter>>::Element *E = importers.front(); E; E = E->next()) { - List<String> extensions; E->get()->get_extensions(&extensions); for (List<String>::Element *F = extensions.front(); F; F = F->next()) { - if (F->get().to_lower() == ext) { - importer = E->get(); break; } @@ -1347,7 +1243,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type)); if (base_node) { - scene->replace_by(base_node); memdelete(scene); scene = base_node; @@ -1389,7 +1284,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p Array animation_clips; { - int clip_count = p_options["animation/clips/amount"]; for (int i = 0; i < clip_count; i++) { @@ -1424,7 +1318,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p String base_path = p_source_file.get_base_dir(); if (external_animations || external_materials || external_meshes || external_scenes) { - if (bool(p_options["external_files/store_in_subdir"])) { String subdir_name = p_source_file.get_file().get_basename(); DirAccess *da = DirAccess::open(base_path); @@ -1436,7 +1329,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p } if (light_bake_mode == 2 /* || generate LOD */) { - Map<Ref<ArrayMesh>, Transform> meshes; _find_meshes(scene, meshes); @@ -1467,7 +1359,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p EditorProgress progress2("gen_lightmaps", TTR("Generating Lightmaps"), meshes.size()); int step = 0; for (Map<Ref<ArrayMesh>, Transform>::Element *E = meshes.front(); E; E = E->next()) { - Ref<ArrayMesh> mesh = E->key(); String name = mesh->get_name(); if (name == "") { //should not happen but.. @@ -1484,7 +1375,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p if (err2 != OK) { EditorNode::add_io_error("Mesh '" + name + "' failed lightmap generation. Please fix geometry."); } else { - String hash = String::md5((unsigned char *)ret_cache_data); used_unwraps.insert(hash, ret_cache_size); @@ -1515,7 +1405,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p if (file) memdelete(file); } else { - // Store number of entries file->store_32(used_unwraps.size()); @@ -1567,7 +1456,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p if (!scr.is_valid()) { EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path); } else { - post_import_script = Ref<EditorScenePostImport>(memnew(EditorScenePostImport)); post_import_script->set_script(scr); if (!post_import_script->get_script_instance()) { @@ -1641,7 +1529,6 @@ void EditorSceneImporterESCN::get_extensions(List<String> *r_extensions) const { r_extensions->push_back("escn"); } Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - Error error; Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error); ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'."); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index f48f181951..34d96bbc44 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -39,7 +39,6 @@ class Material; class EditorSceneImporter : public Reference { - GDCLASS(EditorSceneImporter, Reference); protected: @@ -73,7 +72,6 @@ public: }; class EditorScenePostImport : public Reference { - GDCLASS(EditorScenePostImport, Reference); String source_folder; diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp index f085341969..0813bca6f1 100644 --- a/editor/import/resource_importer_shader_file.cpp +++ b/editor/import/resource_importer_shader_file.cpp @@ -38,16 +38,13 @@ #include "servers/rendering/rendering_device_binds.h" String ResourceImporterShaderFile::get_importer_name() const { - return "glsl"; } String ResourceImporterShaderFile::get_visible_name() const { - return "GLSL Shader File"; } void ResourceImporterShaderFile::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("glsl"); } String ResourceImporterShaderFile::get_save_extension() const { @@ -55,7 +52,6 @@ String ResourceImporterShaderFile::get_save_extension() const { } String ResourceImporterShaderFile::get_resource_type() const { - return "RDShaderFile"; } @@ -63,7 +59,6 @@ int ResourceImporterShaderFile::get_preset_count() const { return 0; } String ResourceImporterShaderFile::get_preset_name(int p_idx) const { - return String(); } @@ -91,7 +86,6 @@ static String _include_function(const String &p_path, void *userpointer) { } Error ResourceImporterShaderFile::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) { - /* STEP 1, Read shader code */ Error err; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 111eab78b4..aeeae36f5b 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -37,7 +37,6 @@ #include "editor/editor_node.h" void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) { - MutexLock lock(singleton->mutex); StringName path = p_tex->get_path(); @@ -52,7 +51,6 @@ void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTextur } void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p_tex) { - MutexLock lock(singleton->mutex); StringName path = p_tex->get_path(); @@ -65,7 +63,6 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p } void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D> &p_tex) { - MutexLock lock(singleton->mutex); StringName path = p_tex->get_path(); @@ -78,7 +75,6 @@ void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D } void ResourceImporterTexture::update_imports() { - if (EditorFileSystem::get_singleton()->is_scanning() || EditorFileSystem::get_singleton()->is_importing()) { return; // do nothing for now } @@ -91,7 +87,6 @@ void ResourceImporterTexture::update_imports() { } for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) { - Ref<ConfigFile> cf; cf.instance(); String src_path = String(E->key()) + ".import"; @@ -139,16 +134,13 @@ void ResourceImporterTexture::update_imports() { } String ResourceImporterTexture::get_importer_name() const { - return "texture"; } String ResourceImporterTexture::get_visible_name() const { - return "Texture2D"; } void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensions) const { - ImageLoader::get_recognized_extensions(p_extensions); } String ResourceImporterTexture::get_save_extension() const { @@ -156,12 +148,10 @@ String ResourceImporterTexture::get_save_extension() const { } String ResourceImporterTexture::get_resource_type() const { - return "StreamTexture2D"; } bool ResourceImporterTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - if (p_option == "compress/lossy_quality") { int compress_mode = int(p_options["compress/mode"]); if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) { @@ -192,7 +182,6 @@ int ResourceImporterTexture::get_preset_count() const { return 4; } String ResourceImporterTexture::get_preset_name(int p_idx) const { - static const char *preset_names[] = { "2D, Detect 3D", "2D", @@ -204,7 +193,6 @@ String ResourceImporterTexture::get_preset_name(int p_idx) const { } void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,VRAM Compressed,VRAM Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1)); @@ -226,10 +214,8 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, } void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) { - switch (p_compress_mode) { case COMPRESS_LOSSLESS: { - f->store_32(StreamTexture2D::DATA_FORMAT_LOSSLESS); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); @@ -237,7 +223,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image f->store_32(p_image->get_format()); for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) { - Vector<uint8_t> data = Image::lossless_packer(p_image->get_image_from_mipmap(i)); int data_len = data.size(); f->store_32(data_len); @@ -248,7 +233,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } break; case COMPRESS_LOSSY: { - f->store_32(StreamTexture2D::DATA_FORMAT_LOSSY); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); @@ -256,7 +240,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image f->store_32(p_image->get_format()); for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) { - Vector<uint8_t> data = Image::lossy_packer(p_image->get_image_from_mipmap(i), p_lossy_quality); int data_len = data.size(); f->store_32(data_len); @@ -266,7 +249,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } } break; case COMPRESS_VRAM_COMPRESSED: { - Ref<Image> image = p_image->duplicate(); image->compress_from_channels(p_compress_format, p_channels, p_lossy_quality); @@ -283,7 +265,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image f->store_buffer(r, dl); } break; case COMPRESS_VRAM_UNCOMPRESSED: { - f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); @@ -298,7 +279,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } break; case COMPRESS_BASIS_UNIVERSAL: { - f->store_32(StreamTexture2D::DATA_FORMAT_BASIS_UNIVERSAL); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); @@ -306,7 +286,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image f->store_32(p_image->get_format()); for (int i = 0; i < p_image->get_mipmap_count() + 1; i++) { - Vector<uint8_t> data = Image::basis_universal_packer(p_image->get_image_from_mipmap(i), p_channels); int data_len = data.size(); f->store_32(data_len); @@ -319,7 +298,6 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) { - FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); f->store_8('S'); @@ -396,7 +374,6 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String } Error ResourceImporterTexture::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) { - CompressMode compress_mode = CompressMode(int(p_options["compress/mode"])); float lossy = p_options["compress/lossy_quality"]; int pack_channels = p_options["compress/channel_pack"]; @@ -440,7 +417,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } else { - int new_height = size_limit; int new_width = image->get_width() * new_height / image->get_height(); @@ -501,7 +477,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String bool has_alpha = image->detect_alpha() != Image::ALPHA_NONE; if (is_hdr && can_compress_hdr) { - if (has_alpha) { //can compress hdr, but hdr with alpha is not compressible if (hdr_compression == 2) { @@ -542,7 +517,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { - _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); @@ -555,7 +529,6 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { - _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("pvrtc"); formats_imported.push_back("pvrtc"); @@ -589,7 +562,6 @@ const char *ResourceImporterTexture::compression_formats[] = { nullptr }; String ResourceImporterTexture::get_import_settings_string() const { - String s; int index = 0; @@ -606,7 +578,6 @@ String ResourceImporterTexture::get_import_settings_string() const { } bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) const { - //will become invalid if formats are missing to import Dictionary metadata = ResourceFormatImporter::get_singleton()->get_resource_metadata(p_path); @@ -644,7 +615,6 @@ bool ResourceImporterTexture::are_import_settings_valid(const String &p_path) co ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr; ResourceImporterTexture::ResourceImporterTexture() { - singleton = this; StreamTexture2D::request_3d_callback = _texture_reimport_3d; StreamTexture2D::request_roughness_callback = _texture_reimport_roughness; diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index da8ce3c0a8..b770d240eb 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -60,7 +60,6 @@ protected: Mutex mutex; struct MakeInfo { - int flags; String normal_path_for_roughness; RS::TextureDetectRoughnessChannel channel_for_roughness; diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp index 2765bb7fae..314c27b8e4 100644 --- a/editor/import/resource_importer_texture_atlas.cpp +++ b/editor/import/resource_importer_texture_atlas.cpp @@ -39,16 +39,13 @@ #include "scene/resources/texture.h" String ResourceImporterTextureAtlas::get_importer_name() const { - return "texture_atlas"; } String ResourceImporterTextureAtlas::get_visible_name() const { - return "TextureAtlas"; } void ResourceImporterTextureAtlas::get_recognized_extensions(List<String> *p_extensions) const { - ImageLoader::get_recognized_extensions(p_extensions); } @@ -57,12 +54,10 @@ String ResourceImporterTextureAtlas::get_save_extension() const { } String ResourceImporterTextureAtlas::get_resource_type() const { - return "Texture2D"; } bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - return true; } @@ -70,12 +65,10 @@ int ResourceImporterTextureAtlas::get_preset_count() const { return 0; } String ResourceImporterTextureAtlas::get_preset_name(int p_idx) const { - return String(); } void ResourceImporterTextureAtlas::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "atlas_file", PROPERTY_HINT_SAVE_FILE, "*.png"), "")); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_mode", PROPERTY_HINT_ENUM, "Region,Mesh2D"), 0)); } @@ -85,7 +78,6 @@ String ResourceImporterTextureAtlas::get_option_group_file() const { } Error ResourceImporterTextureAtlas::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) { - /* If this happens, it's because the atlas_file field was not filled, so just import a broken texture */ //use an xpm because it's size independent, the editor images are vector and size dependent @@ -103,7 +95,6 @@ Error ResourceImporterTextureAtlas::import(const String &p_source_file, const St } static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_transposed, Ref<Image> p_image, const Ref<Image> &p_src_image) { - int width = p_image->get_width(); int height = p_image->get_height(); int src_width = p_src_image->get_width(); @@ -113,7 +104,6 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr int y[3]; for (int j = 0; j < 3; j++) { - x[j] = vertices[j].x; y[j] = vertices[j].y; } @@ -140,7 +130,6 @@ static void _plot_triangle(Vector2 *vertices, const Vector2 &p_offset, bool p_tr for (int yi = y[0]; yi <= (y[2] > height - 1 ? height - 1 : y[2]); yi++) { if (yi >= 0) { for (int xi = (xf > 0 ? int(xf) : 0); xi <= (xt < width ? xt : width - 1); xi++) { - int px = xi, py = yi; int sx = px, sy = py; sx = CLAMP(sx, 0, src_width - 1); @@ -193,7 +182,6 @@ 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) { - ERR_FAIL_COND_V(p_source_file_options.size() == 0, ERR_BUG); //should never happen Vector<EditorAtlasPacker::Chart> charts; @@ -203,7 +191,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file int idx = 0; 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(); const Map<StringName, Variant> &options = E->get(); @@ -218,7 +205,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file int mode = options["import_mode"]; if (mode == IMPORT_MODE_REGION) { - pack_data.is_mesh = false; EditorAtlasPacker::Chart chart; @@ -254,14 +240,12 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file 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++) { - EditorAtlasPacker::Chart chart; chart.vertices = polygons[j]; chart.can_transpose = true; Vector<int> poly = Geometry::triangulate_polygon(polygons[j]); for (int i = 0; i < poly.size(); i += 3) { - EditorAtlasPacker::Chart::Face f; f.vertex[0] = poly[i + 0]; f.vertex[1] = poly[i + 1]; @@ -287,7 +271,6 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file new_atlas->create(atlas_width, atlas_height, false, Image::FORMAT_RGBA8); for (int i = 0; i < pack_data_files.size(); i++) { - PackData &pack_data = pack_data_files.write[i]; for (int j = 0; j < pack_data.chart_pieces.size(); j++) { @@ -324,7 +307,6 @@ 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++) { - PackData &pack_data = pack_data_files.write[idx]; Ref<Texture2D> texture; diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 71f81051bc..3ffc7b34af 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -39,16 +39,13 @@ const float TRIM_DB_LIMIT = -50; const int TRIM_FADE_OUT_FRAMES = 500; String ResourceImporterWAV::get_importer_name() const { - return "wav"; } String ResourceImporterWAV::get_visible_name() const { - return "Microsoft WAV"; } void ResourceImporterWAV::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("wav"); } String ResourceImporterWAV::get_save_extension() const { @@ -56,12 +53,10 @@ String ResourceImporterWAV::get_save_extension() const { } String ResourceImporterWAV::get_resource_type() const { - return "AudioStreamSample"; } bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) { return false; } @@ -73,12 +68,10 @@ int ResourceImporterWAV::get_preset_count() const { return 0; } String ResourceImporterWAV::get_preset_name(int p_idx) const { - return String(); } void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false)); @@ -90,7 +83,6 @@ void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int } Error ResourceImporterWAV::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) { - /* STEP 1, READ WAVE FILE */ Error err; @@ -104,7 +96,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s file->get_buffer((uint8_t *)&riff, 4); //RIFF if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') { - file->close(); memdelete(file); ERR_FAIL_V(ERR_FILE_UNRECOGNIZED); @@ -120,7 +111,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s file->get_buffer((uint8_t *)&wave, 4); //RIFF if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') { - file->close(); memdelete(file); ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Not a WAV file (no WAVE RIFF header)."); @@ -141,7 +131,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s Vector<float> data; while (!file->eof_reached()) { - /* chunk */ char chunkID[4]; file->get_buffer((uint8_t *)&chunkID, 4); //RIFF @@ -151,7 +140,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s uint32_t file_pos = file->get_position(); //save file pos, so we can skip to next chunk safely if (file->eof_reached()) { - //ERR_PRINT("EOF REACH"); break; } @@ -242,7 +230,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s uint32_t s = 0; for (int b = 0; b < (format_bits >> 3); b++) { - s |= ((uint32_t)file->get_8()) << (b * 8); } s <<= (32 - format_bits); @@ -322,12 +309,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s Vector<float> new_data; new_data.resize(new_data_frames * format_channels); for (int c = 0; c < format_channels; c++) { - float frac = .0f; int ipos = 0; for (int i = 0; i < new_data_frames; i++) { - //simple cubic interpolation should be enough. float mu = frac; @@ -370,20 +355,16 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s bool normalize = p_options["edit/normalize"]; if (normalize) { - float max = 0; for (int i = 0; i < data.size(); i++) { - float amp = Math::abs(data[i]); if (amp > max) max = amp; } if (max > 0) { - float mult = 1.0 / max; for (int i = 0; i < data.size(); i++) { - data.write[i] *= mult; } } @@ -392,7 +373,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s bool trim = p_options["edit/trim"]; if (trim && !loop && format_channels > 0) { - int first = 0; int last = (frames / format_channels) - 1; bool found = false; @@ -420,7 +400,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s Vector<float> new_data; new_data.resize((last - first) * format_channels); for (int i = first; i < last; i++) { - float fadeOutMult = 1; if (last - i < TRIM_FADE_OUT_FRAMES) { @@ -440,7 +419,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s bool make_loop = p_options["edit/loop"]; if (make_loop && !loop) { - loop = AudioStreamSample::LOOP_FORWARD; loop_begin = 0; loop_end = frames; @@ -450,7 +428,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s bool force_mono = p_options["force/mono"]; if (force_mono && format_channels == 2) { - Vector<float> new_data; new_data.resize(data.size() / 2); for (int i = 0; i < frames; i++) { @@ -463,7 +440,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s bool force_8_bit = p_options["force/8_bit"]; if (force_8_bit) { - is16 = false; } @@ -471,12 +447,10 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s AudioStreamSample::Format dst_format; if (compression == 1) { - dst_format = AudioStreamSample::FORMAT_IMA_ADPCM; if (format_channels == 1) { _compress_ima_adpcm(data, dst_data); } else { - //byte interleave Vector<float> left; Vector<float> right; @@ -510,7 +484,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s } } else { - dst_format = is16 ? AudioStreamSample::FORMAT_16_BITS : AudioStreamSample::FORMAT_8_BITS; dst_data.resize(data.size() * (is16 ? 2 : 1)); { @@ -518,7 +491,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s int ds = data.size(); for (int i = 0; i < ds; i++) { - if (is16) { int16_t v = CLAMP(data[i] * 32768, -32768, 32767); encode_uint16(v, &w[i * 2]); diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index bc2f023e6b..b48c5f4c32 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -99,7 +99,6 @@ public: if (i >= datamax) xm_sample = 0; else { - xm_sample = CLAMP(in[i] * 32767.0, -32768, 32767); /* if (xm_sample==32767 || xm_sample==-32768) @@ -121,9 +120,7 @@ public: } mask = 4; while (mask) { - if (diff >= step) { - nibble |= mask; diff -= step; vpdiff += step; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 22f6aedeaa..2d8069acea 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -44,7 +44,6 @@ public: bool checking; bool _set(const StringName &p_name, const Variant &p_value) { - if (values.has(p_name)) { values[p_name] = p_value; if (checking) { @@ -58,7 +57,6 @@ public: } bool _get(const StringName &p_name, Variant &r_ret) const { - if (values.has(p_name)) { r_ret = values[p_name]; return true; @@ -67,7 +65,6 @@ public: return false; } void _get_property_list(List<PropertyInfo> *p_list) const { - for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { if (!importer->get_option_visibility(E->get().name, values)) continue; @@ -92,7 +89,6 @@ public: }; void ImportDock::set_edit_path(const String &p_path) { - Ref<ConfigFile> config; config.instance(); Error err = config->load(p_path + ".import"); @@ -140,7 +136,6 @@ void ImportDock::set_edit_path(const String &p_path) { } void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { - List<ResourceImporter::ImportOption> options; params->importer->get_import_options(&options); @@ -150,7 +145,6 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { params->checked.clear(); for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) { params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name); @@ -164,14 +158,12 @@ void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { } void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { - clear(); // Use the value that is repeated the most. Map<String, Dictionary> value_frequency; for (int i = 0; i < p_paths.size(); i++) { - Ref<ConfigFile> config; config.instance(); Error err = config->load(p_paths[i] + ".import"); @@ -189,7 +181,6 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { config->get_section_keys("params", &keys); for (List<String>::Element *E = keys.front(); E; E = E->next()) { - if (!value_frequency.has(E->get())) { value_frequency[E->get()] = Dictionary(); } @@ -215,11 +206,9 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { params->checked.clear(); for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - params->properties.push_back(E->get().option); if (value_frequency.has(E->get().option.name)) { - Dictionary d = value_frequency[E->get().option.name]; int freq = 0; List<Variant> v; @@ -309,7 +298,6 @@ void ImportDock::_importer_selected(int i_idx) { } void ImportDock::_preset_selected(int p_idx) { - int item_id = preset->get_popup()->get_item_id(p_idx); switch (item_id) { @@ -325,7 +313,6 @@ void ImportDock::_preset_selected(int p_idx) { _update_preset_menu(); } break; case ITEM_LOAD_DEFAULT: { - ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name())); Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + params->importer->get_importer_name()); @@ -344,13 +331,11 @@ void ImportDock::_preset_selected(int p_idx) { params->update(); } break; case ITEM_CLEAR_DEFAULT: { - ProjectSettings::get_singleton()->set("importer_defaults/" + params->importer->get_importer_name(), Variant()); ProjectSettings::get_singleton()->save(); _update_preset_menu(); } break; default: { - List<ResourceImporter::ImportOption> options; params->importer->get_import_options(&options, p_idx); @@ -370,7 +355,6 @@ void ImportDock::_preset_selected(int p_idx) { } void ImportDock::clear() { - imported->set_text(""); import->set_disabled(true); import_as->clear(); @@ -383,19 +367,16 @@ void ImportDock::clear() { } static bool _find_owners(EditorFileSystemDirectory *efsd, const String &p_path) { - if (!efsd) return false; for (int i = 0; i < efsd->get_subdir_count(); i++) { - if (_find_owners(efsd->get_subdir(i), p_path)) { return true; } } for (int i = 0; i < efsd->get_file_count(); i++) { - Vector<String> deps = efsd->get_file_deps(i); if (deps.find(p_path) != -1) return true; @@ -404,7 +385,6 @@ static bool _find_owners(EditorFileSystemDirectory *efsd, const String &p_path) return false; } void ImportDock::_reimport_attempt() { - bool need_restart = false; bool used_in_resources = false; for (int i = 0; i < params->paths.size(); i++) { @@ -432,7 +412,6 @@ void ImportDock::_reimport_attempt() { } void ImportDock::_reimport_and_restart() { - EditorNode::get_singleton()->save_all_scenes(); EditorResourcePreview::get_singleton()->stop(); //don't try to re-create previews after import _reimport(); @@ -440,9 +419,7 @@ void ImportDock::_reimport_and_restart() { } void ImportDock::_reimport() { - for (int i = 0; i < params->paths.size(); i++) { - Ref<ConfigFile> config; config.instance(); Error err = config->load(params->paths[i] + ".import"); @@ -489,14 +466,11 @@ void ImportDock::_reimport() { void ImportDock::_notification(int p_what) { switch (p_what) { - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - imported->add_theme_style_override("normal", get_theme_stylebox("normal", "LineEdit")); } break; case NOTIFICATION_ENTER_TREE: { - import_opts->edit(params); label_warning->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor")); } break; @@ -511,19 +485,16 @@ void ImportDock::_property_toggled(const StringName &p_prop, bool p_checked) { } } void ImportDock::_bind_methods() { - ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport); } void ImportDock::initialize_import_options() const { - ERR_FAIL_COND(!import_opts || !params); import_opts->edit(params); } ImportDock::ImportDock() { - set_name("Import"); imported = memnew(Label); imported->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("normal", "LineEdit")); @@ -572,6 +543,5 @@ ImportDock::ImportDock() { } ImportDock::~ImportDock() { - memdelete(params); } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 3715547bdc..ab425aab40 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -85,7 +85,6 @@ void InspectorDock::_menu_option(int p_option) { current->get_property_list(&props); Map<RES, RES> duplicates; for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; @@ -93,10 +92,8 @@ void InspectorDock::_menu_option(int p_option) { if (v.is_ref()) { REF ref = v; if (ref.is_valid()) { - RES res = ref; if (res.is_valid()) { - if (!duplicates.has(res)) { duplicates[res] = res->duplicate(); } @@ -217,7 +214,6 @@ void InspectorDock::_prepare_history() { 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--) { - ObjectID id = editor_history->get_history_obj(i); Object *obj = ObjectDB::get_instance(id); if (!obj || already.has(id)) { @@ -342,7 +338,6 @@ void InspectorDock::_notification(int p_what) { } void InspectorDock::_bind_methods() { - ClassDB::bind_method("update_keying", &InspectorDock::update_keying); ClassDB::bind_method("_transform_keyed", &InspectorDock::_transform_keyed); // Still used by some connect_compat. @@ -376,7 +371,6 @@ void InspectorDock::clear() { } void InspectorDock::update(Object *p_object) { - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); backward_button->set_disabled(editor_history->is_at_beginning()); forward_button->set_disabled(editor_history->is_at_end()); @@ -442,12 +436,10 @@ void InspectorDock::update(Object *p_object) { p_object->get_method_list(&methods); if (!methods.empty()) { - bool found = false; List<MethodInfo>::Element *I = methods.front(); int i = 0; while (I) { - if (I->get().flags & METHOD_FLAG_EDITOR) { if (!found) { p->add_separator(); @@ -469,13 +461,10 @@ void InspectorDock::update_keying() { bool valid = false; if (AnimationPlayerEditor::singleton->get_track_editor()->has_keying()) { - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); if (editor_history->get_path_size() >= 1) { - Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0)); if (Object::cast_to<Node>(obj)) { - valid = true; } } diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 61b3239169..2a99a7db45 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -47,7 +47,6 @@ class EditorNode; class InspectorDock : public VBoxContainer { - GDCLASS(InspectorDock, VBoxContainer); enum MenuOptions { diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index 7bc67b54c1..0d795cc163 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -52,7 +52,6 @@ bool MultiNodeEdit::_set_impl(const StringName &p_name, const Variant &p_value, ur->create_action(TTR("MultiNode Set") + " " + String(name), UndoRedo::MERGE_ENDS); for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) continue; @@ -96,7 +95,6 @@ bool MultiNodeEdit::_get(const StringName &p_name, Variant &r_ret) const { } for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) continue; @@ -125,7 +123,6 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { List<PLData *> data_list; for (const List<NodePath>::Element *E = nodes.front(); E; E = E->next()) { - if (!es->has_node(E->get())) continue; @@ -137,7 +134,6 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { n->get_property_list(&plist, true); for (List<PropertyInfo>::Element *F = plist.front(); F; F = F->next()) { - if (F->get().name == "script") continue; //added later manually, since this is intercepted before being set (check Variant Object::get() ) if (!usage.has(F->get().name)) { @@ -157,7 +153,6 @@ void MultiNodeEdit::_get_property_list(List<PropertyInfo> *p_list) const { } for (List<PLData *>::Element *E = data_list.front(); E; E = E->next()) { - if (nc == E->get()->uses) { p_list->push_back(E->get()->info); } diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h index d3eefafcec..694dad76f1 100644 --- a/editor/multi_node_edit.h +++ b/editor/multi_node_edit.h @@ -34,7 +34,6 @@ #include "scene/main/node.h" class MultiNodeEdit : public Reference { - GDCLASS(MultiNodeEdit, Reference); List<NodePath> nodes; diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index cb0d9fa02b..2bdc0b12e9 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -69,7 +69,6 @@ #define HANDLE_HALF_SIZE 9.5 bool EditorNode3DGizmo::is_editable() const { - ERR_FAIL_COND_V(!spatial_node, false); Node *edited_root = spatial_node->get_tree()->get_edited_scene_root(); if (spatial_node == edited_root) @@ -84,9 +83,7 @@ bool EditorNode3DGizmo::is_editable() const { } void EditorNode3DGizmo::clear() { - for (int i = 0; i < instances.size(); i++) { - if (instances[i].instance.is_valid()) RS::get_singleton()->free(instances[i].instance); } @@ -100,7 +97,6 @@ void EditorNode3DGizmo::clear() { } void EditorNode3DGizmo::redraw() { - if (get_script_instance() && get_script_instance()->has_method("redraw")) { get_script_instance()->call("redraw"); return; @@ -111,7 +107,6 @@ void EditorNode3DGizmo::redraw() { } 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); } @@ -121,7 +116,6 @@ String EditorNode3DGizmo::get_handle_name(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); } @@ -131,7 +125,6 @@ bool EditorNode3DGizmo::is_handle_highlighted(int p_idx) const { } 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); } @@ -141,7 +134,6 @@ Variant EditorNode3DGizmo::get_handle_value(int p_idx) { } 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); return; @@ -152,7 +144,6 @@ void EditorNode3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 & } 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); return; @@ -163,13 +154,11 @@ void EditorNode3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool } void EditorNode3DGizmo::set_spatial_node(Node3D *p_node) { - ERR_FAIL_NULL(p_node); spatial_node = p_node; } void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) { - instance = RS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world_3d()->get_scenario()); RS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); if (skin_reference.is_valid()) { @@ -183,7 +172,6 @@ void EditorNode3DGizmo::Instance::create_instance(Node3D *p_base, bool p_hidden) } 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; @@ -236,7 +224,6 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate if (p_billboard) { float md = 0; for (int i = 0; i < p_lines.size(); i++) { - md = MAX(0, p_lines[i].length()); } if (md) { @@ -255,7 +242,6 @@ void EditorNode3DGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mate } void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) { - ERR_FAIL_COND(!spatial_node); Instance ins; @@ -297,7 +283,6 @@ void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float md = 0; for (int i = 0; i < vs.size(); i++) { - md = MAX(0, vs[i].length()); } if (md) { @@ -325,17 +310,14 @@ void EditorNode3DGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh } void EditorNode3DGizmo::add_collision_segments(const Vector<Vector3> &p_lines) { - int from = collision_segments.size(); collision_segments.resize(from + p_lines.size()); for (int i = 0; i < p_lines.size(); i++) { - collision_segments.write[from + i] = p_lines[i]; } } void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard, bool p_secondary) { - billboard_handle = p_billboard; if (!is_selected() || !is_editable()) @@ -355,7 +337,6 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< colors.resize(p_handles.size()); Color *w = colors.ptrw(); for (int i = 0; i < p_handles.size(); i++) { - Color col(1, 1, 1, 1); if (is_handle_highlighted(i)) col = Color(0, 0, 1, 0.9); @@ -373,7 +354,6 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< if (p_billboard) { float md = 0; for (int i = 0; i < p_handles.size(); i++) { - md = MAX(0, p_handles[i].length()); } if (md) { @@ -396,7 +376,6 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref< handles.write[i + chs] = p_handles[i]; } } else { - int chs = secondary_handles.size(); secondary_handles.resize(chs + p_handles.size()); for (int i = 0; i < p_handles.size(); i++) { @@ -428,7 +407,6 @@ void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, } 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); @@ -444,7 +422,6 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector bool any_out = false; for (int j = 0; j < fc; j++) { - if (p[j].is_point_over(origin)) { any_out = true; break; @@ -455,7 +432,6 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector } if (collision_segments.size()) { - const Plane *p = p_frustum.ptr(); int fc = p_frustum.size(); @@ -504,7 +480,6 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector } 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); @@ -512,7 +487,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, return false; if (r_gizmo_handle && !hidden) { - Transform t = spatial_node->get_global_transform(); if (billboard_handle) { t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); @@ -522,15 +496,12 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, int idx = -1; for (int i = 0; i < secondary_handles.size(); i++) { - Vector3 hpos = t.xform(secondary_handles[i]); Vector2 p = p_camera->unproject_position(hpos); if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); if (dp < min_d) { - r_pos = t.xform(hpos); r_normal = p_camera->get_transform().basis.get_axis(2); min_d = dp; @@ -540,7 +511,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (p_sec_first && idx != -1) { - *r_gizmo_handle = idx; return true; } @@ -548,15 +518,12 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, min_d = 1e20; for (int i = 0; i < handles.size(); i++) { - Vector3 hpos = t.xform(handles[i]); Vector2 p = p_camera->unproject_position(hpos); if (p.distance_to(p_point) < HANDLE_HALF_SIZE) { - real_t dp = p_camera->get_transform().origin.distance_to(hpos); if (dp < min_d) { - r_pos = t.xform(hpos); r_normal = p_camera->get_transform().basis.get_axis(2); min_d = dp; @@ -572,7 +539,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (selectable_icon_size > 0.0f) { - Transform t = spatial_node->get_global_transform(); Vector3 camera_position = p_camera->get_camera_transform().origin; if (camera_position.distance_squared_to(t.origin) > 0.01) { @@ -618,7 +584,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (collision_segments.size()) { - Plane camp(p_camera->get_transform().origin, (-p_camera->get_transform().basis.get_axis(2)).normalized()); int vc = collision_segments.size(); @@ -632,7 +597,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, float cpd = 1e20; for (int i = 0; i < vc / 2; i++) { - Vector3 a = t.xform(vptr[i * 2 + 0]); Vector3 b = t.xform(vptr[i * 2 + 1]); Vector2 s[2]; @@ -644,11 +608,9 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, float pd = p.distance_to(p_point); if (pd < cpd) { - float d = s[0].distance_to(s[1]); Vector3 tcp; if (d > 0) { - float d2 = s[0].distance_to(p) / d; tcp = a + (b - a) * d2; @@ -664,7 +626,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (cpd < 8) { - r_pos = cp; r_normal = -p_camera->project_ray_normal(p_point); return true; @@ -686,7 +647,6 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Vector3 rpos, rnorm; if (collision_mesh->intersect_ray(ray_from, ray_dir, rpos, rnorm)) { - r_pos = gt.xform(rpos); r_normal = gt.basis.xform(rnorm).normalized(); return true; @@ -697,13 +657,11 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } void EditorNode3DGizmo::create() { - ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(valid); valid = true; for (int i = 0; i < instances.size(); i++) { - instances.write[i].create_instance(spatial_node, hidden); } @@ -711,7 +669,6 @@ void EditorNode3DGizmo::create() { } void EditorNode3DGizmo::transform() { - ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { @@ -720,12 +677,10 @@ void EditorNode3DGizmo::transform() { } void EditorNode3DGizmo::free() { - ERR_FAIL_COND(!spatial_node); ERR_FAIL_COND(!valid); for (int i = 0; i < instances.size(); i++) { - if (instances[i].instance.is_valid()) RS::get_singleton()->free(instances[i].instance); instances.write[i].instance = RID(); @@ -749,7 +704,6 @@ void EditorNode3DGizmo::set_plugin(EditorNode3DGizmoPlugin *p_plugin) { } void EditorNode3DGizmo::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorNode3DGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorNode3DGizmo::add_mesh, DEFVAL(false), DEFVAL(Ref<SkinReference>()), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorNode3DGizmo::add_collision_segments); @@ -789,14 +743,12 @@ EditorNode3DGizmo::EditorNode3DGizmo() { } EditorNode3DGizmo::~EditorNode3DGizmo() { - if (gizmo_plugin != nullptr) gizmo_plugin->unregister_gizmo(this); clear(); } Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, handles.size(), Vector3()); return handles[p_idx]; @@ -805,7 +757,6 @@ Vector3 EditorNode3DGizmo::get_handle_pos(int p_idx) const { //// light gizmo 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); @@ -832,7 +783,6 @@ int Light3DGizmoPlugin::get_priority() const { } String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - if (p_idx == 0) return "Radius"; else @@ -840,7 +790,6 @@ String Light3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int } Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_idx == 0) return light->get_param(Light3D::PARAM_RANGE); @@ -851,14 +800,12 @@ Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_i } static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform &p_arc_xform) { - //bleh, discrete is simpler static const int arc_test_points = 64; float min_d = 1e20; Vector3 min_p; for (int i = 0; i < arc_test_points; i++) { - float a = i * Math_PI * 0.5 / arc_test_points; float an = (i + 1) * Math_PI * 0.5 / arc_test_points; Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius; @@ -880,7 +827,6 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec } void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Transform gt = light->get_global_transform(); Transform gi = gt.affine_inverse(); @@ -890,7 +836,6 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; if (p_idx == 0) { - 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); @@ -905,12 +850,10 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer 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)); Vector3 inters; if (cp.intersects_ray(ray_from, ray_dir, &inters)) { - float r = inters.distance_to(gt.origin); if (Node3DEditor::get_singleton()->is_snap_enabled()) { r = Math::stepify(r, Node3DEditor::get_singleton()->get_translate_snap()); @@ -921,28 +864,23 @@ void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer } } else if (p_idx == 1) { - float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], light->get_param(Light3D::PARAM_RANGE), gt); light->set_param(Light3D::PARAM_SPOT_ANGLE, CLAMP(a, 0.01, 89.99)); } } void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); if (p_cancel) { - light->set_param(p_idx == 0 ? Light3D::PARAM_RANGE : Light3D::PARAM_SPOT_ANGLE, p_restore); } else if (p_idx == 0) { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_RANGE, light->get_param(Light3D::PARAM_RANGE)); ur->add_undo_method(light, "set_param", Light3D::PARAM_RANGE, p_restore); ur->commit_action(); } else if (p_idx == 1) { - UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); ur->create_action(TTR("Change Light Radius")); ur->add_do_method(light, "set_param", Light3D::PARAM_SPOT_ANGLE, light->get_param(Light3D::PARAM_SPOT_ANGLE)); @@ -952,7 +890,6 @@ void Light3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, co } void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); Color color = light->get_color(); @@ -962,7 +899,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { p_gizmo->clear(); 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); @@ -1000,7 +936,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } 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); @@ -1012,7 +947,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> points_billboard; for (int i = 0; i < 120; i++) { - // Create a circle const float ra = Math::deg2rad((float)(i * 3)); const float rb = Math::deg2rad((float)((i + 1) * 3)); @@ -1042,7 +976,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } 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); const Ref<Material> icon = get_material("light_spot_icon", p_gizmo); @@ -1056,7 +989,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { float d = r * Math::cos(Math::deg2rad(sl->get_param(Light3D::PARAM_SPOT_ANGLE))); for (int i = 0; i < 120; i++) { - // Draw a circle const float ra = Math::deg2rad((float)(i * 3)); const float rb = Math::deg2rad((float)((i + 1) * 3)); @@ -1095,7 +1027,6 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// player gizmo AudioStreamPlayer3DGizmoPlugin::AudioStreamPlayer3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); create_icon_material("stream_player_3d_icon", Node3DEditor::get_singleton()->get_theme_icon("Gizmo3DSamplePlayer", "EditorIcons")); @@ -1117,7 +1048,6 @@ int AudioStreamPlayer3DGizmoPlugin::get_priority() const { } String AudioStreamPlayer3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - return "Emission Radius"; } @@ -1127,7 +1057,6 @@ Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gi } 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()); Transform gt = player->get_global_transform(); @@ -1144,7 +1073,6 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int float closest_angle = 1e20; for (int i = 0; i < 180; i++) { - float a = i * Math_PI / 180.0; float an = (i + 1) * Math_PI / 180.0; @@ -1166,15 +1094,12 @@ void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int } void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); if (p_cancel) { - player->set_emission_angle(p_restore); } else { - 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()); @@ -1184,7 +1109,6 @@ void AudioStreamPlayer3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, i } void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1192,7 +1116,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { const Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo); if (player->is_emission_angle_enabled()) { - const float pc = player->get_emission_angle(); const float ofs = -Math::cos(Math::deg2rad(pc)); const float radius = Math::sin(Math::deg2rad(pc)); @@ -1201,7 +1124,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { points_primary.resize(200); for (int i = 0; i < 100; i++) { - const float a = i * 2.0 * Math_PI / 100.0; const float an = (i + 1) * 2.0 * Math_PI / 100.0; @@ -1219,7 +1141,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { points_secondary.resize(16); for (int i = 0; i < 8; i++) { - const float a = i * 2.0 * Math_PI / 8.0; const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); @@ -1242,7 +1163,6 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ////// Camera3DGizmoPlugin::Camera3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/camera", Color(0.8, 0.4, 0.8)); create_material("camera_material", gizmo_color); @@ -1262,7 +1182,6 @@ int Camera3DGizmoPlugin::get_priority() const { } String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { @@ -1273,19 +1192,16 @@ String Camera3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, in } Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { return camera->get_fov(); } else { - return camera->get_size(); } } void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); Transform gt = camera->get_global_transform(); @@ -1301,7 +1217,6 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came 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)); } else { - 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; @@ -1316,13 +1231,10 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came } void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { - if (p_cancel) { - camera->set("fov", p_restore); } else { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); @@ -1333,9 +1245,7 @@ void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, c } } else { - if (p_cancel) { - camera->set("size", p_restore); } else { UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); @@ -1348,7 +1258,6 @@ void Camera3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, c } void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1381,9 +1290,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } switch (camera->get_projection()) { - case Camera3D::PROJECTION_PERSPECTIVE: { - // The real FOV is halved for accurate representation float fov = camera->get_fov() / 2.0; @@ -1405,7 +1312,6 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } break; case Camera3D::PROJECTION_ORTHOGONAL: { - float size = camera->get_size(); float hsize = size * 0.5; @@ -1517,7 +1423,6 @@ bool MeshInstance3DGizmoPlugin::can_be_hidden() const { } void MeshInstance3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - MeshInstance3D *mesh = Object::cast_to<MeshInstance3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1554,7 +1459,6 @@ bool Sprite3DGizmoPlugin::can_be_hidden() const { } void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Sprite3D *sprite = Object::cast_to<Sprite3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1613,7 +1517,6 @@ int Position3DGizmoPlugin::get_priority() const { } void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - p_gizmo->clear(); p_gizmo->add_mesh(pos3d_mesh); p_gizmo->add_collision_segments(cursor_points); @@ -1622,7 +1525,6 @@ void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ///// 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); } @@ -1640,7 +1542,6 @@ int Skeleton3DGizmoPlugin::get_priority() const { } void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Skeleton3D *skel = Object::cast_to<Skeleton3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -1672,7 +1573,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Color rootcolor = Color(0.4, 1.0, 0.4, 0.1); for (int i_bone = 0; i_bone < skel->get_bone_count(); i_bone++) { - int i = skel->get_process_order(i_bone); int parent = skel->get_bone_parent(i); @@ -1700,7 +1600,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 points[4]; int pointidx = 0; for (int j = 0; j < 3; j++) { - bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); @@ -1723,7 +1622,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } for (int k = 0; k < 2; k++) { - if (k == 1) axis = -axis; Vector3 point = v0 + d * dist * 0.2; @@ -1755,7 +1653,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SWAP(points[1], points[2]); for (int j = 0; j < 4; j++) { - bones.write[0] = parent; surface_tool->add_bones(bones); surface_tool->add_weights(weights); @@ -1780,7 +1677,6 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { surface_tool->add_vertex(v1); */ } else { - grests.write[i] = skel->get_bone_rest(i); bones.write[0] = i; } @@ -1847,7 +1743,6 @@ int PhysicalBone3DGizmoPlugin::get_priority() const { } void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - p_gizmo->clear(); PhysicalBone3D *physical_bone = Object::cast_to<PhysicalBone3D>(p_gizmo->get_spatial_node()); @@ -1871,11 +1766,9 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { switch (physical_bone->get_joint_type()) { case PhysicalBone3D::JOINT_TYPE_PIN: { - Joint3DGizmoPlugin::CreatePinJointGizmo(physical_bone->get_joint_offset(), points); } break; case PhysicalBone3D::JOINT_TYPE_CONE: { - const PhysicalBone3D::ConeJointData *cjd(static_cast<const PhysicalBone3D::ConeJointData *>(physical_bone->get_joint_data())); Joint3DGizmoPlugin::CreateConeTwistJointGizmo( physical_bone->get_joint_offset(), @@ -1888,7 +1781,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { &points); } break; case PhysicalBone3D::JOINT_TYPE_HINGE: { - const PhysicalBone3D::HingeJointData *hjd(static_cast<const PhysicalBone3D::HingeJointData *>(physical_bone->get_joint_data())); Joint3DGizmoPlugin::CreateHingeJointGizmo( physical_bone->get_joint_offset(), @@ -1903,7 +1795,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { &points); } break; case PhysicalBone3D::JOINT_TYPE_SLIDER: { - const PhysicalBone3D::SliderJointData *sjd(static_cast<const PhysicalBone3D::SliderJointData *>(physical_bone->get_joint_data())); Joint3DGizmoPlugin::CreateSliderJointGizmo( physical_bone->get_joint_offset(), @@ -1919,7 +1810,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { &points); } break; case PhysicalBone3D::JOINT_TYPE_6DOF: { - const PhysicalBone3D::SixDOFJointData *sdofjd(static_cast<const PhysicalBone3D::SixDOFJointData *>(physical_bone->get_joint_data())); Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( physical_bone->get_joint_offset(), @@ -1966,7 +1856,6 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ///// 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); const float gizmo_value = gizmo_color.get_v(); @@ -1987,7 +1876,6 @@ int RayCast3DGizmoPlugin::get_priority() const { } void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - RayCast3D *raycast = Object::cast_to<RayCast3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2007,7 +1895,6 @@ void RayCast3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ///// void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - SpringArm3D *spring_arm = Object::cast_to<SpringArm3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2043,7 +1930,6 @@ int SpringArm3DGizmoPlugin::get_priority() const { ///// 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); } @@ -2061,7 +1947,6 @@ int VehicleWheel3DGizmoPlugin::get_priority() const { } void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - VehicleWheel3D *car_wheel = Object::cast_to<VehicleWheel3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2071,7 +1956,6 @@ void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { float r = car_wheel->get_radius(); const int skip = 10; for (int i = 0; i <= 360; i += skip) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + skip); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r; @@ -2211,7 +2095,6 @@ int VisibilityNotifier3DGizmoPlugin::get_priority() const { } String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { case 0: return "Size X"; @@ -2231,12 +2114,10 @@ String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo } Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); return notifier->get_aabb(); } void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); Transform gt = notifier->get_global_transform(); @@ -2258,7 +2139,6 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int axis[p_idx] = 1.0; if (move) { - Vector3 ra, rb; Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); @@ -2289,7 +2169,6 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int } void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2305,7 +2184,6 @@ void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, } void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2323,7 +2201,6 @@ void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = aabb.position[i] + aabb.size[i]; ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5; @@ -2333,7 +2210,6 @@ void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 center = aabb.position + aabb.size * 0.5; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = 1.0; handles.push_back(center + ax); @@ -2409,7 +2285,6 @@ bool GPUParticles3DGizmoPlugin::is_selectable_when_hidden() const { } String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { case 0: return "Size X"; @@ -2428,12 +2303,10 @@ String GPUParticles3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_giz return ""; } Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); return particles->get_visibility_aabb(); } void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); Transform gt = particles->get_global_transform(); @@ -2454,7 +2327,6 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx axis[p_idx] = 1.0; if (move) { - Vector3 ra, rb; Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); @@ -2485,7 +2357,6 @@ void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx } void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); if (p_cancel) { @@ -2501,7 +2372,6 @@ void GPUParticles3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_ } void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2519,7 +2389,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = aabb.position[i] + aabb.size[i]; ax[(i + 1) % 3] = aabb.position[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5; @@ -2529,7 +2398,6 @@ void GPUParticles3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 center = aabb.position + aabb.size * 0.5; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = 1.0; handles.push_back(center + ax); @@ -2580,7 +2448,6 @@ int ReflectionProbeGizmoPlugin::get_priority() const { } String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { case 0: return "Extents X"; @@ -2599,12 +2466,10 @@ String ReflectionProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gi return ""; } 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(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(); @@ -2634,7 +2499,6 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id extents[p_idx] = d; probe->set_extents(extents); } else { - p_idx -= 3; Vector3 origin = probe->get_origin_offset(); @@ -2662,7 +2526,6 @@ void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_id } 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()); AABB restore = p_restore; @@ -2683,7 +2546,6 @@ void ReflectionProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p } void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2712,14 +2574,12 @@ void ReflectionProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = aabb.position[i] + aabb.size[i]; handles.push_back(ax); } for (int i = 0; i < 3; i++) { - Vector3 orig_handle = probe->get_origin_offset(); orig_handle[i] -= 0.25; lines.push_back(orig_handle); @@ -2769,7 +2629,6 @@ int DecalGizmoPlugin::get_priority() const { } String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { case 0: return "Extents X"; @@ -2782,12 +2641,10 @@ String DecalGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p 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(); @@ -2818,7 +2675,6 @@ void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3 } 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; @@ -2836,7 +2692,6 @@ void DecalGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, cons } void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -2870,7 +2725,6 @@ void DecalGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = aabb.position[i] + aabb.size[i]; handles.push_back(ax); @@ -2913,7 +2767,6 @@ int GIProbeGizmoPlugin::get_priority() const { } String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - switch (p_idx) { case 0: return "Extents X"; @@ -2926,12 +2779,10 @@ String GIProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int return ""; } 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(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); Transform gt = probe->get_global_transform(); @@ -2962,7 +2813,6 @@ void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camer } 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()); Vector3 restore = p_restore; @@ -2980,7 +2830,6 @@ void GIProbeGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, co } void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); Ref<Material> material = get_material("gi_probe_material", p_gizmo); @@ -3010,9 +2859,7 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { lines.clear(); for (int i = 1; i < subdiv; i++) { - for (int j = 0; j < 3; j++) { - if (cell_size * i > aabb.size[j]) { continue; } @@ -3026,7 +2873,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { tb[j_n2] = 1.0; for (int k = 0; k < 4; k++) { - Vector3 from = aabb.position, to = aabb.position; from[j] += cell_size * i; to[j] += cell_size * i; @@ -3034,7 +2880,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { if (k & 1) { to[j_n1] += aabb.size[j_n1]; } else { - to[j_n2] += aabb.size[j_n2]; } @@ -3054,7 +2899,6 @@ void GIProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = aabb.position[i] + aabb.size[i]; handles.push_back(ax); @@ -3089,11 +2933,9 @@ BakedLightmapGizmoPlugin::BakedLightmapGizmoPlugin() { } String BakedLightmapGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - return ""; } Variant BakedLightmapGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - return Variant(); } void BakedLightmapGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { @@ -3115,7 +2957,6 @@ int BakedLightmapGizmoPlugin::get_priority() const { } void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Ref<Material> icon = get_material("baked_indirect_light_icon", p_gizmo); BakedLightmap *baker = Object::cast_to<BakedLightmap>(p_gizmo->get_spatial_node()); Ref<BakedLightmapData> data = baker->get_light_data(); @@ -3146,10 +2987,8 @@ void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<int> tetrahedrons = data->get_capture_tetrahedra(); for (int i = 0; i < tetrahedrons.size(); i += 4) { - for (int j = 0; j < 4; j++) { for (int k = j + 1; k < 4; k++) { - Vector2i pair; pair.x = tetrahedrons[i + j]; pair.y = tetrahedrons[i + k]; @@ -3181,7 +3020,6 @@ void BakedLightmapGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { float radius = 0.3; for (int p = 0; p < points.size(); p++) { - int vertex_base = vertices.size(); Vector3 sh_col[9]; for (int i = 0; i < 9; i++) { @@ -3274,11 +3112,9 @@ LightmapProbeGizmoPlugin::LightmapProbeGizmoPlugin() { } String LightmapProbeGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - return ""; } Variant LightmapProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - return Variant(); } void LightmapProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { @@ -3300,7 +3136,6 @@ int LightmapProbeGizmoPlugin::get_priority() const { } void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - Ref<Material> material_lines = get_material("lightprobe_lines", p_gizmo); p_gizmo->clear(); @@ -3384,7 +3219,6 @@ int CollisionShape3DGizmoPlugin::get_priority() const { } String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { - const CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3392,27 +3226,22 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g return ""; if (Object::cast_to<SphereShape3D>(*s)) { - return "Radius"; } if (Object::cast_to<BoxShape3D>(*s)) { - return "Extents"; } if (Object::cast_to<CapsuleShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; } if (Object::cast_to<CylinderShape3D>(*s)) { - return p_idx == 0 ? "Radius" : "Height"; } if (Object::cast_to<RayShape3D>(*s)) { - return "Length"; } @@ -3420,7 +3249,6 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g } Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3428,31 +3256,26 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo return Variant(); if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape3D> ss = s; return ss->get_radius(); } if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape3D> bs = s; return bs->get_extents(); } if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape3D> cs2 = s; return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape3D> cs2 = s; return p_idx == 0 ? cs2->get_radius() : cs2->get_height(); } if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape3D> cs2 = s; return cs2->get_length(); } @@ -3460,7 +3283,6 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo return Variant(); } void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3476,7 +3298,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; if (Object::cast_to<SphereShape3D>(*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); @@ -3492,7 +3313,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } if (Object::cast_to<RayShape3D>(*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); @@ -3508,7 +3328,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } if (Object::cast_to<BoxShape3D>(*s)) { - Vector3 axis; axis[p_idx] = 1.0; Ref<BoxShape3D> bs = s; @@ -3528,7 +3347,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } if (Object::cast_to<CapsuleShape3D>(*s)) { - Vector3 axis; axis[p_idx == 0 ? 0 : 2] = 1.0; Ref<CapsuleShape3D> cs2 = s; @@ -3552,7 +3370,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } if (Object::cast_to<CylinderShape3D>(*s)) { - Vector3 axis; axis[p_idx == 0 ? 0 : 1] = 1.0; Ref<CylinderShape3D> cs2 = s; @@ -3573,7 +3390,6 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i } } void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); Ref<Shape3D> s = cs->get_shape(); @@ -3581,7 +3397,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int return; if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape3D> ss = s; if (p_cancel) { ss->set_radius(p_restore); @@ -3596,7 +3411,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape3D> ss = s; if (p_cancel) { ss->set_extents(p_restore); @@ -3611,7 +3425,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape3D> ss = s; if (p_cancel) { if (p_idx == 0) @@ -3636,7 +3449,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape3D> ss = s; if (p_cancel) { if (p_idx == 0) @@ -3665,7 +3477,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape3D> ss = s; if (p_cancel) { ss->set_length(p_restore); @@ -3680,7 +3491,6 @@ void CollisionShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int } } void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - CollisionShape3D *cs = Object::cast_to<CollisionShape3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -3694,14 +3504,12 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Ref<Material> handles_material = get_material("handles"); if (Object::cast_to<SphereShape3D>(*s)) { - Ref<SphereShape3D> sp = s; float r = sp->get_radius(); Vector<Vector3> points; for (int i = 0; i <= 360; i++) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r; @@ -3718,7 +3526,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> collision_segments; for (int i = 0; i < 64; i++) { - float ra = i * Math_PI * 2.0 / 64.0; float rb = (i + 1) * Math_PI * 2.0 / 64.0; Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r; @@ -3740,7 +3547,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<BoxShape3D>(*s)) { - Ref<BoxShape3D> bs = s; Vector<Vector3> lines; AABB aabb; @@ -3757,7 +3563,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> handles; for (int i = 0; i < 3; i++) { - Vector3 ax; ax[i] = bs->get_extents()[i]; handles.push_back(ax); @@ -3769,7 +3574,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<CapsuleShape3D>(*s)) { - Ref<CapsuleShape3D> cs2 = s; float radius = cs2->get_radius(); float height = cs2->get_height(); @@ -3778,7 +3582,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; @@ -3791,7 +3594,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { points.push_back(Vector3(b.x, 0, b.y) - d); if (i % 90 == 0) { - points.push_back(Vector3(a.x, 0, a.y) + d); points.push_back(Vector3(a.x, 0, a.y) - d); } @@ -3809,7 +3611,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> collision_segments; for (int i = 0; i < 64; i++) { - float ra = i * Math_PI * 2.0 / 64.0; float rb = (i + 1) * Math_PI * 2.0 / 64.0; Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; @@ -3822,7 +3623,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { collision_segments.push_back(Vector3(b.x, 0, b.y) - d); if (i % 16 == 0) { - collision_segments.push_back(Vector3(a.x, 0, a.y) + d); collision_segments.push_back(Vector3(a.x, 0, a.y) - d); } @@ -3844,7 +3644,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<CylinderShape3D>(*s)) { - Ref<CylinderShape3D> cs2 = s; float radius = cs2->get_radius(); float height = cs2->get_height(); @@ -3853,7 +3652,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector3 d(0, height * 0.5, 0); for (int i = 0; i < 360; i++) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + 1); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; @@ -3866,7 +3664,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { points.push_back(Vector3(b.x, 0, b.y) - d); if (i % 90 == 0) { - points.push_back(Vector3(a.x, 0, a.y) + d); points.push_back(Vector3(a.x, 0, a.y) - d); } @@ -3877,7 +3674,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> collision_segments; for (int i = 0; i < 64; i++) { - float ra = i * Math_PI * 2.0 / 64.0; float rb = (i + 1) * Math_PI * 2.0 / 64.0; Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius; @@ -3890,7 +3686,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { collision_segments.push_back(Vector3(b.x, 0, b.y) - d); if (i % 16 == 0) { - collision_segments.push_back(Vector3(a.x, 0, a.y) + d); collision_segments.push_back(Vector3(a.x, 0, a.y) - d); } @@ -3905,7 +3700,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<WorldMarginShape3D>(*s)) { - Ref<WorldMarginShape3D> ps = s; Plane p = ps->get_plane(); Vector<Vector3> points; @@ -3936,11 +3730,9 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<ConvexPolygonShape3D>(*s)) { - Vector<Vector3> points = Object::cast_to<ConvexPolygonShape3D>(*s)->get_points(); if (points.size() > 3) { - Vector<Vector3> varr = Variant(points); Geometry::MeshData md; Error err = QuickHull::build(varr, md); @@ -3959,7 +3751,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<ConcavePolygonShape3D>(*s)) { - Ref<ConcavePolygonShape3D> cs2 = s; Ref<ArrayMesh> mesh = cs2->get_debug_mesh(); p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); @@ -3967,7 +3758,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<RayShape3D>(*s)) { - Ref<RayShape3D> rs = s; Vector<Vector3> points; @@ -3981,7 +3771,6 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } if (Object::cast_to<HeightMapShape3D>(*s)) { - Ref<HeightMapShape3D> hms = s; Ref<ArrayMesh> mesh = hms->get_debug_mesh(); @@ -4012,7 +3801,6 @@ int CollisionPolygon3DGizmoPlugin::get_priority() const { } void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - CollisionPolygon3D *polygon = Object::cast_to<CollisionPolygon3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); @@ -4022,7 +3810,6 @@ void CollisionPolygon3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> lines; for (int i = 0; i < points.size(); i++) { - int n = (i + 1) % points.size(); lines.push_back(Vector3(points[i].x, points[i].y, depth)); lines.push_back(Vector3(points[n].x, points[n].y, depth)); @@ -4061,7 +3848,6 @@ int NavigationRegion3DGizmoPlugin::get_priority() const { } void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - NavigationRegion3D *navmesh = Object::cast_to<NavigationRegion3D>(p_gizmo->get_spatial_node()); Ref<Material> edge_material = get_material("navigation_edge_material", p_gizmo); @@ -4102,11 +3888,9 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { int tidx = 0; for (List<Face3>::Element *E = faces.front(); E; E = E->next()) { - const Face3 &f = E->get(); for (int j = 0; j < 3; j++) { - tw[tidx++] = f.vertex[j]; _EdgeKey ek; ek.from = f.vertex[j].snapped(Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON)); @@ -4117,11 +3901,9 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Map<_EdgeKey, bool>::Element *F = edge_map.find(ek); if (F) { - F->get() = false; } else { - edge_map[ek] = true; } } @@ -4130,7 +3912,6 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> lines; for (Map<_EdgeKey, bool>::Element *E = edge_map.front(); E; E = E->next()) { - if (E->get()) { lines.push_back(E->key().from); lines.push_back(E->key().to); @@ -4184,7 +3965,6 @@ Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Tra } Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform) { - switch (p_axis) { case Vector3::AXIS_X: return look_body_toward_x(joint_transform, body_transform); @@ -4198,7 +3978,6 @@ Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform } Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform) { - const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4230,7 +4009,6 @@ Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, } Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform) { - const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4262,7 +4040,6 @@ Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, } Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform) { - const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4294,14 +4071,11 @@ Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, } void JointGizmosDrawer::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) { - if (p_limit_lower == p_limit_upper) { - r_points.push_back(p_offset.translated(Vector3()).origin); r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin); } else { - if (p_limit_lower > p_limit_upper) { p_limit_lower = -Math_PI; p_limit_upper = Math_PI; @@ -4310,7 +4084,6 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const const int points = 32; for (int i = 0; i < points; i++) { - real_t s = p_limit_lower + i * (p_limit_upper - p_limit_lower) / points; real_t n = p_limit_lower + (i + 1) * (p_limit_upper - p_limit_lower) / points; @@ -4360,14 +4133,12 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const } void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) { - float r = 1.0; float w = r * Math::sin(p_swing); float d = r * Math::cos(p_swing); //swing for (int i = 0; i < 360; i += 10) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + 10); Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * w; @@ -4377,7 +4148,6 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, b.x, b.y))).origin); if (i % 90 == 0) { - r_points.push_back(p_offset.translated(p_base.xform(Vector3(d, a.x, a.y))).origin); r_points.push_back(p_offset.translated(p_base.xform(Vector3())).origin); } @@ -4391,7 +4161,6 @@ void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base ts = MIN(ts, 720); for (int i = 0; i < int(ts); i += 5) { - float ra = Math::deg2rad((float)i); float rb = Math::deg2rad((float)i + 5); float c = i / 720.0; @@ -4474,7 +4243,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint); if (hinge) { - CreateHingeJointGizmo( Transform(), hinge->get_global_transform(), @@ -4498,7 +4266,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint); if (slider) { - CreateSliderJointGizmo( Transform(), slider->get_global_transform(), @@ -4523,7 +4290,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint); if (cone) { - CreateConeTwistJointGizmo( Transform(), cone->get_global_transform(), @@ -4543,7 +4309,6 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint); if (gen) { - CreateGeneric6DOFJointGizmo( Transform(), gen->get_global_transform(), @@ -4597,7 +4362,6 @@ void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<V } 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); @@ -4607,7 +4371,6 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const } if (r_body_a_points) { - JointGizmosDrawer::draw_circle(Vector3::AXIS_Z, BODY_A_RADIUS, p_offset, @@ -4629,7 +4392,6 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const } 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; @@ -4638,7 +4400,6 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const r_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin); if (p_linear_limit_lower >= p_linear_limit_upper) { - r_points.push_back(p_offset.translated(Vector3(p_linear_limit_upper, 0, 0)).origin); r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, 0, 0)).origin); @@ -4661,7 +4422,6 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const r_points.push_back(p_offset.translated(Vector3(p_linear_limit_lower, -cs, -cs)).origin); } else { - r_points.push_back(p_offset.translated(Vector3(+cs * 2, 0, 0)).origin); r_points.push_back(p_offset.translated(Vector3(-cs * 2, 0, 0)).origin); } @@ -4689,7 +4449,6 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const } 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( p_offset, @@ -4733,7 +4492,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { - float cs = 0.25; for (int ax = 0; ax < 3; ax++) { @@ -4794,7 +4552,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( } if (enable_lin && lll >= lul) { - ADD_VTX(lul, 0, 0); ADD_VTX(lll, 0, 0); @@ -4817,7 +4574,6 @@ void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( ADD_VTX(lll, -cs, -cs); } else { - ADD_VTX(+cs * 2, 0, 0); ADD_VTX(-cs * 2, 0, 0); } diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h index c25fff528c..8154dc7a6d 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/node_3d_editor_gizmos.h @@ -37,7 +37,6 @@ class Camera3D; class Light3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Light3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -55,7 +54,6 @@ public: }; class AudioStreamPlayer3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(AudioStreamPlayer3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -73,7 +71,6 @@ public: }; class Camera3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Camera3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -91,7 +88,6 @@ public: }; class MeshInstance3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(MeshInstance3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -105,7 +101,6 @@ public: }; class Sprite3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Sprite3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -119,7 +114,6 @@ public: }; class Position3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Position3DGizmoPlugin, EditorNode3DGizmoPlugin); Ref<ArrayMesh> pos3d_mesh; @@ -135,7 +129,6 @@ public: }; class Skeleton3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Skeleton3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -148,7 +141,6 @@ public: }; class PhysicalBone3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(PhysicalBone3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -161,7 +153,6 @@ public: }; class RayCast3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(RayCast3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -174,7 +165,6 @@ public: }; class SpringArm3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(SpringArm3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -187,7 +177,6 @@ public: }; class VehicleWheel3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(VehicleWheel3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -200,7 +189,6 @@ public: }; class SoftBody3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(SoftBody3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -219,7 +207,6 @@ public: }; class VisibilityNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(VisibilityNotifier3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -249,7 +236,6 @@ public: }; class GPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(GPUParticles3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -268,7 +254,6 @@ public: }; class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(ReflectionProbeGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -286,7 +271,6 @@ public: }; class DecalGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(DecalGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -304,7 +288,6 @@ public: }; class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -322,7 +305,6 @@ public: }; class BakedLightmapGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(BakedLightmapGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -340,7 +322,6 @@ public: }; class LightmapProbeGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(LightmapProbeGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -358,7 +339,6 @@ public: }; class CollisionShape3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(CollisionShape3DGizmoPlugin, EditorNode3DGizmoPlugin); public: @@ -387,11 +367,9 @@ public: }; class NavigationRegion3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(NavigationRegion3DGizmoPlugin, EditorNode3DGizmoPlugin); struct _EdgeKey { - Vector3 from; Vector3 to; @@ -423,7 +401,6 @@ public: }; class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin); Timer *update_timer; diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index a076b1eecc..aa3ebe5ce7 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -34,7 +34,6 @@ #include "editor_scale.h" void NodeDock::show_groups() { - groups_button->set_pressed(true); connections_button->set_pressed(false); groups->show(); @@ -42,7 +41,6 @@ void NodeDock::show_groups() { } void NodeDock::show_connections() { - groups_button->set_pressed(false); connections_button->set_pressed(true); groups->hide(); @@ -53,7 +51,6 @@ void NodeDock::_bind_methods() { } void NodeDock::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { connections_button->set_icon(get_theme_icon("Signals", "EditorIcons")); groups_button->set_icon(get_theme_icon("Groups", "EditorIcons")); @@ -63,12 +60,10 @@ void NodeDock::_notification(int p_what) { NodeDock *NodeDock::singleton = nullptr; void NodeDock::update_lists() { - connections->update_tree(); } void NodeDock::set_node(Node *p_node) { - connections->set_node(p_node); groups->set_current(p_node); @@ -89,7 +84,6 @@ void NodeDock::set_node(Node *p_node) { } NodeDock::NodeDock() { - singleton = this; set_name("Node"); diff --git a/editor/node_dock.h b/editor/node_dock.h index ae33c5b9a5..c165974678 100644 --- a/editor/node_dock.h +++ b/editor/node_dock.h @@ -35,7 +35,6 @@ #include "groups_editor.h" class NodeDock : public VBoxContainer { - GDCLASS(NodeDock, VBoxContainer); ToolButton *connections_button; diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index ce90fa94dc..0f21a2af88 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -31,20 +31,15 @@ #include "pane_drag.h" void PaneDrag::_gui_input(const Ref<InputEvent> &p_input) { - Ref<InputEventMouseMotion> mm = p_input; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - emit_signal("dragged", Point2(mm->get_relative().x, mm->get_relative().y)); } } void PaneDrag::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_DRAW: { - 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)); @@ -61,7 +56,6 @@ void PaneDrag::_notification(int p_what) { } } Size2 PaneDrag::get_minimum_size() const { - Ref<Texture2D> icon = get_theme_icon("PaneDrag", "EditorIcons"); if (!icon.is_null()) return icon->get_size(); @@ -69,12 +63,10 @@ Size2 PaneDrag::get_minimum_size() const { } void PaneDrag::_bind_methods() { - ClassDB::bind_method("_gui_input", &PaneDrag::_gui_input); ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "amount"))); } PaneDrag::PaneDrag() { - mouse_over = false; } diff --git a/editor/pane_drag.h b/editor/pane_drag.h index 7e66bb429f..81aff4b2a8 100644 --- a/editor/pane_drag.h +++ b/editor/pane_drag.h @@ -34,7 +34,6 @@ #include "scene/gui/control.h" class PaneDrag : public Control { - GDCLASS(PaneDrag, Control); bool mouse_over; diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 4317a5e80f..ac8f4a1ad5 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -52,7 +52,6 @@ void PluginConfigDialog::_clear_fields() { } void PluginConfigDialog::_on_confirmed() { - String path = "res://addons/" + subfolder_edit->get_text(); if (!_edit_mode) { diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h index fa148125bc..93c8c01c70 100644 --- a/editor/plugin_config_dialog.h +++ b/editor/plugin_config_dialog.h @@ -38,7 +38,6 @@ #include "scene/gui/text_edit.h" class PluginConfigDialog : public ConfirmationDialog { - GDCLASS(PluginConfigDialog, ConfirmationDialog); LineEdit *name_edit; diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index beb3d760c0..d3e4c20e50 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -35,29 +35,24 @@ #include "editor/editor_scale.h" bool AbstractPolygon2DEditor::Vertex::operator==(const AbstractPolygon2DEditor::Vertex &p_vertex) const { - return polygon == p_vertex.polygon && vertex == p_vertex.vertex; } bool AbstractPolygon2DEditor::Vertex::operator!=(const AbstractPolygon2DEditor::Vertex &p_vertex) const { - return !(*this == p_vertex); } bool AbstractPolygon2DEditor::Vertex::valid() const { - return vertex >= 0; } bool AbstractPolygon2DEditor::_is_empty() const { - if (!_get_node()) return true; const int n = _get_polygon_count(); for (int i = 0; i < n; i++) { - Vector<Vector2> vertices = _get_polygon(i); if (vertices.size() != 0) @@ -68,66 +63,54 @@ bool AbstractPolygon2DEditor::_is_empty() const { } bool AbstractPolygon2DEditor::_is_line() const { - return false; } bool AbstractPolygon2DEditor::_has_uv() const { - return false; } int AbstractPolygon2DEditor::_get_polygon_count() const { - return 1; } Variant AbstractPolygon2DEditor::_get_polygon(int p_idx) const { - return _get_node()->get("polygon"); } void AbstractPolygon2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { - _get_node()->set("polygon", p_polygon); } void AbstractPolygon2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Node2D *node = _get_node(); undo_redo->add_do_method(node, "set_polygon", p_polygon); undo_redo->add_undo_method(node, "set_polygon", p_previous); } Vector2 AbstractPolygon2DEditor::_get_offset(int p_idx) const { - return Vector2(0, 0); } void AbstractPolygon2DEditor::_commit_action() { - undo_redo->add_do_method(canvas_item_editor, "update_viewport"); undo_redo->add_undo_method(canvas_item_editor, "update_viewport"); undo_redo->commit_action(); } void AbstractPolygon2DEditor::_action_add_polygon(const Variant &p_polygon) { - _action_set_polygon(0, p_polygon); } void AbstractPolygon2DEditor::_action_remove_polygon(int p_idx) { - _action_set_polygon(p_idx, _get_polygon(p_idx), Vector<Vector2>()); } void AbstractPolygon2DEditor::_action_set_polygon(int p_idx, const Variant &p_polygon) { - _action_set_polygon(p_idx, _get_polygon(p_idx), p_polygon); } bool AbstractPolygon2DEditor::_has_resource() const { - return true; } @@ -135,18 +118,14 @@ void AbstractPolygon2DEditor::_create_resource() { } void AbstractPolygon2DEditor::_menu_option(int p_option) { - switch (p_option) { - case MODE_CREATE: { - mode = MODE_CREATE; button_create->set_pressed(true); button_edit->set_pressed(false); button_delete->set_pressed(false); } break; case MODE_EDIT: { - _wip_close(); mode = MODE_EDIT; button_create->set_pressed(false); @@ -154,7 +133,6 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) { button_delete->set_pressed(false); } break; case MODE_DELETE: { - _wip_close(); mode = MODE_DELETE; button_create->set_pressed(false); @@ -165,11 +143,8 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) { } void AbstractPolygon2DEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - disable_polygon_editing(false, String()); button_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("CurveCreate", "EditorIcons")); @@ -184,7 +159,6 @@ void AbstractPolygon2DEditor::_notification(int p_what) { } void AbstractPolygon2DEditor::_node_removed(Node *p_node) { - if (p_node == _get_node()) { edit(nullptr); hide(); @@ -194,14 +168,12 @@ void AbstractPolygon2DEditor::_node_removed(Node *p_node) { } void AbstractPolygon2DEditor::_wip_changed() { - if (wip_active && _is_line()) { _set_polygon(0, wip); } } void AbstractPolygon2DEditor::_wip_cancel() { - wip.clear(); wip_active = false; @@ -217,10 +189,8 @@ void AbstractPolygon2DEditor::_wip_close() { return; if (_is_line()) { - _set_polygon(0, wip); } else if (wip.size() >= (_is_line() ? 2 : 3)) { - undo_redo->create_action(TTR("Create Polygon")); _action_add_polygon(wip); if (_has_uv()) { @@ -229,7 +199,6 @@ void AbstractPolygon2DEditor::_wip_close() { } _commit_action(); } else { - return; } @@ -247,7 +216,6 @@ void AbstractPolygon2DEditor::_wip_close() { } void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_reason) { - _polygon_editing_enabled = !p_disable; button_create->set_disabled(p_disable); @@ -255,12 +223,10 @@ void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_r button_delete->set_disabled(p_disable); if (p_disable) { - button_create->set_tooltip(p_reason); button_edit->set_tooltip(p_reason); button_delete->set_tooltip(p_reason); } else { - button_create->set_tooltip(TTR("Create points.")); button_edit->set_tooltip(TTR("Edit points.\nLMB: Move Point\nRMB: Erase Point")); button_delete->set_tooltip(TTR("Erase points.")); @@ -268,14 +234,12 @@ void AbstractPolygon2DEditor::disable_polygon_editing(bool p_disable, String p_r } bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { - if (!_get_node() || !_polygon_editing_enabled) return false; Ref<InputEventMouseButton> mb = p_event; if (!_has_resource()) { - 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(); @@ -288,7 +252,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return false; if (mb.is_valid()) { - Transform2D xform = canvas_item_editor->get_canvas_transform() * _get_node()->get_global_transform(); Vector2 gpoint = mb->get_position(); @@ -303,11 +266,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) const PosVertex insert = closest_edge_point(gpoint); if (insert.valid()) { - Vector<Vector2> vertices = _get_polygon(insert.polygon); if (vertices.size() < (_is_line() ? 2 : 3)) { - vertices.push_back(cpoint); undo_redo->create_action(TTR("Edit Polygon")); selected_point = Vertex(insert.polygon, vertices.size()); @@ -315,7 +276,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _commit_action(); return true; } else { - Vector<Vector2> vertices2 = _get_polygon(insert.polygon); pre_move_edit = vertices2; edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos)); @@ -329,12 +289,10 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } } else { - //look for points to move const PosVertex closest = closest_point(gpoint); if (closest.valid()) { - pre_move_edit = _get_polygon(closest.polygon); edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos)); selected_point = closest; @@ -342,14 +300,11 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) canvas_item_editor->update_viewport(); return true; } else { - selected_point = Vertex(); } } } else { - if (edited_point.valid()) { - //apply Vector<Vector2> vertices = _get_polygon(edited_point.polygon); @@ -365,23 +320,18 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) } } } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && !edited_point.valid()) { - const PosVertex closest = closest_point(gpoint); if (closest.valid()) { - remove_point(closest); return true; } } } else if (mode == MODE_DELETE) { - if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - const PosVertex closest = closest_point(gpoint); if (closest.valid()) { - remove_point(closest); return true; } @@ -389,11 +339,8 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) } if (mode == MODE_CREATE) { - if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - if (_is_line()) { - // for lines, we don't have a wip mode, and we can undo each single add point. Vector<Vector2> vertices = _get_polygon(0); vertices.push_back(cpoint); @@ -402,7 +349,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _commit_action(); return true; } else if (!wip_active) { - wip.clear(); wip.push_back(cpoint); wip_active = true; @@ -414,7 +360,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) edge_point = PosVertex(); return true; } else { - const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); if (!_is_line() && wip.size() > 1 && xform.xform(wip[0]).distance_to(gpoint) < grab_threshold) { @@ -423,7 +368,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } else { - //add wip point wip.push_back(cpoint); _wip_changed(); @@ -442,11 +386,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - Vector2 gpoint = mm->get_position(); if (edited_point.valid() && (wip_active || (mm->get_button_mask() & BUTTON_MASK_LEFT))) { - Vector2 cpoint = _get_node()->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint))); //Move the point in a single axis. Should only work when editing a polygon and while holding shift. @@ -462,7 +404,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) edited_point = PosVertex(edited_point, cpoint); if (!wip_active) { - Vector<Vector2> vertices = _get_polygon(edited_point.polygon); ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false); vertices.write[edited_point.vertex] = cpoint - _get_offset(edited_point.polygon); @@ -471,25 +412,20 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) canvas_item_editor->update_viewport(); } else if (mode == MODE_EDIT || (_is_line() && mode == MODE_CREATE)) { - const PosVertex onEdgeVertex = closest_edge_point(gpoint); if (onEdgeVertex.valid()) { - hover_point = Vertex(); edge_point = onEdgeVertex; canvas_item_editor->update_viewport(); } else { - if (edge_point.valid()) { - edge_point = PosVertex(); canvas_item_editor->update_viewport(); } const PosVertex new_hover_point = closest_point(gpoint); if (hover_point != new_hover_point) { - hover_point = new_hover_point; canvas_item_editor->update_viewport(); } @@ -500,13 +436,9 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed()) { - if (k->get_keycode() == KEY_DELETE || k->get_keycode() == KEY_BACKSPACE) { - if (wip_active && selected_point.polygon == -1) { - if (wip.size() > selected_point.vertex) { - wip.remove(selected_point.vertex); _wip_changed(); selected_point = wip.size() - 1; @@ -514,17 +446,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) return true; } } else { - const Vertex active_point = get_active_point(); if (active_point.valid()) { - remove_point(active_point); return true; } } } else if (wip_active && k->get_keycode() == KEY_ENTER) { - _wip_close(); } else if (wip_active && k->get_keycode() == KEY_ESCAPE) { _wip_cancel(); @@ -535,7 +464,6 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) } void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { - if (!_get_node()) return; @@ -548,7 +476,6 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl const bool is_closed = !_is_line(); for (int j = -1; j < n_polygons; j++) { - if (wip_active && wip_destructive && j != -1) continue; @@ -556,11 +483,9 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl Vector2 offset; if (wip_active && j == edited_point.polygon) { - points = Variant(wip); offset = Vector2(0, 0); } else { - if (j == -1) continue; points = _get_polygon(j); @@ -568,11 +493,9 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } if (!wip_active && j == edited_point.polygon && EDITOR_GET("editors/poly_editor/show_previous_outline")) { - const Color col = Color(0.5, 0.5, 0.5); // FIXME polygon->get_outline_color(); const int n = pre_move_edit.size(); for (int i = 0; i < n - (is_closed ? 0 : 1); i++) { - Vector2 p, p2; p = pre_move_edit[i] + offset; p2 = pre_move_edit[(i + 1) % n] + offset; @@ -588,14 +511,12 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl const Color col = Color(1, 0.3, 0.1, 0.8); for (int i = 0; i < n_points; i++) { - const Vertex vertex(j, i); const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset); const Vector2 point = xform.xform(p); if (is_closed || i < n_points - 1) { - Vector2 p2; if (j == edited_point.polygon && ((wip_active && i == n_points - 1) || (((i + 1) % n_points) == edited_point.vertex))) @@ -609,7 +530,6 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } for (int i = 0; i < n_points; i++) { - const Vertex vertex(j, i); const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset); @@ -628,19 +548,16 @@ void AbstractPolygon2DEditor::forward_canvas_draw_over_viewport(Control *p_overl } if (edge_point.valid()) { - Ref<Texture2D> add_handle = get_theme_icon("EditorHandleAdd", "EditorIcons"); p_overlay->draw_texture(add_handle, edge_point.pos - add_handle->get_size() * 0.5); } } void AbstractPolygon2DEditor::edit(Node *p_polygon) { - if (!canvas_item_editor) canvas_item_editor = CanvasItemEditor::get_singleton(); if (p_polygon) { - _set_node(p_polygon); // Enable the pencil tool if the polygon is empty. @@ -657,7 +574,6 @@ void AbstractPolygon2DEditor::edit(Node *p_polygon) { canvas_item_editor->update_viewport(); } else { - _set_node(nullptr); } } @@ -666,18 +582,15 @@ void AbstractPolygon2DEditor::_bind_methods() { } void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) { - Vector<Vector2> vertices = _get_polygon(p_vertex.polygon); if (vertices.size() > (_is_line() ? 2 : 3)) { - vertices.remove(p_vertex.vertex); undo_redo->create_action(TTR("Edit Polygon (Remove Point)")); _action_set_polygon(p_vertex.polygon, vertices); _commit_action(); } else { - undo_redo->create_action(TTR("Remove Polygon And Point")); _action_remove_polygon(p_vertex.polygon); _commit_action(); @@ -692,12 +605,10 @@ void AbstractPolygon2DEditor::remove_point(const Vertex &p_vertex) { } AbstractPolygon2DEditor::Vertex AbstractPolygon2DEditor::get_active_point() const { - return hover_point.valid() ? hover_point : selected_point; } AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const Vector2 &p_pos) const { - const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); const int n_polygons = _get_polygon_count(); @@ -707,13 +618,11 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const real_t closest_dist = 1e10; for (int j = 0; j < n_polygons; j++) { - Vector<Vector2> points = _get_polygon(j); const Vector2 offset = _get_offset(j); const int n_points = points.size(); for (int i = 0; i < n_points; i++) { - Vector2 cp = xform.xform(points[i] + offset); real_t d = cp.distance_to(p_pos); @@ -728,7 +637,6 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_point(const } AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(const Vector2 &p_pos) const { - const real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); const real_t eps = grab_threshold * 2; const real_t eps2 = eps * eps; @@ -740,14 +648,12 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c real_t closest_dist = 1e10; for (int j = 0; j < n_polygons; j++) { - Vector<Vector2> points = _get_polygon(j); const Vector2 offset = _get_offset(j); const int n_points = points.size(); const int n_segments = n_points - (_is_line() ? 1 : 0); for (int i = 0; i < n_segments; i++) { - Vector2 segment[2] = { xform.xform(points[i] + offset), xform.xform(points[(i + 1) % n_points] + offset) }; @@ -768,7 +674,6 @@ AbstractPolygon2DEditor::PosVertex AbstractPolygon2DEditor::closest_edge_point(c } AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wip_destructive) { - canvas_item_editor = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -805,22 +710,17 @@ AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wi } void AbstractPolygon2DEditorPlugin::edit(Object *p_object) { - polygon_editor->edit(Object::cast_to<Node>(p_object)); } bool AbstractPolygon2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class(klass); } void AbstractPolygon2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - polygon_editor->show(); } else { - polygon_editor->hide(); polygon_editor->edit(nullptr); } diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index 7d4a3a0f98..d5b3a916d1 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -39,7 +39,6 @@ class CanvasItemEditor; class AbstractPolygon2DEditor : public HBoxContainer { - GDCLASS(AbstractPolygon2DEditor, HBoxContainer); ToolButton *button_create; @@ -151,7 +150,6 @@ public: }; class AbstractPolygon2DEditorPlugin : public EditorPlugin { - GDCLASS(AbstractPolygon2DEditorPlugin, EditorPlugin); AbstractPolygon2DEditor *polygon_editor; diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index eb50df2166..64e5df084b 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -117,7 +117,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven _update_tool_erase(); for (int i = 0; i < points.size(); i++) { - if (Math::abs(float(points[i] - mb->get_position().x)) < 10 * EDSCALE) { selected_point = i; @@ -196,7 +195,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; @@ -227,7 +225,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { } if (snap->is_pressed()) { - linecolor_soft.a = linecolor.a * 0.1; if (blend_space->get_snap() > 0) { @@ -303,7 +300,6 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() { } void AnimationNodeBlendSpace1DEditor::_update_space() { - if (updating) return; @@ -360,7 +356,6 @@ void AnimationNodeBlendSpace1DEditor::_snap_toggled() { } void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) { - file_loaded = ResourceLoader::load(p_file); if (file_loaded.is_valid()) { _add_menu_type(MENU_LOAD_FILE_CONFIRM); @@ -370,7 +365,6 @@ void AnimationNodeBlendSpace1DEditor::_file_opened(const String &p_file) { void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { Ref<AnimationRootNode> node; if (p_index == MENU_LOAD_FILE) { - open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); @@ -383,7 +377,6 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { node = file_loaded; file_loaded.unref(); } else if (p_index == MENU_PASTE) { - node = EditorSettings::get_singleton()->get_resource_clipboard(); } else { String type = menu->get_item_metadata(p_index); @@ -432,7 +425,6 @@ void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { } void AnimationNodeBlendSpace1DEditor::_tool_switch(int p_tool) { - if (p_tool == 0) { tool_erase->show(); tool_erase_sep->show(); @@ -467,7 +459,6 @@ void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() { } void AnimationNodeBlendSpace1DEditor::_update_tool_erase() { - bool point_valid = selected_point >= 0 && selected_point < blend_space->get_blend_point_count(); tool_erase->set_disabled(!point_valid); @@ -522,7 +513,6 @@ void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) { } void AnimationNodeBlendSpace1DEditor::_open_editor() { - if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) { Ref<AnimationNode> an = blend_space->get_blend_point_node(selected_point); ERR_FAIL_COND(an.is_null()); @@ -575,13 +565,11 @@ void AnimationNodeBlendSpace1DEditor::_bind_methods() { } bool AnimationNodeBlendSpace1DEditor::can_edit(const Ref<AnimationNode> &p_node) { - Ref<AnimationNodeBlendSpace1D> b1d = p_node; return b1d.is_valid(); } void AnimationNodeBlendSpace1DEditor::edit(const Ref<AnimationNode> &p_node) { - blend_space = p_node; if (!blend_space.is_null()) { diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h index 346ad36cff..8cfd6714ad 100644 --- a/editor/plugins/animation_blend_space_1d_editor.h +++ b/editor/plugins/animation_blend_space_1d_editor.h @@ -42,7 +42,6 @@ #include "scene/gui/tree.h" class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { - GDCLASS(AnimationNodeBlendSpace1DEditor, AnimationTreeNodeEditorPlugin); Ref<AnimationNodeBlendSpace1D> blend_space; diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 4ea84e716b..a308b5dddb 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -43,7 +43,6 @@ #include "scene/main/window.h" bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) { - Ref<AnimationNodeBlendSpace2D> bs2d = p_node; return bs2d.is_valid(); } @@ -53,7 +52,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_changed() { } void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) { - if (blend_space.is_valid()) { blend_space->disconnect("triangles_updated", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_blend_space_changed)); } @@ -71,7 +69,6 @@ StringName AnimationNodeBlendSpace2DEditor::get_blend_position_path() const { } void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (tool_select->is_pressed() && k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { if (selected_point != -1 || selected_triangle != -1) { @@ -107,7 +104,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); if (name == "Animation") continue; // nope @@ -138,7 +134,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - blend_space_draw->update(); //update anyway //try to see if a point can be selected selected_point = -1; @@ -146,7 +141,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven _update_tool_erase(); for (int i = 0; i < points.size(); i++) { - if (points[i].distance_to(mb->get_position()) < 10 * EDSCALE) { selected_point = i; Ref<AnimationNode> node = blend_space->get_blend_point_node(i); @@ -180,13 +174,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_triangle->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - blend_space_draw->update(); //update anyway //try to see if a point can be selected selected_point = -1; for (int i = 0; i < points.size(); i++) { - if (making_triangle.find(i) != -1) continue; @@ -243,7 +235,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mb.is_valid() && mb->is_pressed() && tool_blend->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Vector2 blend_pos = (mb->get_position() / blend_space_draw->get_size()); blend_pos.y = 1.0 - blend_pos.y; blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); @@ -278,7 +269,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } if (mm.is_valid() && tool_blend->is_pressed() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - Vector2 blend_pos = (mm->get_position() / blend_space_draw->get_size()); blend_pos.y = 1.0 - blend_pos.y; blend_pos *= (blend_space->get_max_space() - blend_space->get_min_space()); @@ -291,7 +281,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } void AnimationNodeBlendSpace2DEditor::_file_opened(const String &p_file) { - file_loaded = ResourceLoader::load(p_file); if (file_loaded.is_valid()) { _add_menu_type(MENU_LOAD_FILE_CONFIRM); @@ -299,10 +288,8 @@ void AnimationNodeBlendSpace2DEditor::_file_opened(const String &p_file) { } void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { - Ref<AnimationRootNode> node; if (p_index == MENU_LOAD_FILE) { - open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); @@ -315,7 +302,6 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { node = file_loaded; file_loaded.unref(); } else if (p_index == MENU_PASTE) { - node = EditorSettings::get_singleton()->get_resource_clipboard(); } else { String type = menu->get_item_metadata(p_index); @@ -346,7 +332,6 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { } void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { - Ref<AnimationNodeAnimation> anim; anim.instance(); @@ -405,7 +390,6 @@ void AnimationNodeBlendSpace2DEditor::_tool_switch(int p_tool) { } void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { - Color linecolor = get_theme_color("font_color", "Label"); Color linecolor_soft = linecolor; linecolor_soft.a *= 0.5; @@ -438,14 +422,11 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } if (snap->is_pressed()) { - linecolor_soft.a = linecolor.a * 0.1; if (blend_space->get_snap().x > 0) { - int prev_idx = 0; for (int i = 0; i < s.x; i++) { - float v = blend_space->get_min_space().x + i * (blend_space->get_max_space().x - blend_space->get_min_space().x) / s.x; int idx = int(v / blend_space->get_snap().x); @@ -458,10 +439,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } if (blend_space->get_snap().y > 0) { - int prev_idx = 0; for (int i = 0; i < s.y; i++) { - float v = blend_space->get_max_space().y - i * (blend_space->get_max_space().y - blend_space->get_min_space().y) / s.y; int idx = int(v / blend_space->get_snap().y); @@ -476,7 +455,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { //triangles first for (int i = 0; i < blend_space->get_triangle_count(); i++) { - Vector<Vector2> points; points.resize(3); @@ -518,7 +496,6 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { points.clear(); for (int i = 0; i < blend_space->get_blend_point_count(); i++) { - Vector2 point = blend_space->get_blend_point_position(i); if (dragging_selected && selected_point == i) { point += drag_ofs; @@ -597,12 +574,10 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() { } void AnimationNodeBlendSpace2DEditor::_snap_toggled() { - blend_space_draw->update(); } void AnimationNodeBlendSpace2DEditor::_update_space() { - if (updating) return; @@ -674,9 +649,7 @@ void AnimationNodeBlendSpace2DEditor::_labels_changed(String) { } void AnimationNodeBlendSpace2DEditor::_erase_selected() { - if (selected_point != -1) { - updating = true; undo_redo->create_action(TTR("Remove BlendSpace2D Point")); undo_redo->add_do_method(blend_space.ptr(), "remove_blend_point", selected_point); @@ -699,7 +672,6 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { blend_space_draw->update(); } else if (selected_triangle != -1) { - updating = true; undo_redo->create_action(TTR("Remove BlendSpace2D Triangle")); undo_redo->add_do_method(blend_space.ptr(), "remove_triangle", selected_triangle); @@ -752,7 +724,6 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { } void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); @@ -772,7 +743,6 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - String error; if (!AnimationTreeEditor::get_singleton()->get_tree()) { @@ -801,7 +771,6 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) { } void AnimationNodeBlendSpace2DEditor::_open_editor() { - if (selected_point >= 0 && selected_point < blend_space->get_blend_point_count()) { Ref<AnimationNode> an = blend_space->get_blend_point_node(selected_point); ERR_FAIL_COND(an.is_null()); @@ -814,7 +783,6 @@ void AnimationNodeBlendSpace2DEditor::_removed_from_graph() { } void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() { - undo_redo->create_action(TTR("Toggle Auto Triangles")); undo_redo->add_do_method(blend_space.ptr(), "set_auto_triangles", auto_triangles->is_pressed()); undo_redo->add_undo_method(blend_space.ptr(), "set_auto_triangles", blend_space->get_auto_triangles()); @@ -824,7 +792,6 @@ void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() { } void AnimationNodeBlendSpace2DEditor::_bind_methods() { - ClassDB::bind_method("_update_space", &AnimationNodeBlendSpace2DEditor::_update_space); ClassDB::bind_method("_update_tool_erase", &AnimationNodeBlendSpace2DEditor::_update_tool_erase); @@ -836,7 +803,6 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() { AnimationNodeBlendSpace2DEditor *AnimationNodeBlendSpace2DEditor::singleton = nullptr; AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { - singleton = this; updating = false; diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index 50b0d9a06c..b430a12297 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -42,7 +42,6 @@ #include "scene/gui/tree.h" class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { - GDCLASS(AnimationNodeBlendSpace2DEditor, AnimationTreeNodeEditorPlugin); Ref<AnimationNodeBlendSpace2D> blend_space; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 23e547f55d..3363e1b804 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -43,7 +43,6 @@ #include "scene/main/window.h" void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) { - for (int i = 0; i < add_options.size(); i++) { ERR_FAIL_COND(add_options[i].script == p_script); } @@ -57,7 +56,6 @@ void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const R } void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_script) { - for (int i = 0; i < add_options.size(); i++) { if (add_options[i].script == p_script) { add_options.remove(i); @@ -69,7 +67,6 @@ void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_scrip } void AnimationNodeBlendTreeEditor::_update_options_menu() { - add_node->get_popup()->clear(); for (int i = 0; i < add_options.size(); i++) { add_node->get_popup()->add_item(add_options[i].name, i); @@ -86,12 +83,10 @@ void AnimationNodeBlendTreeEditor::_update_options_menu() { } Size2 AnimationNodeBlendTreeEditor::get_minimum_size() const { - return Size2(10, 200); } void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { - AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_tree(); updating = true; undo_redo->create_action(TTR("Parameter Changed") + ": " + String(p_property), UndoRedo::MERGE_ENDS); @@ -104,7 +99,6 @@ void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_propert } void AnimationNodeBlendTreeEditor::_update_graph() { - if (updating) return; @@ -115,7 +109,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { graph->clear_connections(); //erase all nodes for (int i = 0; i < graph->get_child_count(); i++) { - if (Object::cast_to<GraphNode>(graph->get_child(i))) { memdelete(graph->get_child(i)); i--; @@ -128,7 +121,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { blend_tree->get_node_list(&nodes); for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - GraphNode *node = memnew(GraphNode); graph->add_child(node); @@ -163,7 +155,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { List<PropertyInfo> pinfo; agnode->get_parameter_list(&pinfo); for (List<PropertyInfo>::Element *F = pinfo.front(); F; F = F->next()) { - if (!(F->get().usage & PROPERTY_USAGE_EDITOR)) { continue; } @@ -192,7 +183,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } if (agnode->has_filter()) { - node->add_child(memnew(HSeparator)); Button *edit_filters = memnew(Button); edit_filters->set_text(TTR("Edit Filters")); @@ -204,7 +194,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { Ref<AnimationNodeAnimation> anim = agnode; if (anim.is_valid()) { - MenuButton *mb = memnew(MenuButton); mb->set_text(anim->get_animation()); mb->set_icon(get_theme_icon("Animation", "EditorIcons")); @@ -259,7 +248,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { blend_tree->get_node_connections(&connections); for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; StringName to = E->get().input_node; int to_idx = E->get().input_index; @@ -269,7 +257,6 @@ void AnimationNodeBlendTreeEditor::_update_graph() { } void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) { - file_loaded = ResourceLoader::load(p_file); if (file_loaded.is_valid()) { _add_node(MENU_LOAD_FILE_CONFIRM); @@ -277,13 +264,11 @@ void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) { } void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { - Ref<AnimationNode> anode; String base_name; if (p_idx == MENU_LOAD_FILE) { - open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationNode", &filters); @@ -297,7 +282,6 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { file_loaded.unref(); base_name = anode->get_class(); } else if (p_idx == MENU_PASTE) { - anode = EditorSettings::get_singleton()->get_resource_clipboard(); ERR_FAIL_COND(!anode.is_valid()); base_name = anode->get_class(); @@ -347,7 +331,6 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { } void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which) { - updating = true; undo_redo->create_action(TTR("Node Moved")); undo_redo->add_do_method(blend_tree.ptr(), "set_node_position", p_which, p_to / EDSCALE); @@ -359,7 +342,6 @@ void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Ve } void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) { - AnimationNodeBlendTree::ConnectionError err = blend_tree->can_connect_node(p_to, p_to_index, p_from); if (err != AnimationNodeBlendTree::CONNECTION_OK) { @@ -376,7 +358,6 @@ void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int } void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) { - graph->disconnect_node(p_from, p_from_index, p_to, p_to_index); updating = true; @@ -390,7 +371,6 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, } void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, const String &p_node) { - String option = p_options[p_index]; Ref<AnimationNodeAnimation> anim = blend_tree->get_node(p_node); @@ -405,7 +385,6 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, } void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { - undo_redo->create_action(TTR("Delete Node")); undo_redo->add_do_method(blend_tree.ptr(), "remove_node", p_which); undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which), blend_tree.ptr()->get_node_position(p_which)); @@ -425,7 +404,6 @@ void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { } void AnimationNodeBlendTreeEditor::_delete_nodes_request() { - List<StringName> to_erase; for (int i = 0; i < graph->get_child_count(); i++) { @@ -450,7 +428,6 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() { } void AnimationNodeBlendTreeEditor::_popup_request(const Vector2 &p_position) { - _update_options_menu(); use_popup_menu_position = true; popup_menu_position = graph->get_local_mouse_position(); @@ -459,7 +436,6 @@ void AnimationNodeBlendTreeEditor::_popup_request(const Vector2 &p_position) { } void AnimationNodeBlendTreeEditor::_node_selected(Object *p_node) { - GraphNode *gn = Object::cast_to<GraphNode>(p_node); ERR_FAIL_COND(!gn); @@ -472,14 +448,12 @@ void AnimationNodeBlendTreeEditor::_node_selected(Object *p_node) { } void AnimationNodeBlendTreeEditor::_open_in_editor(const String &p_which) { - Ref<AnimationNode> an = blend_tree->get_node(p_which); ERR_FAIL_COND(!an.is_valid()); AnimationTreeEditor::get_singleton()->enter_editor(p_which); } void AnimationNodeBlendTreeEditor::_filter_toggled() { - updating = true; undo_redo->create_action(TTR("Toggle Filter On/Off")); undo_redo->add_do_method(_filter_edit.ptr(), "set_filter_enabled", filter_enabled->is_pressed()); @@ -491,7 +465,6 @@ void AnimationNodeBlendTreeEditor::_filter_toggled() { } void AnimationNodeBlendTreeEditor::_filter_edited() { - TreeItem *edited = filters->get_edited(); ERR_FAIL_COND(!edited); @@ -509,7 +482,6 @@ void AnimationNodeBlendTreeEditor::_filter_edited() { } bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &anode) { - if (updating || _filter_edit != anode) return false; @@ -542,7 +514,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano player->get_animation_list(&animations); for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); for (int i = 0; i < anim->get_track_count(); i++) { String track_path = anim->track_get_path(i); @@ -577,7 +548,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano Map<String, TreeItem *> parenthood; for (Set<String>::Element *E = paths.front(); E; E = E->next()) { - NodePath path = E->get(); TreeItem *ti = nullptr; String accum; @@ -616,7 +586,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano continue; //no node, can't edit if (path.get_subname_count()) { - String concat = path.get_concatenated_subnames(); Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); @@ -697,7 +666,6 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano } void AnimationNodeBlendTreeEditor::_edit_filters(const String &p_which) { - Ref<AnimationNode> anode = blend_tree->get_node(p_which); ERR_FAIL_COND(!anode.is_valid()); @@ -715,9 +683,7 @@ void AnimationNodeBlendTreeEditor::_removed_from_graph() { } void AnimationNodeBlendTreeEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); @@ -726,7 +692,6 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - String error; if (!AnimationTreeEditor::get_singleton()->get_tree()->is_active()) { @@ -797,7 +762,6 @@ void AnimationNodeBlendTreeEditor::_scroll_changed(const Vector2 &p_scroll) { } void AnimationNodeBlendTreeEditor::_bind_methods() { - ClassDB::bind_method("_update_graph", &AnimationNodeBlendTreeEditor::_update_graph); ClassDB::bind_method("_update_filters", &AnimationNodeBlendTreeEditor::_update_filters); } @@ -805,7 +769,6 @@ void AnimationNodeBlendTreeEditor::_bind_methods() { AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr; void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) { - String prev_name = blend_tree->get_node_name(p_node); ERR_FAIL_COND(prev_name == String()); GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name)); @@ -858,7 +821,6 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima blend_tree->get_node_connections(&connections); for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) { - StringName from = E->get().output_node; StringName to = E->get().input_node; int to_idx = E->get().input_index; @@ -888,7 +850,6 @@ bool AnimationNodeBlendTreeEditor::can_edit(const Ref<AnimationNode> &p_node) { } void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) { - if (blend_tree.is_valid()) { blend_tree->disconnect("removed_from_graph", callable_mp(this, &AnimationNodeBlendTreeEditor::_removed_from_graph)); } @@ -905,7 +866,6 @@ void AnimationNodeBlendTreeEditor::edit(const Ref<AnimationNode> &p_node) { } AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { - singleton = this; updating = false; use_popup_menu_position = false; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index 4f5badea9f..6bdb7e7909 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -44,7 +44,6 @@ class ProgressBar; class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { - GDCLASS(AnimationNodeBlendTreeEditor, AnimationTreeNodeEditorPlugin); Ref<AnimationNodeBlendTree> blend_tree; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 0a252cc0a3..aba2d53eba 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -44,7 +44,6 @@ #include "servers/rendering_server.h" void AnimationPlayerEditor::_node_removed(Node *p_node) { - if (player && player == p_node) { player = nullptr; @@ -58,24 +57,20 @@ void AnimationPlayerEditor::_node_removed(Node *p_node) { } void AnimationPlayerEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_PROCESS: { - if (!player) return; updating = true; if (player->is_playing()) { - { String animname = player->get_assigned_animation(); if (player->has_animation(animname)) { Ref<Animation> anim = player->get_animation(animname); if (!anim.is_null()) { - frame->set_max(anim->get_length()); } } @@ -96,7 +91,6 @@ void AnimationPlayerEditor::_notification(int p_what) { updating = false; } break; case NOTIFICATION_ENTER_TREE: { - tool_anim->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_animation_tool_menu)); onion_skinning->get_popup()->connect("id_pressed", callable_mp(this, &AnimationPlayerEditor::_onion_skinning_menu)); @@ -108,11 +102,9 @@ void AnimationPlayerEditor::_notification(int p_what) { add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox("panel", "Panel")); } break; case NOTIFICATION_THEME_CHANGED: { - autoplay->set_icon(get_theme_icon("AutoPlay", "EditorIcons")); play->set_icon(get_theme_icon("PlayStart", "EditorIcons")); @@ -147,7 +139,6 @@ void AnimationPlayerEditor::_notification(int p_what) { } void AnimationPlayerEditor::_autoplay_pressed() { - if (updating) return; if (animation->get_item_count() == 0) { @@ -176,15 +167,12 @@ void AnimationPlayerEditor::_autoplay_pressed() { } void AnimationPlayerEditor::_play_pressed() { - String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { - current = animation->get_item_text(animation->get_selected()); } if (current != "") { - if (current == player->get_assigned_animation()) player->stop(); //so it won't blend with itself player->play(current); @@ -195,19 +183,15 @@ void AnimationPlayerEditor::_play_pressed() { } void AnimationPlayerEditor::_play_from_pressed() { - String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { - current = animation->get_item_text(animation->get_selected()); } if (current != "") { - float time = player->get_current_animation_position(); if (current == player->get_assigned_animation() && player->is_playing()) { - player->stop(); //so it won't blend with itself } @@ -220,15 +204,12 @@ void AnimationPlayerEditor::_play_from_pressed() { } void AnimationPlayerEditor::_play_bw_pressed() { - String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { - current = animation->get_item_text(animation->get_selected()); } if (current != "") { - if (current == player->get_assigned_animation()) player->stop(); //so it won't blend with itself player->play(current, -1, -1, true); @@ -239,15 +220,12 @@ void AnimationPlayerEditor::_play_bw_pressed() { } void AnimationPlayerEditor::_play_bw_from_pressed() { - String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { - current = animation->get_item_text(animation->get_selected()); } if (current != "") { - float time = player->get_current_animation_position(); if (current == player->get_assigned_animation()) player->stop(); //so it won't blend with itself @@ -260,7 +238,6 @@ void AnimationPlayerEditor::_play_bw_from_pressed() { stop->set_pressed(false); } void AnimationPlayerEditor::_stop_pressed() { - if (!player) { return; } @@ -271,24 +248,20 @@ void AnimationPlayerEditor::_stop_pressed() { } void AnimationPlayerEditor::_animation_selected(int p_which) { - if (updating) return; // when selecting an animation, the idea is that the only interesting behavior // ui-wise is that it should play/blend the next one if currently playing String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { - current = animation->get_item_text(animation->get_selected()); } if (current != "") { - player->set_assigned_animation(current); Ref<Animation> anim = player->get_animation(current); { - track_editor->set_animation(anim); Node *root = player->get_node(player->get_root()); if (root) { @@ -310,7 +283,6 @@ void AnimationPlayerEditor::_animation_selected(int p_which) { } void AnimationPlayerEditor::_animation_new() { - renaming = false; name_title->set_text(TTR("New Animation Name:")); @@ -334,7 +306,6 @@ void AnimationPlayerEditor::_animation_new() { name->grab_focus(); } void AnimationPlayerEditor::_animation_rename() { - if (animation->get_item_count() == 0) return; int selected = animation->get_selected(); @@ -355,7 +326,6 @@ void AnimationPlayerEditor::_animation_load() { ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } @@ -364,7 +334,6 @@ void AnimationPlayerEditor::_animation_load() { } void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path) { - int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; @@ -382,7 +351,6 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou } void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) { - if (p_resource->get_path().is_resource_file()) { _animation_save_in_path(p_resource, p_resource->get_path()); } else { @@ -391,14 +359,12 @@ void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) { } void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) { - file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); List<String> extensions; ResourceSaver::get_recognized_extensions(p_resource, &extensions); file->clear_filters(); for (int i = 0; i < extensions.size(); i++) { - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } @@ -412,7 +378,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) } } } else { - String existing; if (extensions.size()) { if (p_resource->get_name() != "") { @@ -429,7 +394,6 @@ void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) } void AnimationPlayerEditor::_animation_remove() { - if (animation->get_item_count() == 0) return; @@ -440,7 +404,6 @@ void AnimationPlayerEditor::_animation_remove() { } void AnimationPlayerEditor::_animation_remove_confirmed() { - String current = animation->get_item_text(animation->get_selected()); Ref<Animation> anim = player->get_animation(current); @@ -463,12 +426,9 @@ void AnimationPlayerEditor::_animation_remove_confirmed() { } void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) { - int idx = -1; for (int i = 0; i < animation->get_item_count(); i++) { - if (animation->get_item_text(i) == p_anim) { - idx = i; break; } @@ -482,7 +442,6 @@ void AnimationPlayerEditor::_select_anim_by_name(const String &p_anim) { } double AnimationPlayerEditor::_get_editor_step() const { - // Returns the effective snapping value depending on snapping modifiers, or 0 if snapping is disabled. if (track_editor->is_snap_enabled()) { const String current = player->get_assigned_animation(); @@ -497,7 +456,6 @@ double AnimationPlayerEditor::_get_editor_step() const { } void AnimationPlayerEditor::_animation_name_edited() { - player->stop(); String new_name = name->get_text(); @@ -534,7 +492,6 @@ void AnimationPlayerEditor::_animation_name_edited() { _select_anim_by_name(new_name); } else { - Ref<Animation> new_anim = Ref<Animation>(memnew(Animation)); new_anim->set_name(new_name); @@ -556,7 +513,6 @@ void AnimationPlayerEditor::_animation_name_edited() { } void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) { - if (animation->get_item_count() == 0) return; @@ -571,7 +527,6 @@ void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) { } void AnimationPlayerEditor::_animation_blend() { - if (updating_blends) return; @@ -599,7 +554,6 @@ void AnimationPlayerEditor::_animation_blend() { blend_editor.next->add_item("", i); for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - String to = E->get(); TreeItem *blend = blend_editor.tree->create_item(root); blend->set_editable(0, false); @@ -627,7 +581,6 @@ void AnimationPlayerEditor::_animation_blend() { } void AnimationPlayerEditor::_blend_edited() { - if (updating_blends) return; @@ -655,7 +608,6 @@ void AnimationPlayerEditor::_blend_edited() { } void AnimationPlayerEditor::ensure_visibility() { - if (player && pin->is_pressed()) return; // another player is pinned, don't reset @@ -663,7 +615,6 @@ void AnimationPlayerEditor::ensure_visibility() { } Dictionary AnimationPlayerEditor::get_state() const { - Dictionary d; d["visible"] = is_visible_in_tree(); @@ -676,7 +627,6 @@ Dictionary AnimationPlayerEditor::get_state() const { return d; } void AnimationPlayerEditor::set_state(const Dictionary &p_state) { - if (!p_state.has("visible") || !p_state["visible"]) { return; } @@ -685,7 +635,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) { } if (p_state.has("player")) { - Node *n = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["player"]); if (Object::cast_to<AnimationPlayer>(n) && EditorNode::get_singleton()->get_editor_selection()->is_selected(n)) { player = Object::cast_to<AnimationPlayer>(n); @@ -710,7 +659,6 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) { } void AnimationPlayerEditor::_animation_resource_edit() { - if (animation->get_item_count()) { String current = animation->get_item_text(animation->get_selected()); Ref<Animation> anim = player->get_animation(current); @@ -719,7 +667,6 @@ void AnimationPlayerEditor::_animation_resource_edit() { } void AnimationPlayerEditor::_animation_edit() { - if (animation->get_item_count()) { String current = animation->get_item_text(animation->get_selected()); Ref<Animation> anim = player->get_animation(current); @@ -736,7 +683,6 @@ void AnimationPlayerEditor::_animation_edit() { } void AnimationPlayerEditor::_dialog_action(String p_file) { - switch (current_option) { case RESOURCE_LOAD: { ERR_FAIL_COND(!player); @@ -745,11 +691,9 @@ void AnimationPlayerEditor::_dialog_action(String p_file) { ERR_FAIL_COND_MSG(res.is_null(), "Cannot load Animation from file '" + p_file + "'."); ERR_FAIL_COND_MSG(!res->is_class("Animation"), "Loaded resource from file '" + p_file + "' is not Animation."); if (p_file.find_last("/") != -1) { - p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length()); } if (p_file.find_last("\\") != -1) { - p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length()); } @@ -768,7 +712,6 @@ void AnimationPlayerEditor::_dialog_action(String p_file) { break; } case RESOURCE_SAVE: { - String current = animation->get_item_text(animation->get_selected()); if (current != "") { Ref<Animation> anim = player->get_animation(current); @@ -784,24 +727,20 @@ void AnimationPlayerEditor::_dialog_action(String p_file) { } void AnimationPlayerEditor::_scale_changed(const String &p_scale) { - player->set_speed_scale(p_scale.to_double()); } void AnimationPlayerEditor::_update_animation() { - // the purpose of _update_animation is to reflect the current state // of the animation player in the current editor.. updating = true; if (player->is_playing()) { - play->set_pressed(true); stop->set_pressed(false); } else { - play->set_pressed(false); stop->set_pressed(true); } @@ -810,7 +749,6 @@ void AnimationPlayerEditor::_update_animation() { String current = player->get_assigned_animation(); for (int i = 0; i < animation->get_item_count(); i++) { - if (animation->get_item_text(i) == current) { animation->select(i); break; @@ -821,7 +759,6 @@ void AnimationPlayerEditor::_update_animation() { } void AnimationPlayerEditor::_update_player() { - updating = true; List<StringName> animlist; if (player) @@ -860,7 +797,6 @@ void AnimationPlayerEditor::_update_player() { int active_idx = -1; for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) { - if (player->get_autoplay() == E->get()) animation->add_icon_item(autoplay_icon, E->get()); else @@ -877,7 +813,6 @@ void AnimationPlayerEditor::_update_player() { _animation_selected(active_idx); } else if (animation->get_item_count() > 0) { - animation->select(0); autoplay->set_pressed(animation->get_item_text(0) == player->get_autoplay()); _animation_selected(0); @@ -899,7 +834,6 @@ void AnimationPlayerEditor::_update_player() { } void AnimationPlayerEditor::edit(AnimationPlayer *p_player) { - if (player && pin->is_pressed()) return; // Ignore, pinned. player = p_player; @@ -924,7 +858,6 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) { } void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_overlay) { - if (!onion.can_overlay) return; @@ -973,7 +906,6 @@ void AnimationPlayerEditor::forward_canvas_force_draw_over_viewport(Control *p_o } void AnimationPlayerEditor::_animation_duplicate() { - if (!animation->get_item_count()) return; @@ -986,9 +918,7 @@ void AnimationPlayerEditor::_animation_duplicate() { List<PropertyInfo> plist; anim->get_property_list(&plist); for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE) { - new_anim->set(E->get().name, anim->get(E->get().name)); } } @@ -1009,9 +939,7 @@ void AnimationPlayerEditor::_animation_duplicate() { undo_redo->commit_action(); for (int i = 0; i < animation->get_item_count(); i++) { - if (animation->get_item_text(i) == new_name) { - animation->select(i); _animation_selected(i); return; @@ -1020,7 +948,6 @@ void AnimationPlayerEditor::_animation_duplicate() { } void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) { - if (updating || !player || player->is_playing()) { return; }; @@ -1056,9 +983,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) { }; void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) { - if (player == p_pl && is_visible_in_tree()) { - _update_player(); if (blend_editor.dialog->is_visible()) _animation_blend(); // Update. @@ -1066,18 +991,15 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) { } void AnimationPlayerEditor::_list_changed() { - if (is_visible_in_tree()) _update_player(); } void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) { - frame->set_max(p_len); } void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) { - timeline_position = p_pos; if (!is_visible_in_tree()) @@ -1101,7 +1023,6 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag) } void AnimationPlayerEditor::_animation_tool_menu(int p_option) { - String current; if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) { current = animation->get_item_text(animation->get_selected()); @@ -1113,47 +1034,37 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { } switch (p_option) { - case TOOL_NEW_ANIM: { - _animation_new(); } break; case TOOL_LOAD_ANIM: { - _animation_load(); } break; case TOOL_SAVE_ANIM: { - if (anim.is_valid()) { _animation_save(anim); } } break; case TOOL_SAVE_AS_ANIM: { - if (anim.is_valid()) { _animation_save_as(anim); } } break; case TOOL_DUPLICATE_ANIM: { - _animation_duplicate(); [[fallthrough]]; // Allow immediate rename after animation is duplicated } case TOOL_RENAME_ANIM: { - _animation_rename(); } break; case TOOL_EDIT_TRANSITIONS: { - _animation_blend(); } break; case TOOL_REMOVE_ANIM: { - _animation_remove(); } break; case TOOL_COPY_ANIM: { - if (!animation->get_item_count()) { error_dialog->set_text(TTR("No animation to copy!")); error_dialog->popup_centered(); @@ -1165,7 +1076,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { EditorSettings::get_singleton()->set_resource_clipboard(anim2); } break; case TOOL_PASTE_ANIM: { - Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard(); if (!anim2.is_valid()) { error_dialog->set_text(TTR("No animation resource on clipboard!")); @@ -1181,7 +1091,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { int idx = 1; String base = name; while (player->has_animation(name)) { - idx++; name = base + " " + itos(idx); } @@ -1196,7 +1105,6 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { _select_anim_by_name(name); } break; case TOOL_EDIT_RESOURCE: { - if (!animation->get_item_count()) { error_dialog->set_text(TTR("No animation to edit!")); error_dialog->popup_centered(); @@ -1211,14 +1119,11 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) { } void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { - PopupMenu *menu = onion_skinning->get_popup(); int idx = menu->get_item_index(p_option); switch (p_option) { - case ONION_SKINNING_ENABLE: { - onion.enabled = !onion.enabled; if (onion.enabled) @@ -1228,13 +1133,11 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { } break; case ONION_SKINNING_PAST: { - // Ensure at least one of past/future is checked. onion.past = onion.future ? !onion.past : true; menu->set_item_checked(idx, onion.past); } break; case ONION_SKINNING_FUTURE: { - // Ensure at least one of past/future is checked. onion.future = onion.past ? !onion.future : true; menu->set_item_checked(idx, onion.future); @@ -1242,7 +1145,6 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { case ONION_SKINNING_1_STEP: // Fall-through. case ONION_SKINNING_2_STEPS: case ONION_SKINNING_3_STEPS: { - onion.steps = (p_option - ONION_SKINNING_1_STEP) + 1; int one_frame_idx = menu->get_item_index(ONION_SKINNING_1_STEP); for (int i = 0; i <= ONION_SKINNING_LAST_STEPS_OPTION - ONION_SKINNING_1_STEP; i++) { @@ -1250,17 +1152,14 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { } } break; case ONION_SKINNING_DIFFERENCES_ONLY: { - onion.differences_only = !onion.differences_only; menu->set_item_checked(idx, onion.differences_only); } break; case ONION_SKINNING_FORCE_WHITE_MODULATE: { - onion.force_white_modulate = !onion.force_white_modulate; menu->set_item_checked(idx, onion.force_white_modulate); } break; case ONION_SKINNING_INCLUDE_GIZMOS: { - onion.include_gizmos = !onion.include_gizmos; menu->set_item_checked(idx, onion.include_gizmos); } break; @@ -1268,12 +1167,9 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { } void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { - Ref<InputEventKey> k = p_ev; if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) { - switch (k->get_keycode()) { - case KEY_A: { if (!k->get_shift()) _play_bw_from_pressed(); @@ -1294,14 +1190,12 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { } void AnimationPlayerEditor::_editor_visibility_changed() { - if (is_visible() && animation->get_item_count() > 0) { _start_onion_skinning(); } } bool AnimationPlayerEditor::_are_onion_layers_valid() { - ERR_FAIL_COND_V(!onion.past && !onion.future, false); Point2 capture_size = get_tree()->get_root()->get_size(); @@ -1309,7 +1203,6 @@ bool AnimationPlayerEditor::_are_onion_layers_valid() { } void AnimationPlayerEditor::_allocate_onion_layers() { - _free_onion_layers(); int captures = onion.get_needed_capture_count(); @@ -1338,7 +1231,6 @@ void AnimationPlayerEditor::_allocate_onion_layers() { } void AnimationPlayerEditor::_free_onion_layers() { - for (int i = 0; i < onion.captures.size(); i++) { if (onion.captures[i].is_valid()) { RS::get_singleton()->free(onion.captures[i]); @@ -1349,7 +1241,6 @@ void AnimationPlayerEditor::_free_onion_layers() { } void AnimationPlayerEditor::_prepare_onion_layers_1() { - // This would be called per viewport and we want to act once only. int64_t frame = get_tree()->get_frame(); if (frame == onion.last_frame) @@ -1378,7 +1269,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_1_deferred() { } void AnimationPlayerEditor::_prepare_onion_layers_2() { - Ref<Animation> anim = player->get_animation(player->get_assigned_animation()); if (!anim.is_valid()) return; @@ -1455,7 +1345,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { int cidx = 0; onion.capture.material->set_shader_param("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color"))); for (int step_off = step_off_a; step_off <= step_off_b; step_off++) { - if (step_off == 0) { // Skip present step and switch to the color of future. if (!onion.force_white_modulate) @@ -1507,7 +1396,6 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { } void AnimationPlayerEditor::_start_onion_skinning() { - // FIXME: Using "idle_frame" makes onion layers update one frame behind the current. if (!get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) { get_tree()->connect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred)); @@ -1515,9 +1403,7 @@ void AnimationPlayerEditor::_start_onion_skinning() { } void AnimationPlayerEditor::_stop_onion_skinning() { - if (get_tree()->is_connected("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred))) { - get_tree()->disconnect("idle_frame", callable_mp(this, &AnimationPlayerEditor::_prepare_onion_layers_1_deferred)); _free_onion_layers(); @@ -1529,12 +1415,10 @@ void AnimationPlayerEditor::_stop_onion_skinning() { } void AnimationPlayerEditor::_pin_pressed() { - EditorNode::get_singleton()->get_scene_tree_dock()->get_tree_editor()->update_tree(); } void AnimationPlayerEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new); ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename); ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load); @@ -1556,7 +1440,6 @@ void AnimationPlayerEditor::_bind_methods() { AnimationPlayerEditor *AnimationPlayerEditor::singleton = nullptr; AnimationPlayer *AnimationPlayerEditor::get_player() const { - return player; } @@ -1800,24 +1683,20 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay } AnimationPlayerEditor::~AnimationPlayerEditor() { - _free_onion_layers(); RS::get_singleton()->free(onion.capture.canvas); RS::get_singleton()->free(onion.capture.canvas_item); } void AnimationPlayerEditorPlugin::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - set_force_draw_over_forwarding_enabled(); } break; } } void AnimationPlayerEditorPlugin::edit(Object *p_object) { - anim_editor->set_undo_redo(&get_undo_redo()); if (!p_object) return; @@ -1825,14 +1704,11 @@ void AnimationPlayerEditorPlugin::edit(Object *p_object) { } bool AnimationPlayerEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("AnimationPlayer"); } void AnimationPlayerEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - editor->make_bottom_panel_item_visible(anim_editor); anim_editor->set_process(true); anim_editor->ensure_visibility(); @@ -1840,7 +1716,6 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) { } AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin(EditorNode *p_node) { - editor = p_node; anim_editor = memnew(AnimationPlayerEditor(editor, this)); anim_editor->set_undo_redo(EditorNode::get_undo_redo()); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 1abefad635..18f2d3b25e 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -43,7 +43,6 @@ class AnimationTrackEditor; class AnimationPlayerEditorPlugin; class AnimationPlayerEditor : public VBoxContainer { - GDCLASS(AnimationPlayerEditor, VBoxContainer); EditorNode *editor; @@ -114,7 +113,6 @@ class AnimationPlayerEditor : public VBoxContainer { int current_option; struct BlendEditor { - AcceptDialog *dialog; Tree *tree; OptionButton *next; @@ -244,7 +242,6 @@ public: }; class AnimationPlayerEditorPlugin : public EditorPlugin { - GDCLASS(AnimationPlayerEditorPlugin, EditorPlugin); AnimationPlayerEditor *anim_editor; diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 509bf59716..ce41be7f28 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -43,17 +43,14 @@ #include "scene/main/window.h" bool AnimationNodeStateMachineEditor::can_edit(const Ref<AnimationNode> &p_node) { - Ref<AnimationNodeStateMachine> ansm = p_node; return ansm.is_valid(); } void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) { - state_machine = p_node; if (state_machine.is_valid()) { - selected_transition_from = StringName(); selected_transition_to = StringName(); selected_node = StringName(); @@ -63,7 +60,6 @@ void AnimationNodeStateMachineEditor::edit(const Ref<AnimationNode> &p_node) { } void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEvent> &p_event) { - Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); if (playback.is_null()) return; @@ -104,7 +100,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } for (List<StringName>::Element *E = classes.front(); E; E = E->next()) { - String name = String(E->get()).replace_first("AnimationNode", ""); if (name == "Animation") continue; // nope @@ -128,7 +123,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv // select node or push a field inside if (mb.is_valid() && !mb->get_shift() && mb->is_pressed() && tool_select->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - selected_transition_from = StringName(); selected_transition_to = StringName(); selected_node = StringName(); @@ -191,7 +185,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv int closest = -1; float closest_d = 1e20; for (int i = 0; i < transition_lines.size(); i++) { - Vector2 s[2] = { transition_lines[i].from, transition_lines[i].to @@ -222,9 +215,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //end moving node if (mb.is_valid() && dragging_selected_attempt && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) { - if (dragging_selected) { - Ref<AnimationNode> an = state_machine->get_node(selected_node); updating = true; undo_redo->create_action(TTR("Move Node")); @@ -245,7 +236,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //connect nodes if (mb.is_valid() && ((tool_select->is_pressed() && mb->get_shift()) || tool_connect->is_pressed()) && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order if (node_rects[i].node.has_point(mb->get_position())) { //select node since nothing else was selected connecting = true; @@ -259,14 +249,11 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //end connecting nodes if (mb.is_valid() && connecting && mb->get_button_index() == BUTTON_LEFT && !mb->is_pressed()) { - if (connecting_to_node != StringName()) { - if (state_machine->has_transition(connecting_from, connecting_to_node)) { EditorNode::get_singleton()->show_warning(TTR("Transition exists!")); } else { - Ref<AnimationNodeStateMachineTransition> tr; tr.instance(); tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected())); @@ -296,14 +283,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //pan window if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_MIDDLE) { - h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x); v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y); } //move mouse while connecting if (mm.is_valid() && connecting) { - connecting_to = mm->get_position(); connecting_to_node = StringName(); state_machine_draw->update(); @@ -318,7 +303,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //move mouse while moving a node if (mm.is_valid() && dragging_selected_attempt) { - dragging_selected = true; drag_ofs = mm->get_position() - drag_from; snap_x = StringName(); @@ -358,14 +342,12 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv //put ibeam (text cursor) over names to make it clearer that they are editable if (mm.is_valid()) { - state_machine_draw->grab_focus(); bool over_text_now = false; String new_over_node = StringName(); int new_over_node_what = -1; if (tool_select->is_pressed()) { - for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order if (node_rects[i].name.has_point(mm->get_position())) { @@ -392,7 +374,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } if (over_text != over_text_now) { - if (over_text_now) { state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM); } else { @@ -405,7 +386,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) { - file_loaded = ResourceLoader::load(p_file); if (file_loaded.is_valid()) { _add_menu_type(MENU_LOAD_FILE_CONFIRM); @@ -413,12 +393,10 @@ void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) { } void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { - String base_name; Ref<AnimationRootNode> node; if (p_index == MENU_LOAD_FILE) { - open_file->clear_filters(); List<String> filters; ResourceLoader::get_recognized_extensions_for_type("AnimationRootNode", &filters); @@ -431,7 +409,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { node = file_loaded; file_loaded.unref(); } else if (p_index == MENU_PASTE) { - node = EditorSettings::get_singleton()->get_resource_clipboard(); } else { @@ -452,7 +429,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { } if (base_name == String()) { - base_name = node->get_class().replace_first("AnimationNode", ""); } @@ -476,7 +452,6 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { } void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { - Ref<AnimationNodeAnimation> anim; anim.instance(); @@ -503,7 +478,6 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { } void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, const Vector2 &p_to, AnimationNodeStateMachineTransition::SwitchMode p_mode, bool p_enabled, bool p_selected, bool p_travel, bool p_auto_advance) { - Color linecolor = get_theme_color("font_color", "Label"); Color icon_color(1, 1, 1); Color accent = get_theme_color("accent_color", "Editor"); @@ -546,7 +520,6 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co } void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) { - if (r_to == r_from) return; @@ -558,7 +531,6 @@ void AnimationNodeStateMachineEditor::_clip_src_line_to_rect(Vector2 &r_from, Ve } void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Vector2 &r_to, const Rect2 &p_rect) { - if (r_to == r_from) return; @@ -570,7 +542,6 @@ void AnimationNodeStateMachineEditor::_clip_dst_line_to_rect(Vector2 &r_from, Ve } void AnimationNodeStateMachineEditor::_state_machine_draw() { - Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); Ref<StyleBox> style = get_theme_stylebox("state_machine_frame", "GraphNode"); @@ -611,7 +582,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { //snap lines if (dragging_selected) { - Vector2 from = (state_machine->get_node_position(selected_node) * EDSCALE) + drag_ofs - state_machine->get_graph_offset() * EDSCALE; if (snap_x != StringName()) { Vector2 to = (state_machine->get_node_position(snap_x) * EDSCALE) - state_machine->get_graph_offset() * EDSCALE; @@ -625,7 +595,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { //pre pass nodes so we know the rectangles for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) { - Ref<AnimationNode> anode = state_machine->get_node(E->get()); String name = E->get(); bool needs_editor = EditorNode::get_singleton()->item_has_editor(anode.ptr()); @@ -691,7 +660,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { //draw transition lines for (int i = 0; i < state_machine->get_transition_count(); i++) { - TransitionLine tl; tl.from_node = state_machine->get_transition_from(i); Vector2 ofs_from = (dragging_selected && tl.from_node == selected_node) ? drag_ofs : Vector2(); @@ -733,7 +701,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } if (travel_path.size()) { - if (current == tl.from_node && travel_path[0] == tl.to_node) { travel = true; } else { @@ -759,7 +726,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { //draw actual nodes for (int i = 0; i < node_rects.size(); i++) { - String name = node_rects[i].node_name; Ref<AnimationNode> anode = state_machine->get_node(name); bool needs_editor = AnimationTreeEditor::get_singleton()->can_edit(anode); @@ -786,7 +752,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } if (state_machine->get_end_node() == name) { - int endofs = nr.node.size.x - font->get_string_size(TTR("End")).x; state_machine_draw->draw_string(font, offset + Vector2(endofs, -font->get_height() - 3 * EDSCALE + font->get_ascent()), TTR("End"), font_color); } @@ -844,7 +809,6 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() { } void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { - Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); if (!playback.is_valid() || !playback->is_playing()) @@ -891,7 +855,6 @@ void AnimationNodeStateMachineEditor::_state_machine_pos_draw() { } void AnimationNodeStateMachineEditor::_update_graph() { - if (updating) return; @@ -903,7 +866,6 @@ void AnimationNodeStateMachineEditor::_update_graph() { } void AnimationNodeStateMachineEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); error_label->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); @@ -928,7 +890,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - String error; Ref<AnimationNodeStateMachinePlayback> playback = AnimationTreeEditor::get_singleton()->get_tree()->get(AnimationTreeEditor::get_singleton()->get_base_path() + "playback"); @@ -1017,7 +978,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } { - if (last_travel_path.size() != tp.size()) { same_travel_path = false; } else { @@ -1032,7 +992,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { //update if travel state changed if (!same_travel_path || last_active != is_playing || last_current_node != current_node || last_blend_from_node != blend_from_node) { - state_machine_draw->update(); last_travel_path = tp; last_current_node = current_node; @@ -1043,7 +1002,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { { if (current_node != StringName() && state_machine->has_node(current_node)) { - String next = current_node; Ref<AnimationNodeStateMachine> anodesm = state_machine->get_node(next); Ref<AnimationNodeStateMachinePlayback> current_node_playback; @@ -1063,7 +1021,6 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } if (last_play_pos != play_pos) { - last_play_pos = play_pos; state_machine_play_pos->update(); } @@ -1076,17 +1033,14 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) { } void AnimationNodeStateMachineEditor::_open_editor(const String &p_name) { - AnimationTreeEditor::get_singleton()->enter_editor(p_name); } void AnimationNodeStateMachineEditor::_removed_from_graph() { - EditorNode::get_singleton()->edit_item(nullptr); } void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { - const String &new_name = p_text; ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1); @@ -1117,7 +1071,6 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { } void AnimationNodeStateMachineEditor::_name_edited_focus_out() { - if (updating) return; @@ -1125,7 +1078,6 @@ void AnimationNodeStateMachineEditor::_name_edited_focus_out() { } void AnimationNodeStateMachineEditor::_scroll_changed(double) { - if (updating) return; @@ -1134,7 +1086,6 @@ void AnimationNodeStateMachineEditor::_scroll_changed(double) { } void AnimationNodeStateMachineEditor::_erase_selected() { - if (selected_node != StringName() && state_machine->has_node(selected_node)) { updating = true; undo_redo->create_action(TTR("Node Removed")); @@ -1158,7 +1109,6 @@ void AnimationNodeStateMachineEditor::_erase_selected() { } if (selected_transition_to != StringName() && selected_transition_from != StringName() && state_machine->has_transition(selected_transition_from, selected_transition_to)) { - Ref<AnimationNodeStateMachineTransition> tr = state_machine->get_transition(state_machine->find_transition(selected_transition_from, selected_transition_to)); updating = true; undo_redo->create_action(TTR("Transition Removed")); @@ -1176,9 +1126,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() { } void AnimationNodeStateMachineEditor::_autoplay_selected() { - if (selected_node != StringName() && state_machine->has_node(selected_node)) { - StringName new_start_node; if (state_machine->get_start_node() == selected_node) { //toggle it new_start_node = StringName(); @@ -1199,9 +1147,7 @@ void AnimationNodeStateMachineEditor::_autoplay_selected() { } void AnimationNodeStateMachineEditor::_end_selected() { - if (selected_node != StringName() && state_machine->has_node(selected_node)) { - StringName new_end_node; if (state_machine->get_end_node() == selected_node) { //toggle it new_end_node = StringName(); @@ -1221,7 +1167,6 @@ void AnimationNodeStateMachineEditor::_end_selected() { } } void AnimationNodeStateMachineEditor::_update_mode() { - if (tool_select->is_pressed()) { tool_erase_hb->show(); tool_erase->set_disabled(selected_node == StringName() && selected_transition_from == StringName() && selected_transition_to == StringName()); @@ -1233,7 +1178,6 @@ void AnimationNodeStateMachineEditor::_update_mode() { } void AnimationNodeStateMachineEditor::_bind_methods() { - ClassDB::bind_method("_update_graph", &AnimationNodeStateMachineEditor::_update_graph); ClassDB::bind_method("_removed_from_graph", &AnimationNodeStateMachineEditor::_removed_from_graph); @@ -1244,7 +1188,6 @@ void AnimationNodeStateMachineEditor::_bind_methods() { AnimationNodeStateMachineEditor *AnimationNodeStateMachineEditor::singleton = nullptr; AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { - singleton = this; updating = false; diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 5c4fc87df5..022c32ef48 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -42,7 +42,6 @@ #include "scene/gui/tree.h" class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { - GDCLASS(AnimationNodeStateMachineEditor, AnimationTreeNodeEditorPlugin); Ref<AnimationNodeStateMachine> state_machine; diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 9c48444e3e..2512dbdfb2 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -48,7 +48,6 @@ #include "scene/scene_string_names.h" void AnimationTreeEditor::edit(AnimationTree *p_tree) { - if (tree == p_tree) return; @@ -64,7 +63,6 @@ void AnimationTreeEditor::edit(AnimationTree *p_tree) { } void AnimationTreeEditor::_path_button_pressed(int p_path) { - edited_path.clear(); for (int i = 0; i <= p_path; i++) { edited_path.push_back(button_path[i]); @@ -100,7 +98,6 @@ void AnimationTreeEditor::_update_path() { } void AnimationTreeEditor::edit_path(const Vector<String> &p_path) { - button_path.clear(); Ref<AnimationNode> node = tree->get_tree_root(); @@ -109,7 +106,6 @@ void AnimationTreeEditor::edit_path(const Vector<String> &p_path) { current_root = node->get_instance_id(); for (int i = 0; i < p_path.size(); i++) { - Ref<AnimationNode> child = node->get_child_by_name(p_path[i]); ERR_BREAK(child.is_null()); node = child; @@ -140,7 +136,6 @@ Vector<String> AnimationTreeEditor::get_edited_path() const { } void AnimationTreeEditor::enter_editor(const String &p_path) { - Vector<String> path = edited_path; path.push_back(p_path); edit_path(path); @@ -204,7 +199,6 @@ bool AnimationTreeEditor::can_edit(const Ref<AnimationNode> &p_node) const { } Vector<String> AnimationTreeEditor::get_animation_list() { - if (!singleton->is_visible()) { return Vector<String>(); } @@ -229,7 +223,6 @@ Vector<String> AnimationTreeEditor::get_animation_list() { } AnimationTreeEditor::AnimationTreeEditor() { - AnimationNodeAnimation::get_editable_animation_list = get_animation_list; path_edit = memnew(ScrollContainer); add_child(path_edit); @@ -253,17 +246,14 @@ AnimationTreeEditor::AnimationTreeEditor() { } void AnimationTreeEditorPlugin::edit(Object *p_object) { - anim_tree_editor->edit(Object::cast_to<AnimationTree>(p_object)); } bool AnimationTreeEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("AnimationTree"); } void AnimationTreeEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { //editor->hide_animation_player_editors(); //editor->animation_panel_make_visible(true); @@ -271,7 +261,6 @@ void AnimationTreeEditorPlugin::make_visible(bool p_visible) { editor->make_bottom_panel_item_visible(anim_tree_editor); anim_tree_editor->set_process(true); } else { - if (anim_tree_editor->is_visible_in_tree()) editor->hide_bottom_panel(); button->hide(); @@ -280,7 +269,6 @@ void AnimationTreeEditorPlugin::make_visible(bool p_visible) { } AnimationTreeEditorPlugin::AnimationTreeEditorPlugin(EditorNode *p_node) { - editor = p_node; anim_tree_editor = memnew(AnimationTreeEditor); anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index 0b93b0fd8e..25af81ea9b 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -49,7 +49,6 @@ public: }; class AnimationTreeEditor : public VBoxContainer { - GDCLASS(AnimationTreeEditor, VBoxContainer); ScrollContainer *path_edit; @@ -95,7 +94,6 @@ public: }; class AnimationTreeEditorPlugin : public EditorPlugin { - GDCLASS(AnimationTreeEditorPlugin, EditorPlugin); AnimationTreeEditor *anim_tree_editor; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 1928d49556..5ec76d8471 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -40,7 +40,6 @@ #include "editor/project_settings_editor.h" void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost) { - title->set_text(p_title); asset_id = p_asset_id; category->set_text(p_category); @@ -51,7 +50,6 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co } void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { - ERR_FAIL_COND(p_type != EditorAssetLibrary::IMAGE_QUEUE_ICON); ERR_FAIL_COND(p_index != 0); @@ -59,9 +57,7 @@ void EditorAssetLibraryItem::set_image(int p_type, int p_index, const Ref<Textur } void EditorAssetLibraryItem::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - icon->set_normal_texture(get_theme_icon("ProjectIconLoading", "EditorIcons")); 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)); @@ -70,21 +66,17 @@ void EditorAssetLibraryItem::_notification(int p_what) { } void EditorAssetLibraryItem::_asset_clicked() { - emit_signal("asset_selected", asset_id); } void EditorAssetLibraryItem::_category_clicked() { - emit_signal("category_selected", category_id); } void EditorAssetLibraryItem::_author_clicked() { - emit_signal("author_selected", author_id); } void EditorAssetLibraryItem::_bind_methods() { - ClassDB::bind_method("set_image", &EditorAssetLibraryItem::set_image); ADD_SIGNAL(MethodInfo("asset_selected")); ADD_SIGNAL(MethodInfo("category_selected")); @@ -92,7 +84,6 @@ void EditorAssetLibraryItem::_bind_methods() { } EditorAssetLibraryItem::EditorAssetLibraryItem() { - Ref<StyleBoxEmpty> border; border.instance(); border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE); @@ -143,16 +134,12 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() { ////////////////////////////////////////////////////////////////////////////// void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const Ref<Texture2D> &p_image) { - switch (p_type) { - case EditorAssetLibrary::IMAGE_QUEUE_ICON: { - item->call("set_image", p_type, p_index, p_image); icon = p_image; } break; case EditorAssetLibrary::IMAGE_QUEUE_THUMBNAIL: { - for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { if (preview_images[i].is_video) { @@ -181,7 +168,6 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const } } break; case EditorAssetLibrary::IMAGE_QUEUE_SCREENSHOT: { - for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { preview_images.write[i].image = p_image; @@ -231,7 +217,6 @@ void EditorAssetLibraryItemDescription::_preview_click(int p_id) { } void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, const String &p_cost, int p_version, const String &p_version_string, const String &p_description, const String &p_download_url, const String &p_browse_url, const String &p_sha256_hash) { - asset_id = p_asset_id; title = p_title; download_url = p_download_url; @@ -249,7 +234,6 @@ void EditorAssetLibraryItemDescription::configure(const String &p_title, int p_a } void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) { - Preview preview; preview.id = p_id; preview.video_link = p_url; @@ -270,7 +254,6 @@ void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, cons } EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { - HBoxContainer *hbox = memnew(HBoxContainer); add_child(hbox); VBoxContainer *desc_vbox = memnew(VBoxContainer); @@ -317,11 +300,9 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { /////////////////////////////////////////////////////////////////////////////////// void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) { - String error_text; switch (p_status) { - case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: case HTTPRequest::RESULT_CONNECTION_ERROR: case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED: { @@ -388,7 +369,6 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int } void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asset_id, const Ref<Texture2D> &p_preview, const String &p_download_url, const String &p_sha256_hash) { - title->set_text(p_title); icon->set_texture(p_preview); asset_id = p_asset_id; @@ -400,17 +380,13 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse } void EditorAssetLibraryItemDownload::_notification(int p_what) { - switch (p_what) { - // FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used. case NOTIFICATION_ENTER_TREE: { - add_theme_style_override("panel", get_theme_stylebox("panel", "TabContainer")); dismiss->set_normal_texture(get_theme_icon("Close", "EditorIcons")); } break; case NOTIFICATION_PROCESS: { - // Make the progress bar visible again when retrying the download. progress->set_modulate(Color(1, 1, 1, 1)); @@ -438,7 +414,6 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { if (cstatus != prev_status) { switch (cstatus) { - case HTTPClient::STATUS_RESOLVING: { status->set_text(TTR("Resolving...")); progress->set_max(1); @@ -463,14 +438,12 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) { } } void EditorAssetLibraryItemDownload::_close() { - // Clean up downloaded file. DirAccess::remove_file_or_error(download->get_download_file()); queue_delete(); } void EditorAssetLibraryItemDownload::_install() { - String file = download->get_download_file(); if (external_install) { @@ -494,12 +467,10 @@ void EditorAssetLibraryItemDownload::_make_request() { } void EditorAssetLibraryItemDownload::_bind_methods() { - ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name"))); } EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { - HBoxContainer *hb = memnew(HBoxContainer); add_child(hb); icon = memnew(TextureRect); @@ -566,11 +537,8 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { //////////////////////////////////////////////////////////////////////////////// void EditorAssetLibrary::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); filter->set_right_icon(get_theme_icon("Search", "EditorIcons")); filter->set_clear_button_enabled(true); @@ -578,13 +546,11 @@ void EditorAssetLibrary::_notification(int p_what) { error_label->raise(); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible() && initial_loading) { _repository_changed(0); // Update when shown for the first time. } } break; case NOTIFICATION_PROCESS: { - HTTPClient::Status s = request->get_http_client_status(); const bool loading = s != HTTPClient::STATUS_DISCONNECTED; @@ -601,7 +567,6 @@ void EditorAssetLibrary::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - library_scroll_bg->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); downloads_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); error_tr->set_texture(get_theme_icon("Error", "EditorIcons")); @@ -612,13 +577,10 @@ void EditorAssetLibrary::_notification(int p_what) { } void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) { - const Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed()) { - if (key->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) { - filter->grab_focus(); filter->select_all(); accept_event(); @@ -627,14 +589,11 @@ void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorAssetLibrary::_install_asset() { - ERR_FAIL_COND(!description); for (int i = 0; i < downloads_hb->get_child_count(); i++) { - 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() != nullptr) EditorNode::get_singleton()->show_warning(TTR("Download for this asset is already in progress!")); return; @@ -676,14 +635,11 @@ const char *EditorAssetLibrary::support_key[SUPPORT_MAX] = { }; void EditorAssetLibrary::_select_author(int p_id) { - // Open author window. } void EditorAssetLibrary::_select_category(int p_id) { - for (int i = 0; i < categories->get_item_count(); i++) { - if (i == 0) continue; int id = categories->get_item_metadata(i); @@ -695,7 +651,6 @@ void EditorAssetLibrary::_select_category(int p_id) { } } void EditorAssetLibrary::_select_asset(int p_id) { - _api_request("asset/" + itos(p_id), REQUESTING_ASSET); } @@ -780,11 +735,9 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB } void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data, int p_queue_id) { - ERR_FAIL_COND(!image_queue.has(p_queue_id)); if (p_status == HTTPRequest::RESULT_SUCCESS && p_code < HTTPClient::RESPONSE_BAD_REQUEST) { - if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag @@ -830,14 +783,12 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons } void EditorAssetLibrary::_update_image_queue() { - const int max_images = 6; int current_images = 0; List<int> to_delete; for (Map<int, ImageQueue>::Element *E = image_queue.front(); E; E = E->next()) { if (!E->get().active && current_images < max_images) { - String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + E->get().image_url.md5_text()); Vector<String> headers; @@ -870,7 +821,6 @@ void EditorAssetLibrary::_update_image_queue() { } void EditorAssetLibrary::_request_image(ObjectID p_for, String p_image_url, ImageType p_type, int p_image_index) { - ImageQueue iq; iq.image_url = p_image_url; iq.image_index = p_image_index; @@ -911,7 +861,6 @@ void EditorAssetLibrary::_rerun_search(int p_ignore) { } void EditorAssetLibrary::_search(int p_page) { - String args; if (templates_only) { @@ -935,7 +884,6 @@ void EditorAssetLibrary::_search(int p_page) { } if (categories->get_selected() > 0) { - args += "&category=" + itos(categories->get_item_metadata(categories->get_selected())); } @@ -956,12 +904,10 @@ void EditorAssetLibrary::_search(int p_page) { } void EditorAssetLibrary::_search_text_entered(const String &p_text) { - _search(); } HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items) { - HBoxContainer *hbc = memnew(HBoxContainer); if (p_page_count < 2) @@ -1000,9 +946,7 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int hbc->add_child(memnew(VSeparator)); for (int i = from; i < to; i++) { - if (i == p_page) { - Button *current = memnew(Button); current->set_text(itos(i + 1)); current->set_disabled(true); @@ -1010,7 +954,6 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int hbc->add_child(current); } else { - Button *current = memnew(Button); current->set_text(itos(i + 1)); current->connect("pressed", callable_mp(this, &EditorAssetLibrary::_search), varray(i)); @@ -1046,7 +989,6 @@ HBoxContainer *EditorAssetLibrary::_make_pages(int p_page, int p_page_count, int } void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_request_type, const String &p_arguments) { - if (requesting != REQUESTING_NONE) { request->cancel_request(); } @@ -1058,7 +1000,6 @@ void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_req } void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) { - String str; { @@ -1070,7 +1011,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const bool error_abort = true; switch (p_status) { - case HTTPRequest::RESULT_CANT_RESOLVE: { error_label->set_text(TTR("Can't resolve hostname:") + " " + host); } break; @@ -1097,7 +1037,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const if (p_code != 200) { error_label->set_text(TTR("Request failed, return code:") + " " + itos(p_code)); } else { - error_abort = false; } } break; @@ -1122,7 +1061,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const switch (requested) { case REQUESTING_CONFIG: { - categories->clear(); categories->add_item(TTR("All")); categories->set_item_metadata(0, 0); @@ -1143,7 +1081,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const _search(); } break; case REQUESTING_SEARCH: { - initial_loading = false; // The loading text only needs to be displayed before the first page is loaded. @@ -1214,7 +1151,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const } for (int i = 0; i < result.size(); i++) { - Dictionary r = result[i]; ERR_CONTINUE(!r.has("title")); @@ -1273,7 +1209,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const Array previews = d["previews"]; for (int i = 0; i < previews.size(); i++) { - Dictionary p = previews[i]; ERR_CONTINUE(!p.has("type")); @@ -1303,7 +1238,6 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const } void EditorAssetLibrary::_asset_file_selected(const String &p_file) { - if (asset_installer) { memdelete(asset_installer); asset_installer = nullptr; @@ -1315,18 +1249,15 @@ void EditorAssetLibrary::_asset_file_selected(const String &p_file) { } void EditorAssetLibrary::_asset_open() { - asset_open->popup_centered_ratio(); } void EditorAssetLibrary::_manage_plugins() { - ProjectSettingsEditor::get_singleton()->popup_project_settings(); ProjectSettingsEditor::get_singleton()->set_plugins_page(); } void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) { - emit_signal("install_asset", p_zip_path, p_title); } @@ -1335,14 +1266,12 @@ void EditorAssetLibrary::disable_community_support() { } void EditorAssetLibrary::_bind_methods() { - ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input); ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name"))); } EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { - requesting = REQUESTING_NONE; templates_only = p_templates_only; initial_loading = true; @@ -1527,18 +1456,14 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { /////// void AssetLibraryEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - addon_library->show(); } else { - addon_library->hide(); } } AssetLibraryEditorPlugin::AssetLibraryEditorPlugin(EditorNode *p_node) { - editor = p_node; addon_library = memnew(EditorAssetLibrary); addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 536a855d03..d5d381dee3 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -50,7 +50,6 @@ #include "scene/main/http_request.h" class EditorAssetLibraryItem : public PanelContainer { - GDCLASS(EditorAssetLibraryItem, PanelContainer); TextureButton *icon; @@ -81,7 +80,6 @@ public: }; class EditorAssetLibraryItemDescription : public ConfirmationDialog { - GDCLASS(EditorAssetLibraryItemDescription, ConfirmationDialog); EditorAssetLibraryItem *item; @@ -129,7 +127,6 @@ public: }; class EditorAssetLibraryItemDownload : public PanelContainer { - GDCLASS(EditorAssetLibraryItemDownload, PanelContainer); TextureRect *icon; @@ -237,7 +234,6 @@ class EditorAssetLibrary : public PanelContainer { }; struct ImageQueue { - bool active; int queue_id; ImageType image_type; @@ -309,7 +305,6 @@ public: }; class AssetLibraryEditorPlugin : public EditorPlugin { - GDCLASS(AssetLibraryEditorPlugin, EditorPlugin); EditorAssetLibrary *addon_library; diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp index 0459ac7618..44238323ea 100644 --- a/editor/plugins/audio_stream_editor_plugin.cpp +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -37,7 +37,6 @@ #include "editor/editor_settings.h" void AudioStreamEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", callable_mp(this, &AudioStreamEditor::_preview_changed)); } @@ -75,7 +74,6 @@ void AudioStreamEditor::_draw_preview() { lines.resize(size.width * 2); for (int i = 0; i < size.width; i++) { - float ofs = i * preview_len / size.width; float ofs_n = (i + 1) * preview_len / size.width; float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5; @@ -93,21 +91,18 @@ void AudioStreamEditor::_draw_preview() { } void AudioStreamEditor::_preview_changed(ObjectID p_which) { - if (stream.is_valid() && stream->get_instance_id() == p_which) { _preview->update(); } } void AudioStreamEditor::_changed_callback(Object *p_changed, const char *p_prop) { - if (!is_visible()) return; update(); } void AudioStreamEditor::_play() { - if (_player->is_playing()) { _player->stop(); _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); @@ -120,7 +115,6 @@ void AudioStreamEditor::_play() { } void AudioStreamEditor::_stop() { - _player->stop(); _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); _current = 0; @@ -129,7 +123,6 @@ void AudioStreamEditor::_stop() { } void AudioStreamEditor::_on_finished() { - _play_button->set_icon(get_theme_icon("MainPlay", "EditorIcons")); if (_current == _player->get_stream()->get_length()) { _current = 0; @@ -138,7 +131,6 @@ void AudioStreamEditor::_on_finished() { } void AudioStreamEditor::_draw_indicator() { - if (!stream.is_valid()) { return; } @@ -178,7 +170,6 @@ void AudioStreamEditor::_seek_to(real_t p_x) { } void AudioStreamEditor::edit(Ref<AudioStream> p_stream) { - if (!stream.is_null()) stream->remove_change_receptor(this); @@ -200,7 +191,6 @@ void AudioStreamEditor::_bind_methods() { } AudioStreamEditor::AudioStreamEditor() { - set_custom_minimum_size(Size2(1, 100) * EDSCALE); _current = 0; _dragging = false; @@ -251,7 +241,6 @@ AudioStreamEditor::AudioStreamEditor() { } void AudioStreamEditorPlugin::edit(Object *p_object) { - AudioStream *s = Object::cast_to<AudioStream>(p_object); if (!s) return; @@ -260,17 +249,14 @@ void AudioStreamEditorPlugin::edit(Object *p_object) { } bool AudioStreamEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("AudioStream"); } void AudioStreamEditorPlugin::make_visible(bool p_visible) { - audio_editor->set_visible(p_visible); } AudioStreamEditorPlugin::AudioStreamEditorPlugin(EditorNode *p_node) { - editor = p_node; audio_editor = memnew(AudioStreamEditor); add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, audio_editor); diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h index 2191b541f6..dd7caaa15e 100644 --- a/editor/plugins/audio_stream_editor_plugin.h +++ b/editor/plugins/audio_stream_editor_plugin.h @@ -38,7 +38,6 @@ #include "scene/resources/texture.h" class AudioStreamEditor : public ColorRect { - GDCLASS(AudioStreamEditor, ColorRect); Ref<AudioStream> stream; @@ -73,7 +72,6 @@ public: }; class AudioStreamEditorPlugin : public EditorPlugin { - GDCLASS(AudioStreamEditorPlugin, EditorPlugin); AudioStreamEditor *audio_editor; diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp index f754dd4725..4f1b794c0c 100644 --- a/editor/plugins/baked_lightmap_editor_plugin.cpp +++ b/editor/plugins/baked_lightmap_editor_plugin.cpp @@ -31,7 +31,6 @@ #include "baked_lightmap_editor_plugin.h" void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) { - if (lightmap) { BakedLightmap::BakeError err; if (get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root() == lightmap) { @@ -71,12 +70,10 @@ void BakedLightmapEditorPlugin::_bake_select_file(const String &p_file) { } void BakedLightmapEditorPlugin::_bake() { - _bake_select_file(""); } void BakedLightmapEditorPlugin::edit(Object *p_object) { - BakedLightmap *s = Object::cast_to<BakedLightmap>(p_object); if (!s) return; @@ -85,16 +82,13 @@ void BakedLightmapEditorPlugin::edit(Object *p_object) { } bool BakedLightmapEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("BakedLightmap"); } void BakedLightmapEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { bake->show(); } else { - bake->hide(); } } @@ -102,7 +96,6 @@ void BakedLightmapEditorPlugin::make_visible(bool p_visible) { EditorProgress *BakedLightmapEditorPlugin::tmp_progress = nullptr; bool BakedLightmapEditorPlugin::bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh) { - if (!tmp_progress) { tmp_progress = memnew(EditorProgress("bake_lightmaps", TTR("Bake Lightmaps"), 1000, false)); ERR_FAIL_COND_V(tmp_progress == nullptr, false); @@ -118,12 +111,10 @@ void BakedLightmapEditorPlugin::bake_func_end() { } void BakedLightmapEditorPlugin::_bind_methods() { - ClassDB::bind_method("_bake", &BakedLightmapEditorPlugin::_bake); } BakedLightmapEditorPlugin::BakedLightmapEditorPlugin(EditorNode *p_node) { - editor = p_node; bake = memnew(ToolButton); bake->set_icon(editor->get_gui_base()->get_theme_icon("Bake", "EditorIcons")); diff --git a/editor/plugins/baked_lightmap_editor_plugin.h b/editor/plugins/baked_lightmap_editor_plugin.h index 2dbc09fc1d..67fb368a86 100644 --- a/editor/plugins/baked_lightmap_editor_plugin.h +++ b/editor/plugins/baked_lightmap_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/resources/material.h" class BakedLightmapEditorPlugin : public EditorPlugin { - GDCLASS(BakedLightmapEditorPlugin, EditorPlugin); BakedLightmap *lightmap; diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp index 8bc1374269..58ea5e45bb 100644 --- a/editor/plugins/camera_3d_editor_plugin.cpp +++ b/editor/plugins/camera_3d_editor_plugin.cpp @@ -33,7 +33,6 @@ #include "node_3d_editor_plugin.h" void Camera3DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; Node3DEditor::get_singleton()->set_custom_camera(nullptr); @@ -42,7 +41,6 @@ void Camera3DEditor::_node_removed(Node *p_node) { } void Camera3DEditor::_pressed() { - Node *sn = (node && preview->is_pressed()) ? node : nullptr; Node3DEditor::get_singleton()->set_custom_camera(sn); } @@ -51,14 +49,12 @@ void Camera3DEditor::_bind_methods() { } void Camera3DEditor::edit(Node *p_camera) { - node = p_camera; if (!node) { preview->set_pressed(false); Node3DEditor::get_singleton()->set_custom_camera(nullptr); } else { - if (preview->is_pressed()) Node3DEditor::get_singleton()->set_custom_camera(p_camera); else @@ -67,7 +63,6 @@ void Camera3DEditor::edit(Node *p_camera) { } Camera3DEditor::Camera3DEditor() { - preview = memnew(Button); add_child(preview); @@ -83,18 +78,15 @@ Camera3DEditor::Camera3DEditor() { } void Camera3DEditorPlugin::edit(Object *p_object) { - Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object)); //camera_editor->edit(Object::cast_to<Node>(p_object)); } bool Camera3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Camera3D"); } void Camera3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { //Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object)); } else { @@ -103,7 +95,6 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) { } Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) { - editor = p_node; /* camera_editor = memnew( CameraEditor ); editor->get_viewport()->add_child(camera_editor); diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h index 1e57ac7cd2..2603229a46 100644 --- a/editor/plugins/camera_3d_editor_plugin.h +++ b/editor/plugins/camera_3d_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/3d/camera_3d.h" class Camera3DEditor : public Control { - GDCLASS(Camera3DEditor, Control); Panel *panel; @@ -55,7 +54,6 @@ public: }; class Camera3DEditorPlugin : public EditorPlugin { - GDCLASS(Camera3DEditorPlugin, EditorPlugin); //CameraEditor *camera_editor; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index b5fcf82d76..0f794d0f48 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -61,7 +61,6 @@ #define MOVE_HANDLE_DISTANCE 25 class SnapDialog : public ConfirmationDialog { - GDCLASS(SnapDialog, ConfirmationDialog); friend class CanvasItemEditor; @@ -252,7 +251,6 @@ void CanvasItemEditor::_snap_if_closer_float( float &r_current_snap, SnapTarget &r_current_snap_target, float p_target_value, SnapTarget p_snap_target, float p_radius) { - float radius = p_radius / zoom; float dist = Math::abs(p_value - p_target_value); if ((p_radius < 0 || dist < radius) && (r_current_snap_target == SNAP_TARGET_NONE || dist < Math::abs(r_current_snap - p_value))) { @@ -267,7 +265,6 @@ void CanvasItemEditor::_snap_if_closer_point( Point2 p_target_value, SnapTarget p_snap_target, real_t rotation, float p_radius) { - Transform2D rot_trans = Transform2D(rotation, Point2()); p_value = rot_trans.inverse().xform(p_value); p_target_value = rot_trans.inverse().xform(p_target_value); @@ -330,7 +327,6 @@ void CanvasItemEditor::_snap_other_nodes( } Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsigned int p_forced_modes, const CanvasItem *p_self_canvas_item, List<CanvasItem *> p_other_nodes_exceptions) { - snap_target[0] = SNAP_TARGET_NONE; snap_target[1] = SNAP_TARGET_NONE; @@ -474,7 +470,6 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const { } void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { - Ref<InputEventKey> k = p_ev; if (!is_visible_in_tree()) @@ -500,7 +495,6 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { } Object *CanvasItemEditor::_get_editor_data(Object *p_what) { - CanvasItem *ci = Object::cast_to<CanvasItem>(p_what); if (!ci) return nullptr; @@ -509,7 +503,6 @@ Object *CanvasItemEditor::_get_editor_data(Object *p_what) { } void CanvasItemEditor::_keying_changed() { - if (AnimationPlayerEditor::singleton->get_track_editor()->is_visible_in_tree()) animation_hb->show(); else @@ -615,7 +608,6 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no } void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked) { - Node *scene = editor->get_edited_scene(); _find_canvas_items_at_pos(p_pos, scene, r_items); @@ -778,7 +770,6 @@ void CanvasItemEditor::_find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_n p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, 0))) && p_rect.has_point(xform.xform(rect.position + Vector2(rect.size.x, rect.size.y))) && p_rect.has_point(xform.xform(rect.position + Vector2(0, rect.size.y)))) { - r_items->push_back(canvas_item); } } else { @@ -965,7 +956,6 @@ void CanvasItemEditor::_snap_changed() { } void CanvasItemEditor::_selection_result_pressed(int p_result) { - if (selection_results.size() <= p_result) return; @@ -976,7 +966,6 @@ void CanvasItemEditor::_selection_result_pressed(int p_result) { } void CanvasItemEditor::_selection_menu_hide() { - selection_results.clear(); selection_menu->clear(); selection_menu->set_size(Vector2(0, 0)); @@ -1027,7 +1016,6 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve // Start dragging a guide if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) { - // Press button if (b->get_position().x < RULER_WIDTH && b->get_position().y < RULER_WIDTH) { // Drag a new double guide @@ -1397,7 +1385,6 @@ void CanvasItemEditor::_solve_IK(Node2D *leaf_node, Point2 target_position) { if (se) { int nb_bones = se->pre_drag_bones_undo_state.size(); if (nb_bones > 0) { - // Build the node list Point2 leaf_pos = target_position; @@ -1866,7 +1853,6 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { } bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseMotion> m = p_event; @@ -1878,7 +1864,6 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) { CanvasItem *canvas_item = selection[0]; if (_is_node_movable(canvas_item)) { - Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; @@ -2041,7 +2026,6 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (drag_type == DRAG_MOVE || drag_type == DRAG_MOVE_X || drag_type == DRAG_MOVE_Y) { // Move the nodes if (m.is_valid()) { - // Save the ik chain for reapplying before IK solve Vector<List<Dictionary>> all_bones_ik_states; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { @@ -2143,7 +2127,6 @@ 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; for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { @@ -2419,7 +2402,6 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { } bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) { - if (tool != TOOL_RULER) return false; @@ -2442,7 +2424,6 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) { } if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) { - viewport->update(); return true; } @@ -2451,7 +2432,6 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) { } bool CanvasItemEditor::_gui_input_hover(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseMotion> m = p_event; if (m.is_valid()) { Point2 click = transform.affine_inverse().xform(m->get_position()); @@ -2646,7 +2626,6 @@ void CanvasItemEditor::_draw_focus() { } void CanvasItemEditor::_draw_guides() { - Color guide_color = EditorSettings::get_singleton()->get("editors/2d/guides_color"); Transform2D xform = viewport_scrollable->get_transform() * transform; @@ -2793,7 +2772,6 @@ void CanvasItemEditor::_draw_rulers() { } void CanvasItemEditor::_draw_grid() { - if (show_grid || grid_snap_active) { // Draw the grid Vector2 real_grid_offset; @@ -2866,7 +2844,6 @@ void CanvasItemEditor::_draw_grid() { } void CanvasItemEditor::_draw_ruler_tool() { - if (tool != TOOL_RULER) return; @@ -2967,7 +2944,6 @@ void CanvasItemEditor::_draw_ruler_tool() { } if (grid_snap_active) { - text_pos = (begin + end) / 2 + Vector2(-text_width / 2, text_height / 2); text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5); text_pos.y = CLAMP(text_pos.y, text_height * 2.5, viewport->get_rect().size.y - text_height / 2); @@ -2987,7 +2963,6 @@ void CanvasItemEditor::_draw_ruler_tool() { } } } else { - if (grid_snap_active) { Ref<Texture2D> position_icon = get_theme_icon("EditorPosition", "EditorIcons"); viewport->draw_texture(get_theme_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); @@ -2999,7 +2974,6 @@ void CanvasItemEditor::_draw_control_anchors(Control *control) { Transform2D xform = transform * control->get_global_transform_with_canvas(); RID ci = viewport->get_canvas_item(); if (tool == TOOL_SELECT && !Object::cast_to<Container>(control->get_parent())) { - // Compute the anchors float anchors_values[4]; anchors_values[0] = control->get_anchor(MARGIN_LEFT); @@ -3264,7 +3238,6 @@ void CanvasItemEditor::_draw_selection() { viewport->draw_line(endpoints[i], endpoints[(i + 1) % 4], c, Math::round(2 * EDSCALE)); } } else { - 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); @@ -3275,7 +3248,6 @@ void CanvasItemEditor::_draw_selection() { 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()) { - // Draw the node's pivot Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * canvas_item->_edit_get_transform()).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; @@ -3453,15 +3425,12 @@ void CanvasItemEditor::_draw_straight_line(Point2 p_from, Point2 p_to, Color p_c } void CanvasItemEditor::_draw_axis() { - if (show_origin) { - _draw_straight_line(Point2(), Point2(1, 0), get_theme_color("axis_x_color", "Editor") * Color(1, 1, 1, 0.75)); _draw_straight_line(Point2(), Point2(0, 1), get_theme_color("axis_y_color", "Editor") * Color(1, 1, 1, 0.75)); } if (show_viewport) { - RID ci = viewport->get_canvas_item(); Color area_axis_color = EditorSettings::get_singleton()->get("editors/2d/viewport_border_color"); @@ -3492,7 +3461,6 @@ void CanvasItemEditor::_draw_bones() { Color bone_selected_color = EditorSettings::get_singleton()->get("editors/2d/bone_selected_color"); for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { - Vector<Vector2> bone_shape; Vector<Vector2> bone_shape_outline; if (!_get_bone_shape(&bone_shape, &bone_shape_outline, E)) @@ -3581,7 +3549,6 @@ void CanvasItemEditor::_draw_hover() { List<Rect2> previous_rects; for (int i = 0; i < hovering_results.size(); i++) { - Ref<Texture2D> node_icon = hovering_results[i].icon; String node_name = hovering_results[i].name; @@ -3717,7 +3684,6 @@ bool CanvasItemEditor::_build_bones_list(Node *p_node) { } void CanvasItemEditor::_draw_viewport() { - // Update the transform transform = Transform2D(); transform.scale_basis(Size2(zoom, zoom)); @@ -3796,7 +3762,6 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) { } void CanvasItemEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_PHYSICS_PROCESS) { EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); @@ -3882,10 +3847,8 @@ void CanvasItemEditor::_notification(int p_what) { // Update the viewport if bones changes for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { - Object *b = ObjectDB::get_instance(E->key().from); if (!b) { - viewport->update(); break; } @@ -3898,14 +3861,12 @@ void CanvasItemEditor::_notification(int p_what) { Transform2D global_xform = b2->get_global_transform(); if (global_xform != E->get().xform) { - E->get().xform = global_xform; viewport->update(); } Bone2D *bone = Object::cast_to<Bone2D>(b); if (bone && bone->get_default_length() != E->get().length) { - E->get().length = bone->get_default_length(); viewport->update(); } @@ -3913,7 +3874,6 @@ void CanvasItemEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); for (int i = 0; i < 4; i++) { select_sb->set_margin_size(Margin(i), 4); @@ -3926,7 +3886,6 @@ void CanvasItemEditor::_notification(int p_what) { get_tree()->connect("node_removed", callable_mp(this, &CanvasItemEditor::_tree_changed), varray()); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons")); } @@ -4054,7 +4013,6 @@ void CanvasItemEditor::_selection_changed() { } void CanvasItemEditor::edit(CanvasItem *p_canvas_item) { - Array selection = editor_selection->get_selected_nodes(); if (selection.size() != 1 || (Node *)selection[0] != p_canvas_item) { drag_type = DRAG_NONE; @@ -4066,7 +4024,6 @@ void CanvasItemEditor::edit(CanvasItem *p_canvas_item) { } void CanvasItemEditor::_queue_update_bone_list() { - if (bone_list_dirty) return; @@ -4075,7 +4032,6 @@ void CanvasItemEditor::_queue_update_bone_list() { } void CanvasItemEditor::_update_bone_list() { - bone_last_frame++; if (editor->get_edited_scene()) { @@ -4107,7 +4063,6 @@ void CanvasItemEditor::_tree_changed(Node *) { } void CanvasItemEditor::_update_scrollbars() { - updating_scroll = true; // Move the zoom buttons. @@ -4225,7 +4180,6 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa } void CanvasItemEditor::_update_scroll(float) { - if (updating_scroll) return; @@ -4240,7 +4194,6 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p undo_redo->create_action(TTR("Change Anchors and Margins")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); @@ -4282,7 +4235,6 @@ void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() { undo_redo->create_action(TTR("Change Anchors and Margins")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); if (control) { Point2 top_left_anchor = _position_to_anchor(control, Point2()); @@ -4310,7 +4262,6 @@ void CanvasItemEditor::_set_anchors_preset(Control::LayoutPreset p_preset) { undo_redo->create_action(TTR("Change Anchors")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Control *control = Object::cast_to<Control>(E->get()); if (control) { undo_redo->add_do_method(control, "set_anchors_preset", p_preset); @@ -4394,7 +4345,6 @@ void CanvasItemEditor::_button_override_camera(bool p_pressed) { } void CanvasItemEditor::_button_tool_select(int p_index) { - ToolButton *tb[TOOL_MAX] = { select_button, list_select_button, move_button, scale_button, rotate_button, pivot_button, pan_button, ruler_button }; for (int i = 0; i < TOOL_MAX; i++) { tb[i]->set_pressed(i == p_index); @@ -4405,11 +4355,9 @@ void CanvasItemEditor::_button_tool_select(int p_index) { } void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) { - Map<Node *, Object *> &selection = editor_selection->get_selection(); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key()); if (!canvas_item || !canvas_item->is_visible_in_tree()) continue; @@ -4435,7 +4383,6 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool has_chain = false; while (n) { - ik_chain.push_back(n); if (n->has_meta("_edit_ik_")) { has_chain = true; @@ -4448,9 +4395,7 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } if (has_chain && ik_chain.size()) { - for (List<Node2D *>::Element *F = ik_chain.front(); F; F = F->next()) { - if (key_pos) AnimationPlayerEditor::singleton->get_track_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), p_on_existing); if (key_rot) @@ -4462,7 +4407,6 @@ void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, } } else if (Object::cast_to<Control>(canvas_item)) { - Control *ctrl = Object::cast_to<Control>(canvas_item); if (key_pos) @@ -4796,32 +4740,26 @@ void CanvasItemEditor::_popup_callback(int p_op) { case ANIM_INSERT_KEY: case ANIM_INSERT_KEY_EXISTING: { - bool existing = p_op == ANIM_INSERT_KEY_EXISTING; _insert_animation_keys(true, true, true, existing); } break; case ANIM_INSERT_POS: { - key_pos = key_loc_button->is_pressed(); } break; case ANIM_INSERT_ROT: { - key_rot = key_rot_button->is_pressed(); } break; case ANIM_INSERT_SCALE: { - key_scale = key_scale_button->is_pressed(); } break; case ANIM_COPY_POSE: { - pose_clipboard.clear(); Map<Node *, Object *> &selection = editor_selection->get_selection(); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key()); if (!canvas_item || !canvas_item->is_visible_in_tree()) continue; @@ -4830,7 +4768,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { continue; if (Object::cast_to<Node2D>(canvas_item)) { - Node2D *n2d = Object::cast_to<Node2D>(canvas_item); PoseClipboard pc; pc.pos = n2d->get_position(); @@ -4843,13 +4780,11 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case ANIM_PASTE_POSE: { - if (!pose_clipboard.size()) break; undo_redo->create_action(TTR("Paste Pose")); for (List<PoseClipboard>::Element *E = pose_clipboard.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(ObjectDB::get_instance(E->get().id)); if (!n2d) continue; @@ -4864,11 +4799,9 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case ANIM_CLEAR_POSE: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->key()); if (!canvas_item || !canvas_item->is_visible_in_tree()) continue; @@ -4886,7 +4819,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_scale) n2d->set_scale(Vector2(1, 1)); } else if (Object::cast_to<Control>(canvas_item)) { - Control *ctrl = Object::cast_to<Control>(canvas_item); if (key_pos) @@ -4900,7 +4832,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case CLEAR_GUIDES: { - Node *const root = EditorNode::get_singleton()->get_edited_scene(); if (root && (root->has_meta("_edit_horizontal_guides_") || root->has_meta("_edit_vertical_guides_"))) { @@ -4924,12 +4855,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case VIEW_CENTER_TO_SELECTION: case VIEW_FRAME_TO_SELECTION: { - _focus_selection(p_op); } break; case PREVIEW_CANVAS_SCALE: { - bool preview = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(PREVIEW_CANVAS_SCALE)); preview = !preview; RS::get_singleton()->canvas_set_disable_scale(!preview); @@ -4937,12 +4866,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_MAKE_BONES: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); undo_redo->create_action(TTR("Create Custom Bone(s) from Node(s)")); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(E->key()); if (!n2d) continue; @@ -4964,12 +4891,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_CLEAR_BONES: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); undo_redo->create_action(TTR("Clear Bones")); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node2D *n2d = Object::cast_to<Node2D>(E->key()); if (!n2d) continue; @@ -4989,12 +4914,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_SET_IK_CHAIN: { - List<Node *> selection = editor_selection->get_selected_node_list(); undo_redo->create_action(TTR("Make IK Chain")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E->get()); if (!canvas_item || !canvas_item->is_visible_in_tree()) continue; @@ -5012,12 +4935,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_CLEAR_IK_CHAIN: { - Map<Node *, Object *> &selection = editor_selection->get_selection(); undo_redo->create_action(TTR("Clear IK Chain")); for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - CanvasItem *n2d = Object::cast_to<CanvasItem>(E->key()); if (!n2d) continue; @@ -5078,7 +4999,6 @@ void CanvasItemEditor::_focus_selection(int p_op) { return; if (p_op == VIEW_CENTER_TO_SELECTION) { - center = rect.position + rect.size / 2; Vector2 offset = viewport->get_size() / 2 - editor->get_scene_root()->get_global_canvas_transform().xform(center); view_offset.x -= Math::round(offset.x / zoom); @@ -5100,7 +5020,6 @@ void CanvasItemEditor::_focus_selection(int p_op) { } void CanvasItemEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_override_camera_button", "game_running"), &CanvasItemEditor::_update_override_camera_button); ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data); ClassDB::bind_method("_unhandled_key_input", &CanvasItemEditor::_unhandled_key_input); @@ -5114,7 +5033,6 @@ void CanvasItemEditor::_bind_methods() { } Dictionary CanvasItemEditor::get_state() const { - Dictionary state; // Take the editor scale into account. state["zoom"] = zoom / MAX(1, EDSCALE); @@ -5151,7 +5069,6 @@ Dictionary CanvasItemEditor::get_state() const { } void CanvasItemEditor::set_state(const Dictionary &p_state) { - bool update_scrollbars = false; Dictionary state = p_state; if (state.has("zoom")) { @@ -5336,7 +5253,6 @@ void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) { } void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) { - info_overlay->remove_child(p_control); info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10); } @@ -5348,17 +5264,14 @@ void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { } void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) { - hb->remove_child(p_control); } HSplitContainer *CanvasItemEditor::get_palette_split() { - return palette_split; } VSplitContainer *CanvasItemEditor::get_bottom_split() { - return bottom_split; } @@ -5367,7 +5280,6 @@ void CanvasItemEditor::focus_selection() { } CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { - key_pos = true; key_rot = true; key_scale = false; @@ -5826,25 +5738,21 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { CanvasItemEditor *CanvasItemEditor::singleton = nullptr; void CanvasItemEditorPlugin::edit(Object *p_object) { - canvas_item_editor->set_undo_redo(&get_undo_redo()); canvas_item_editor->edit(Object::cast_to<CanvasItem>(p_object)); } bool CanvasItemEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("CanvasItem"); } void CanvasItemEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { canvas_item_editor->show(); canvas_item_editor->set_physics_process(true); 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); RenderingServer::get_singleton()->viewport_set_hide_canvas(editor->get_scene_root()->get_viewport_rid(), true); @@ -5852,16 +5760,13 @@ void CanvasItemEditorPlugin::make_visible(bool p_visible) { } Dictionary CanvasItemEditorPlugin::get_state() const { - return canvas_item_editor->get_state(); } void CanvasItemEditorPlugin::set_state(const Dictionary &p_state) { - canvas_item_editor->set_state(p_state); } CanvasItemEditorPlugin::CanvasItemEditorPlugin(EditorNode *p_node) { - editor = p_node; canvas_item_editor = memnew(CanvasItemEditor(editor)); canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -5897,7 +5802,6 @@ void CanvasItemEditorViewport::_on_change_type_confirmed() { } void CanvasItemEditorViewport::_on_change_type_closed() { - _remove_preview(); } @@ -6203,7 +6107,6 @@ void CanvasItemEditorViewport::_show_resource_type_selector() { } bool CanvasItemEditorViewport::_only_packed_scenes_selected() const { - for (int i = 0; i < selected_files.size(); ++i) { if (ResourceLoader::load(selected_files[i])->get_class() != "PackedScene") { return false; diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 77f23dfd6d..a4ef84f5f3 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -43,7 +43,6 @@ class CanvasItemEditorViewport; class CanvasItemEditorSelectedItem : public Object { - GDCLASS(CanvasItemEditorSelectedItem, Object); public: @@ -65,7 +64,6 @@ public: }; class CanvasItemEditor : public VBoxContainer { - GDCLASS(CanvasItemEditor, VBoxContainer); public: @@ -290,7 +288,6 @@ private: MenuOption last_option; struct _SelectResult { - CanvasItem *item; float z_index; bool has_z; @@ -301,7 +298,6 @@ private: Vector<_SelectResult> selection_results; struct _HoverResult { - Point2 position; Ref<Texture2D> icon; String name; @@ -309,7 +305,6 @@ private: Vector<_HoverResult> hovering_results; struct BoneList { - Transform2D xform; float length = 0.f; uint64_t last_pass = 0; @@ -646,7 +641,6 @@ public: }; class CanvasItemEditorPlugin : public EditorPlugin { - GDCLASS(CanvasItemEditorPlugin, EditorPlugin); CanvasItemEditor *canvas_item_editor; diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 87e9987aa1..08d6fc966d 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -31,12 +31,10 @@ #include "collision_polygon_2d_editor_plugin.h" Node2D *CollisionPolygon2DEditor::_get_node() const { - return node; } void CollisionPolygon2DEditor::_set_node(Node *p_polygon) { - node = Object::cast_to<CollisionPolygon2D>(p_polygon); } diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h index a4fa7c7b3b..b0be92db44 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.h +++ b/editor/plugins/collision_polygon_2d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/2d/collision_polygon_2d.h" class CollisionPolygon2DEditor : public AbstractPolygon2DEditor { - GDCLASS(CollisionPolygon2DEditor, AbstractPolygon2DEditor); CollisionPolygon2D *node; @@ -49,7 +48,6 @@ public: }; class CollisionPolygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - GDCLASS(CollisionPolygon2DEditorPlugin, AbstractPolygon2DEditorPlugin); public: diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 1cee1a040f..9619a97807 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -39,11 +39,8 @@ #include "scene/3d/camera_3d.h" void CollisionPolygon3DEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - button_create->set_icon(get_theme_icon("Edit", "EditorIcons")); button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons")); button_edit->set_pressed(true); @@ -64,7 +61,6 @@ void CollisionPolygon3DEditor::_notification(int p_what) { } } void CollisionPolygon3DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; if (imgeom->get_parent() == p_node) @@ -75,17 +71,13 @@ void CollisionPolygon3DEditor::_node_removed(Node *p_node) { } void CollisionPolygon3DEditor::_menu_option(int p_option) { - switch (p_option) { - case MODE_CREATE: { - mode = MODE_CREATE; button_create->set_pressed(true); button_edit->set_pressed(false); } break; case MODE_EDIT: { - mode = MODE_EDIT; button_create->set_pressed(false); button_edit->set_pressed(true); @@ -94,7 +86,6 @@ void CollisionPolygon3DEditor::_menu_option(int p_option) { } void CollisionPolygon3DEditor::_wip_close() { - undo_redo->create_action(TTR("Create Polygon3D")); undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon")); undo_redo->add_do_method(node, "set_polygon", wip); @@ -110,7 +101,6 @@ void CollisionPolygon3DEditor::_wip_close() { } bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { - if (!node) return false; @@ -123,7 +113,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - Vector2 gpoint = mb->get_position(); Vector3 ray_from = p_camera->project_ray_origin(gpoint); Vector3 ray_dir = p_camera->project_ray_normal(gpoint); @@ -147,13 +136,9 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con real_t grab_threshold = EDITOR_GET("editors/poly_editor/point_grab_radius"); switch (mode) { - case MODE_CREATE: { - if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - if (!wip_active) { - wip.clear(); wip.push_back(cpoint); wip_active = true; @@ -163,14 +148,12 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con edited_point = 1; return true; } else { - if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) { //wip closed _wip_close(); return true; } else { - wip.push_back(cpoint); edited_point = wip.size(); snap_ignore = false; @@ -185,14 +168,10 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } break; case MODE_EDIT: { - if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { - if (mb->get_control()) { - if (poly.size() < 3) { - undo_redo->create_action(TTR("Edit Poly")); undo_redo->add_undo_method(node, "set_polygon", poly); poly.push_back(cpoint); @@ -208,7 +187,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con Vector2 closest_pos; real_t closest_dist = 1e10; for (int i = 0; i < poly.size(); i++) { - Vector2 points[2] = { p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))), p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth))) @@ -227,7 +205,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } if (closest_idx >= 0) { - pre_move_edit = poly; poly.insert(closest_idx + 1, cpoint); edited_point = closest_idx + 1; @@ -239,14 +216,12 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con return true; } } else { - //look for points to move int closest_idx = -1; Vector2 closest_pos; real_t closest_dist = 1e10; for (int i = 0; i < poly.size(); i++) { - Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))); real_t d = cp.distance_to(gpoint); @@ -258,7 +233,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } if (closest_idx >= 0) { - pre_move_edit = poly; edited_point = closest_idx; edited_point_pos = poly[closest_idx]; @@ -268,11 +242,9 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } } } else { - snap_ignore = false; if (edited_point != -1) { - //apply ERR_FAIL_INDEX_V(edited_point, poly.size(), false); @@ -290,12 +262,10 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } } if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) { - int closest_idx = -1; Vector2 closest_pos; real_t closest_dist = 1e10; for (int i = 0; i < poly.size(); i++) { - Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))); real_t d = cp.distance_to(gpoint); @@ -307,7 +277,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } if (closest_idx >= 0) { - undo_redo->create_action(TTR("Edit Poly (Remove Point)")); undo_redo->add_undo_method(node, "set_polygon", poly); poly.remove(closest_idx); @@ -327,7 +296,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con if (mm.is_valid()) { if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) { - Vector2 gpoint = mm->get_position(); Vector3 ray_from = p_camera->project_ray_origin(gpoint); @@ -361,7 +329,6 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con } float CollisionPolygon3DEditor::_get_depth() { - if (bool(node->call("_has_editable_3d_polygon_no_depth"))) return 0; @@ -369,7 +336,6 @@ float CollisionPolygon3DEditor::_get_depth() { } void CollisionPolygon3DEditor::_polygon_draw() { - if (!node) return; @@ -389,7 +355,6 @@ void CollisionPolygon3DEditor::_polygon_draw() { Rect2 rect; for (int i = 0; i < poly.size(); i++) { - Vector2 p, p2; p = i == edited_point ? edited_point_pos : poly[i]; if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point)) @@ -472,11 +437,9 @@ void CollisionPolygon3DEditor::_polygon_draw() { a.resize(Mesh::ARRAY_MAX); Vector<Vector3> va; { - va.resize(poly.size()); Vector3 *w = va.ptrw(); for (int i = 0; i < poly.size(); i++) { - Vector2 p, p2; p = i == edited_point ? edited_point_pos : poly[i]; @@ -490,9 +453,7 @@ void CollisionPolygon3DEditor::_polygon_draw() { } void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) { - if (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) { @@ -517,12 +478,10 @@ void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) { } void CollisionPolygon3DEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw); } CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { - node = nullptr; editor = p_editor; undo_redo = EditorNode::get_undo_redo(); @@ -570,33 +529,27 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { } CollisionPolygon3DEditor::~CollisionPolygon3DEditor() { - memdelete(imgeom); } void Polygon3DEditorPlugin::edit(Object *p_object) { - collision_polygon_editor->edit(Object::cast_to<Node>(p_object)); } bool Polygon3DEditorPlugin::handles(Object *p_object) const { - return Object::cast_to<Node3D>(p_object) && bool(p_object->call("_is_editable_3d_polygon")); } void Polygon3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { collision_polygon_editor->show(); } else { - collision_polygon_editor->hide(); collision_polygon_editor->edit(nullptr); } } Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) { - editor = p_node; collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node)); Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.h b/editor/plugins/collision_polygon_3d_editor_plugin.h index 9751b1f79e..5215cbb678 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.h +++ b/editor/plugins/collision_polygon_3d_editor_plugin.h @@ -41,7 +41,6 @@ class CanvasItemEditor; class CollisionPolygon3DEditor : public HBoxContainer { - GDCLASS(CollisionPolygon3DEditor, HBoxContainer); UndoRedo *undo_redo; @@ -97,7 +96,6 @@ public: }; class Polygon3DEditorPlugin : public EditorPlugin { - GDCLASS(Polygon3DEditorPlugin, EditorPlugin); CollisionPolygon3DEditor *collision_polygon_editor; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 8973dca963..0f381c06b4 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -40,14 +40,12 @@ #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) { case CAPSULE_SHAPE: { Ref<CapsuleShape2D> capsule = node->get_shape(); @@ -70,11 +68,9 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const { } break; case CONCAVE_POLYGON_SHAPE: { - } break; case CONVEX_POLYGON_SHAPE: { - } break; case LINE_SHAPE: { @@ -122,7 +118,6 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const { } void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { - switch (shape_type) { case CAPSULE_SHAPE: { if (idx < 2) { @@ -150,11 +145,9 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { } break; case CONCAVE_POLYGON_SHAPE: { - } break; case CONVEX_POLYGON_SHAPE: { - } break; case LINE_SHAPE: { @@ -217,7 +210,6 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) { } void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { - undo_redo->create_action(TTR("Set Handle")); switch (shape_type) { @@ -249,11 +241,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { } break; case CONCAVE_POLYGON_SHAPE: { - } break; case CONVEX_POLYGON_SHAPE: { - } break; case LINE_SHAPE: { @@ -314,7 +304,6 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) { } bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) { - if (!node) { return false; } @@ -331,7 +320,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); if (mb.is_valid()) { - Vector2 gpoint = mb->get_position(); if (mb->get_button_index() == BUTTON_LEFT) { @@ -373,7 +361,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (edit_handle == -1 || !pressed) { return false; } @@ -390,7 +377,6 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e } void CollisionShape2DEditor::_get_current_shape_type() { - if (!node) { return; } @@ -425,7 +411,6 @@ void CollisionShape2DEditor::_get_current_shape_type() { } void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { - if (!node) { return; } @@ -474,11 +459,9 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case CONCAVE_POLYGON_SHAPE: { - } break; case CONVEX_POLYGON_SHAPE: { - } break; case LINE_SHAPE: { @@ -533,9 +516,7 @@ 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; @@ -547,7 +528,6 @@ void CollisionShape2DEditor::_notification(int p_what) { } void CollisionShape2DEditor::edit(Node *p_node) { - if (!canvas_item_editor) { canvas_item_editor = CanvasItemEditor::get_singleton(); } @@ -568,12 +548,10 @@ void CollisionShape2DEditor::edit(Node *p_node) { } void CollisionShape2DEditor::_bind_methods() { - ClassDB::bind_method("_get_current_shape_type", &CollisionShape2DEditor::_get_current_shape_type); } CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) { - node = nullptr; canvas_item_editor = nullptr; editor = p_editor; @@ -585,24 +563,20 @@ CollisionShape2DEditor::CollisionShape2DEditor(EditorNode *p_editor) { } void CollisionShape2DEditorPlugin::edit(Object *p_obj) { - collision_shape_2d_editor->edit(Object::cast_to<Node>(p_obj)); } bool CollisionShape2DEditorPlugin::handles(Object *p_obj) const { - return p_obj->is_class("CollisionShape2D"); } void CollisionShape2DEditorPlugin::make_visible(bool visible) { - if (!visible) { edit(nullptr); } } CollisionShape2DEditorPlugin::CollisionShape2DEditorPlugin(EditorNode *p_editor) { - editor = p_editor; collision_shape_2d_editor = memnew(CollisionShape2DEditor(p_editor)); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index ef4d7d7646..a601c1440d 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -37,53 +37,42 @@ #include "scene/resources/particles_material.h" void CPUParticles2DEditorPlugin::edit(Object *p_object) { - particles = Object::cast_to<CPUParticles2D>(p_object); } bool CPUParticles2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("CPUParticles2D"); } void CPUParticles2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - toolbar->show(); } else { - toolbar->hide(); } } void CPUParticles2DEditorPlugin::_file_selected(const String &p_file) { - source_emission_file = p_file; emission_mask->popup_centered(); } void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) { - switch (p_idx) { case MENU_LOAD_EMISSION_MASK: { - file->popup_centered_ratio(); } break; case MENU_CLEAR_EMISSION_MASK: { - emission_mask->popup_centered(); } break; case MENU_RESTART: { - particles->restart(); } } } void CPUParticles2DEditorPlugin::_generate_emission_mask() { - Ref<Image> img; img.instance(); Error err = ImageLoader::load_image(source_emission_file, img); @@ -123,13 +112,10 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { - uint8_t a = r[(j * s.width + i) * 4 + 3]; if (a > 128) { - if (emode == EMISSION_MODE_SOLID) { - if (capture_colors) { valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; @@ -139,11 +125,9 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { valid_positions.write[vpc++] = Point2(i, j); } else { - bool on_border = false; for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { - if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) { on_border = true; break; @@ -161,7 +145,6 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { Vector2 normal; for (int x = i - 2; x <= i + 2; x++) { for (int y = j - 2; y <= j + 2; y++) { - if (x == i && y == j) continue; @@ -237,9 +220,7 @@ void CPUParticles2DEditorPlugin::_generate_emission_mask() { } void CPUParticles2DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback)); menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons")); file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected)); @@ -250,7 +231,6 @@ void CPUParticles2DEditorPlugin::_bind_methods() { } CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h index 21b06b6489..fecbb8b1cd 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.h +++ b/editor/plugins/cpu_particles_2d_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/gui/file_dialog.h" class CPUParticles2DEditorPlugin : public EditorPlugin { - GDCLASS(CPUParticles2DEditorPlugin, EditorPlugin); enum { diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp index 59a353a581..ef26ecd767 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp @@ -33,7 +33,6 @@ #include "editor/plugins/node_3d_editor_plugin.h" void CPUParticles3DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; hide(); @@ -41,24 +40,19 @@ void CPUParticles3DEditor::_node_removed(Node *p_node) { } void CPUParticles3DEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE) { options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons")); } } void CPUParticles3DEditor::_menu_option(int p_option) { - switch (p_option) { - case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { - emission_tree_dialog->popup_centered_ratio(); } break; case MENU_OPTION_RESTART: { - node->restart(); } break; @@ -66,13 +60,11 @@ void CPUParticles3DEditor::_menu_option(int p_option) { } void CPUParticles3DEditor::edit(CPUParticles3D *p_particles) { - base_node = p_particles; node = p_particles; } void CPUParticles3DEditor::_generate_emission_points() { - /// hacer codigo aca Vector<Vector3> points; Vector<Vector3> normals; @@ -95,7 +87,6 @@ void CPUParticles3DEditor::_bind_methods() { } CPUParticles3DEditor::CPUParticles3DEditor() { - particles_editor_hb = memnew(HBoxContainer); Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); options = memnew(MenuButton); @@ -110,17 +101,14 @@ CPUParticles3DEditor::CPUParticles3DEditor() { } void CPUParticles3DEditorPlugin::edit(Object *p_object) { - particles_editor->edit(Object::cast_to<CPUParticles3D>(p_object)); } bool CPUParticles3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("CPUParticles3D"); } void CPUParticles3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { particles_editor->show(); particles_editor->particles_editor_hb->show(); @@ -132,7 +120,6 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) { } CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) { - editor = p_node; particles_editor = memnew(CPUParticles3DEditor); editor->get_viewport()->add_child(particles_editor); diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index 796c842e07..d9680496ba 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/cpu_particles_3d.h" class CPUParticles3DEditor : public GPUParticles3DEditorBase { - GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase); enum Menu { @@ -65,7 +64,6 @@ public: }; class CPUParticles3DEditorPlugin : public EditorPlugin { - GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin); CPUParticles3DEditor *particles_editor; diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index fc8eef52c0..94059ea39d 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -65,7 +65,6 @@ CurveEditor::CurveEditor() { } void CurveEditor::set_curve(Ref<Curve> curve) { - if (curve == _curve_ref) return; @@ -101,14 +100,11 @@ void CurveEditor::_notification(int p_what) { } void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb_ref = p_event; if (mb_ref.is_valid()) { - const InputEventMouseButton &mb = **mb_ref; if (mb.is_pressed() && !_dragging) { - Vector2 mpos = mb.get_position(); _selected_tangent = get_tangent_at(mpos); @@ -134,7 +130,6 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { if (!mb.is_pressed() && _dragging && mb.get_button_index() == BUTTON_LEFT) { _dragging = false; if (_has_undo_data) { - UndoRedo &ur = *EditorNode::get_singleton()->get_undo_redo(); ur.create_action(_selected_tangent == TANGENT_NONE ? TTR("Modify Curve Point") : TTR("Modify Curve Tangent")); @@ -151,13 +146,11 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm_ref = p_event; if (mm_ref.is_valid()) { - const InputEventMouseMotion &mm = **mm_ref; Vector2 mpos = mm.get_position(); if (_dragging && _curve_ref.is_valid()) { - if (_selected_point != -1) { Curve &curve = **_curve_ref; @@ -473,7 +466,6 @@ void CurveEditor::toggle_linear(TangentIndex tangent) { tangent = _selected_tangent; if (tangent == TANGENT_LEFT) { - bool is_linear = _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR; Curve::TangentMode prev_mode = _curve_ref->get_point_left_mode(_selected_point); @@ -483,7 +475,6 @@ void CurveEditor::toggle_linear(TangentIndex tangent) { ur.add_undo_method(*_curve_ref, "set_point_left_mode", _selected_point, prev_mode); } else { - bool is_linear = _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR; Curve::TangentMode prev_mode = _curve_ref->get_point_right_mode(_selected_point); @@ -538,7 +529,6 @@ void CurveEditor::update_view_transform() { } Vector2 CurveEditor::get_tangent_view_pos(int i, TangentIndex tangent) const { - Vector2 dir; if (tangent == TANGENT_LEFT) dir = -Vector2(1, _curve_ref->get_point_left_tangent(i)); @@ -562,7 +552,6 @@ Vector2 CurveEditor::get_world_pos(Vector2 view_pos) const { // Uses non-baked points, but takes advantage of ordered iteration to be faster template <typename T> static void plot_curve_accurate(const Curve &curve, float step, T plot_func) { - if (curve.get_point_count() <= 1) { // Not enough points to make a curve, so it's just a straight line float y = curve.interpolate(0); @@ -600,7 +589,6 @@ static void plot_curve_accurate(const Curve &curve, float step, T plot_func) { } struct CanvasItemPlotCurve { - CanvasItem &ci; Color color1; Color color2; @@ -685,7 +673,6 @@ void CurveEditor::_draw() { // Draw tangents for current point if (_selected_point >= 0) { - const Color tangent_color = get_theme_color("accent_color", "Editor"); int i = _selected_point; @@ -754,12 +741,10 @@ void CurveEditor::_bind_methods() { //--------------- bool EditorInspectorPluginCurve::can_handle(Object *p_object) { - return Object::cast_to<Curve>(p_object) != nullptr; } void EditorInspectorPluginCurve::parse_begin(Object *p_object) { - Curve *curve = Object::cast_to<Curve>(p_object); ERR_FAIL_COND(!curve); Ref<Curve> c(curve); @@ -785,7 +770,6 @@ bool CurvePreviewGenerator::handles(const String &p_type) const { } Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, const Size2 &p_size) const { - Ref<Curve> curve_ref = p_from; ERR_FAIL_COND_V_MSG(curve_ref.is_null(), Ref<Texture2D>(), "It's not a reference to a valid Resource object."); Curve &curve = **curve_ref; @@ -811,7 +795,6 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons int prev_y = 0; for (int x = 0; x < im.get_width(); ++x) { - float t = static_cast<float>(x) / im.get_width(); float v = (curve.interpolate_baked(t) - curve.get_min_value()) / range_y; int y = CLAMP(im.get_height() - v * im.get_height(), 0, im.get_height()); diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index e0d345663c..da060c3093 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -114,7 +114,6 @@ void DebuggerEditorPlugin::_select_run_count(int p_index) { void DebuggerEditorPlugin::_menu_option(int p_option) { switch (p_option) { case RUN_FILE_SERVER: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_FILE_SERVER)); if (ischecked) { @@ -128,7 +127,6 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { } break; case RUN_LIVE_DEBUG: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_LIVE_DEBUG), !ischecked); @@ -137,28 +135,24 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { } break; case RUN_DEPLOY_REMOTE_DEBUG: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEPLOY_REMOTE_DEBUG), !ischecked); EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_deploy_remote_debug", !ischecked); } break; case RUN_DEBUG_COLLISONS: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_COLLISONS), !ischecked); EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_collisons", !ischecked); } break; case RUN_DEBUG_NAVIGATION: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked); EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked); } break; case RUN_RELOAD_SCRIPTS: { - bool ischecked = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS)); debug_menu->get_popup()->set_item_checked(debug_menu->get_popup()->get_item_index(RUN_RELOAD_SCRIPTS), !ischecked); diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h index 5ec6399921..465041b5a7 100644 --- a/editor/plugins/debugger_editor_plugin.h +++ b/editor/plugins/debugger_editor_plugin.h @@ -39,7 +39,6 @@ class MenuButton; class PopupMenu; class DebuggerEditorPlugin : public EditorPlugin { - GDCLASS(DebuggerEditorPlugin, EditorPlugin); private: diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 2db0903f04..4895696f36 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -43,7 +43,6 @@ #include "servers/audio/audio_stream.h" void post_process_preview(Ref<Image> p_image) { - if (p_image->get_format() != Image::FORMAT_RGBA8) p_image->convert(Image::FORMAT_RGBA8); @@ -71,7 +70,6 @@ void post_process_preview(Ref<Image> p_image) { } bool EditorTexturePreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture2D"); } @@ -80,7 +78,6 @@ bool EditorTexturePreviewPlugin::generate_small_preview_automatically() const { } Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<Image> img; Ref<AtlasTexture> atex = p_from; Ref<LargeTexture> ltex = p_from; @@ -143,12 +140,10 @@ EditorTexturePreviewPlugin::EditorTexturePreviewPlugin() { //////////////////////////////////////////////////////////////////////////// bool EditorImagePreviewPlugin::handles(const String &p_type) const { - return p_type == "Image"; } Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<Image> img = p_from; if (img.is_null() || img->empty()) @@ -191,12 +186,10 @@ bool EditorImagePreviewPlugin::generate_small_preview_automatically() const { //////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////// bool EditorBitmapPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "BitMap"); } Ref<Texture2D> EditorBitmapPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<BitMap> bm = p_from; if (bm->get_size() == Size2()) { @@ -259,17 +252,14 @@ EditorBitmapPreviewPlugin::EditorBitmapPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// bool EditorPackedScenePreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "PackedScene"); } Ref<Texture2D> EditorPackedScenePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - return generate_from_path(p_from->get_path(), p_size); } Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { - String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -285,7 +275,6 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String & img.instance(); Error err = img->load(path); if (err == OK) { - Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); post_process_preview(img); @@ -303,17 +292,14 @@ EditorPackedScenePreviewPlugin::EditorPackedScenePreviewPlugin() { ////////////////////////////////////////////////////////////////// void EditorMaterialPreviewPlugin::_preview_done(const Variant &p_udata) { - preview_done = true; } void EditorMaterialPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorMaterialPreviewPlugin::_preview_done); } bool EditorMaterialPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Material"); //any material } @@ -322,12 +308,10 @@ bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const { } Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<Material> material = p_from; ERR_FAIL_COND_V(material.is_null(), Ref<Texture2D>()); if (material->get_shader_mode() == Shader::MODE_SPATIAL) { - RS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture @@ -357,7 +341,6 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si } EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { - scenario = RS::get_singleton()->scenario_create(); viewport = RS::get_singleton()->viewport_create(); @@ -408,7 +391,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { double zr1 = Math::cos(lat1); for (int j = lons; j >= 1; j--) { - double lng0 = 2 * Math_PI * (double)(j - 1) / lons; double x0 = Math::cos(lng0); double y0 = Math::sin(lng0); @@ -462,7 +444,6 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { } EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() { - RS::get_singleton()->free(sphere); RS::get_singleton()->free(sphere_instance); RS::get_singleton()->free(viewport); @@ -477,17 +458,14 @@ EditorMaterialPreviewPlugin::~EditorMaterialPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// static bool _is_text_char(CharType c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'; } bool EditorScriptPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Script"); } Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<Script> scr = p_from; if (scr.is_null()) return Ref<Texture2D>(); @@ -502,7 +480,6 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size Set<String> keywords; for (List<String>::Element *E = kwors.front(); E; E = E->next()) { - keywords.insert(E->get()); } @@ -536,7 +513,6 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size bool prev_is_text = false; bool in_keyword = false; for (int i = 0; i < code.length(); i++) { - CharType c = code[i]; if (c > 32) { if (col < thumbnail_size) { @@ -571,7 +547,6 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size prev_is_text = _is_text_char(c); } } else { - prev_is_text = false; in_keyword = false; @@ -600,12 +575,10 @@ EditorScriptPreviewPlugin::EditorScriptPreviewPlugin() { /////////////////////////////////////////////////////////////////// bool EditorAudioStreamPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "AudioStream"); } Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<AudioStream> stream = p_from; ERR_FAIL_COND_V(stream.is_null(), Ref<Texture2D>()); @@ -635,7 +608,6 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const playback->stop(); for (int i = 0; i < w; i++) { - float max = -1000; float min = 1000; int from = uint64_t(i) * frame_length / w; @@ -647,7 +619,6 @@ Ref<Texture2D> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const } for (int j = from; j < to; j++) { - max = MAX(max, frames[j].l); max = MAX(max, frames[j].r); @@ -688,21 +659,17 @@ EditorAudioStreamPreviewPlugin::EditorAudioStreamPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) { - preview_done = true; } void EditorMeshPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorMeshPreviewPlugin::_preview_done); } bool EditorMeshPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh } Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - Ref<Mesh> mesh = p_from; ERR_FAIL_COND_V(mesh.is_null(), Ref<Texture2D>()); @@ -758,7 +725,6 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 } EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { - scenario = RS::get_singleton()->scenario_create(); viewport = RS::get_singleton()->viewport_create(); @@ -792,7 +758,6 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { } EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { - //RS::get_singleton()->free(sphere); RS::get_singleton()->free(mesh_instance); RS::get_singleton()->free(viewport); @@ -807,22 +772,18 @@ EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// void EditorFontPreviewPlugin::_preview_done(const Variant &p_udata) { - preview_done = true; } void EditorFontPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorFontPreviewPlugin::_preview_done); } bool EditorFontPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont"); } Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const { - RES res = ResourceLoader::load(p_path); Ref<DynamicFont> sampled_font; if (res->is_class("DynamicFont")) { @@ -881,7 +842,6 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, } Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { - String path = p_from->get_path(); if (!FileAccess::exists(path)) { return Ref<Texture2D>(); @@ -890,7 +850,6 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 } EditorFontPreviewPlugin::EditorFontPreviewPlugin() { - 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); @@ -905,7 +864,6 @@ EditorFontPreviewPlugin::EditorFontPreviewPlugin() { } EditorFontPreviewPlugin::~EditorFontPreviewPlugin() { - RS::get_singleton()->free(canvas_item); RS::get_singleton()->free(canvas); RS::get_singleton()->free(viewport); diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index 840fa2410a..8a9d6a93fb 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -69,7 +69,6 @@ public: }; class EditorPackedScenePreviewPlugin : public EditorResourcePreviewGenerator { - public: virtual bool handles(const String &p_type) const; virtual Ref<Texture2D> generate(const RES &p_from, const Size2 &p_size) const; @@ -79,7 +78,6 @@ public: }; class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator { - GDCLASS(EditorMaterialPreviewPlugin, EditorResourcePreviewGenerator); RID scenario; @@ -125,7 +123,6 @@ public: }; class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { - GDCLASS(EditorMeshPreviewPlugin, EditorResourcePreviewGenerator); RID scenario; @@ -153,7 +150,6 @@ public: }; class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { - GDCLASS(EditorFontPreviewPlugin, EditorResourcePreviewGenerator); RID viewport; diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp index 6a171c4703..9669853f1b 100644 --- a/editor/plugins/gi_probe_editor_plugin.cpp +++ b/editor/plugins/gi_probe_editor_plugin.cpp @@ -31,7 +31,6 @@ #include "gi_probe_editor_plugin.h" void GIProbeEditorPlugin::_bake() { - if (gi_probe) { if (gi_probe->get_probe_data().is_null()) { String path = get_tree()->get_edited_scene_root()->get_filename(); @@ -50,7 +49,6 @@ void GIProbeEditorPlugin::_bake() { } void GIProbeEditorPlugin::edit(Object *p_object) { - GIProbe *s = Object::cast_to<GIProbe>(p_object); if (!s) return; @@ -59,12 +57,10 @@ void GIProbeEditorPlugin::edit(Object *p_object) { } bool GIProbeEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("GIProbe"); } void GIProbeEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_PROCESS) { if (!gi_probe) { return; @@ -102,12 +98,10 @@ void GIProbeEditorPlugin::_notification(int p_what) { } void GIProbeEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { bake_hb->show(); set_process(true); } else { - bake_hb->hide(); set_process(false); } @@ -116,14 +110,12 @@ void GIProbeEditorPlugin::make_visible(bool p_visible) { EditorProgress *GIProbeEditorPlugin::tmp_progress = nullptr; void GIProbeEditorPlugin::bake_func_begin(int p_steps) { - 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 == nullptr); tmp_progress->step(p_description, p_step, false); } @@ -147,7 +139,6 @@ void GIProbeEditorPlugin::_bind_methods() { } GIProbeEditorPlugin::GIProbeEditorPlugin(EditorNode *p_node) { - editor = p_node; bake_hb = memnew(HBoxContainer); bake_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h index 2068ebaaa8..508c3d825b 100644 --- a/editor/plugins/gi_probe_editor_plugin.h +++ b/editor/plugins/gi_probe_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/resources/material.h" class GIProbeEditorPlugin : public EditorPlugin { - GDCLASS(GIProbeEditorPlugin, EditorPlugin); GIProbe *gi_probe; diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp index 5c35285c22..fa97e3dcca 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp @@ -37,34 +37,27 @@ #include "scene/resources/particles_material.h" void GPUParticles2DEditorPlugin::edit(Object *p_object) { - particles = Object::cast_to<GPUParticles2D>(p_object); } bool GPUParticles2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("GPUParticles2D"); } void GPUParticles2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - toolbar->show(); } else { - toolbar->hide(); } } void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) { - source_emission_file = p_file; emission_mask->popup_centered(); } void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { - switch (p_idx) { case MENU_GENERATE_VISIBILITY_RECT: { float gen_time = particles->get_lifetime(); @@ -75,16 +68,13 @@ void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { generate_visibility_rect->popup_centered(); } break; case MENU_LOAD_EMISSION_MASK: { - file->popup_centered_ratio(); } break; case MENU_CLEAR_EMISSION_MASK: { - emission_mask->popup_centered(); } break; case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { - CPUParticles2D *cpu_particles = memnew(CPUParticles2D); cpu_particles->convert_from_particles(particles); cpu_particles->set_name(particles->get_name()); @@ -103,14 +93,12 @@ void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) { } break; case MENU_RESTART: { - particles->restart(); } } } void GPUParticles2DEditorPlugin::_generate_visibility_rect() { - float time = generate_seconds->get_value(); float running = 0.0; @@ -125,7 +113,6 @@ void GPUParticles2DEditorPlugin::_generate_visibility_rect() { Rect2 rect; while (running < time) { - uint64_t ticks = OS::get_singleton()->get_ticks_usec(); ep.step("Generating...", int(running), true); OS::get_singleton()->delay_usec(1000); @@ -150,7 +137,6 @@ void GPUParticles2DEditorPlugin::_generate_visibility_rect() { } void GPUParticles2DEditorPlugin::_generate_emission_mask() { - Ref<ParticlesMaterial> pm = particles->get_process_material(); if (!pm.is_valid()) { EditorNode::get_singleton()->show_warning(TTR("Can only set point into a ParticlesMaterial process material")); @@ -196,13 +182,10 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { for (int i = 0; i < s.width; i++) { for (int j = 0; j < s.height; j++) { - uint8_t a = r[(j * s.width + i) * 4 + 3]; if (a > 128) { - if (emode == EMISSION_MODE_SOLID) { - if (capture_colors) { valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0]; valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1]; @@ -212,11 +195,9 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { valid_positions.write[vpc++] = Point2(i, j); } else { - bool on_border = false; for (int x = i - 1; x <= i + 1; x++) { for (int y = j - 1; y <= j + 1; y++) { - if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) { on_border = true; break; @@ -234,7 +215,6 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { Vector2 normal; for (int x = i - 2; x <= i + 2; x++) { for (int y = j - 2; y <= j + 2; y++) { - if (x == i && y == j) continue; @@ -281,7 +261,6 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { uint8_t *tw = texdata.ptrw(); float *twf = (float *)tw; for (int i = 0; i < vpc; i++) { - twf[i * 2 + 0] = valid_positions[i].x; twf[i * 2 + 1] = valid_positions[i].y; } @@ -298,14 +277,12 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { pm->set_emission_point_count(vpc); if (capture_colors) { - Vector<uint8_t> colordata; colordata.resize(w * h * 4); //use RG texture { uint8_t *tw = colordata.ptrw(); for (int i = 0; i < vpc * 4; i++) { - tw[i] = valid_colors[i]; } } @@ -346,9 +323,7 @@ void GPUParticles2DEditorPlugin::_generate_emission_mask() { } void GPUParticles2DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback)); menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons")); file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected)); @@ -359,7 +334,6 @@ void GPUParticles2DEditorPlugin::_bind_methods() { } GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) { - particles = nullptr; editor = p_node; undo_redo = editor->get_undo_redo(); diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 008d04a211..c76cecb3a2 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/gui/file_dialog.h" class GPUParticles2DEditorPlugin : public EditorPlugin { - GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin); enum { diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 7f80acc176..da1bc89e33 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -36,16 +36,13 @@ #include "scene/resources/particles_material.h" bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) { - bool use_normals = emission_fill->get_selected() == 1; if (emission_fill->get_selected() < 2) { - float area_accum = 0; Map<float, int> triangle_area_map; for (int i = 0; i < geometry.size(); i++) { - float area = geometry[i].get_area(); if (area < CMP_EPSILON) continue; @@ -54,7 +51,6 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 } if (!triangle_area_map.size() || area_accum == 0) { - EditorNode::get_singleton()->show_warning(TTR("The geometry's faces don't contain any area.")); return false; } @@ -62,7 +58,6 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 int emissor_count = emission_amount->get_value(); for (int i = 0; i < emissor_count; i++) { - float areapos = Math::random(0.0f, area_accum); Map<float, int>::Element *E = triangle_area_map.find_closest(areapos); @@ -84,11 +79,9 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 } } } else { - int gcount = geometry.size(); if (gcount == 0) { - EditorNode::get_singleton()->show_warning(TTR("The geometry doesn't contain any faces.")); return false; } @@ -98,9 +91,7 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 AABB aabb; for (int i = 0; i < gcount; i++) { - for (int j = 0; j < 3; j++) { - if (i == 0 && j == 0) aabb.position = r[i].vertex[j]; else @@ -111,11 +102,9 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 int emissor_count = emission_amount->get_value(); for (int i = 0; i < emissor_count; i++) { - int attempts = 5; for (int j = 0; j < attempts; j++) { - Vector3 dir; dir[Math::rand() % 3] = 1.0; Vector3 ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size + aabb.position; @@ -129,12 +118,10 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 float max = -1e7, min = 1e7; for (int k = 0; k < gcount; k++) { - const Face3 &f3 = r[k]; Vector3 res; if (f3.intersects_segment(ofs, ofsv, &res)) { - res -= ofs; float d = dir.dot(res); @@ -162,20 +149,17 @@ bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3 } void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) { - Node *sel = get_node(p_path); if (!sel) return; if (!sel->is_class("Node3D")) { - EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Node3D."), sel->get_name())); return; } 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; } @@ -183,7 +167,6 @@ void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) { geometry = vi->get_faces(VisualInstance3D::FACES_SOLID); if (geometry.size() == 0) { - EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain face geometry."), sel->get_name())); return; } @@ -206,7 +189,6 @@ void GPUParticles3DEditorBase::_bind_methods() { } GPUParticles3DEditorBase::GPUParticles3DEditorBase() { - emission_dialog = memnew(ConfirmationDialog); emission_dialog->set_title(TTR("Create Emitter")); add_child(emission_dialog); @@ -234,7 +216,6 @@ GPUParticles3DEditorBase::GPUParticles3DEditorBase() { } void GPUParticles3DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; hide(); @@ -242,7 +223,6 @@ void GPUParticles3DEditor::_node_removed(Node *p_node) { } void GPUParticles3DEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE) { options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons")); get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed)); @@ -250,9 +230,7 @@ void GPUParticles3DEditor::_notification(int p_notification) { } void GPUParticles3DEditor::_menu_option(int p_option) { - switch (p_option) { - case MENU_OPTION_GENERATE_AABB: { float gen_time = node->get_lifetime(); @@ -273,7 +251,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { - CPUParticles3D *cpu_particles = memnew(CPUParticles3D); cpu_particles->convert_from_particles(node); cpu_particles->set_name(node->get_name()); @@ -291,7 +268,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_RESTART: { - node->restart(); } break; @@ -299,7 +275,6 @@ void GPUParticles3DEditor::_menu_option(int p_option) { } void GPUParticles3DEditor::_generate_aabb() { - float time = generate_seconds->get_value(); float running = 0.0; @@ -315,7 +290,6 @@ void GPUParticles3DEditor::_generate_aabb() { AABB rect; while (running < time) { - uint64_t ticks = OS::get_singleton()->get_ticks_usec(); ep.step("Generating...", int(running), true); OS::get_singleton()->delay_usec(1000); @@ -341,13 +315,11 @@ void GPUParticles3DEditor::_generate_aabb() { } void GPUParticles3DEditor::edit(GPUParticles3D *p_particles) { - base_node = p_particles; node = p_particles; } void GPUParticles3DEditor::_generate_emission_points() { - /// hacer codigo aca Vector<Vector3> points; Vector<Vector3> normals; @@ -385,7 +357,6 @@ void GPUParticles3DEditor::_generate_emission_points() { ERR_FAIL_COND(material.is_null()); if (normals.size() > 0) { - material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_DIRECTED_POINTS); material->set_emission_point_count(point_count); material->set_emission_point_texture(tex); @@ -412,7 +383,6 @@ void GPUParticles3DEditor::_generate_emission_points() { material->set_emission_normal_texture(tex2); } else { - material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_POINTS); material->set_emission_point_count(point_count); material->set_emission_point_texture(tex); @@ -423,7 +393,6 @@ void GPUParticles3DEditor::_bind_methods() { } GPUParticles3DEditor::GPUParticles3DEditor() { - node = nullptr; particles_editor_hb = memnew(HBoxContainer); Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); @@ -456,17 +425,14 @@ GPUParticles3DEditor::GPUParticles3DEditor() { } void GPUParticles3DEditorPlugin::edit(Object *p_object) { - particles_editor->edit(Object::cast_to<GPUParticles3D>(p_object)); } bool GPUParticles3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("GPUParticles3D"); } void GPUParticles3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { particles_editor->show(); particles_editor->particles_editor_hb->show(); @@ -478,7 +444,6 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) { } GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) { - editor = p_node; particles_editor = memnew(GPUParticles3DEditor); editor->get_viewport()->add_child(particles_editor); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index cf1cff32c0..7838a63436 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/spin_box.h" class GPUParticles3DEditorBase : public Control { - GDCLASS(GPUParticles3DEditorBase, Control); protected: @@ -65,7 +64,6 @@ public: }; class GPUParticles3DEditor : public GPUParticles3DEditorBase { - GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase); ConfirmationDialog *generate_aabb; @@ -101,7 +99,6 @@ public: }; class GPUParticles3DEditorPlugin : public EditorPlugin { - GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin); GPUParticles3DEditor *particles_editor; diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 67de610ae7..6c0ce699ac 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -38,7 +38,6 @@ Size2 GradientEditor::get_minimum_size() const { return Size2(0, 60) * EDSCALE; } void GradientEditor::_gradient_changed() { - if (editing) return; @@ -49,7 +48,6 @@ void GradientEditor::_gradient_changed() { } void GradientEditor::_ramp_changed() { - editing = true; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); undo_redo->create_action(TTR("Gradient Edited")); @@ -78,12 +76,10 @@ GradientEditor::GradientEditor() { /////////////////////// bool EditorInspectorPluginGradient::can_handle(Object *p_object) { - return Object::cast_to<Gradient>(p_object) != nullptr; } void EditorInspectorPluginGradient::parse_begin(Object *p_object) { - Gradient *gradient = Object::cast_to<Gradient>(p_object); Ref<Gradient> g(gradient); @@ -93,7 +89,6 @@ void EditorInspectorPluginGradient::parse_begin(Object *p_object) { } GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginGradient> plugin; plugin.instance(); add_inspector_plugin(plugin); diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h index 9ebd9610e5..0641d54d5c 100644 --- a/editor/plugins/gradient_editor_plugin.h +++ b/editor/plugins/gradient_editor_plugin.h @@ -62,7 +62,6 @@ public: }; class GradientEditorPlugin : public EditorPlugin { - GDCLASS(GradientEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 1dbc78804b..77f60b6677 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -34,7 +34,6 @@ #include "editor/editor_scale.h" bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; int idx = name.get_slice("/", 0).to_int(); String what = name.get_slice("/", 1); @@ -69,7 +68,6 @@ bool ItemListPlugin::_set(const StringName &p_name, const Variant &p_value) { } bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; int idx = name.get_slice("/", 0).to_int(); String what = name.get_slice("/", 1); @@ -99,9 +97,7 @@ bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const { return true; } void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const { - for (int i = 0; i < get_item_count(); i++) { - String base = itos(i) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, base + "text")); @@ -130,46 +126,38 @@ void ItemListPlugin::_get_property_list(List<PropertyInfo> *p_list) const { /////////////////////////////////////////////////////////////// void ItemListOptionButtonPlugin::set_object(Object *p_object) { - ob = Object::cast_to<OptionButton>(p_object); } bool ItemListOptionButtonPlugin::handles(Object *p_object) const { - return p_object->is_class("OptionButton"); } int ItemListOptionButtonPlugin::get_flags() const { - return FLAG_ICON | FLAG_ID | FLAG_ENABLE; } void ItemListOptionButtonPlugin::add_item() { - ob->add_item(vformat(TTR("Item %d"), ob->get_item_count())); _change_notify(); } int ItemListOptionButtonPlugin::get_item_count() const { - return ob->get_item_count(); } void ItemListOptionButtonPlugin::erase(int p_idx) { - ob->remove_item(p_idx); _change_notify(); } ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() { - ob = nullptr; } /////////////////////////////////////////////////////////////// void ItemListPopupMenuPlugin::set_object(Object *p_object) { - if (p_object->is_class("MenuButton")) pp = Object::cast_to<MenuButton>(p_object)->get_popup(); else @@ -177,73 +165,60 @@ void ItemListPopupMenuPlugin::set_object(Object *p_object) { } bool ItemListPopupMenuPlugin::handles(Object *p_object) const { - return p_object->is_class("PopupMenu") || p_object->is_class("MenuButton"); } int ItemListPopupMenuPlugin::get_flags() const { - return FLAG_ICON | FLAG_CHECKABLE | FLAG_ID | FLAG_ENABLE | FLAG_SEPARATOR; } void ItemListPopupMenuPlugin::add_item() { - pp->add_item(vformat(TTR("Item %d"), pp->get_item_count())); _change_notify(); } int ItemListPopupMenuPlugin::get_item_count() const { - return pp->get_item_count(); } void ItemListPopupMenuPlugin::erase(int p_idx) { - pp->remove_item(p_idx); _change_notify(); } ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() { - pp = nullptr; } /////////////////////////////////////////////////////////////// void ItemListItemListPlugin::set_object(Object *p_object) { - pp = Object::cast_to<ItemList>(p_object); } bool ItemListItemListPlugin::handles(Object *p_object) const { - return p_object->is_class("ItemList"); } int ItemListItemListPlugin::get_flags() const { - return FLAG_ICON | FLAG_ENABLE; } void ItemListItemListPlugin::add_item() { - pp->add_item(vformat(TTR("Item %d"), pp->get_item_count())); _change_notify(); } int ItemListItemListPlugin::get_item_count() const { - return pp->get_item_count(); } void ItemListItemListPlugin::erase(int p_idx) { - pp->remove_item(p_idx); _change_notify(); } ItemListItemListPlugin::ItemListItemListPlugin() { - pp = nullptr; } @@ -252,7 +227,6 @@ ItemListItemListPlugin::ItemListItemListPlugin() { /////////////////////////////////////////////////////////////// void ItemListEditor::_node_removed(Node *p_node) { - if (p_node == item_list) { item_list = nullptr; hide(); @@ -261,19 +235,15 @@ void ItemListEditor::_node_removed(Node *p_node) { } void ItemListEditor::_notification(int p_notification) { - if (p_notification == NOTIFICATION_ENTER_TREE || p_notification == NOTIFICATION_THEME_CHANGED) { - add_button->set_icon(get_theme_icon("Add", "EditorIcons")); del_button->set_icon(get_theme_icon("Remove", "EditorIcons")); } else if (p_notification == NOTIFICATION_READY) { - get_tree()->connect("node_removed", callable_mp(this, &ItemListEditor::_node_removed)); } } void ItemListEditor::_add_pressed() { - if (selected_idx == -1) return; @@ -281,7 +251,6 @@ void ItemListEditor::_add_pressed() { } void ItemListEditor::_delete_pressed() { - if (selected_idx == -1) return; @@ -301,12 +270,10 @@ void ItemListEditor::_delete_pressed() { } void ItemListEditor::_edit_items() { - dialog->popup_centered_clamped(Vector2(425, 1200) * EDSCALE, 0.8); } void ItemListEditor::edit(Node *p_item_list) { - item_list = p_item_list; if (!item_list) { @@ -317,7 +284,6 @@ void ItemListEditor::edit(Node *p_item_list) { for (int i = 0; i < item_plugins.size(); i++) { if (item_plugins[i]->handles(p_item_list)) { - item_plugins[i]->set_object(p_item_list); property_editor->edit(item_plugins[i]); @@ -333,7 +299,6 @@ void ItemListEditor::edit(Node *p_item_list) { } bool ItemListEditor::handles(Object *p_object) const { - for (int i = 0; i < item_plugins.size(); i++) { if (item_plugins[i]->handles(p_object)) { return true; @@ -347,7 +312,6 @@ void ItemListEditor::_bind_methods() { } ItemListEditor::ItemListEditor() { - selected_idx = -1; item_list = nullptr; @@ -386,34 +350,28 @@ ItemListEditor::ItemListEditor() { } ItemListEditor::~ItemListEditor() { - for (int i = 0; i < item_plugins.size(); i++) memdelete(item_plugins[i]); } void ItemListEditorPlugin::edit(Object *p_object) { - item_list_editor->edit(Object::cast_to<Node>(p_object)); } bool ItemListEditorPlugin::handles(Object *p_object) const { - return item_list_editor->handles(p_object); } void ItemListEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { item_list_editor->show(); } else { - item_list_editor->hide(); item_list_editor->edit(nullptr); } } ItemListEditorPlugin::ItemListEditorPlugin(EditorNode *p_node) { - editor = p_node; item_list_editor = memnew(ItemListEditor); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(item_list_editor); diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index 8dcf938139..61dd617e3b 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -40,7 +40,6 @@ #include "scene/gui/popup_menu.h" class ItemListPlugin : public Object { - GDCLASS(ItemListPlugin, Object); protected: @@ -96,7 +95,6 @@ public: /////////////////////////////////////////////////////////////// class ItemListOptionButtonPlugin : public ItemListPlugin { - GDCLASS(ItemListOptionButtonPlugin, ItemListPlugin); OptionButton *ob; @@ -126,7 +124,6 @@ public: }; class ItemListPopupMenuPlugin : public ItemListPlugin { - GDCLASS(ItemListPopupMenuPlugin, ItemListPlugin); PopupMenu *pp; @@ -169,7 +166,6 @@ public: /////////////////////////////////////////////////////////////// class ItemListItemListPlugin : public ItemListPlugin { - GDCLASS(ItemListItemListPlugin, ItemListPlugin); ItemList *pp; @@ -198,7 +194,6 @@ public: /////////////////////////////////////////////////////////////// class ItemListEditor : public HBoxContainer { - GDCLASS(ItemListEditor, HBoxContainer); Node *item_list; @@ -235,7 +230,6 @@ public: }; class ItemListEditorPlugin : public EditorPlugin { - GDCLASS(ItemListEditorPlugin, EditorPlugin); ItemListEditor *item_list_editor; diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index f8550a884b..0cbb3f5d9d 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -31,10 +31,8 @@ #include "light_occluder_2d_editor_plugin.h" Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const { - Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon(); if (!occluder.is_valid()) { - occluder = Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D)); node->set_occluder_polygon(occluder); } @@ -42,17 +40,14 @@ Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const { } Node2D *LightOccluder2DEditor::_get_node() const { - return node; } void LightOccluder2DEditor::_set_node(Node *p_polygon) { - node = Object::cast_to<LightOccluder2D>(p_polygon); } bool LightOccluder2DEditor::_is_line() const { - Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon(); if (occluder.is_valid()) return !occluder->is_closed(); @@ -61,7 +56,6 @@ bool LightOccluder2DEditor::_is_line() const { } int LightOccluder2DEditor::_get_polygon_count() const { - Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon(); if (occluder.is_valid()) return occluder->get_polygon().size(); @@ -70,7 +64,6 @@ int LightOccluder2DEditor::_get_polygon_count() const { } Variant LightOccluder2DEditor::_get_polygon(int p_idx) const { - Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon(); if (occluder.is_valid()) return occluder->get_polygon(); @@ -79,25 +72,21 @@ Variant LightOccluder2DEditor::_get_polygon(int p_idx) const { } void LightOccluder2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { - Ref<OccluderPolygon2D> occluder = _ensure_occluder(); occluder->set_polygon(p_polygon); } void LightOccluder2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Ref<OccluderPolygon2D> occluder = _ensure_occluder(); undo_redo->add_do_method(occluder.ptr(), "set_polygon", p_polygon); undo_redo->add_undo_method(occluder.ptr(), "set_polygon", p_previous); } bool LightOccluder2DEditor::_has_resource() const { - return node && node->get_occluder_polygon().is_valid(); } void LightOccluder2DEditor::_create_resource() { - if (!node) return; @@ -111,7 +100,6 @@ void LightOccluder2DEditor::_create_resource() { LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - node = nullptr; } diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h index 74ae9e0889..11c9f2b2a4 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.h +++ b/editor/plugins/light_occluder_2d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/2d/light_occluder_2d.h" class LightOccluder2DEditor : public AbstractPolygon2DEditor { - GDCLASS(LightOccluder2DEditor, AbstractPolygon2DEditor); LightOccluder2D *node; @@ -61,7 +60,6 @@ public: }; class LightOccluder2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - GDCLASS(LightOccluder2DEditorPlugin, AbstractPolygon2DEditorPlugin); public: diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 5b887390a6..77eeb19d26 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -31,32 +31,26 @@ #include "line_2d_editor_plugin.h" Node2D *Line2DEditor::_get_node() const { - return node; } void Line2DEditor::_set_node(Node *p_line) { - node = Object::cast_to<Line2D>(p_line); } bool Line2DEditor::_is_line() const { - return true; } Variant Line2DEditor::_get_polygon(int p_idx) const { - return _get_node()->get("points"); } void Line2DEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { - _get_node()->set("points", p_polygon); } void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Node2D *node = _get_node(); undo_redo->add_do_method(node, "set_points", p_polygon); undo_redo->add_undo_method(node, "set_points", p_previous); diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h index ef54dbc3f7..bf411a070a 100644 --- a/editor/plugins/line_2d_editor_plugin.h +++ b/editor/plugins/line_2d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/2d/line_2d.h" class Line2DEditor : public AbstractPolygon2DEditor { - GDCLASS(Line2DEditor, AbstractPolygon2DEditor); Line2D *node; @@ -54,7 +53,6 @@ public: }; class Line2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - GDCLASS(Line2DEditorPlugin, AbstractPolygon2DEditorPlugin); public: diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index f63bcb69b8..2e61ff59fd 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -36,9 +36,7 @@ #include "scene/resources/sky_material.h" void MaterialEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); if (first_enter) { @@ -59,7 +57,6 @@ void MaterialEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); @@ -68,20 +65,17 @@ void MaterialEditor::_notification(int p_what) { } void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) { - material = p_material; camera->set_environment(p_env); if (!material.is_null()) { sphere_instance->set_material_override(material); box_instance->set_material_override(material); } else { - hide(); } } void MaterialEditor::_button_pressed(Node *p_button) { - if (p_button == light_1_switch) { light1->set_visible(!light_1_switch->is_pressed()); } @@ -111,7 +105,6 @@ void MaterialEditor::_bind_methods() { } MaterialEditor::MaterialEditor() { - vc = memnew(SubViewportContainer); vc->set_stretch(true); add_child(vc); @@ -209,7 +202,6 @@ MaterialEditor::MaterialEditor() { /////////////////////// bool EditorInspectorPluginMaterial::can_handle(Object *p_object) { - Material *material = Object::cast_to<Material>(p_object); if (!material) return false; @@ -218,7 +210,6 @@ bool EditorInspectorPluginMaterial::can_handle(Object *p_object) { } void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { - Material *material = Object::cast_to<Material>(p_object); if (!material) { return; @@ -240,23 +231,19 @@ EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() { } MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginMaterial> plugin; plugin.instance(); add_inspector_plugin(plugin); } String StandardMaterial3DConversionPlugin::converts_to() const { - return "ShaderMaterial"; } bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const { - Ref<StandardMaterial3D> mat = p_resource; return mat.is_valid(); } Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const { - Ref<StandardMaterial3D> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); @@ -276,7 +263,6 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p RS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); @@ -293,16 +279,13 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p } String ParticlesMaterialConversionPlugin::converts_to() const { - return "ShaderMaterial"; } bool ParticlesMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { - Ref<ParticlesMaterial> mat = p_resource; return mat.is_valid(); } Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { - Ref<ParticlesMaterial> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); @@ -331,16 +314,13 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ } String CanvasItemMaterialConversionPlugin::converts_to() const { - return "ShaderMaterial"; } bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { - Ref<CanvasItemMaterial> mat = p_resource; return mat.is_valid(); } Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { - Ref<CanvasItemMaterial> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); @@ -369,16 +349,13 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p } 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>()); @@ -407,16 +384,13 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> } 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>()); @@ -445,16 +419,13 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> & } 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>()); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 50036e4f72..e03cb1b3ab 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -44,7 +44,6 @@ class SubViewportContainer; class MaterialEditor : public Control { - GDCLASS(MaterialEditor, Control); SubViewportContainer *vc; @@ -91,7 +90,6 @@ public: }; class MaterialEditorPlugin : public EditorPlugin { - GDCLASS(MaterialEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 3e603fa499..7ac44cf53a 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -33,10 +33,8 @@ #include "editor/editor_scale.h" void MeshEditor::_gui_input(Ref<InputEvent> p_event) { - Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - rot_x -= mm->get_relative().y * 0.01; rot_y -= mm->get_relative().x * 0.01; if (rot_x < -Math_PI / 2) @@ -49,9 +47,7 @@ void MeshEditor::_gui_input(Ref<InputEvent> p_event) { } void MeshEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); if (first_enter) { @@ -67,7 +63,6 @@ void MeshEditor::_notification(int p_what) { } void MeshEditor::_update_rotation() { - Transform t; t.basis.rotate(Vector3(0, 1, 0), -rot_y); t.basis.rotate(Vector3(1, 0, 0), -rot_x); @@ -75,7 +70,6 @@ void MeshEditor::_update_rotation() { } void MeshEditor::edit(Ref<Mesh> p_mesh) { - mesh = p_mesh; mesh_instance->set_mesh(mesh); @@ -98,7 +92,6 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { } void MeshEditor::_button_pressed(Node *p_button) { - if (p_button == light_1_switch) { light1->set_visible(!light_1_switch->is_pressed()); } @@ -109,12 +102,10 @@ void MeshEditor::_button_pressed(Node *p_button) { } void MeshEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &MeshEditor::_gui_input); } MeshEditor::MeshEditor() { - viewport = memnew(SubViewport); Ref<World3D> world_3d; world_3d.instance(); @@ -172,12 +163,10 @@ MeshEditor::MeshEditor() { /////////////////////// bool EditorInspectorPluginMesh::can_handle(Object *p_object) { - return Object::cast_to<Mesh>(p_object) != nullptr; } void EditorInspectorPluginMesh::parse_begin(Object *p_object) { - Mesh *mesh = Object::cast_to<Mesh>(p_object); if (!mesh) { return; @@ -190,7 +179,6 @@ void EditorInspectorPluginMesh::parse_begin(Object *p_object) { } MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginMesh> plugin; plugin.instance(); add_inspector_plugin(plugin); diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 072e21f260..6f171a0eab 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -40,7 +40,6 @@ #include "scene/resources/material.h" class MeshEditor : public SubViewportContainer { - GDCLASS(MeshEditor, SubViewportContainer); float rot_x; @@ -82,7 +81,6 @@ public: }; class MeshEditorPlugin : public EditorPlugin { - GDCLASS(MeshEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 7819f62bc7..3c1554de27 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -38,7 +38,6 @@ #include "scene/gui/box_container.h" void MeshInstance3DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; options->hide(); @@ -46,12 +45,10 @@ void MeshInstance3DEditor::_node_removed(Node *p_node) { } void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) { - node = p_mesh; } 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!")); @@ -61,7 +58,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { switch (p_option) { case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: { - EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); @@ -95,7 +91,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->create_action(TTR("Create Static Trimesh Body")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get()); if (!instance) continue; @@ -127,7 +122,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE: { - if (node == get_tree()->get_edited_scene_root()) { err_dialog->set_text(TTR("This doesn't work on scene root!")); err_dialog->popup_centered(); @@ -155,7 +149,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->commit_action(); } break; case MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE: { - 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(); @@ -189,7 +182,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES: { - 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(); @@ -208,7 +200,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { ur->create_action(TTR("Create Multiple Convex Shapes")); for (int i = 0; i < shapes.size(); i++) { - CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shapes[i]); cshape->set_transform(node->get_transform()); @@ -226,7 +217,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_NAVMESH: { - Ref<NavigationMesh> nmesh = memnew(NavigationMesh); if (nmesh.is_null()) @@ -250,11 +240,9 @@ void MeshInstance3DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_OUTLINE_MESH: { - outline_dialog->popup_centered(Vector2(200, 90)); } break; case MENU_OPTION_CREATE_UV2: { - Ref<ArrayMesh> mesh2 = node->get_mesh(); if (!mesh2.is_valid()) { err_dialog->set_text(TTR("Contained Mesh is not of type ArrayMesh.")); @@ -292,7 +280,6 @@ void MeshInstance3DEditor::_menu_option(int p_option) { } struct MeshInstance3DEditorEdgeSort { - Vector2 a; Vector2 b; @@ -316,7 +303,6 @@ struct MeshInstance3DEditorEdgeSort { }; void MeshInstance3DEditor::_create_uv_lines(int p_layer) { - Ref<Mesh> mesh = node->get_mesh(); ERR_FAIL_COND(!mesh.is_valid()); @@ -349,9 +335,7 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { } for (int j = 0; j < ic; j += 3) { - for (int k = 0; k < 3; k++) { - MeshInstance3DEditorEdgeSort edge; if (ri) { edge.a = r[ri[j + k]]; @@ -375,7 +359,6 @@ void MeshInstance3DEditor::_create_uv_lines(int p_layer) { } void MeshInstance3DEditor::_debug_uv_draw() { - if (uv_lines.size() == 0) return; @@ -386,7 +369,6 @@ void MeshInstance3DEditor::_debug_uv_draw() { } void MeshInstance3DEditor::_create_outline_mesh() { - Ref<Mesh> mesh = node->get_mesh(); if (mesh.is_null()) { err_dialog->set_text(TTR("MeshInstance3D lacks a Mesh.")); @@ -435,7 +417,6 @@ void MeshInstance3DEditor::_bind_methods() { } MeshInstance3DEditor::MeshInstance3DEditor() { - options = memnew(MenuButton); options->set_switch_on_hover(true); Node3DEditor::get_singleton()->add_control_to_menu_panel(options); @@ -495,28 +476,23 @@ MeshInstance3DEditor::MeshInstance3DEditor() { } void MeshInstance3DEditorPlugin::edit(Object *p_object) { - mesh_editor->edit(Object::cast_to<MeshInstance3D>(p_object)); } bool MeshInstance3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("MeshInstance3D"); } void MeshInstance3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { mesh_editor->options->show(); } else { - mesh_editor->options->hide(); mesh_editor->edit(nullptr); } } MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) { - editor = p_node; mesh_editor = memnew(MeshInstance3DEditor); editor->get_viewport()->add_child(mesh_editor); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h index a5d90c42d5..3350a792bc 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.h +++ b/editor/plugins/mesh_instance_3d_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/spin_box.h" class MeshInstance3DEditor : public Control { - GDCLASS(MeshInstance3DEditor, Control); enum Menu { @@ -84,7 +83,6 @@ public: }; class MeshInstance3DEditorPlugin : public EditorPlugin { - GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin); MeshInstance3DEditor *mesh_editor; diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 1ca8be528f..30ffba0db4 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -41,18 +41,14 @@ #include "scene/resources/packed_scene.h" void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) { - mesh_library = p_mesh_library; if (mesh_library.is_valid()) menu->get_popup()->set_item_disabled(menu->get_popup()->get_item_index(MENU_OPTION_UPDATE_FROM_SCENE), !mesh_library->has_meta("_editor_source_scene")); } void MeshLibraryEditor::_menu_confirm() { - switch (option) { - case MENU_OPTION_REMOVE_ITEM: { - mesh_library->remove_item(to_erase); } break; case MENU_OPTION_UPDATE_FROM_SCENE: { @@ -67,14 +63,12 @@ void MeshLibraryEditor::_menu_confirm() { } void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, bool p_merge) { - if (!p_merge) p_library->clear(); 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<MeshInstance3D>(child)) { @@ -104,7 +98,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, int id = p_library->find_item_by_name(mi->get_name()); if (id < 0) { - id = p_library->get_last_unused_item_id(); p_library->create_item(id); p_library->set_item_name(id, mi->get_name()); @@ -116,7 +109,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, Vector<MeshLibrary::ShapeData> collisions; for (int j = 0; j < mi->get_child_count(); j++) { - Node *child2 = mi->get_child(j); if (!Object::cast_to<StaticBody3D>(child2)) continue; @@ -134,7 +126,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, //shape_transform.set_origin(shape_transform.get_origin() - phys_offset); for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k); if (!collision.is_valid()) continue; @@ -169,14 +160,11 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, //generate previews! if (true) { - Vector<Ref<Mesh>> meshes; Vector<Transform> transforms; Vector<int> ids = p_library->get_item_list(); for (int i = 0; i < ids.size(); i++) { - if (mesh_instances.find(ids[i])) { - meshes.push_back(p_library->get_item_mesh(ids[i])); transforms.push_back(mesh_instances[ids[i]]->get_transform()); } @@ -185,9 +173,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")); int j = 0; for (int i = 0; i < ids.size(); i++) { - if (mesh_instances.find(ids[i])) { - p_library->set_item_preview(ids[i], textures[j]); j++; } @@ -196,7 +182,6 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, } void MeshLibraryEditor::_import_scene_cbk(const String &p_str) { - Ref<PackedScene> ps = ResourceLoader::load(p_str, "PackedScene"); ERR_FAIL_COND(ps.is_null()); Node *scene = ps->instance(); @@ -211,36 +196,28 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) { } Error MeshLibraryEditor::update_library_file(Node *p_base_scene, Ref<MeshLibrary> ml, bool p_merge) { - _import_scene(p_base_scene, ml, p_merge); return OK; } void MeshLibraryEditor::_menu_cbk(int p_option) { - option = p_option; switch (p_option) { - case MENU_OPTION_ADD_ITEM: { - mesh_library->create_item(mesh_library->get_last_unused_item_id()); } break; case MENU_OPTION_REMOVE_ITEM: { - String p = editor->get_inspector()->get_selected_path(); if (p.begins_with("/MeshLibrary/item") && p.get_slice_count("/") >= 3) { - to_erase = p.get_slice("/", 3).to_int(); cd->set_text(vformat(TTR("Remove item %d?"), to_erase)); cd->popup_centered(Size2(300, 60)); } } break; case MENU_OPTION_IMPORT_FROM_SCENE: { - file->popup_centered_ratio(); } break; case MENU_OPTION_UPDATE_FROM_SCENE: { - cd->set_text(vformat(TTR("Update from existing scene?:\n%s"), String(mesh_library->get_meta("_editor_source_scene")))); cd->popup_centered(Size2(500, 60)); } break; @@ -251,7 +228,6 @@ void MeshLibraryEditor::_bind_methods() { } MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { - file = memnew(EditorFileDialog); file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); //not for now? @@ -260,7 +236,6 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { file->clear_filters(); file->set_title(TTR("Import Scene")); for (int i = 0; i < extensions.size(); i++) { - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); } add_child(file); @@ -287,7 +262,6 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { } void MeshLibraryEditorPlugin::edit(Object *p_node) { - if (Object::cast_to<MeshLibrary>(p_node)) { mesh_library_editor->edit(Object::cast_to<MeshLibrary>(p_node)); mesh_library_editor->show(); @@ -296,12 +270,10 @@ void MeshLibraryEditorPlugin::edit(Object *p_node) { } bool MeshLibraryEditorPlugin::handles(Object *p_node) const { - return p_node->is_class("MeshLibrary"); } void MeshLibraryEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { mesh_library_editor->show(); mesh_library_editor->get_menu_button()->show(); @@ -312,7 +284,6 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) { } MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) { - EDITOR_DEF("editors/grid_map/preview_size", 64); mesh_library_editor = memnew(MeshLibraryEditor(p_node)); diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h index 74b0a280e3..61ce5692bc 100644 --- a/editor/plugins/mesh_library_editor_plugin.h +++ b/editor/plugins/mesh_library_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/resources/mesh_library.h" class MeshLibraryEditor : public Control { - GDCLASS(MeshLibraryEditor, Control); Ref<MeshLibrary> mesh_library; @@ -74,7 +73,6 @@ public: }; class MeshLibraryEditorPlugin : public EditorPlugin { - GDCLASS(MeshLibraryEditorPlugin, EditorPlugin); MeshLibraryEditor *mesh_library_editor; diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 4f482c2b43..9d4442174c 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -35,7 +35,6 @@ #include "scene/gui/box_container.h" void MultiMeshEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; hide(); @@ -43,24 +42,20 @@ void MultiMeshEditor::_node_removed(Node *p_node) { } void MultiMeshEditor::_populate() { - if (!node) return; Ref<Mesh> mesh; if (mesh_source->get_text() == "") { - Ref<MultiMesh> multimesh; multimesh = node->get_multimesh(); if (multimesh.is_null()) { - err_dialog->set_text(TTR("No mesh source specified (and no MultiMesh set in node).")); 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(); return; @@ -68,11 +63,9 @@ void MultiMeshEditor::_populate() { mesh = multimesh->get_mesh(); } else { - Node *ms_node = node->get_node(mesh_source->get_text()); if (!ms_node) { - err_dialog->set_text(TTR("Mesh source is invalid (invalid path).")); err_dialog->popup_centered(); return; @@ -81,7 +74,6 @@ void MultiMeshEditor::_populate() { MeshInstance3D *ms_instance = Object::cast_to<MeshInstance3D>(ms_node); if (!ms_instance) { - err_dialog->set_text(TTR("Mesh source is invalid (not a MeshInstance3D).")); err_dialog->popup_centered(); return; @@ -90,7 +82,6 @@ void MultiMeshEditor::_populate() { mesh = ms_instance->get_mesh(); if (mesh.is_null()) { - err_dialog->set_text(TTR("Mesh source is invalid (contains no Mesh resource).")); err_dialog->popup_centered(); return; @@ -98,7 +89,6 @@ void MultiMeshEditor::_populate() { } if (surface_source->get_text() == "") { - err_dialog->set_text(TTR("No surface source specified.")); err_dialog->popup_centered(); return; @@ -107,7 +97,6 @@ void MultiMeshEditor::_populate() { Node *ss_node = node->get_node(surface_source->get_text()); if (!ss_node) { - err_dialog->set_text(TTR("Surface source is invalid (invalid path).")); err_dialog->popup_centered(); return; @@ -116,7 +105,6 @@ void MultiMeshEditor::_populate() { 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(); return; @@ -127,7 +115,6 @@ void MultiMeshEditor::_populate() { 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(); return; @@ -153,7 +140,6 @@ void MultiMeshEditor::_populate() { float area_accum = 0; Map<float, int> triangle_area_map; for (int i = 0; i < facecount; i++) { - float area = r[i].get_area(); if (area < CMP_EPSILON) continue; @@ -188,7 +174,6 @@ void MultiMeshEditor::_populate() { } for (int i = 0; i < instance_count; i++) { - float areapos = Math::random(0.0f, area_accum); Map<float, int>::Element *E = triangle_area_map.find_closest(areapos); @@ -227,7 +212,6 @@ void MultiMeshEditor::_populate() { } void MultiMeshEditor::_browsed(const NodePath &p_path) { - NodePath path = node->get_path_to(get_node(p_path)); if (browsing_source) @@ -237,13 +221,9 @@ void MultiMeshEditor::_browsed(const NodePath &p_path) { } void MultiMeshEditor::_menu_option(int p_option) { - switch (p_option) { - case MENU_OPTION_POPULATE: { - if (_last_pp_node != node) { - surface_source->set_text(".."); mesh_source->set_text(".."); populate_axis->select(1); @@ -262,12 +242,10 @@ void MultiMeshEditor::_menu_option(int p_option) { } void MultiMeshEditor::edit(MultiMeshInstance3D *p_multimesh) { - node = p_multimesh; } void MultiMeshEditor::_browse(bool p_source) { - browsing_source = p_source; std->get_scene_tree()->set_marked(node, false); std->popup_centered_ratio(); @@ -281,7 +259,6 @@ void MultiMeshEditor::_bind_methods() { } MultiMeshEditor::MultiMeshEditor() { - options = memnew(MenuButton); options->set_switch_on_hover(true); Node3DEditor::get_singleton()->add_control_to_menu_panel(options); @@ -378,28 +355,23 @@ MultiMeshEditor::MultiMeshEditor() { } void MultiMeshEditorPlugin::edit(Object *p_object) { - multimesh_editor->edit(Object::cast_to<MultiMeshInstance3D>(p_object)); } bool MultiMeshEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("MultiMeshInstance3D"); } void MultiMeshEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { multimesh_editor->options->show(); } else { - multimesh_editor->options->hide(); multimesh_editor->edit(nullptr); } } MultiMeshEditorPlugin::MultiMeshEditorPlugin(EditorNode *p_node) { - editor = p_node; multimesh_editor = memnew(MultiMeshEditor); editor->get_viewport()->add_child(multimesh_editor); diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h index 15c9b91fee..2b0a0c137f 100644 --- a/editor/plugins/multimesh_editor_plugin.h +++ b/editor/plugins/multimesh_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/spin_box.h" class MultiMeshEditor : public Control { - GDCLASS(MultiMeshEditor, Control); friend class MultiMeshEditorPlugin; @@ -83,7 +82,6 @@ public: }; class MultiMeshEditorPlugin : public EditorPlugin { - GDCLASS(MultiMeshEditorPlugin, EditorPlugin); MultiMeshEditor *multimesh_editor; diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index e41b32ac86..d4cc96b7df 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -31,10 +31,8 @@ #include "navigation_polygon_editor_plugin.h" Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const { - Ref<NavigationPolygon> navpoly = node->get_navigation_polygon(); if (!navpoly.is_valid()) { - navpoly = Ref<NavigationPolygon>(memnew(NavigationPolygon)); node->set_navigation_polygon(navpoly); } @@ -42,17 +40,14 @@ Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const { } Node2D *NavigationPolygonEditor::_get_node() const { - return node; } void NavigationPolygonEditor::_set_node(Node *p_polygon) { - node = Object::cast_to<NavigationRegion2D>(p_polygon); } int NavigationPolygonEditor::_get_polygon_count() const { - Ref<NavigationPolygon> navpoly = node->get_navigation_polygon(); if (navpoly.is_valid()) return navpoly->get_outline_count(); @@ -61,7 +56,6 @@ int NavigationPolygonEditor::_get_polygon_count() const { } Variant NavigationPolygonEditor::_get_polygon(int p_idx) const { - Ref<NavigationPolygon> navpoly = node->get_navigation_polygon(); if (navpoly.is_valid()) return navpoly->get_outline(p_idx); @@ -70,14 +64,12 @@ Variant NavigationPolygonEditor::_get_polygon(int p_idx) const { } void NavigationPolygonEditor::_set_polygon(int p_idx, const Variant &p_polygon) const { - Ref<NavigationPolygon> navpoly = _ensure_navpoly(); navpoly->set_outline(p_idx, p_polygon); navpoly->make_polygons_from_outlines(); } void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) { - Ref<NavigationPolygon> navpoly = _ensure_navpoly(); undo_redo->add_do_method(navpoly.ptr(), "add_outline", p_polygon); undo_redo->add_undo_method(navpoly.ptr(), "remove_outline", navpoly->get_outline_count()); @@ -86,7 +78,6 @@ void NavigationPolygonEditor::_action_add_polygon(const Variant &p_polygon) { } void NavigationPolygonEditor::_action_remove_polygon(int p_idx) { - Ref<NavigationPolygon> navpoly = _ensure_navpoly(); undo_redo->add_do_method(navpoly.ptr(), "remove_outline", p_idx); undo_redo->add_undo_method(navpoly.ptr(), "add_outline_at_index", navpoly->get_outline(p_idx), p_idx); @@ -95,7 +86,6 @@ void NavigationPolygonEditor::_action_remove_polygon(int p_idx) { } void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_previous, const Variant &p_polygon) { - Ref<NavigationPolygon> navpoly = _ensure_navpoly(); undo_redo->add_do_method(navpoly.ptr(), "set_outline", p_idx, p_polygon); undo_redo->add_undo_method(navpoly.ptr(), "set_outline", p_idx, p_previous); @@ -104,12 +94,10 @@ void NavigationPolygonEditor::_action_set_polygon(int p_idx, const Variant &p_pr } bool NavigationPolygonEditor::_has_resource() const { - return node && node->get_navigation_polygon().is_valid(); } void NavigationPolygonEditor::_create_resource() { - if (!node) return; diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 0bc35e2498..0767322c17 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/2d/navigation_region_2d.h" class NavigationPolygonEditor : public AbstractPolygon2DEditor { - GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor); NavigationRegion2D *node; @@ -62,7 +61,6 @@ public: }; class NavigationPolygonEditorPlugin : public AbstractPolygon2DEditorPlugin { - GDCLASS(NavigationPolygonEditorPlugin, AbstractPolygon2DEditorPlugin); public: diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 1614f3f073..fa600ad744 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -77,7 +77,6 @@ #define MAX_FOV 179 void ViewportRotationControl::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { axis_menu_options.clear(); axis_menu_options.push_back(Node3DEditorViewport::VIEW_RIGHT); @@ -255,19 +254,16 @@ void ViewportRotationControl::_bind_methods() { } void Node3DEditorViewport::_update_camera(float p_interp_delta) { - bool is_orthogonal = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL; Cursor old_camera_cursor = camera_cursor; camera_cursor = cursor; if (p_interp_delta > 0) { - //------- // Perform smoothing if (is_freelook_active()) { - // Higher inertia should increase "lag" (lerp with factor between 0 and 1) // Inertia of zero should produce instant movement (lerp with factor of 1) in this case it returns a really high value and gets clamped to 1. real_t inertia = EDITOR_GET("editors/3d/freelook/freelook_inertia"); @@ -294,7 +290,6 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { camera_cursor.pos = camera_cursor.eye_pos + forward * camera_cursor.distance; } else { - //when not being manipulated, move softly float free_orbit_inertia = EDITOR_GET("editors/3d/navigation_feel/orbit_inertia"); float free_translation_inertia = EDITOR_GET("editors/3d/navigation_feel/translation_inertia"); @@ -348,7 +343,6 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { } if (!equal || p_interp_delta == 0 || is_freelook_active() || is_orthogonal != orthogonal) { - camera->set_global_transform(to_camera_transform(camera_cursor)); if (orthogonal) { @@ -379,13 +373,11 @@ Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) cons } int Node3DEditorViewport::get_selected_count() const { - Map<Node *, Object *> &selection = editor_selection->get_selection(); int count = 0; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->key()); if (!sp) continue; @@ -401,55 +393,44 @@ int Node3DEditorViewport::get_selected_count() const { } float Node3DEditorViewport::get_znear() const { - return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z); } float Node3DEditorViewport::get_zfar() const { - return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z); } float Node3DEditorViewport::get_fov() const { - return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV); } Transform Node3DEditorViewport::_get_camera_transform() const { - return camera->get_global_transform(); } Vector3 Node3DEditorViewport::_get_camera_position() const { - return _get_camera_transform().origin; } Point2 Node3DEditorViewport::_point_to_screen(const Vector3 &p_point) { - return camera->unproject_position(p_point) * subviewport_container->get_stretch_shrink(); } Vector3 Node3DEditorViewport::_get_ray_pos(const Vector2 &p_pos) const { - return camera->project_ray_origin(p_pos / subviewport_container->get_stretch_shrink()); } Vector3 Node3DEditorViewport::_get_camera_normal() const { - return -_get_camera_transform().basis.get_axis(2); } Vector3 Node3DEditorViewport::_get_ray(const Vector2 &p_pos) const { - return camera->project_ray_normal(p_pos / subviewport_container->get_stretch_shrink()); } void Node3DEditorViewport::_clear_selected() { - editor_selection->clear(); } void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_allow_locked) { - if (clicked.is_null()) return; @@ -475,7 +456,6 @@ void Node3DEditorViewport::_select_clicked(bool p_append, bool p_single, bool p_ } void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { - if (!p_append) { editor_selection->clear(); } @@ -484,7 +464,6 @@ void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { //erase editor_selection->remove_node(p_node); } else { - editor_selection->add_node(p_node); } @@ -495,7 +474,6 @@ void Node3DEditorViewport::_select(Node *p_node, bool p_append, bool p_single) { } 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; @@ -513,7 +491,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b int selected_handle = -1; for (int i = 0; i < instances.size(); i++) { - Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!spat) @@ -541,7 +518,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b continue; if (dist < closest_dist) { - item = Object::cast_to<Node>(spat); while (item->get_owner() && item->get_owner() != edited_scene && !edited_scene->is_editable_instance(item->get_owner())) { item = item->get_owner(); @@ -557,7 +533,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b return ObjectID(); if (!editor_selection->is_selected(item) || (r_gizmo_handle && selected_handle >= 0)) { - if (r_gizmo_handle) *r_gizmo_handle = selected_handle; } @@ -566,7 +541,6 @@ ObjectID Node3DEditorViewport::_select_ray(const Point2 &p_pos, bool p_append, b } 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); @@ -576,7 +550,6 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu r_includes_current = false; for (int i = 0; i < instances.size(); i++) { - Node3D *spat = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!spat) @@ -622,7 +595,6 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu } Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { - CameraMatrix cm; if (orthogonal) { cm.set_orthogonal(camera->get_size(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar()); @@ -641,7 +613,6 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { } void Node3DEditorViewport::_select_region() { - if (cursor.region_begin == cursor.region_end) return; //nothing really @@ -671,7 +642,6 @@ void Node3DEditorViewport::_select_region() { Vector3 cam_pos = _get_camera_position(); for (int i = 0; i < 4; i++) { - Vector3 a = _get_screen_to_space(box[i]); Vector3 b = _get_screen_to_space(box[(i + 1) % 4]); if (orthogonal) { @@ -695,7 +665,6 @@ void Node3DEditorViewport::_select_region() { Node *edited_scene = get_tree()->get_edited_scene_root(); for (int i = 0; i < instances.size(); i++) { - Node3D *sp = Object::cast_to<Node3D>(ObjectDB::get_instance(instances[i])); if (!sp || _is_node_locked(sp)) continue; @@ -741,7 +710,6 @@ void Node3DEditorViewport::_select_region() { } void Node3DEditorViewport::_update_name() { - String view_mode = orthogonal ? TTR("Orthogonal") : TTR("Perspective"); if (auto_orthogonal) { @@ -757,7 +725,6 @@ void Node3DEditorViewport::_update_name() { } 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)); _edit.plane = TRANSFORM_VIEW; @@ -767,7 +734,6 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -782,9 +748,7 @@ void Node3DEditorViewport::_compute_edit(const Point2 &p_point) { } static int _get_key_modifier_setting(const String &p_property) { - switch (EditorSettings::get_singleton()->get(p_property).operator int()) { - case 0: return 0; case 1: @@ -812,7 +776,6 @@ static int _get_key_modifier(Ref<InputEventWithModifiers> e) { } bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_highlight_only) { - if (!spatial_editor->is_gizmo_visible()) return false; if (get_selected_count() == 0) { @@ -828,12 +791,10 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high float gs = gizmo_scale; 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; for (int i = 0; i < 3; i++) { - Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * (GIZMO_ARROW_OFFSET + (GIZMO_ARROW_SIZE * 0.5)); float grabber_radius = gs * GIZMO_ARROW_SIZE; @@ -854,7 +815,6 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high col_d = 1e20; for (int i = 0; i < 3; i++) { - Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); @@ -864,10 +824,8 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); if (plane.intersects_ray(ray_pos, ray, &r)) { - float dist = r.distance_to(grabber_pos); if (dist < (gs * GIZMO_PLANE_SIZE)) { - float d = ray_pos.distance_to(r); if (d < col_d) { col_d = d; @@ -881,9 +839,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } if (col_axis != -1) { - if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_translate ? 6 : 0)); } else { @@ -897,12 +853,10 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } 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; for (int i = 0; i < 3; i++) { - Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); Vector3 r; if (!plane.intersects_ray(ray_pos, ray, &r)) @@ -911,7 +865,6 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high float dist = r.distance_to(gt.origin); if (dist > gs * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && dist < gs * (GIZMO_CIRCLE_SIZE + GIZMO_RING_HALF_WIDTH)) { - float d = ray_pos.distance_to(r); if (d < col_d) { col_d = d; @@ -921,9 +874,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } if (col_axis != -1) { - if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis + 3); } else { //handle rotate @@ -936,12 +887,10 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) { - int col_axis = -1; float col_d = 1e20; for (int i = 0; i < 3; i++) { - Vector3 grabber_pos = gt.origin + gt.basis.get_axis(i) * gs * GIZMO_SCALE_OFFSET; float grabber_radius = gs * GIZMO_ARROW_SIZE; @@ -962,7 +911,6 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high col_d = 1e20; for (int i = 0; i < 3; i++) { - Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); @@ -972,10 +920,8 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); if (plane.intersects_ray(ray_pos, ray, &r)) { - float dist = r.distance_to(grabber_pos); if (dist < (gs * GIZMO_PLANE_SIZE)) { - float d = ray_pos.distance_to(r); if (d < col_d) { col_d = d; @@ -989,9 +935,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } if (col_axis != -1) { - if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_scale ? 12 : 9)); } else { @@ -1011,30 +955,25 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high } void Node3DEditorViewport::_surface_mouse_enter() { - if (!surface->has_focus() && (!get_focus_owner() || !get_focus_owner()->is_text_field())) surface->grab_focus(); } void Node3DEditorViewport::_surface_mouse_exit() { - _remove_preview(); } void Node3DEditorViewport::_surface_focus_enter() { - view_menu->set_disable_shortcuts(false); } void Node3DEditorViewport::_surface_focus_exit() { - view_menu->set_disable_shortcuts(true); } bool Node3DEditorViewport ::_is_node_locked(const Node *p_node) { return p_node->has_meta("_edit_lock_") && p_node->get_meta("_edit_lock_"); } 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(); @@ -1051,7 +990,6 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { clicked_wants_append = b->get_shift(); if (selection_results.size() == 1) { - clicked = selection_results[0].item->get_instance_id(); selection_results.clear(); @@ -1061,12 +999,10 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { } } else if (!selection_results.empty()) { - NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); StringName root_name = root_path.get_name(root_path.get_name_count() - 1); for (int i = 0; i < selection_results.size(); i++) { - Node3D *spat = selection_results[i].item; Ref<Texture2D> icon = EditorNode::get_singleton()->get_object_icon(spat, "Node"); @@ -1107,7 +1043,6 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) { } void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { - if (previewing) return; //do NONE @@ -1137,7 +1072,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { float zoom_factor = 1 + (ZOOM_MULTIPLIER - 1) * b->get_factor(); switch (b->get_button_index()) { - case BUTTON_WHEEL_UP: { if (is_freelook_active()) scale_freelook_speed(zoom_factor); @@ -1153,7 +1087,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } break; case BUTTON_RIGHT: { - NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); if (b->is_pressed() && _edit.gizmo.is_valid()) { @@ -1163,9 +1096,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (_edit.mode == TRANSFORM_NONE && b->is_pressed()) { - if (b->get_alt()) { - if (nav_scheme == NAVIGATION_MAYA) break; @@ -1181,7 +1112,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -1215,32 +1145,25 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } break; case BUTTON_MIDDLE: { - if (b->is_pressed() && _edit.mode != TRANSFORM_NONE) { - switch (_edit.plane) { - case TRANSFORM_VIEW: { - _edit.plane = TRANSFORM_X_AXIS; set_message(TTR("X-Axis Transform."), 2); name = ""; _update_name(); } break; case TRANSFORM_X_AXIS: { - _edit.plane = TRANSFORM_Y_AXIS; set_message(TTR("Y-Axis Transform."), 2); } break; case TRANSFORM_Y_AXIS: { - _edit.plane = TRANSFORM_Z_AXIS; set_message(TTR("Z-Axis Transform."), 2); } break; case TRANSFORM_Z_AXIS: { - _edit.plane = TRANSFORM_VIEW; set_message(TTR("View Plane Transform."), 2); @@ -1253,9 +1176,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } break; case BUTTON_LEFT: { - if (b->is_pressed()) { - NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); if ((nav_scheme == NAVIGATION_MAYA || nav_scheme == NAVIGATION_MODO) && b->get_alt()) { break; @@ -1280,7 +1201,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (can_select_gizmos && spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); if (seg.is_valid()) { int handle = -1; @@ -1288,7 +1208,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 normal; bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, b->get_shift()); if (inters && handle != -1) { - _edit.gizmo = seg; _edit.gizmo_handle = handle; _edit.gizmo_initial_value = seg->get_handle_value(handle); @@ -1304,7 +1223,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { clicked_includes_current = false; 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) break; //bye @@ -1315,7 +1233,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) { - if (get_selected_count() == 0) break; //bye //handle translate @@ -1325,7 +1242,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SCALE) { - if (get_selected_count() == 0) break; //bye //handle scale @@ -1345,7 +1261,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { clicked_wants_append = b->get_shift(); if (clicked.is_null()) { - if (!clicked_wants_append) _clear_selected(); @@ -1356,13 +1271,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (clicked.is_valid() && gizmo_handle >= 0) { - Node3D *spa = Object::cast_to<Node3D>(ObjectDB::get_instance(clicked)); if (spa) { - Ref<EditorNode3DGizmo> seg = spa->get_gizmo(); if (seg.is_valid()) { - _edit.gizmo = seg; _edit.gizmo_handle = gizmo_handle; _edit.gizmo_initial_value = seg->get_handle_value(gizmo_handle); @@ -1373,9 +1285,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { surface->update(); } else { - if (_edit.gizmo.is_valid()) { - _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_initial_value, false); _edit.gizmo = Ref<EditorNode3DGizmo>(); break; @@ -1387,7 +1297,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (cursor.region_select) { - if (!clicked_wants_append) _clear_selected(); @@ -1397,14 +1306,12 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (_edit.mode != TRANSFORM_NONE) { - static const char *_transform_name[4] = { "None", "Rotate", "Translate", "Scale" }; undo_redo->create_action(_transform_name[_edit.mode]); List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -1431,14 +1338,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> m = p_event; if (m.is_valid()) { - _edit.mouse_pos = m->get_position(); if (spatial_editor->get_selected()) { - Ref<EditorNode3DGizmo> seg = spatial_editor->get_selected()->get_gizmo(); if (seg.is_valid()) { - int selected_handle = -1; int handle = -1; @@ -1446,7 +1350,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 normal; bool inters = seg->intersect_ray(camera, _edit.mouse_pos, point, normal, &handle, false); if (inters && handle != -1) { - selected_handle = handle; } @@ -1460,7 +1363,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } if (spatial_editor->get_over_gizmo_handle() == -1 && !(m->get_button_mask() & 1) && !_edit.gizmo.is_valid()) { - _gizmo_select(_edit.mouse_pos, true); } @@ -1468,14 +1370,12 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { NavigationMode nav_mode = NAVIGATION_NONE; if (_edit.gizmo.is_valid()) { - _edit.gizmo->set_handle(_edit.gizmo_handle, camera, m->get_position()); Variant v = _edit.gizmo->get_handle_value(_edit.gizmo_handle); String n = _edit.gizmo->get_handle_name(_edit.gizmo_handle); set_message(n + ": " + String(v)); } else if (m->get_button_mask() & BUTTON_MASK_LEFT) { - if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) { nav_mode = NAVIGATION_ORBIT; } else if (nav_scheme == NAVIGATION_MODO && m->get_alt() && m->get_shift()) { @@ -1486,9 +1386,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { nav_mode = NAVIGATION_ORBIT; } else { if (clicked.is_valid()) { - if (!clicked_includes_current) { - _select_clicked(clicked_wants_append, true); // Processing was deferred. } @@ -1514,9 +1412,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { int snap_step_decimals = Math::range_step_decimals(snap); switch (_edit.mode) { - case TRANSFORM_SCALE: { - Vector3 motion_mask; Plane plane; bool plane_mv = false; @@ -1565,13 +1461,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 motion = intersection - click; if (_edit.plane != TRANSFORM_VIEW) { - if (!plane_mv) { - motion = motion_mask.dot(motion) * motion_mask; } else { - // Alternative planar scaling mode if (_get_key_modifier(m) != KEY_SHIFT) { motion = motion_mask.dot(motion) * motion_mask; @@ -1603,7 +1496,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) { continue; @@ -1625,7 +1517,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 local_scale; if (local_coords) { - Basis g = original.basis.orthonormalized(); Vector3 local_motion = g.inverse().xform(motion); @@ -1639,13 +1530,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Basis check = original_local.basis; check.scale(local_scale); if (check.determinant() != 0) { - // Apply scale sp->set_scale(local_scale); } } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { motion.snap(Vector3(snap, snap, snap)); } @@ -1664,7 +1553,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } break; case TRANSFORM_TRANSLATE: { - Vector3 motion_mask; Plane plane; bool plane_mv = false; @@ -1728,7 +1616,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { String::num(motion_snapped.y, snap_step_decimals) + ", " + String::num(motion_snapped.z, snap_step_decimals) + ")"); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) { continue; @@ -1747,7 +1634,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform t; if (local_coords) { - if (_edit.snap || spatial_editor->is_snap_enabled()) { Basis g = original.basis.orthonormalized(); Vector3 local_motion = g.inverse().xform(motion); @@ -1757,7 +1643,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } else { - if (_edit.snap || spatial_editor->is_snap_enabled()) { motion.snap(Vector3(snap, snap, snap)); } @@ -1774,7 +1659,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } break; case TRANSFORM_ROTATE: { - Plane plane; Vector3 axis; @@ -1826,7 +1710,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -1842,7 +1725,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform t; if (local_coords) { - Transform original_local = se->original_local; Basis rot = Basis(axis, angle); @@ -1854,7 +1736,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { sp->set_scale(original_local.basis.get_scale()); // re-apply original scale } else { - Transform original = se->original; Transform r; Transform base = Transform(Basis(), _edit.center); @@ -1876,7 +1757,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } else if ((m->get_button_mask() & BUTTON_MASK_RIGHT) || freelook_active) { - if (nav_scheme == NAVIGATION_MAYA && m->get_alt()) { nav_mode = NAVIGATION_ZOOM; } else if (freelook_active) { @@ -1886,9 +1766,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } } else if (m->get_button_mask() & BUTTON_MASK_MIDDLE) { - if (nav_scheme == NAVIGATION_GODOT) { - const int mod = _get_key_modifier(m); if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) { @@ -1949,7 +1827,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Ref<InputEventMagnifyGesture> magnify_gesture = p_event; if (magnify_gesture.is_valid()) { - if (is_freelook_active()) scale_freelook_speed(magnify_gesture->get_factor()); else @@ -1958,12 +1835,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Ref<InputEventPanGesture> pan_gesture = p_event; if (pan_gesture.is_valid()) { - NavigationScheme nav_scheme = (NavigationScheme)EditorSettings::get_singleton()->get("editors/3d/navigation/navigation_scheme").operator int(); NavigationMode nav_mode = NAVIGATION_NONE; if (nav_scheme == NAVIGATION_GODOT) { - const int mod = _get_key_modifier(pan_gesture); if (mod == _get_key_modifier_setting("editors/3d/navigation/pan_modifier")) { @@ -2064,7 +1939,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -2096,7 +1970,6 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { } 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(); real_t pan_speed = 1 / 150.0; @@ -2116,7 +1989,6 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const } 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(); real_t zoom_speed = 1 / 80.0; @@ -2139,7 +2011,6 @@ void Node3DEditorViewport::_nav_zoom(Ref<InputEventWithModifiers> p_event, const } void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { - if (lock_rotation) { _nav_pan(p_event, p_relative); return; @@ -2168,7 +2039,6 @@ void Node3DEditorViewport::_nav_orbit(Ref<InputEventWithModifiers> p_event, cons } void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const Vector2 &p_relative) { - if (orthogonal) { _nav_pan(p_event, p_relative); return; @@ -2208,7 +2078,6 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const } 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 cursor = camera_cursor; @@ -2240,7 +2109,6 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) { } void Node3DEditorViewport::scale_cursor_distance(real_t scale) { - // Prevents zero distance which would short-circuit any scaling if (cursor.distance < ZOOM_MIN_DISTANCE) cursor.distance = ZOOM_MIN_DISTANCE; @@ -2255,7 +2123,6 @@ void Node3DEditorViewport::scale_cursor_distance(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) freelook_speed = FREELOOK_MIN_SPEED; @@ -2294,7 +2161,6 @@ static bool is_shortcut_pressed(const String &p_path) { } void Node3DEditorViewport::_update_freelook(real_t delta) { - if (!is_freelook_active()) { return; } @@ -2357,7 +2223,6 @@ void Node3DEditorViewport::_update_freelook(real_t delta) { } void Node3DEditorViewport::set_message(String p_message, float p_time) { - message = p_message; message_time = p_time; } @@ -2372,9 +2237,7 @@ void Node3DEditorPlugin::edited_scene_changed() { } void Node3DEditorViewport::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - bool visible = is_visible_in_tree(); set_process(visible); @@ -2391,7 +2254,6 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_RESIZED) { - call_deferred("update_transform_gizmo_view"); } @@ -2403,7 +2265,6 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_PROCESS) { - real_t delta = get_process_delta_time(); if (zoom_indicator_delay > 0) { @@ -2438,7 +2299,6 @@ void Node3DEditorViewport::_notification(int p_what) { bool exist = false; for (Map<Node *, Object *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->key()); if (!sp) continue; @@ -2475,7 +2335,6 @@ void Node3DEditorViewport::_notification(int p_what) { } if (message_time > 0) { - if (message != last_message) { surface->update(); last_message = message; @@ -2561,7 +2420,6 @@ void Node3DEditorViewport::_notification(int p_what) { 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; @@ -2600,7 +2458,6 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE) { - 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)); @@ -2612,12 +2469,10 @@ void Node3DEditorViewport::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - _finish_gizmo_instances(); } if (p_what == NOTIFICATION_THEME_CHANGED) { - view_menu->set_icon(get_theme_icon("GuiTabMenu", "EditorIcons")); preview_camera->set_icon(get_theme_icon("Camera3D", "EditorIcons")); @@ -2641,7 +2496,6 @@ void Node3DEditorViewport::_notification(int p_what) { } static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> icon) { - // Adjust bar size from control height Vector2 surface_size = surface.get_size(); real_t h = surface_size.y / 2.0; @@ -2662,7 +2516,6 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture2D> ico } void Node3DEditorViewport::_draw() { - EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over(); if (!over_plugin_list->empty()) { over_plugin_list->forward_spatial_draw_over_viewport(surface); @@ -2704,7 +2557,6 @@ void Node3DEditorViewport::_draw() { } if (_edit.mode == TRANSFORM_ROTATE) { - Point2 center = _point_to_screen(_edit.center); RenderingServer::get_singleton()->canvas_item_add_line( ci, @@ -2714,7 +2566,6 @@ void Node3DEditorViewport::_draw() { Math::round(2 * EDSCALE)); } if (previewing) { - Size2 ss = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")); float aspect = ss.aspect(); Size2 s = get_size(); @@ -2723,14 +2574,12 @@ void Node3DEditorViewport::_draw() { switch (previewing->get_keep_aspect_mode()) { 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 Camera3D::KEEP_HEIGHT: { - draw_rect.size = Size2(s.height * aspect, s.height); draw_rect.position.y = 0; draw_rect.position.x = (s.width - draw_rect.size.x) * 0.5; @@ -2743,9 +2592,7 @@ void Node3DEditorViewport::_draw() { surface->draw_rect(draw_rect, Color(0.6, 0.6, 0.1, 0.5), false, Math::round(2 * EDSCALE)); } else { - if (zoom_indicator_delay > 0.0) { - if (is_freelook_active()) { // Show speed @@ -2787,11 +2634,8 @@ void Node3DEditorViewport::_draw() { } void Node3DEditorViewport::_menu_option(int p_option) { - switch (p_option) { - case VIEW_TOP: { - cursor.y_rot = 0; cursor.x_rot = Math_PI / 2.0; set_message(TTR("Top View."), 2); @@ -2801,7 +2645,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_BOTTOM: { - cursor.y_rot = 0; cursor.x_rot = -Math_PI / 2.0; set_message(TTR("Bottom View."), 2); @@ -2811,7 +2654,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_LEFT: { - cursor.x_rot = 0; cursor.y_rot = Math_PI / 2.0; set_message(TTR("Left View."), 2); @@ -2821,7 +2663,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_RIGHT: { - cursor.x_rot = 0; cursor.y_rot = -Math_PI / 2.0; set_message(TTR("Right View."), 2); @@ -2831,7 +2672,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_FRONT: { - cursor.x_rot = 0; cursor.y_rot = 0; set_message(TTR("Front View."), 2); @@ -2841,7 +2681,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_REAR: { - cursor.x_rot = 0; cursor.y_rot = Math_PI; set_message(TTR("Rear View."), 2); @@ -2851,17 +2690,14 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_CENTER_TO_ORIGIN: { - cursor.pos = Vector3(0, 0, 0); } break; case VIEW_CENTER_TO_SELECTION: { - focus_selection(); } break; case VIEW_ALIGN_TRANSFORM_WITH_VIEW: { - if (!get_selected_count()) break; @@ -2872,7 +2708,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { undo_redo->create_action(TTR("Align Transform with View")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -2897,7 +2732,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_ALIGN_ROTATION_WITH_VIEW: { - if (!get_selected_count()) break; @@ -2907,7 +2741,6 @@ void Node3DEditorViewport::_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()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -2923,15 +2756,12 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_ENVIRONMENT: { - int idx = view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; if (current) { - camera->set_environment(RES()); } else { - camera->set_environment(Node3DEditor::get_singleton()->get_viewport_environment()); } @@ -2939,7 +2769,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_PERSPECTIVE: { - view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), true); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), false); orthogonal = false; @@ -2949,7 +2778,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_ORTHOGONAL: { - view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_PERSPECTIVE), false); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ORTHOGONAL), true); orthogonal = true; @@ -2959,7 +2787,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_AUTO_ORTHOGONAL: { - int idx = view_menu->get_popup()->get_item_index(VIEW_AUTO_ORTHOGONAL); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; @@ -2970,7 +2797,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } } break; case VIEW_LOCK_ROTATION: { - int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION); bool current = view_menu->get_popup()->is_item_checked(idx); lock_rotation = !current; @@ -2983,7 +2809,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_AUDIO_LISTENER: { - int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_LISTENER); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; @@ -2992,7 +2817,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_AUDIO_DOPPLER: { - int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; @@ -3001,7 +2825,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_CINEMATIC_PREVIEW: { - int idx = view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; @@ -3017,7 +2840,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { } } break; case VIEW_GIZMOS: { - int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; @@ -3029,21 +2851,18 @@ void Node3DEditorViewport::_menu_option(int p_option) { } break; case VIEW_HALF_RESOLUTION: { - int idx = view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION); bool current = view_menu->get_popup()->is_item_checked(idx); current = !current; view_menu->get_popup()->set_item_checked(idx, current); } break; case VIEW_INFORMATION: { - int idx = view_menu->get_popup()->get_item_index(VIEW_INFORMATION); bool current = view_menu->get_popup()->is_item_checked(idx); view_menu->get_popup()->set_item_checked(idx, !current); } break; case VIEW_FRAME_TIME: { - 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); @@ -3065,7 +2884,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { case VIEW_DISPLAY_DEBUG_PSSM_SPLITS: case VIEW_DISPLAY_DEBUG_DECAL_ATLAS: case VIEW_DISPLAY_DEBUG_ROUGHNESS_LIMITER: { - static const int display_options[] = { VIEW_DISPLAY_NORMAL, VIEW_DISPLAY_WIREFRAME, @@ -3109,7 +2927,6 @@ void Node3DEditorViewport::_menu_option(int p_option) { int idx = 0; while (display_options[idx] != VIEW_MAX) { - int id = display_options[idx]; int item_idx = view_menu->get_popup()->get_item_index(id); if (item_idx != -1) { @@ -3137,7 +2954,6 @@ void Node3DEditorViewport::_set_auto_orthogonal() { } void Node3DEditorViewport::_preview_exited_scene() { - preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); preview_camera->set_pressed(false); _toggle_camera_preview(false); @@ -3146,7 +2962,6 @@ void Node3DEditorViewport::_preview_exited_scene() { } void Node3DEditorViewport::_init_gizmo_instance(int p_idx) { - uint32_t layer = 1 << (GIZMO_BASE_LAYER + p_idx); for (int i = 0; i < 3; i++) { @@ -3188,7 +3003,6 @@ void Node3DEditorViewport::_init_gizmo_instance(int p_idx) { } void Node3DEditorViewport::_finish_gizmo_instances() { - for (int i = 0; i < 3; i++) { RS::get_singleton()->free(move_gizmo_instance[i]); RS::get_singleton()->free(move_plane_gizmo_instance[i]); @@ -3198,14 +3012,12 @@ void Node3DEditorViewport::_finish_gizmo_instances() { } } void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { - ERR_FAIL_COND(p_activate && !preview); ERR_FAIL_COND(!p_activate && !previewing); rotation_control->set_visible(!p_activate); if (!p_activate) { - 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 @@ -3215,7 +3027,6 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) { surface->update(); } else { - previewing = preview; 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 @@ -3244,7 +3055,6 @@ void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) { } void Node3DEditorViewport::_selection_result_pressed(int p_result) { - if (selection_results.size() <= p_result) return; @@ -3257,14 +3067,12 @@ void Node3DEditorViewport::_selection_result_pressed(int p_result) { } void Node3DEditorViewport::_selection_menu_hide() { - selection_results.clear(); selection_menu->clear(); selection_menu->set_size(Vector2(0, 0)); } void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) { - preview = p_preview; if (!preview_camera->is_pressed() && !previewing_cinema) @@ -3272,7 +3080,6 @@ void Node3DEditorViewport::set_can_preview(Camera3D *p_preview) { } void Node3DEditorViewport::update_transform_gizmo_view() { - if (!is_visible_in_tree()) return; @@ -3328,7 +3135,6 @@ void Node3DEditorViewport::update_transform_gizmo_view() { } void Node3DEditorViewport::set_state(const Dictionary &p_state) { - if (p_state.has("position")) cursor.pos = p_state["position"]; if (p_state.has("x_rotation")) @@ -3444,7 +3250,6 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { } Dictionary Node3DEditorViewport::get_state() const { - Dictionary d; d["position"] = cursor.pos; d["x_rotation"] = cursor.x_rot; @@ -3479,7 +3284,6 @@ Dictionary Node3DEditorViewport::get_state() const { } void Node3DEditorViewport::_bind_methods() { - 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); @@ -3489,7 +3293,6 @@ void Node3DEditorViewport::_bind_methods() { } void Node3DEditorViewport::reset() { - orthogonal = false; auto_orthogonal = false; lock_rotation = false; @@ -3516,7 +3319,6 @@ void Node3DEditorViewport::focus_selection() { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -3557,7 +3359,6 @@ Vector3 Node3DEditorViewport::_get_instance_position(const Point2 &p_pos) const Vector3 normal = Vector3(0.0, 0.0, 0.0); for (int i = 0; i < instances.size(); i++) { - MeshInstance3D *mesh_instance = Object::cast_to<MeshInstance3D>(ObjectDB::get_instance(instances[i])); if (!mesh_instance) @@ -3781,7 +3582,6 @@ void Node3DEditorViewport::_perform_drop_data() { } bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - bool can_instance = false; if (!preview_node->is_inside_tree()) { @@ -3878,7 +3678,6 @@ void Node3DEditorViewport::drop_data_fw(const Point2 &p_point, const Variant &p_ } Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index) { - cpu_time_history_index = 0; gpu_time_history_index = 0; @@ -4132,11 +3931,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito ////////////////////////////////////////////////////////////// void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) { - if (mb->is_pressed()) { Vector2 size = get_size(); @@ -4155,25 +3952,21 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { switch (view) { case VIEW_USE_1_VIEWPORT: { - dragging_h = false; dragging_v = false; } break; case VIEW_USE_2_VIEWPORTS: { - dragging_h = false; } break; case VIEW_USE_2_VIEWPORTS_ALT: { - dragging_v = false; } break; case VIEW_USE_3_VIEWPORTS: case VIEW_USE_3_VIEWPORTS_ALT: case VIEW_USE_4_VIEWPORTS: { - // Do nothing. } break; @@ -4187,7 +3980,6 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (view == VIEW_USE_3_VIEWPORTS || view == VIEW_USE_3_VIEWPORTS_ALT || view == VIEW_USE_4_VIEWPORTS) { Vector2 size = get_size(); @@ -4225,15 +4017,12 @@ void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) { } void Node3DEditorViewportContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_MOUSE_ENTER || p_what == NOTIFICATION_MOUSE_EXIT) { - mouseover = (p_what == NOTIFICATION_MOUSE_ENTER); update(); } if (p_what == NOTIFICATION_DRAW && mouseover) { - Ref<Texture2D> h_grabber = get_theme_icon("grabber", "HSplitContainer"); Ref<Texture2D> v_grabber = get_theme_icon("grabber", "VSplitContainer"); @@ -4254,26 +4043,21 @@ void Node3DEditorViewportContainer::_notification(int p_what) { int size_bottom = size.height - mid_h - v_sep / 2; switch (view) { - case VIEW_USE_1_VIEWPORT: { - // Nothing to show. } break; case VIEW_USE_2_VIEWPORTS: { - draw_texture(v_grabber, Vector2((size.width - v_grabber->get_width()) / 2, mid_h - v_grabber->get_height() / 2)); set_default_cursor_shape(CURSOR_VSPLIT); } break; case VIEW_USE_2_VIEWPORTS_ALT: { - draw_texture(h_grabber, Vector2(mid_w - h_grabber->get_width() / 2, (size.height - h_grabber->get_height()) / 2)); set_default_cursor_shape(CURSOR_HSPLIT); } break; case VIEW_USE_3_VIEWPORTS: { - if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { draw_texture(hdiag_grabber, Vector2(mid_w - hdiag_grabber->get_width() / 2, mid_h - v_grabber->get_height() / 4)); set_default_cursor_shape(CURSOR_DRAG); @@ -4287,7 +4071,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_3_VIEWPORTS_ALT: { - if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { draw_texture(vdiag_grabber, Vector2(mid_w - vdiag_grabber->get_width() + v_grabber->get_height() / 4, mid_h - vdiag_grabber->get_height() / 2)); set_default_cursor_shape(CURSOR_DRAG); @@ -4301,7 +4084,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_4_VIEWPORTS: { - Vector2 half(mid_w, mid_h); if ((hovering_v && hovering_h && !dragging_v && !dragging_h) || (dragging_v && dragging_h)) { draw_texture(vh_grabber, half - vh_grabber->get_size() / 2.0); @@ -4319,7 +4101,6 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } if (p_what == NOTIFICATION_SORT_CHILDREN) { - Node3DEditorViewport *viewports[4]; int vc = 0; for (int i = 0; i < get_child_count(); i++) { @@ -4353,12 +4134,9 @@ void Node3DEditorViewportContainer::_notification(int p_what) { int size_bottom = size.height - mid_h - v_sep / 2; switch (view) { - case VIEW_USE_1_VIEWPORT: { - viewports[0]->show(); for (int i = 1; i < 4; i++) { - viewports[i]->hide(); } @@ -4366,9 +4144,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_2_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - if (i == 1 || i == 3) viewports[i]->hide(); else @@ -4380,9 +4156,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_2_VIEWPORTS_ALT: { - for (int i = 0; i < 4; i++) { - if (i == 1 || i == 3) viewports[i]->hide(); else @@ -4393,9 +4167,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_3_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - if (i == 1) viewports[i]->hide(); else @@ -4408,9 +4180,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_3_VIEWPORTS_ALT: { - for (int i = 0; i < 4; i++) { - if (i == 1) viewports[i]->hide(); else @@ -4423,9 +4193,7 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } break; case VIEW_USE_4_VIEWPORTS: { - for (int i = 0; i < 4; i++) { - viewports[i]->show(); } @@ -4440,23 +4208,19 @@ void Node3DEditorViewportContainer::_notification(int p_what) { } void Node3DEditorViewportContainer::set_view(View p_view) { - view = p_view; queue_sort(); } Node3DEditorViewportContainer::View Node3DEditorViewportContainer::get_view() { - return view; } void Node3DEditorViewportContainer::_bind_methods() { - ClassDB::bind_method("_gui_input", &Node3DEditorViewportContainer::_gui_input); } Node3DEditorViewportContainer::Node3DEditorViewportContainer() { - set_clip_contents(true); view = VIEW_USE_1_VIEWPORT; mouseover = false; @@ -4473,15 +4237,12 @@ Node3DEditorViewportContainer::Node3DEditorViewportContainer() { Node3DEditor *Node3DEditor::singleton = nullptr; Node3DEditorSelectedItem::~Node3DEditorSelectedItem() { - if (sbox_instance.is_valid()) RenderingServer::get_singleton()->free(sbox_instance); } void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { - for (int i = 0; i < 3; i++) { - move_gizmo[i]->surface_set_material(0, i == p_axis ? gizmo_color_hl[i] : gizmo_color[i]); move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? plane_gizmo_color_hl[i] : plane_gizmo_color[i]); rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_color_hl[i] : gizmo_color[i]); @@ -4491,7 +4252,6 @@ void Node3DEditor::select_gizmo_highlight_axis(int p_axis) { } void Node3DEditor::update_transform_gizmo() { - List<Node *> &selection = editor_selection->get_selected_node_list(); AABB center; bool first = true; @@ -4500,7 +4260,6 @@ void Node3DEditor::update_transform_gizmo() { bool local_gizmo_coords = are_local_coords_enabled(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -4553,7 +4312,6 @@ void Node3DEditor::update_all_gizmos(Node *p_node) { } Object *Node3DEditor::_get_editor_data(Object *p_what) { - Node3D *sp = Object::cast_to<Node3D>(p_what); if (!sp) return nullptr; @@ -4568,7 +4326,6 @@ Object *Node3DEditor::_get_editor_data(Object *p_what) { } void Node3DEditor::_generate_selection_box() { - AABB aabb(Vector3(), Vector3(1, 1, 1)); aabb.grow_by(aabb.get_longest_axis_size() / 20.0); @@ -4576,7 +4333,6 @@ void Node3DEditor::_generate_selection_box() { st->begin(Mesh::PRIMITIVE_LINES); for (int i = 0; i < 12; i++) { - Vector3 a, b; aabb.get_edge(i, a, b); @@ -4602,7 +4358,6 @@ void Node3DEditor::_generate_selection_box() { } Dictionary Node3DEditor::get_state() const { - Dictionary d; d["snap_enabled"] = snap_enabled; @@ -4654,7 +4409,6 @@ Dictionary Node3DEditor::get_state() const { return d; } void Node3DEditor::set_state(const Dictionary &p_state) { - Dictionary d = p_state; if (d.has("snap_enabled")) { @@ -4754,10 +4508,8 @@ void Node3DEditor::set_state(const Dictionary &p_state) { } void Node3DEditor::edit(Node3D *p_spatial) { - if (p_spatial != selected) { if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); if (seg.is_valid()) { seg->set_selected(false); @@ -4769,7 +4521,6 @@ void Node3DEditor::edit(Node3D *p_spatial) { over_gizmo_handle = -1; if (selected) { - Ref<EditorNode3DGizmo> seg = selected->get_gizmo(); if (seg.is_valid()) { seg->set_selected(true); @@ -4780,21 +4531,18 @@ void Node3DEditor::edit(Node3D *p_spatial) { } 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 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 Node3DEditor::_xform_dialog_action() { - Transform t; //translation Vector3 scale; @@ -4816,7 +4564,6 @@ void Node3DEditor::_xform_dialog_action() { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *sp = Object::cast_to<Node3D>(E->get()); if (!sp) continue; @@ -4831,7 +4578,6 @@ void Node3DEditor::_xform_dialog_action() { if (post) tr = tr * t; else { - tr.basis = t.basis * tr.basis; tr.origin += t.origin; } @@ -4843,10 +4589,8 @@ void Node3DEditor::_xform_dialog_action() { } void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) { - switch (p_option) { case MENU_TOOL_LOCAL_COORDS: { - tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_pressed(pressed); update_transform_gizmo(); } break; @@ -4861,7 +4605,6 @@ void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) { using Override = EditorDebuggerNode::CameraOverride; if (pressed) { - debugger->set_camera_override((Override)(Override::OVERRIDE_3D_1 + camera_override_viewport_id)); } else { debugger->set_camera_override(Override::OVERRIDE_NONE); @@ -4872,7 +4615,6 @@ void Node3DEditor::_menu_item_toggled(bool pressed, 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); @@ -4925,15 +4667,12 @@ void Node3DEditor::_update_camera_override_viewport(Object *p_viewport) { } void Node3DEditor::_menu_item_pressed(int p_option) { - switch (p_option) { - case MENU_TOOL_SELECT: case MENU_TOOL_MOVE: case MENU_TOOL_ROTATE: case MENU_TOOL_SCALE: case MENU_TOOL_LIST_SELECT: { - for (int i = 0; i < TOOL_MAX; i++) tool_button[i]->set_pressed(i == p_option); tool_mode = (ToolMode)p_option; @@ -4941,13 +4680,10 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_TRANSFORM_CONFIGURE_SNAP: { - snap_dialog->popup_centered(Size2(200, 180)); } break; case MENU_TRANSFORM_DIALOG: { - for (int i = 0; i < 3; i++) { - xform_translate[i]->set_text("0"); xform_rotate[i]->set_text("0"); xform_scale[i]->set_text("1"); @@ -4957,7 +4693,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -4969,7 +4704,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -4981,7 +4715,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -4993,7 +4726,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -5005,7 +4737,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -5017,7 +4748,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_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); @@ -5029,7 +4759,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_ORIGIN: { - bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option)); origin_enabled = !is_checked; @@ -5041,7 +4770,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), origin_enabled); } break; case MENU_VIEW_GRID: { - bool is_checked = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(p_option)); grid_enabled = !is_checked; @@ -5057,7 +4785,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } break; case MENU_VIEW_CAMERA_SETTINGS: { - settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50)); } break; case MENU_SNAP_TO_FLOOR: { @@ -5069,7 +4796,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5093,7 +4819,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5117,7 +4842,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5140,7 +4864,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node3D *spatial = Object::cast_to<Node3D>(E->get()); if (!spatial || !spatial->is_visible_in_tree()) continue; @@ -5162,7 +4885,6 @@ void Node3DEditor::_menu_item_pressed(int p_option) { } void Node3DEditor::_init_indicators() { - { origin_enabled = true; grid_enabled = true; @@ -5224,11 +4946,9 @@ void Node3DEditor::_init_indicators() { } { - //move gizmo for (int i = 0; i < 3; i++) { - Color col; switch (i) { case 0: @@ -5276,7 +4996,6 @@ void Node3DEditor::_init_indicators() { //translate { - Ref<SurfaceTool> surftool = memnew(SurfaceTool); surftool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -5293,12 +5012,10 @@ void Node3DEditor::_init_indicators() { int arrow_sides = 16; for (int k = 0; k < arrow_sides; k++) { - Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides); Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides); for (int j = 0; j < arrow_points - 1; j++) { - Vector3 points[4] = { ma.xform(arrow[j]), mb.xform(arrow[j]), @@ -5365,7 +5082,6 @@ void Node3DEditor::_init_indicators() { // Rotate { - Ref<SurfaceTool> surftool = memnew(SurfaceTool); surftool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -5378,12 +5094,10 @@ void Node3DEditor::_init_indicators() { }; for (int k = 0; k < 64; k++) { - Basis ma(ivec, Math_PI * 2 * float(k) / 64); Basis mb(ivec, Math_PI * 2 * float(k + 1) / 64); for (int j = 0; j < 4; j++) { - Vector3 points[4] = { ma.xform(circle[j]), mb.xform(circle[j]), @@ -5423,12 +5137,10 @@ void Node3DEditor::_init_indicators() { int arrow_sides = 4; for (int k = 0; k < 4; k++) { - Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides); Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides); for (int j = 0; j < arrow_points - 1; j++) { - Vector3 points[4] = { ma.xform(arrow[j]), mb.xform(arrow[j]), @@ -5499,7 +5211,6 @@ void Node3DEditor::_init_indicators() { } void Node3DEditor::_update_gizmos_menu() { - gizmos_menu->clear(); for (int i = 0; i < gizmo_plugins_by_name.size(); ++i) { @@ -5544,7 +5255,6 @@ void Node3DEditor::_update_gizmos_menu_theme() { } void Node3DEditor::_init_grid() { - Vector<Color> grid_colors[3]; Vector<Vector3> grid_points[3]; @@ -5603,7 +5313,6 @@ void Node3DEditor::_init_grid() { } void Node3DEditor::_finish_indicators() { - RenderingServer::get_singleton()->free(origin_instance); RenderingServer::get_singleton()->free(origin); @@ -5626,7 +5335,6 @@ bool Node3DEditor::is_any_freelook_active() const { } void Node3DEditor::_refresh_menu_icons() { - bool all_locked = true; bool all_grouped = true; @@ -5798,16 +5506,13 @@ void Node3DEditor::snap_selected_nodes_to_floor() { } void Node3DEditor::_unhandled_key_input(Ref<InputEvent> p_event) { - if (!is_visible_in_tree()) return; snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL); } void Node3DEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon("ToolMove", "EditorIcons")); tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon("ToolRotate", "EditorIcons")); @@ -5840,14 +5545,12 @@ void Node3DEditor::_notification(int p_what) { 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(); _update_gizmos_menu(); _init_indicators(); } else if (p_what == NOTIFICATION_THEME_CHANGED) { _update_gizmos_menu_theme(); } else if (p_what == NOTIFICATION_EXIT_TREE) { - _finish_indicators(); } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon("ToolSelect", "EditorIcons")); @@ -5884,39 +5587,32 @@ void Node3DEditor::_notification(int p_what) { } void Node3DEditor::add_control_to_menu_panel(Control *p_control) { - hbc_menu->add_child(p_control); } void Node3DEditor::remove_control_from_menu_panel(Control *p_control) { - hbc_menu->remove_child(p_control); } void Node3DEditor::set_can_preview(Camera3D *p_preview) { - for (int i = 0; i < 4; i++) { viewports[i]->set_can_preview(p_preview); } } VSplitContainer *Node3DEditor::get_shader_split() { - return shader_split; } HSplitContainer *Node3DEditor::get_palette_split() { - return palette_split; } void Node3DEditor::_request_gizmo(Object *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<EditorNode3DGizmo> seg; for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) { @@ -5957,7 +5653,6 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { return; if (!maximized) { - for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { if (i == (uint32_t)index) viewports[i]->set_anchors_and_margins_preset(Control::PRESET_WIDE); @@ -5965,7 +5660,6 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { viewports[i]->hide(); } } else { - for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) viewports[i]->show(); @@ -5985,7 +5679,6 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { } void Node3DEditor::_node_removed(Node *p_node) { - if (p_node == selected) selected = nullptr; } @@ -6018,7 +5711,6 @@ void Node3DEditor::_register_all_gizmos() { } void Node3DEditor::_bind_methods() { - ClassDB::bind_method("_unhandled_key_input", &Node3DEditor::_unhandled_key_input); ClassDB::bind_method("_get_editor_data", &Node3DEditor::_get_editor_data); ClassDB::bind_method("_request_gizmo", &Node3DEditor::_request_gizmo); @@ -6029,7 +5721,6 @@ void Node3DEditor::_bind_methods() { } 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)); settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0)); @@ -6048,7 +5739,6 @@ void Node3DEditor::clear() { } 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(Node3DEditorViewport::VIEW_AUDIO_LISTENER), i == 0); viewports[i]->viewport->set_as_audio_listener(i == 0); } @@ -6057,7 +5747,6 @@ void Node3DEditor::clear() { } Node3DEditor::Node3DEditor(EditorNode *p_editor) { - gizmo.visible = true; gizmo.scale = 1.0; @@ -6270,7 +5959,6 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { 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(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)); @@ -6355,7 +6043,6 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { xform_vbc->add_child(xform_hbc); for (int i = 0; i < 3; i++) { - xform_translate[i] = memnew(LineEdit); xform_translate[i]->set_h_size_flags(SIZE_EXPAND_FILL); xform_hbc->add_child(xform_translate[i]); @@ -6420,25 +6107,20 @@ Node3DEditor::~Node3DEditor() { } void Node3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - spatial_editor->show(); spatial_editor->set_process(true); } else { - spatial_editor->hide(); spatial_editor->set_process(false); } } void Node3DEditorPlugin::edit(Object *p_object) { - spatial_editor->edit(Object::cast_to<Node3D>(p_object)); } bool Node3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Node3D"); } @@ -6447,12 +6129,10 @@ Dictionary Node3DEditorPlugin::get_state() const { } void Node3DEditorPlugin::set_state(const Dictionary &p_state) { - spatial_editor->set_state(p_state); } void Node3DEditor::snap_cursor_to_plane(const Plane &p_plane) { - //cursor.pos=p_plane.project(cursor.pos); } @@ -6499,17 +6179,14 @@ float Node3DEditor::get_scale_snap() const { } void Node3DEditorPlugin::_bind_methods() { - ClassDB::bind_method("snap_cursor_to_plane", &Node3DEditorPlugin::snap_cursor_to_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<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(); @@ -6519,7 +6196,6 @@ struct _GizmoPluginPriorityComparator { }; struct _GizmoPluginNameComparator { - bool operator()(const Ref<EditorNode3DGizmoPlugin> &p_a, const Ref<EditorNode3DGizmoPlugin> &p_b) const { return p_a->get_name() < p_b->get_name(); } @@ -6545,7 +6221,6 @@ void Node3DEditor::remove_gizmo_plugin(Ref<EditorNode3DGizmoPlugin> p_plugin) { } Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) { - editor = p_node; spatial_editor = memnew(Node3DEditor(p_node)); spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -6559,7 +6234,6 @@ Node3DEditorPlugin::~Node3DEditorPlugin() { } void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { - Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); Vector<Ref<StandardMaterial3D>> mats; @@ -6601,7 +6275,6 @@ void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color } 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; @@ -6703,7 +6376,6 @@ int EditorNode3DGizmoPlugin::get_priority() const { } 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); } @@ -6764,7 +6436,6 @@ bool EditorNode3DGizmoPlugin::has_gizmo(Node3D *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); } diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index fdc0741651..3d92e7e7e1 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -46,7 +46,6 @@ class Node3DEditorViewport; class SubViewportContainer; class EditorNode3DGizmo : public Node3DGizmo { - GDCLASS(EditorNode3DGizmo, Node3DGizmo); bool selected; @@ -57,7 +56,6 @@ public: bool is_selected() const { return selected; } struct Instance { - RID instance; Ref<ArrayMesh> mesh; Ref<Material> material; @@ -68,7 +66,6 @@ public: bool can_intersect; bool extra_margin; Instance() { - billboard = false; unscaled = false; can_intersect = false; @@ -179,7 +176,6 @@ public: }; class Node3DEditorViewport : public Control { - GDCLASS(Node3DEditorViewport, Control); friend class Node3DEditor; friend class ViewportRotationControl; @@ -299,7 +295,6 @@ private: Label *fps_label; struct _RayResult { - Node3D *item; float depth; int handle; @@ -389,7 +384,6 @@ private: } _edit; struct Cursor { - Vector3 pos; float x_rot, y_rot, distance; Vector3 eye_pos; // Used in freelook mode @@ -490,7 +484,6 @@ public: }; class Node3DEditorSelectedItem : public Object { - GDCLASS(Node3DEditorSelectedItem, Object); public: @@ -510,7 +503,6 @@ public: }; class Node3DEditorViewportContainer : public Container { - GDCLASS(Node3DEditorViewportContainer, Container); public: @@ -551,7 +543,6 @@ public: }; class Node3DEditor : public VBoxContainer { - GDCLASS(Node3DEditor, VBoxContainer); public: @@ -629,7 +620,6 @@ private: AABB preview_bounds; struct Gizmo { - bool visible; float scale; Transform transform; @@ -819,7 +809,6 @@ public: }; class Node3DEditorPlugin : public EditorPlugin { - GDCLASS(Node3DEditorPlugin, EditorPlugin); Node3DEditor *spatial_editor; @@ -849,7 +838,6 @@ public: }; class EditorNode3DGizmoPlugin : public Resource { - GDCLASS(EditorNode3DGizmoPlugin, Resource); public: diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 2edb337b1c..41011343c8 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -37,11 +37,8 @@ #include "editor/editor_settings.h" void Path2DEditor::_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")); //set_pressed_button(button_edit); @@ -49,12 +46,10 @@ void Path2DEditor::_notification(int p_what) { } break; case NOTIFICATION_PHYSICS_PROCESS: { - } break; } } void Path2DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; hide(); @@ -75,18 +70,15 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); Vector2 gpoint = mb->get_position(); Vector2 cpoint = node->get_global_transform().affine_inverse().xform(canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mb->get_position()))); if (mb->is_pressed() && action == ACTION_NONE) { - Ref<Curve2D> curve = node->get_curve(); for (int i = 0; i < curve->get_point_count(); i++) { - real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_position(i))); real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_out(i))); real_t dist_to_p_in = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_in(i))); @@ -104,7 +96,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } else if (mode == MODE_EDIT || mode == MODE_EDIT_CURVE) { // In/out controls can be moved in multiple modes. if (dist_to_p_out < grab_threshold && i < (curve->get_point_count() - 1)) { - action = ACTION_MOVING_OUT; action_point = i; moving_from = curve->get_point_out(i); @@ -112,7 +103,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { orig_in_length = curve->get_point_in(action_point).length(); return true; } else if (dist_to_p_in < grab_threshold && i > 0) { - action = ACTION_MOVING_IN; action_point = i; moving_from = curve->get_point_in(i); @@ -126,7 +116,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // Check for point deletion. if ((mb->get_button_index() == BUTTON_RIGHT && mode == MODE_EDIT) || (mb->get_button_index() == BUTTON_LEFT && mode == MODE_DELETE)) { if (dist_to_p < grab_threshold) { - undo_redo->create_action(TTR("Remove Point from Curve")); undo_redo->add_do_method(curve.ptr(), "remove_point", i); undo_redo->add_undo_method(curve.ptr(), "add_point", curve->get_point_position(i), curve->get_point_in(i), curve->get_point_out(i), i); @@ -135,7 +124,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->commit_action(); return true; } else if (dist_to_p_out < grab_threshold) { - undo_redo->create_action(TTR("Remove Out-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_out", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_out", i, curve->get_point_out(i)); @@ -144,7 +132,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->commit_action(); return true; } else if (dist_to_p_in < grab_threshold) { - undo_redo->create_action(TTR("Remove In-Control from Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_in", i, Vector2()); undo_redo->add_undo_method(curve.ptr(), "set_point_in", i, curve->get_point_in(i)); @@ -159,7 +146,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // Check for point creation. if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && ((mb->get_command() && mode == MODE_EDIT) || mode == MODE_CREATE)) { - Ref<Curve2D> curve = node->get_curve(); undo_redo->create_action(TTR("Add Point to Curve")); @@ -216,18 +202,15 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { // Check for point movement completion. if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && action != ACTION_NONE) { - Ref<Curve2D> curve = node->get_curve(); Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from); switch (action) { - case ACTION_NONE: // N/A, handled in above condition. break; case ACTION_MOVING_POINT: { - undo_redo->create_action(TTR("Move Point in Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_position", action_point, cpoint); undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from); @@ -238,7 +221,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } break; case ACTION_MOVING_IN: { - undo_redo->create_action(TTR("Move In-Control in Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos); undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from); @@ -254,7 +236,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } break; case ACTION_MOVING_OUT: { - undo_redo->create_action(TTR("Move Out-Control in Curve")); undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos); undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from); @@ -279,7 +260,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (action == ACTION_NONE && mode == MODE_EDIT) { // Handle Edge Follow bool old_edge = on_edge; @@ -336,7 +316,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Vector2 new_pos = moving_from + xform.affine_inverse().basis_xform(gpoint - moving_screen_from); switch (action) { - case ACTION_NONE: // N/A, handled in above condition. break; @@ -369,7 +348,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } void Path2DEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { - if (!node || !node->is_visible_in_tree() || !node->get_curve().is_valid()) return; @@ -435,19 +413,16 @@ void Path2DEditor::_node_visibility_changed() { } void Path2DEditor::edit(Node *p_path2d) { - if (!canvas_item_editor) { canvas_item_editor = CanvasItemEditor::get_singleton(); } if (p_path2d) { - node = Object::cast_to<Path2D>(p_path2d); if (!node->is_connected("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed))) node->connect("visibility_changed", callable_mp(this, &Path2DEditor::_node_visibility_changed)); } else { - // 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)); @@ -456,38 +431,31 @@ void Path2DEditor::edit(Node *p_path2d) { } void Path2DEditor::_bind_methods() { - //ClassDB::bind_method(D_METHOD("_menu_option"),&Path2DEditor::_menu_option); } void Path2DEditor::_mode_selected(int p_mode) { - if (p_mode == MODE_CREATE) { - curve_create->set_pressed(true); curve_edit->set_pressed(false); curve_edit_curve->set_pressed(false); curve_del->set_pressed(false); } else if (p_mode == MODE_EDIT) { - curve_create->set_pressed(false); curve_edit->set_pressed(true); curve_edit_curve->set_pressed(false); curve_del->set_pressed(false); } else if (p_mode == MODE_EDIT_CURVE) { - curve_create->set_pressed(false); curve_edit->set_pressed(false); curve_edit_curve->set_pressed(true); curve_del->set_pressed(false); } else if (p_mode == MODE_DELETE) { - curve_create->set_pressed(false); curve_edit->set_pressed(false); curve_edit_curve->set_pressed(false); curve_del->set_pressed(true); } else if (p_mode == ACTION_CLOSE) { - //? if (!node->get_curve().is_valid()) @@ -513,7 +481,6 @@ void Path2DEditor::_mode_selected(int p_mode) { } void Path2DEditor::_handle_option_pressed(int p_option) { - PopupMenu *pm; pm = handle_menu->get_popup(); @@ -533,7 +500,6 @@ void Path2DEditor::_handle_option_pressed(int p_option) { } Path2DEditor::Path2DEditor(EditorNode *p_editor) { - canvas_item_editor = nullptr; editor = p_editor; undo_redo = editor->get_undo_redo(); @@ -603,23 +569,19 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { } void Path2DEditorPlugin::edit(Object *p_object) { - path2d_editor->edit(Object::cast_to<Node>(p_object)); } bool Path2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Path2D"); } void Path2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { path2d_editor->show(); path2d_editor->base_hb->show(); } else { - path2d_editor->hide(); path2d_editor->base_hb->hide(); path2d_editor->edit(nullptr); @@ -627,7 +589,6 @@ void Path2DEditorPlugin::make_visible(bool p_visible) { } Path2DEditorPlugin::Path2DEditorPlugin(EditorNode *p_node) { - editor = p_node; path2d_editor = memnew(Path2DEditor(p_node)); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(path2d_editor); diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index aae0e11c99..390dfdfdf7 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -39,7 +39,6 @@ class CanvasItemEditor; class Path2DEditor : public HBoxContainer { - GDCLASS(Path2DEditor, HBoxContainer); UndoRedo *undo_redo; @@ -112,7 +111,6 @@ public: }; class Path2DEditorPlugin : public EditorPlugin { - GDCLASS(Path2DEditorPlugin, EditorPlugin); Path2DEditor *path2d_editor; diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 6c475d829f..0ed7995914 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -35,13 +35,11 @@ #include "scene/resources/curve.h" String Path3DGizmo::get_handle_name(int p_idx) const { - Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return ""; if (p_idx < c->get_point_count()) { - return TTR("Curve Point #") + itos(p_idx); } @@ -58,13 +56,11 @@ String Path3DGizmo::get_handle_name(int p_idx) const { return n; } Variant Path3DGizmo::get_handle_value(int p_idx) { - Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return Variant(); if (p_idx < c->get_point_count()) { - original = c->get_point_position(p_idx); return original; } @@ -85,7 +81,6 @@ Variant Path3DGizmo::get_handle_value(int p_idx) { return ofs; } void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_point) { - Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return; @@ -97,13 +92,11 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin // Setting curve point positions if (p_idx < c->get_point_count()) { - Plane p(gt.xform(original), p_camera->get_transform().basis.get_axis(2)); Vector3 inters; if (p.intersects_ray(ray_from, ray_dir, &inters)) { - if (Node3DEditor::get_singleton()->is_snap_enabled()) { float snap = Node3DEditor::get_singleton()->get_translate_snap(); inters.snap(Vector3(snap, snap, snap)); @@ -129,7 +122,6 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin // Setting curve in/out positions if (p.intersects_ray(ray_from, ray_dir, &inters)) { - if (!Path3DEditorPlugin::singleton->is_handle_clicked()) { orig_in_length = c->get_point_in(idx).length(); orig_out_length = c->get_point_out(idx).length(); @@ -155,7 +147,6 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin } void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { - Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return; @@ -163,9 +154,7 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); if (p_idx < c->get_point_count()) { - if (p_cancel) { - c->set_point_position(p_idx, p_restore); return; } @@ -218,7 +207,6 @@ void Path3DGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_canc } void Path3DGizmo::redraw() { - clear(); Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this); @@ -240,7 +228,6 @@ void Path3DGizmo::redraw() { // BUG: the following won't work when v3s, avoid drawing as a temporary workaround. for (int i = 0; i < v3s - 1; i++) { - v3p.push_back(r[i]); v3p.push_back(r[i + 1]); //v3p.push_back(r[i]); @@ -258,7 +245,6 @@ void Path3DGizmo::redraw() { Vector<Vector3> sec_handles; for (int i = 0; i < c->get_point_count(); i++) { - Vector3 p = c->get_point_position(i); handles.push_back(p); if (i > 0) { @@ -287,13 +273,11 @@ void Path3DGizmo::redraw() { } Path3DGizmo::Path3DGizmo(Path3D *p_path) { - path = p_path; set_spatial_node(p_path); } bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) { - if (!path) return false; Ref<Curve3D> c = path->get_curve(); @@ -307,7 +291,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid()) { - Point2 mbpos(mb->get_position().x, mb->get_position().y); if (!mb->is_pressed()) @@ -335,7 +318,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref return false; //nope, existing while (j < rc && c->get_point_position(i + 1) != r[j]) { - Vector3 from = r[j]; Vector3 to = r[j + 1]; real_t cdist = from.distance_to(to); @@ -349,7 +331,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref float d = inters.distance_to(mbpos); if (d < 10 && d < closest_d) { - closest_d = d; closest_seg = i; Vector3 ray_from = p_camera->project_ray_origin(mbpos); @@ -384,7 +365,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref return true; } else { - Vector3 org; if (c->get_point_count() == 0) org = path->get_transform().get_origin(); @@ -396,7 +376,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref Vector3 inters; if (p.intersects_ray(ray_from, ray_dir, &inters)) { - ur->create_action(TTR("Add Point to Curve")); ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1); ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count()); @@ -408,7 +387,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref } } else if (mb->is_pressed() && ((mb->get_button_index() == BUTTON_LEFT && curve_del->is_pressed()) || (mb->get_button_index() == BUTTON_RIGHT && curve_edit->is_pressed()))) { - for (int i = 0; i < c->get_point_count(); i++) { real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_position(i))).distance_to(mbpos); real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_position(i) + c->get_point_out(i))).distance_to(mbpos); @@ -417,7 +395,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref // Find the offset and point index of the place to break up. // Also check for the control points. if (dist_to_p < click_dist) { - UndoRedo *ur = editor->get_undo_redo(); ur->create_action(TTR("Remove Path Point")); ur->add_do_method(c.ptr(), "remove_point", i); @@ -425,7 +402,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref ur->commit_action(); return true; } else if (dist_to_p_out < click_dist) { - UndoRedo *ur = editor->get_undo_redo(); ur->create_action(TTR("Remove Out-Control Point")); ur->add_do_method(c.ptr(), "set_point_out", i, Vector3()); @@ -433,7 +409,6 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref ur->commit_action(); return true; } else if (dist_to_p_in < click_dist) { - UndoRedo *ur = editor->get_undo_redo(); ur->create_action(TTR("Remove In-Control Point")); ur->add_do_method(c.ptr(), "set_point_in", i, Vector3()); @@ -449,11 +424,9 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref } void Path3DEditorPlugin::edit(Object *p_object) { - if (p_object) { path = Object::cast_to<Path3D>(p_object); if (path) { - if (path->get_curve().is_valid()) { path->get_curve()->emit_signal("changed"); } @@ -469,14 +442,11 @@ void Path3DEditorPlugin::edit(Object *p_object) { } bool Path3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Path3D"); } void Path3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - curve_create->show(); curve_edit->show(); curve_del->show(); @@ -484,7 +454,6 @@ void Path3DEditorPlugin::make_visible(bool p_visible) { handle_menu->show(); sep->show(); } else { - curve_create->hide(); curve_edit->hide(); curve_del->hide(); @@ -503,14 +472,12 @@ void Path3DEditorPlugin::make_visible(bool p_visible) { } 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 Path3DEditorPlugin::_close_curve() { - Ref<Curve3D> c = path->get_curve(); if (c.is_null()) return; @@ -520,7 +487,6 @@ void Path3DEditorPlugin::_close_curve() { } void Path3DEditorPlugin::_handle_option_pressed(int p_option) { - PopupMenu *pm; pm = handle_menu->get_popup(); @@ -540,9 +506,7 @@ void Path3DEditorPlugin::_handle_option_pressed(int p_option) { } void Path3DEditorPlugin::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - 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)); @@ -556,7 +520,6 @@ void Path3DEditorPlugin::_bind_methods() { Path3DEditorPlugin *Path3DEditorPlugin::singleton = nullptr; Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) { - path = nullptr; editor = p_node; singleton = this; @@ -646,7 +609,6 @@ int Path3DGizmoPlugin::get_priority() const { } Path3DGizmoPlugin::Path3DGizmoPlugin() { - Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); create_material("path_material", path_color); create_material("path_thin_material", Color(0.5, 0.5, 0.5)); diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 3f18cadacd..8bec5df797 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/3d/path_3d.h" class Path3DGizmo : public EditorNode3DGizmo { - GDCLASS(Path3DGizmo, EditorNode3DGizmo); Path3D *path; @@ -54,7 +53,6 @@ public: }; class Path3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(Path3DGizmoPlugin, EditorNode3DGizmoPlugin); protected: @@ -67,7 +65,6 @@ public: }; class Path3DEditorPlugin : public EditorPlugin { - GDCLASS(Path3DEditorPlugin, EditorPlugin); Separator *sep; diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index 567d58922f..bcbf88e7dc 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -37,7 +37,6 @@ void PhysicalBone3DEditor::_bind_methods() { } void PhysicalBone3DEditor::_on_toggle_button_transform_joint(bool p_is_pressed) { - _set_move_joint(); } @@ -49,7 +48,6 @@ void PhysicalBone3DEditor::_set_move_joint() { PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : editor(p_editor) { - spatial_editor_hb = memnew(HBoxContainer); spatial_editor_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); spatial_editor_hb->set_alignment(BoxContainer::ALIGN_BEGIN); @@ -69,7 +67,6 @@ PhysicalBone3DEditor::PhysicalBone3DEditor(EditorNode *p_editor) : } void PhysicalBone3DEditor::set_selected(PhysicalBone3D *p_pb) { - button_transform_joint->set_pressed(false); _set_move_joint(); @@ -91,10 +88,8 @@ PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin(EditorNode *p_editor) : void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { - physical_bone_editor.show(); } else { - physical_bone_editor.hide(); physical_bone_editor.set_selected(nullptr); selected = nullptr; diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index e15d8556e4..3fcf3131b0 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -39,23 +39,19 @@ #include "scene/2d/skeleton_2d.h" Node2D *Polygon2DEditor::_get_node() const { - return node; } void Polygon2DEditor::_set_node(Node *p_polygon) { - node = Object::cast_to<Polygon2D>(p_polygon); _update_polygon_editing_state(); } Vector2 Polygon2DEditor::_get_offset(int p_idx) const { - return node->get_offset(); } int Polygon2DEditor::_get_polygon_count() const { - if (node->get_internal_vertex_count() > 0) { return 0; //do not edit if internal vertices exist } else { @@ -64,17 +60,13 @@ int Polygon2DEditor::_get_polygon_count() const { } void Polygon2DEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: case NOTIFICATION_THEME_CHANGED: { - uv_edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); bone_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree")); } break; case NOTIFICATION_READY: { - button_uv->set_icon(get_theme_icon("Uv", "EditorIcons")); uv_button[UV_MODE_CREATE]->set_icon(get_theme_icon("Edit", "EditorIcons")); @@ -97,7 +89,6 @@ void Polygon2DEditor::_notification(int p_what) { uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE); } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (!is_visible()) { uv_edit->hide(); } @@ -106,7 +97,6 @@ void Polygon2DEditor::_notification(int p_what) { } void Polygon2DEditor::_sync_bones() { - 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")); @@ -161,7 +151,6 @@ void Polygon2DEditor::_sync_bones() { } void Polygon2DEditor::_update_bone_list() { - NodePath selected; while (bone_scroll_vb->get_child_count()) { CheckBox *cb = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(0)); @@ -203,7 +192,6 @@ void Polygon2DEditor::_bone_paint_selected(int p_index) { } void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { - if (p_mode == 0) { //uv uv_button[UV_MODE_CREATE]->hide(); @@ -274,20 +262,15 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) { } void Polygon2DEditor::_uv_edit_popup_hide() { - EditorSettings::get_singleton()->set("interface/dialogs/uv_editor_bounds", Rect2(uv_edit->get_position(), uv_edit->get_size())); _cancel_editing(); } void Polygon2DEditor::_menu_option(int p_option) { - switch (p_option) { - case MODE_EDIT_UV: { - 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(); return; @@ -311,7 +294,6 @@ void Polygon2DEditor::_menu_option(int p_option) { _update_bone_list(); } break; case UVEDIT_POLYGON_TO_UV: { - Vector<Vector2> points = node->get_polygon(); if (points.size() == 0) break; @@ -324,7 +306,6 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->commit_action(); } break; case UVEDIT_UV_TO_POLYGON: { - Vector<Vector2> points = node->get_polygon(); Vector<Vector2> uvs = node->get_uv(); if (uvs.size() == 0) @@ -338,7 +319,6 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->commit_action(); } break; case UVEDIT_UV_CLEAR: { - Vector<Vector2> uvs = node->get_uv(); if (uvs.size() == 0) break; @@ -350,18 +330,15 @@ void Polygon2DEditor::_menu_option(int p_option) { undo_redo->commit_action(); } break; case UVEDIT_GRID_SETTINGS: { - grid_settings->popup_centered(); } break; default: { - AbstractPolygon2DEditor::_menu_option(p_option); } break; } } void Polygon2DEditor::_cancel_editing() { - if (uv_create) { uv_drag = false; uv_create = false; @@ -386,7 +363,6 @@ void Polygon2DEditor::_cancel_editing() { } void Polygon2DEditor::_update_polygon_editing_state() { - if (!_get_node()) return; @@ -397,7 +373,6 @@ void Polygon2DEditor::_update_polygon_editing_state() { } void Polygon2DEditor::_commit_action() { - // Makes that undo/redoing actions made outside of the UV editor still affect its polygon. undo_redo->add_do_method(uv_edit_draw, "update"); undo_redo->add_undo_method(uv_edit_draw, "update"); @@ -442,7 +417,6 @@ void Polygon2DEditor::_set_snap_step_y(float p_val) { } void Polygon2DEditor::_uv_mode(int p_mode) { - polygon_create.clear(); uv_drag = false; uv_create = false; @@ -454,7 +428,6 @@ void Polygon2DEditor::_uv_mode(int p_mode) { } void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { - if (!_get_node()) return; @@ -465,11 +438,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseButton> mb = p_input; if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_LEFT) { - if (mb->is_pressed()) { - uv_drag_from = snap_point(Vector2(mb->get_position().x, mb->get_position().y)); uv_drag = true; points_prev = node->get_uv(); @@ -482,9 +452,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { uv_move_current = uv_mode; if (uv_move_current == UV_MODE_CREATE) { - if (!uv_create) { - points_prev.resize(0); Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y))); points_prev.push_back(tuv); @@ -506,7 +474,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { uv_edit_draw->update(); } else { - Vector2 tuv = mtx.affine_inverse().xform(snap_point(Vector2(mb->get_position().x, mb->get_position().y))); if (points_prev.size() > 2 && tuv.distance_to(points_prev[0]) < 8) { @@ -544,7 +511,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_CREATE_INTERNAL) { - uv_create_uv_prev = node->get_uv(); uv_create_poly_prev = node->get_polygon(); uv_create_colors_prev = node->get_vertex_colors(); @@ -582,7 +548,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_REMOVE_INTERNAL) { - uv_create_uv_prev = node->get_uv(); uv_create_poly_prev = node->get_polygon(); uv_create_colors_prev = node->get_vertex_colors(); @@ -596,7 +561,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { float closest_dist = 1e20; for (int i = points_prev.size() - internal_vertices; i < points_prev.size(); i++) { - Vector2 tuv = mtx.xform(uv_create_poly_prev[i]); float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)); if (dist < 8 && dist < closest_dist) { @@ -637,7 +601,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_EDIT_POINT) { - if (mb->get_shift() && mb->get_command()) uv_move_current = UV_MODE_SCALE; else if (mb->get_shift()) @@ -647,10 +610,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_EDIT_POINT) { - point_drag_index = -1; for (int i = 0; i < points_prev.size(); i++) { - Vector2 tuv = mtx.xform(points_prev[i]); if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) { uv_drag_from = tuv; @@ -664,12 +625,10 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_ADD_POLYGON) { - int closest = -1; float closest_dist = 1e20; for (int i = 0; i < points_prev.size(); i++) { - Vector2 tuv = mtx.xform(points_prev[i]); float dist = tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)); if (dist < 8 && dist < closest_dist) { @@ -740,7 +699,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (uv_move_current == UV_MODE_PAINT_WEIGHT || uv_move_current == UV_MODE_CLEAR_WEIGHT) { - int bone_selected = -1; for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) { CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i)); @@ -751,7 +709,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } if (bone_selected != -1 && node->get_bone_weights(bone_selected).size() == points_prev.size()) { - prev_weights = node->get_bone_weights(bone_selected); bone_painting = true; bone_painting_bone = bone_selected; @@ -759,7 +716,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } } else if (uv_drag && !uv_create) { - if (uv_edit_mode[0]->is_pressed()) { // Edit UV. undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); @@ -778,7 +734,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { uv_drag = false; } else if (bone_painting) { - undo_redo->create_action(TTR("Paint Bone Weights")); undo_redo->add_do_method(node, "set_bone_weights", bone_painting_bone, node->get_bone_weights(bone_painting_bone)); undo_redo->add_undo_method(node, "set_bone_weights", bone_painting_bone, prev_weights); @@ -789,7 +744,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - _cancel_editing(); if (bone_painting) @@ -798,10 +752,8 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { uv_edit_draw->update(); } else if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) { - uv_zoom->set_value(uv_zoom->get_value() / (1 - (0.1 * mb->get_factor()))); } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && mb->is_pressed()) { - uv_zoom->set_value(uv_zoom->get_value() * (1 - (0.1 * mb->get_factor()))); } } @@ -809,29 +761,23 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseMotion> mm = p_input; if (mm.is_valid()) { - if ((mm->get_button_mask() & BUTTON_MASK_MIDDLE) || Input::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); uv_vscroll->set_value(uv_vscroll->get_value() - drag.y); } else if (uv_drag) { - Vector2 uv_drag_to = mm->get_position(); uv_drag_to = snap_point(uv_drag_to); // FIXME: Only works correctly with 'UV_MODE_EDIT_POINT', it's imprecise with the rest. Vector2 drag = mtx.affine_inverse().xform(uv_drag_to) - mtx.affine_inverse().xform(uv_drag_from); switch (uv_move_current) { - case UV_MODE_CREATE: { - if (uv_create) { uv_create_to = mtx.affine_inverse().xform(snap_point(Vector2(mm->get_position().x, mm->get_position().y))); } } break; case UV_MODE_EDIT_POINT: { - Vector<Vector2> uv_new = points_prev; uv_new.set(point_drag_index, uv_new[point_drag_index] + drag); @@ -842,7 +788,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } } break; case UV_MODE_MOVE: { - Vector<Vector2> uv_new = points_prev; for (int i = 0; i < uv_new.size(); i++) uv_new.set(i, uv_new[i] + drag); @@ -854,7 +799,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } } break; case UV_MODE_ROTATE: { - Vector2 center; Vector<Vector2> uv_new = points_prev; @@ -877,7 +821,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } } break; case UV_MODE_SCALE: { - Vector2 center; Vector<Vector2> uv_new = points_prev; @@ -906,7 +849,6 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } break; case UV_MODE_PAINT_WEIGHT: case UV_MODE_CLEAR_WEIGHT: { - bone_paint_pos = Vector2(mm->get_position().x, mm->get_position().y); } break; default: { @@ -952,20 +894,17 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { Ref<InputEventMagnifyGesture> magnify_gesture = p_input; if (magnify_gesture.is_valid()) { - uv_zoom->set_value(uv_zoom->get_value() * magnify_gesture->get_factor()); } Ref<InputEventPanGesture> pan_gesture = p_input; if (pan_gesture.is_valid()) { - uv_hscroll->set_value(uv_hscroll->get_value() + uv_hscroll->get_page() * pan_gesture->get_delta().x / 8); uv_vscroll->set_value(uv_vscroll->get_value() + uv_vscroll->get_page() * pan_gesture->get_delta().y / 8); } } void Polygon2DEditor::_uv_scroll_changed(float) { - if (updating_uv_scroll) return; @@ -976,7 +915,6 @@ void Polygon2DEditor::_uv_scroll_changed(float) { } void Polygon2DEditor::_uv_draw() { - if (!uv_edit->is_visible() || !_get_node()) return; @@ -1073,7 +1011,6 @@ void Polygon2DEditor::_uv_draw() { } for (int i = 0; i < uvs.size(); i++) { - int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0; if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/poly_editor/show_previous_outline", true)) { @@ -1092,7 +1029,6 @@ void Polygon2DEditor::_uv_draw() { } for (int i = 0; i < polygons.size(); i++) { - Vector<int> points = polygons[i]; Vector<Vector2> polypoints; for (int j = 0; j < points.size(); j++) { @@ -1114,7 +1050,6 @@ void Polygon2DEditor::_uv_draw() { } for (int i = 0; i < uvs.size(); i++) { - if (weight_r) { Vector2 draw_pos = mtx.xform(uvs[i]); float weight = weight_r[i]; @@ -1138,7 +1073,6 @@ void Polygon2DEditor::_uv_draw() { } if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) { - NodePath bone_path; for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) { CheckBox *c = Object::cast_to<CheckBox>(bone_scroll_vb->get_child(i)); @@ -1154,7 +1088,6 @@ void Polygon2DEditor::_uv_draw() { Skeleton2D *skeleton = Object::cast_to<Skeleton2D>(node->get_node(skeleton_path)); if (skeleton) { for (int i = 0; i < skeleton->get_bone_count(); i++) { - Bone2D *bone = skeleton->get_bone(i); if (bone->get_rest() == Transform2D(0, 0, 0, 0, 0, 0)) continue; //not set @@ -1164,7 +1097,6 @@ void Polygon2DEditor::_uv_draw() { bool found_child = false; for (int j = 0; j < bone->get_child_count(); j++) { - Bone2D *n = Object::cast_to<Bone2D>(bone->get_child(j)); if (!n) continue; @@ -1232,7 +1164,6 @@ void Polygon2DEditor::_uv_draw() { } void Polygon2DEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_bone_list"), &Polygon2DEditor::_update_bone_list); ClassDB::bind_method(D_METHOD("_update_polygon_editing_state"), &Polygon2DEditor::_update_polygon_editing_state); } @@ -1248,7 +1179,6 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : AbstractPolygon2DEditor(p_editor) { - 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)); @@ -1305,7 +1235,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : uv_main_vb->add_child(uv_mode_hb); for (int i = 0; i < UV_MODE_MAX; i++) { - uv_button[i] = memnew(ToolButton); uv_button[i]->set_toggle_mode(true); uv_mode_hb->add_child(uv_button[i]); diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 2b00b50e5c..b94ae53e2b 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -35,7 +35,6 @@ #include "scene/gui/scroll_container.h" class Polygon2DEditor : public AbstractPolygon2DEditor { - GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor); enum Mode { @@ -165,7 +164,6 @@ public: }; class Polygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin { - GDCLASS(Polygon2DEditorPlugin, AbstractPolygon2DEditorPlugin); public: diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 852feeb675..0d4ee492ee 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -39,13 +39,11 @@ void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { } void ResourcePreloaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { load->set_icon(get_theme_icon("Folder", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { - //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector<Variant>(),true); } @@ -54,9 +52,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { } void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) { - for (int i = 0; i < p_paths.size(); i++) { - String path = p_paths[i]; RES resource; @@ -89,7 +85,6 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) } void ResourcePreloaderEditor::_load_pressed() { - loading_scene = false; file->clear_filters(); @@ -104,7 +99,6 @@ void ResourcePreloaderEditor::_load_pressed() { } void ResourcePreloaderEditor::_item_edited() { - if (!tree->get_selected()) return; @@ -118,7 +112,6 @@ void ResourcePreloaderEditor::_item_edited() { return; if (new_name == "" || new_name.find("\\") != -1 || new_name.find("/") != -1 || preloader->has_resource(new_name)) { - s->set_text(0, old_name); return; } @@ -136,7 +129,6 @@ void ResourcePreloaderEditor::_item_edited() { } void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) { - undo_redo->create_action(TTR("Delete Resource")); undo_redo->add_do_method(preloader, "remove_resource", p_to_remove); undo_redo->add_undo_method(preloader, "add_resource", p_to_remove, preloader->get_resource(p_to_remove)); @@ -146,7 +138,6 @@ void ResourcePreloaderEditor::_remove_resource(const String &p_to_remove) { } void ResourcePreloaderEditor::_paste_pressed() { - RES r = EditorSettings::get_singleton()->get_resource_clipboard(); if (!r.is_valid()) { dialog->set_text(TTR("Resource clipboard is empty!")); @@ -178,7 +169,6 @@ void ResourcePreloaderEditor::_paste_pressed() { } void ResourcePreloaderEditor::_update_library() { - tree->clear(); tree->set_hide_root(true); TreeItem *root = tree->create_item(nullptr); @@ -194,7 +184,6 @@ void ResourcePreloaderEditor::_update_library() { names.sort(); for (List<String>::Element *E = names.front(); E; E = E->next()) { - TreeItem *ti = tree->create_item(root); ti->set_cell_mode(0, TreeItem::CELL_MODE_STRING); ti->set_editable(0, true); @@ -226,7 +215,6 @@ void ResourcePreloaderEditor::_update_library() { } void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) { - TreeItem *item = Object::cast_to<TreeItem>(p_item); ERR_FAIL_COND(!item); @@ -244,20 +232,17 @@ void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column, } void ResourcePreloaderEditor::edit(ResourcePreloader *p_preloader) { - preloader = p_preloader; if (p_preloader) { _update_library(); } else { - hide(); set_physics_process(false); } } Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - TreeItem *ti = tree->get_item_at_position(p_point); if (!ti) return Variant(); @@ -272,7 +257,6 @@ Variant ResourcePreloaderEditor::get_drag_data_fw(const Point2 &p_point, Control } bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type")) @@ -288,7 +272,6 @@ bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Vari } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; return files.size() != 0; @@ -297,7 +280,6 @@ bool ResourcePreloaderEditor::can_drop_data_fw(const Point2 &p_point, const Vari } void ResourcePreloaderEditor::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; @@ -310,7 +292,6 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant RES r = d["resource"]; if (r.is_valid()) { - String basename; if (r->get_name() != "") { basename = r->get_name(); @@ -337,7 +318,6 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; _files_load_request(files); @@ -345,7 +325,6 @@ void ResourcePreloaderEditor::drop_data_fw(const Point2 &p_point, const Variant } void ResourcePreloaderEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &ResourcePreloaderEditor::_gui_input); ClassDB::bind_method(D_METHOD("_update_library"), &ResourcePreloaderEditor::_update_library); ClassDB::bind_method(D_METHOD("_remove_resource", "to_remove"), &ResourcePreloaderEditor::_remove_resource); @@ -356,7 +335,6 @@ void ResourcePreloaderEditor::_bind_methods() { } ResourcePreloaderEditor::ResourcePreloaderEditor() { - //add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); VBoxContainer *vbc = memnew(VBoxContainer); @@ -399,7 +377,6 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() { } void ResourcePreloaderEditorPlugin::edit(Object *p_object) { - preloader_editor->set_undo_redo(&get_undo_redo()); ResourcePreloader *s = Object::cast_to<ResourcePreloader>(p_object); if (!s) @@ -409,19 +386,16 @@ void ResourcePreloaderEditorPlugin::edit(Object *p_object) { } bool ResourcePreloaderEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("ResourcePreloader"); } void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { //preloader_editor->show(); button->show(); editor->make_bottom_panel_item_visible(preloader_editor); //preloader_editor->set_process(true); } else { - if (preloader_editor->is_visible_in_tree()) editor->hide_bottom_panel(); button->hide(); @@ -431,7 +405,6 @@ void ResourcePreloaderEditorPlugin::make_visible(bool p_visible) { } ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin(EditorNode *p_node) { - editor = p_node; preloader_editor = memnew(ResourcePreloaderEditor); preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE); diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h index 88e9cf4956..2d7a54eda5 100644 --- a/editor/plugins/resource_preloader_editor_plugin.h +++ b/editor/plugins/resource_preloader_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/main/resource_preloader.h" class ResourcePreloaderEditor : public PanelContainer { - GDCLASS(ResourcePreloaderEditor, PanelContainer); enum { @@ -87,7 +86,6 @@ public: }; class ResourcePreloaderEditorPlugin : public EditorPlugin { - GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin); ResourcePreloaderEditor *preloader_editor; diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp index a7120c5d68..12a2b4c2b7 100644 --- a/editor/plugins/root_motion_editor_plugin.cpp +++ b/editor/plugins/root_motion_editor_plugin.cpp @@ -33,7 +33,6 @@ #include "scene/main/window.h" void EditorPropertyRootMotion::_confirmed() { - TreeItem *ti = filters->get_selected(); if (!ti) return; @@ -45,7 +44,6 @@ void EditorPropertyRootMotion::_confirmed() { } void EditorPropertyRootMotion::_node_assign() { - NodePath current = get_edited_object()->get(get_edited_property()); AnimationTree *atree = Object::cast_to<AnimationTree>(get_edited_object()); @@ -72,7 +70,6 @@ void EditorPropertyRootMotion::_node_assign() { player->get_animation_list(&animations); for (List<StringName>::Element *E = animations.front(); E; E = E->next()) { - Ref<Animation> anim = player->get_animation(E->get()); for (int i = 0; i < anim->get_track_count(); i++) { paths.insert(anim->track_get_path(i)); @@ -86,7 +83,6 @@ void EditorPropertyRootMotion::_node_assign() { Map<String, TreeItem *> parenthood; for (Set<String>::Element *E = paths.front(); E; E = E->next()) { - NodePath path = E->get(); TreeItem *ti = nullptr; String accum; @@ -125,7 +121,6 @@ void EditorPropertyRootMotion::_node_assign() { continue; //no node, can't edit if (path.get_subname_count()) { - String concat = path.get_concatenated_subnames(); Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node); @@ -194,13 +189,11 @@ void EditorPropertyRootMotion::_node_assign() { } void EditorPropertyRootMotion::_node_clear() { - emit_changed(get_edited_property(), NodePath()); update_property(); } void EditorPropertyRootMotion::update_property() { - NodePath p = get_edited_object()->get(get_edited_property()); assign->set_tooltip(p); @@ -235,12 +228,10 @@ void EditorPropertyRootMotion::update_property() { } void EditorPropertyRootMotion::setup(const NodePath &p_base_hint) { - base_hint = p_base_hint; } void EditorPropertyRootMotion::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { Ref<Texture2D> t = get_theme_icon("Clear", "EditorIcons"); clear->set_icon(t); @@ -251,7 +242,6 @@ void EditorPropertyRootMotion::_bind_methods() { } EditorPropertyRootMotion::EditorPropertyRootMotion() { - HBoxContainer *hbc = memnew(HBoxContainer); add_child(hbc); assign = memnew(Button); @@ -289,7 +279,6 @@ void EditorInspectorRootMotionPlugin::parse_begin(Object *p_object) { } bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { - if (p_path == "root_motion_track" && p_object->is_class("AnimationTree") && p_type == Variant::NODE_PATH) { EditorPropertyRootMotion *editor = memnew(EditorPropertyRootMotion); if (p_hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && p_hint_text != String()) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index e6d3f17f12..dbeb6e339b 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -54,7 +54,6 @@ /*** SCRIPT EDITOR ****/ void ScriptEditorBase::_bind_methods() { - ADD_SIGNAL(MethodInfo("name_changed")); ADD_SIGNAL(MethodInfo("edited_script_changed")); ADD_SIGNAL(MethodInfo("request_help", PropertyInfo(Variant::STRING, "topic"))); @@ -73,7 +72,6 @@ static bool _is_built_in_script(Script *p_script) { } class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache { - struct Cache { uint64_t time_loaded; RES cache; @@ -86,7 +84,6 @@ public: int max_cache_size; void cleanup() { - List<Map<String, Cache>::Element *> to_clean; Map<String, Cache>::Element *I = cached.front(); @@ -104,10 +101,8 @@ public: } virtual RES get_cached_resource(const String &p_path) { - Map<String, Cache>::Element *E = cached.find(p_path); if (!E) { - Cache c; c.cache = ResourceLoader::load(p_path); E = cached.insert(p_path, c); @@ -137,7 +132,6 @@ public: } EditorScriptCodeCompletionCache() { - max_cache_size = 128; max_time_cache = 5 * 60 * 1000; //minutes, five } @@ -146,7 +140,6 @@ public: }; void ScriptEditorQuickOpen::popup_dialog(const Vector<String> &p_functions, bool p_dontclear) { - popup_centered_ratio(0.6); if (p_dontclear) search_box->select_all(); @@ -158,34 +151,28 @@ void ScriptEditorQuickOpen::popup_dialog(const Vector<String> &p_functions, bool } void ScriptEditorQuickOpen::_text_changed(const String &p_newtext) { - _update_search(); } void ScriptEditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; if (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_PAGEUP || k->get_keycode() == KEY_PAGEDOWN)) { - search_options->call("_gui_input", k); search_box->accept_event(); } } void ScriptEditorQuickOpen::_update_search() { - search_options->clear(); TreeItem *root = search_options->create_item(); for (int i = 0; i < functions.size(); i++) { - String file = functions[i]; if ((search_box->get_text() == "" || file.findn(search_box->get_text()) != -1)) { - TreeItem *ti = search_options->create_item(root); ti->set_text(0, file); if (root->get_children() == ti) @@ -197,7 +184,6 @@ void ScriptEditorQuickOpen::_update_search() { } void ScriptEditorQuickOpen::_confirmed() { - TreeItem *ti = search_options->get_selected(); if (!ti) return; @@ -208,7 +194,6 @@ void ScriptEditorQuickOpen::_confirmed() { } void ScriptEditorQuickOpen::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); @@ -226,12 +211,10 @@ void ScriptEditorQuickOpen::_notification(int p_what) { } void ScriptEditorQuickOpen::_bind_methods() { - ADD_SIGNAL(MethodInfo("goto_line", PropertyInfo(Variant::INT, "line"))); } ScriptEditorQuickOpen::ScriptEditorQuickOpen() { - VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); search_box = memnew(LineEdit); @@ -257,24 +240,20 @@ ScriptEditor *ScriptEditor::script_editor = nullptr; /*** SCRIPT EDITOR ******/ String ScriptEditor::_get_debug_tooltip(const String &p_text, Node *_se) { - String val = EditorDebuggerNode::get_singleton()->get_var_value(p_text); if (val != String()) { return p_text + ": " + val; } else { - return String(); } } void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) { - if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { return; } for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) { continue; @@ -289,14 +268,12 @@ void ScriptEditor::_script_created(Ref<Script> p_script) { } void ScriptEditor::_goto_script_line2(int p_line) { - ScriptEditorBase *current = _get_current_editor(); if (current) current->goto_line(p_line); } void ScriptEditor::_goto_script_line(REF p_script, int p_line) { - Ref<Script> script = Object::cast_to<Script>(*p_script); if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { if (edit(p_script, p_line, 0)) { @@ -316,7 +293,6 @@ void ScriptEditor::_set_execution(REF p_script, int p_line) { Ref<Script> script = Object::cast_to<Script>(*p_script); if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -332,7 +308,6 @@ void ScriptEditor::_clear_execution(REF p_script) { Ref<Script> script = Object::cast_to<Script>(*p_script); if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -345,7 +320,6 @@ void ScriptEditor::_clear_execution(REF p_script) { } ScriptEditorBase *ScriptEditor::_get_current_editor() const { - int selected = tab_container->get_current_tab(); if (selected < 0 || selected >= tab_container->get_child_count()) return nullptr; @@ -354,23 +328,18 @@ ScriptEditorBase *ScriptEditor::_get_current_editor() const { } void ScriptEditor::_update_history_arrows() { - script_back->set_disabled(history_pos <= 0); script_forward->set_disabled(history_pos >= history.size() - 1); } void ScriptEditor::_save_history() { - if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) { - Node *n = tab_container->get_current_tab_control(); if (Object::cast_to<ScriptEditorBase>(n)) { - history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } } @@ -387,11 +356,9 @@ void ScriptEditor::_save_history() { } void ScriptEditor::_go_to_tab(int p_idx) { - ScriptEditorBase *current = _get_current_editor(); if (current) { if (current->is_unsaved()) { - current->apply_code(); } } @@ -401,15 +368,12 @@ void ScriptEditor::_go_to_tab(int p_idx) { return; if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) { - Node *n = tab_container->get_current_tab_control(); if (Object::cast_to<ScriptEditorBase>(n)) { - history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } } @@ -427,7 +391,6 @@ void ScriptEditor::_go_to_tab(int p_idx) { c = tab_container->get_current_tab_control(); 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_theme_icon()); if (is_visible_in_tree()) @@ -441,7 +404,6 @@ void ScriptEditor::_go_to_tab(int p_idx) { Object::cast_to<ScriptEditorBase>(c)->validate(); } if (Object::cast_to<EditorHelp>(c)) { - script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class()); script_icon->set_texture(get_theme_icon("Help", "EditorIcons")); if (is_visible_in_tree()) @@ -459,7 +421,6 @@ void ScriptEditor::_go_to_tab(int p_idx) { } void ScriptEditor::_add_recent_script(String p_path) { - if (p_path.empty()) { return; } @@ -478,13 +439,11 @@ void ScriptEditor::_add_recent_script(String p_path) { } void ScriptEditor::_update_recent_scripts() { - Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array()); recent_scripts->clear(); String path; for (int i = 0; i < rc.size(); i++) { - path = rc[i]; recent_scripts->add_item(path.replace("res://", "")); } @@ -496,7 +455,6 @@ void ScriptEditor::_update_recent_scripts() { } void ScriptEditor::_open_recent_script(int p_idx) { - // clear button if (p_idx == recent_scripts->get_item_count() - 1) { EditorSettings::get_singleton()->set_project_metadata("recent_files", "scripts", Array()); @@ -555,13 +513,11 @@ 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(); } void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { - int selected = p_idx; if (selected < 0 || selected >= tab_container->get_child_count()) return; @@ -609,7 +565,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { if (idx >= tab_container->get_child_count()) idx = tab_container->get_child_count() - 1; if (idx >= 0) { - if (history_pos >= 0) { idx = history[history_pos].control->get_index(); } @@ -627,7 +582,6 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { } void ScriptEditor::_close_current_tab() { - _close_tab(tab_container->get_current_tab()); } @@ -637,10 +591,8 @@ void ScriptEditor::_close_discard_current_tab(const String &p_str) { } void ScriptEditor::_close_docs_tab() { - int child_count = tab_container->get_child_count(); for (int i = child_count - 1; i >= 0; i--) { - EditorHelp *se = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (se) { @@ -656,11 +608,9 @@ void ScriptEditor::_copy_script_path() { } void ScriptEditor::_close_other_tabs() { - int child_count = tab_container->get_child_count(); int current_idx = tab_container->get_current_tab(); for (int i = child_count - 1; i >= 0; i--) { - if (i == current_idx) { continue; } @@ -669,7 +619,6 @@ void ScriptEditor::_close_other_tabs() { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - // Maybe there are unsaved changes if (se->is_unsaved()) { _ask_close_current_unsaved_tab(se); @@ -682,15 +631,12 @@ void ScriptEditor::_close_other_tabs() { } void ScriptEditor::_close_all_tabs() { - int child_count = tab_container->get_child_count(); for (int i = child_count - 1; i >= 0; i--) { - tab_container->set_current_tab(i); ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - // Maybe there are unsaved changes if (se->is_unsaved()) { _ask_close_current_unsaved_tab(se); @@ -708,11 +654,9 @@ void ScriptEditor::_ask_close_current_unsaved_tab(ScriptEditorBase *current) { } void ScriptEditor::_resave_scripts(const String &p_str) { - apply_scripts(); for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -751,19 +695,15 @@ void ScriptEditor::_resave_scripts(const String &p_str) { } void ScriptEditor::_reload_scripts() { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) { - continue; } RES edited_res = se->get_edited_resource(); if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) { - continue; //internal script, who cares } @@ -799,12 +739,9 @@ void ScriptEditor::_reload_scripts() { } void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) { - continue; } @@ -815,7 +752,6 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) { } if (script == p_res) { - se->tag_saved_version(); } } @@ -834,7 +770,6 @@ void ScriptEditor::_live_auto_reload_running_scripts() { } bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { - disk_changed_list->clear(); TreeItem *r = disk_changed_list->create_item(); disk_changed_list->set_hide_root(true); @@ -844,10 +779,8 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false)); for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - RES edited_res = se->get_edited_resource(); if (p_for_script.is_valid() && edited_res.is_valid() && p_for_script != edited_res) continue; @@ -859,7 +792,6 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { uint64_t date = FileAccess::get_modified_time(edited_res->get_path()); if (last_date != date) { - TreeItem *ti = disk_changed_list->create_item(r); ti->set_text(0, edited_res->get_path().get_file()); @@ -884,7 +816,6 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { } void ScriptEditor::_file_dialog_action(String p_file) { - switch (file_dialog_option) { case FILE_NEW_TEXTFILE: { Error err; @@ -899,7 +830,6 @@ void ScriptEditor::_file_dialog_action(String p_file) { [[fallthrough]]; } case FILE_OPEN: { - List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); if (extensions.find(p_file.get_extension())) { @@ -956,7 +886,6 @@ void ScriptEditor::_file_dialog_action(String p_file) { } Ref<Script> ScriptEditor::_get_current_script() { - ScriptEditorBase *current = _get_current_editor(); if (current) { @@ -968,7 +897,6 @@ Ref<Script> ScriptEditor::_get_current_script() { } Array ScriptEditor::_get_open_scripts() const { - Array ret; Vector<Ref<Script>> scripts = get_open_scripts(); int scrits_amount = scripts.size(); @@ -988,7 +916,6 @@ bool ScriptEditor::is_scripts_panel_toggled() { } void ScriptEditor::_menu_option(int p_option) { - ScriptEditorBase *current = _get_current_editor(); switch (p_option) { case FILE_NEW: { @@ -1021,7 +948,6 @@ void ScriptEditor::_menu_option(int p_option) { return; } break; case FILE_REOPEN_CLOSED: { - if (previous_scripts.empty()) return; @@ -1071,34 +997,27 @@ void ScriptEditor::_menu_option(int p_option) { } } break; case FILE_SAVE_ALL: { - if (_test_script_times_on_disk()) return; save_all_scripts(); } break; case SEARCH_IN_FILES: { - _on_find_in_files_requested(""); } break; case REPLACE_IN_FILES: { - _on_replace_in_files_requested(""); } break; case SEARCH_HELP: { - help_search_dialog->popup_dialog(); } break; case SEARCH_WEBSITE: { - OS::get_singleton()->shell_open("https://docs.godotengine.org/"); } break; case WINDOW_NEXT: { - _history_forward(); } break; case WINDOW_PREV: { - _history_back(); } break; case WINDOW_SORT: { @@ -1119,10 +1038,8 @@ void ScriptEditor::_menu_option(int p_option) { } if (current) { - switch (p_option) { case FILE_SAVE: { - if (_test_script_times_on_disk()) return; @@ -1149,7 +1066,6 @@ void ScriptEditor::_menu_option(int p_option) { } break; case FILE_SAVE_AS: { - if (trim_trailing_whitespace_on_save) current->trim_trailing_whitespace(); @@ -1186,12 +1102,10 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_TOOL_RELOAD: case FILE_TOOL_RELOAD_SOFT: { - current->reload(p_option == FILE_TOOL_RELOAD_SOFT); } break; case FILE_RUN: { - Ref<Script> scr = current->get_edited_resource(); if (scr == nullptr || scr.is_null()) { EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running.")); @@ -1206,13 +1120,11 @@ void ScriptEditor::_menu_option(int p_option) { return; } if (!scr->is_tool()) { - EditorNode::get_singleton()->show_warning(TTR("Script is not in tool mode, will not be able to run.")); return; } if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) { - EditorNode::get_singleton()->show_warning(TTR("To run this script, it must inherit EditorScript and be set to tool mode.")); return; } @@ -1256,7 +1168,6 @@ void ScriptEditor::_menu_option(int p_option) { _close_all_tabs(); } break; case WINDOW_MOVE_UP: { - if (tab_container->get_current_tab() > 0) { tab_container->move_child(current, tab_container->get_current_tab() - 1); tab_container->set_current_tab(tab_container->get_current_tab() - 1); @@ -1264,7 +1175,6 @@ void ScriptEditor::_menu_option(int p_option) { } } break; case WINDOW_MOVE_DOWN: { - if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) { tab_container->move_child(current, tab_container->get_current_tab() + 1); tab_container->set_current_tab(tab_container->get_current_tab() + 1); @@ -1272,19 +1182,15 @@ void ScriptEditor::_menu_option(int p_option) { } } break; default: { - if (p_option >= WINDOW_SELECT_BASE) { - tab_container->set_current_tab(p_option - WINDOW_SELECT_BASE); _update_script_names(); } } } } else { - EditorHelp *help = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control()); if (help) { - switch (p_option) { case HELP_SEARCH_FIND: { help->popup_search(); @@ -1308,7 +1214,6 @@ void ScriptEditor::_menu_option(int p_option) { _close_all_tabs(); } break; case WINDOW_MOVE_UP: { - if (tab_container->get_current_tab() > 0) { tab_container->move_child(help, tab_container->get_current_tab() - 1); tab_container->set_current_tab(tab_container->get_current_tab() - 1); @@ -1316,7 +1221,6 @@ void ScriptEditor::_menu_option(int p_option) { } } break; case WINDOW_MOVE_DOWN: { - if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) { tab_container->move_child(help, tab_container->get_current_tab() + 1); tab_container->set_current_tab(tab_container->get_current_tab() + 1); @@ -1367,16 +1271,12 @@ void ScriptEditor::_show_save_theme_as_dialog() { } void ScriptEditor::_tab_changed(int p_which) { - ensure_select_current(); } void ScriptEditor::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - editor->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); editor->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback)); editor->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback)); @@ -1390,7 +1290,6 @@ void ScriptEditor::_notification(int p_what) { [[fallthrough]]; } case NOTIFICATION_THEME_CHANGED: { - help_search->set_icon(get_theme_icon("HelpSearch", "EditorIcons")); site_search->set_icon(get_theme_icon("Instance", "EditorIcons")); @@ -1408,25 +1307,21 @@ void ScriptEditor::_notification(int p_what) { } break; case NOTIFICATION_READY: { - get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); editor->get_inspector_dock()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); editor->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); } break; case NOTIFICATION_EXIT_TREE: { - editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); } break; case NOTIFICATION_WM_FOCUS_IN: { - _test_script_times_on_disk(); _update_modified_scripts_for_external_editor(); } break; case CanvasItem::NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible()) { find_in_files_button->show(); } else { @@ -1444,7 +1339,6 @@ void ScriptEditor::_notification(int p_what) { } bool ScriptEditor::can_take_away_focus() const { - ScriptEditorBase *current = _get_current_editor(); if (current) return current->can_lose_focus_on_node_selection(); @@ -1453,13 +1347,10 @@ bool ScriptEditor::can_take_away_focus() const { } void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - Ref<Script> script = se->get_edited_resource(); if (script == nullptr || !script.is_valid()) continue; @@ -1473,7 +1364,6 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { } void ScriptEditor::edited_scene_changed() { - _update_modified_scripts_for_external_editor(); } @@ -1486,9 +1376,7 @@ void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { } void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -1504,14 +1392,12 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { ERR_CONTINUE(base.begins_with("local://") || base == ""); for (List<int>::Element *E = bpoints.front(); E; E = E->next()) { - p_breakpoints->push_back(base + ":" + itos(E->get() + 1)); } } } void ScriptEditor::ensure_focus_current() { - if (!is_inside_tree()) return; @@ -1544,7 +1430,6 @@ 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 _go_to_tab(script_list->get_item_metadata(p_idx)); @@ -1552,12 +1437,9 @@ void ScriptEditor::_script_selected(int p_idx) { } void ScriptEditor::ensure_select_current() { - if (tab_container->get_child_count() && tab_container->get_current_tab() >= 0) { - ScriptEditorBase *se = _get_current_editor(); if (se) { - if (!grab_focus_block && is_visible_in_tree()) se->ensure_focus(); } @@ -1582,7 +1464,6 @@ void ScriptEditor::_find_scripts(Node *p_base, Node *p_current, Set<Ref<Script>> } struct _ScriptEditorItemData { - String name; String sort_key; Ref<Texture2D> icon; @@ -1593,7 +1474,6 @@ struct _ScriptEditorItemData { Node *ref; bool operator<(const _ScriptEditorItemData &id) const { - if (category == id.category) { if (sort_key == id.sort_key) { return index < id.index; @@ -1607,7 +1487,6 @@ struct _ScriptEditorItemData { }; void ScriptEditor::_update_members_overview_visibility() { - ScriptEditorBase *se = _get_current_editor(); if (!se) { members_overview_alphabeta_sort_button->set_visible(false); @@ -1661,7 +1540,6 @@ void ScriptEditor::_update_members_overview() { } void ScriptEditor::_update_help_overview_visibility() { - int selected = tab_container->get_current_tab(); if (selected < 0 || selected >= tab_container->get_child_count()) { help_overview->set_visible(false); @@ -1707,7 +1585,6 @@ void ScriptEditor::_update_help_overview() { } void ScriptEditor::_update_script_colors() { - bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled"); bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script"); @@ -1716,7 +1593,6 @@ void ScriptEditor::_update_script_colors() { Color cold_color = get_theme_color("font_color", "Editor"); for (int i = 0; i < script_list->get_item_count(); i++) { - int c = script_list->get_item_metadata(i); Node *n = tab_container->get_child(c); if (!n) @@ -1729,7 +1605,6 @@ void ScriptEditor::_update_script_colors() { script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/script_list/current_script_background_color")); } else if (script_temperature_enabled) { - if (!n->has_meta("__editor_pass")) { continue; } @@ -1748,7 +1623,6 @@ void ScriptEditor::_update_script_colors() { } void ScriptEditor::_update_script_names() { - if (restoring_layout) return; @@ -1766,17 +1640,14 @@ void ScriptEditor::_update_script_names() { Vector<_ScriptEditorItemData> sedata; for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - Ref<Texture2D> icon = se->get_theme_icon(); String path = se->get_edited_resource()->get_path(); bool built_in = !path.is_resource_file(); String name; if (built_in) { - name = path.get_file(); const String &resource_name = se->get_edited_resource()->get_name(); if (resource_name != "") { @@ -1785,7 +1656,6 @@ void ScriptEditor::_update_script_names() { name = vformat("%s (%s)", resource_name, name.substr(0, name.find("::", 0))); } } else { - name = se->get_name(); } @@ -1831,7 +1701,6 @@ void ScriptEditor::_update_script_names() { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh) { - String name = eh->get_class(); Ref<Texture2D> icon = get_theme_icon("Help", "EditorIcons"); String tooltip = vformat(TTR("%s Class Reference"), name); @@ -1978,7 +1847,6 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p } bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus) { - if (p_resource.is_null()) return false; @@ -2005,7 +1873,6 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra p_resource->get_path().is_resource_file() && p_resource->get_class_name() != StringName("VisualScript") && bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) { - String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path"); String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); @@ -2025,16 +1892,13 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra bool inside_quotes = false; for (int i = 0; i < flags.size(); i++) { - if (flags[i] == '"' && (!i || flags[i - 1] != '\\')) { - if (!inside_quotes) { from++; } inside_quotes = !inside_quotes; } else if (flags[i] == '\0' || (!inside_quotes && flags[i] == ' ')) { - String arg = flags.substr(from, num_chars); if (arg.find("{file}") != -1) { has_file_flag = true; @@ -2065,13 +1929,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra } for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; 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) { _go_to_tab(i); @@ -2157,9 +2019,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra } void ScriptEditor::save_all_scripts() { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -2201,9 +2061,7 @@ void ScriptEditor::save_all_scripts() { } void ScriptEditor::apply_scripts() const { - for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -2218,10 +2076,8 @@ void ScriptEditor::open_script_create_dialog(const String &p_base_name, const St void ScriptEditor::_editor_stop() { for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) { - continue; } @@ -2230,7 +2086,6 @@ void ScriptEditor::_editor_stop() { } void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args) { - ERR_FAIL_COND(!p_obj); Ref<Script> script = p_obj->get_script(); ERR_FAIL_COND(!script.is_valid()); @@ -2238,7 +2093,6 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const editor->push_item(script.ptr()); for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -2256,7 +2110,6 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const } void ScriptEditor::_save_layout() { - if (restoring_layout) { return; } @@ -2265,7 +2118,6 @@ void ScriptEditor::_save_layout() { } void ScriptEditor::_editor_settings_changed() { - trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/files/trim_trailing_whitespace_on_save"); convert_indent_on_save = EditorSettings::get_singleton()->get("text_editor/indent/convert_indent_on_save"); use_space_indentation = EditorSettings::get_singleton()->get("text_editor/indent/type"); @@ -2285,7 +2137,6 @@ void ScriptEditor::_editor_settings_changed() { } for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (!se) continue; @@ -2299,12 +2150,10 @@ void ScriptEditor::_editor_settings_changed() { } void ScriptEditor::_autosave_scripts() { - save_all_scripts(); } void ScriptEditor::_update_autosave_timer() { - if (!autosave_timer->is_inside_tree()) { return; } @@ -2319,7 +2168,6 @@ void ScriptEditor::_update_autosave_timer() { } void ScriptEditor::_tree_changed() { - if (waiting_update_names) return; @@ -2329,12 +2177,10 @@ void ScriptEditor::_tree_changed() { } void ScriptEditor::_script_split_dragged(float) { - _save_layout(); } Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - if (tab_container->get_child_count() == 0) return Variant(); @@ -2372,13 +2218,11 @@ Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { } bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type")) return false; if (String(d["type"]) == "script_list_element") { - Node *node = d["script_list_element"]; ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); @@ -2392,7 +2236,6 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data } if (String(d["type"]) == "nodes") { - Array nodes = d["nodes"]; if (nodes.size() == 0) return false; @@ -2409,7 +2252,6 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; if (files.size() == 0) @@ -2431,7 +2273,6 @@ bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data } void ScriptEditor::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; @@ -2440,7 +2281,6 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co return; if (String(d["type"]) == "script_list_element") { - Node *node = d["script_list_element"]; ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); @@ -2457,7 +2297,6 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co } if (String(d["type"]) == "nodes") { - Array nodes = d["nodes"]; if (nodes.size() == 0) return; @@ -2477,7 +2316,6 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; int new_index = 0; @@ -2533,11 +2371,9 @@ void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) { } void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) { - Ref<InputEventMouseButton> mb = ev; if (mb.is_valid() && mb->is_pressed()) { switch (mb->get_button_index()) { - case BUTTON_MIDDLE: { // Right-click selects automatically; middle-click does not. int idx = script_list->get_item_at_position(mb->get_position(), true); @@ -2556,7 +2392,6 @@ void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) { } void ScriptEditor::_make_script_list_context_menu() { - context_menu->clear(); int selected = tab_container->get_current_tab(); @@ -2597,7 +2432,6 @@ void ScriptEditor::_make_script_list_context_menu() { } void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { - if (!bool(EDITOR_DEF("text_editor/files/restore_scripts_on_load", true))) { return; } @@ -2616,7 +2450,6 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { ResourceLoader::get_recognized_extensions_for_type("Script", &extensions); for (int i = 0; i < scripts.size(); i++) { - String path = scripts[i]; Dictionary script_info = scripts[i]; @@ -2655,7 +2488,6 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } for (int i = 0; i < helps.size(); i++) { - String path = helps[i]; if (path == "") { // invalid, skip continue; @@ -2677,15 +2509,12 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { - Array scripts; Array helps; for (int i = 0; i < tab_container->get_child_count(); i++) { - ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se) { - String path = se->get_edited_resource()->get_path(); if (!path.is_resource_file()) continue; @@ -2700,7 +2529,6 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh) { - helps.push_back(eh->get_class()); } } @@ -2711,16 +2539,13 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { } void ScriptEditor::_help_class_open(const String &p_class) { - if (p_class == "") return; for (int i = 0; i < tab_container->get_child_count(); i++) { - EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh && eh->get_class() == p_class) { - _go_to_tab(i); _update_script_names(); return; @@ -2741,15 +2566,12 @@ void ScriptEditor::_help_class_open(const String &p_class) { } void ScriptEditor::_help_class_goto(const String &p_desc) { - String cname = p_desc.get_slice(":", 1); for (int i = 0; i < tab_container->get_child_count(); i++) { - EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i)); if (eh && eh->get_class() == cname) { - _go_to_tab(i); eh->go_to_help(p_desc); _update_script_names(); @@ -2771,14 +2593,11 @@ void ScriptEditor::_help_class_goto(const String &p_desc) { } void ScriptEditor::_update_selected_editor_menu() { - for (int i = 0; i < tab_container->get_child_count(); i++) { - bool current = tab_container->get_current_tab() == i; ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); if (se && se->get_edit_menu()) { - if (current) se->get_edit_menu()->show(); else @@ -2789,7 +2608,6 @@ void ScriptEditor::_update_selected_editor_menu() { EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_current_tab_control()); script_search_menu->get_popup()->clear(); if (eh) { - script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find..."), KEY_MASK_CMD | KEY_F), HELP_SEARCH_FIND); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), HELP_SEARCH_FIND_NEXT); script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), HELP_SEARCH_FIND_PREVIOUS); @@ -2797,7 +2615,6 @@ void ScriptEditor::_update_selected_editor_menu() { script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES); script_search_menu->show(); } else { - if (tab_container->get_child_count() == 0) { script_search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_in_files", TTR("Find in Files"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F), SEARCH_IN_FILES); script_search_menu->show(); @@ -2808,15 +2625,12 @@ void ScriptEditor::_update_selected_editor_menu() { } void ScriptEditor::_update_history_pos(int p_new_pos) { - Node *n = tab_container->get_current_tab_control(); if (Object::cast_to<ScriptEditorBase>(n)) { - history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_edit_state(); } if (Object::cast_to<EditorHelp>(n)) { - history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll(); } @@ -2826,7 +2640,6 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { n = history[history_pos].control; if (Object::cast_to<ScriptEditorBase>(n)) { - Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state); Object::cast_to<ScriptEditorBase>(n)->ensure_focus(); @@ -2837,7 +2650,6 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { } if (Object::cast_to<EditorHelp>(n)) { - Object::cast_to<EditorHelp>(n)->set_scroll(history[history_pos].state); Object::cast_to<EditorHelp>(n)->set_focused(); } @@ -2849,21 +2661,18 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { } void ScriptEditor::_history_forward() { - if (history_pos < history.size() - 1) { _update_history_pos(history_pos + 1); } } void ScriptEditor::_history_back() { - if (history_pos > 0) { _update_history_pos(history_pos - 1); } } Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { - Vector<Ref<Script>> out_scripts = Vector<Ref<Script>>(); for (int i = 0; i < tab_container->get_child_count(); i++) { @@ -2881,7 +2690,6 @@ Vector<Ref<Script>> ScriptEditor::get_open_scripts() const { } void ScriptEditor::set_scene_root_script(Ref<Script> p_script) { - bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change"); if (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) @@ -2893,7 +2701,6 @@ void ScriptEditor::set_scene_root_script(Ref<Script> p_script) { } bool ScriptEditor::script_goto_method(Ref<Script> p_script, const String &p_method) { - int line = p_script->get_member_line(p_method); if (line == -1) @@ -2903,7 +2710,6 @@ bool ScriptEditor::script_goto_method(Ref<Script> p_script, const String &p_meth } void ScriptEditor::set_live_auto_reload_running_scripts(bool p_enabled) { - auto_reload_running_scripts = p_enabled; } @@ -2912,7 +2718,6 @@ void ScriptEditor::_help_search(String p_text) { } void ScriptEditor::_open_script_request(const String &p_path) { - Ref<Script> script = ResourceLoader::load(p_path); if (script.is_valid()) { script_editor->edit(script, false); @@ -2939,25 +2744,21 @@ int ScriptEditor::script_editor_func_count = 0; CreateScriptEditorFunc ScriptEditor::script_editor_funcs[ScriptEditor::SCRIPT_EDITOR_FUNC_MAX]; void ScriptEditor::register_create_script_editor_function(CreateScriptEditorFunc p_func) { - ERR_FAIL_COND(script_editor_func_count == SCRIPT_EDITOR_FUNC_MAX); script_editor_funcs[script_editor_func_count++] = p_func; } void ScriptEditor::_script_changed() { - NodeDock::singleton->update_lists(); } 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(); } 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(""); @@ -2965,7 +2766,6 @@ void ScriptEditor::_on_replace_in_files_requested(String text) { } void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) { - if (ResourceLoader::exists(fpath)) { RES res = ResourceLoader::load(fpath); @@ -3003,7 +2803,6 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb } void ScriptEditor::_start_find_in_files(bool with_replace) { - FindInFiles *f = find_in_files->get_finder(); f->set_search_text(find_in_files_dialog->get_search_text()); @@ -3020,7 +2819,6 @@ void ScriptEditor::_start_find_in_files(bool with_replace) { } void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) { - _test_script_times_on_disk(); _update_modified_scripts_for_external_editor(); } @@ -3034,7 +2832,6 @@ void ScriptEditor::_filter_methods_text_changed(const String &p_newtext) { } void ScriptEditor::_bind_methods() { - ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); ClassDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs); @@ -3063,7 +2860,6 @@ void ScriptEditor::_bind_methods() { } ScriptEditor::ScriptEditor(EditorNode *p_editor) { - current_theme = ""; completion_cache = memnew(EditorScriptCodeCompletionCache); @@ -3364,14 +3160,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { } ScriptEditor::~ScriptEditor() { - memdelete(completion_cache); } void ScriptEditorPlugin::edit(Object *p_object) { - if (Object::cast_to<Script>(p_object)) { - Script *p_script = Object::cast_to<Script>(p_object); String res_path = p_script->get_path().get_slice("::", 0); @@ -3391,7 +3184,6 @@ void ScriptEditorPlugin::edit(Object *p_object) { } bool ScriptEditorPlugin::handles(Object *p_object) const { - if (Object::cast_to<TextFile>(p_object)) { return true; } @@ -3404,30 +3196,25 @@ bool ScriptEditorPlugin::handles(Object *p_object) const { } void ScriptEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { script_editor->show(); script_editor->set_process(true); script_editor->ensure_select_current(); } else { - script_editor->hide(); script_editor->set_process(false); } } void ScriptEditorPlugin::selected_notify() { - script_editor->ensure_select_current(); } void ScriptEditorPlugin::save_external_data() { - script_editor->save_all_scripts(); } void ScriptEditorPlugin::apply_changes() { - script_editor->apply_scripts(); } @@ -3438,27 +3225,22 @@ void ScriptEditorPlugin::save_global_state() { } void ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { - script_editor->set_window_layout(p_layout); } void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) { - script_editor->get_window_layout(p_layout); } void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) { - script_editor->get_breakpoints(p_breakpoints); } void ScriptEditorPlugin::edited_scene_changed() { - script_editor->edited_scene_changed(); } ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { - editor = p_node; script_editor = memnew(ScriptEditor(p_node)); editor->get_viewport()->add_child(script_editor); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index e895867268..f7352be7e8 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -49,7 +49,6 @@ #include "scene/resources/text_file.h" class ScriptEditorQuickOpen : public ConfirmationDialog { - GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog); LineEdit *search_box; @@ -76,7 +75,6 @@ public: class EditorDebuggerNode; class ScriptEditorBase : public VBoxContainer { - GDCLASS(ScriptEditorBase, VBoxContainer); protected: @@ -131,7 +129,6 @@ class FindInFilesDialog; class FindInFilesPanel; class ScriptEditor : public PanelContainer { - GDCLASS(ScriptEditor, PanelContainer); EditorNode *editor; @@ -250,7 +247,6 @@ class ScriptEditor : public PanelContainer { static CreateSyntaxHighlighterFunc syntax_highlighters_funcs[SYNTAX_HIGHLIGHTER_FUNC_MAX]; struct ScriptHistory { - Control *control; Variant state; }; @@ -454,7 +450,6 @@ public: }; class ScriptEditorPlugin : public EditorPlugin { - GDCLASS(ScriptEditorPlugin, EditorPlugin); ScriptEditor *script_editor; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 109d83d838..1f916fb3ba 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -109,7 +109,6 @@ ConnectionInfoDialog::ConnectionInfoDialog() { //////////////////////////////////////////////////////////////////////////////// Vector<String> ScriptTextEditor::get_functions() { - String errortxt; int line = -1, col; TextEdit *te = code_editor->get_text_edit(); @@ -117,11 +116,9 @@ Vector<String> ScriptTextEditor::get_functions() { List<String> fnc; if (script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) { - //if valid rewrite functions to latest functions.clear(); for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); } } @@ -130,7 +127,6 @@ Vector<String> ScriptTextEditor::get_functions() { } void ScriptTextEditor::apply_code() { - if (script.is_null()) return; script->set_source_code(code_editor->get_text_edit()->get_text()); @@ -184,13 +180,11 @@ void ScriptTextEditor::_update_member_keywords() { ClassDB::get_integer_constant_list(instance_base, &clist); for (List<String>::Element *E = clist.front(); E; E = E->next()) { - code_editor->get_text_edit()->add_member_keyword(E->get(), member_variable_color); } } void ScriptTextEditor::_load_theme_settings() { - TextEdit *text_edit = code_editor->get_text_edit(); text_edit->clear_colors(); @@ -275,7 +269,6 @@ void ScriptTextEditor::_load_theme_settings() { } void ScriptTextEditor::_set_theme_for_script() { - if (!theme_loaded) return; @@ -285,7 +278,6 @@ void ScriptTextEditor::_set_theme_for_script() { script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - text_edit->add_keyword_color(E->get(), colors_cache.keyword_color); } @@ -327,7 +319,6 @@ void ScriptTextEditor::_set_theme_for_script() { ClassDB::get_class_list(&types); for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - String n = E->get(); if (n.begins_with("_")) n = n.substr(1, n.length()); @@ -341,7 +332,6 @@ void ScriptTextEditor::_set_theme_for_script() { ScriptServer::get_global_class_list(&global_classes); for (List<StringName>::Element *E = global_classes.front(); E; E = E->next()) { - text_edit->add_keyword_color(E->get(), colors_cache.usertype_color); } @@ -364,7 +354,6 @@ void ScriptTextEditor::_set_theme_for_script() { script->get_language()->get_comment_delimiters(&comments); for (List<String>::Element *E = comments.front(); E; E = E->next()) { - String comment = E->get(); String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); @@ -376,7 +365,6 @@ void ScriptTextEditor::_set_theme_for_script() { List<String> strings; script->get_language()->get_string_delimiters(&strings); for (List<String>::Element *E = strings.front(); E; E = E->next()) { - String string = E->get(); String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); @@ -403,7 +391,6 @@ void ScriptTextEditor::_warning_clicked(Variant p_line) { } void ScriptTextEditor::reload_text() { - ERR_FAIL_COND(script.is_null()); TextEdit *te = code_editor->get_text_edit(); @@ -424,7 +411,6 @@ void ScriptTextEditor::reload_text() { } void ScriptTextEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: _load_theme_settings(); @@ -433,7 +419,6 @@ void ScriptTextEditor::_notification(int p_what) { } void ScriptTextEditor::add_callback(const String &p_function, PackedStringArray p_args) { - String code = code_editor->get_text_edit()->get_text(); int pos = script->get_language()->find_function(p_function, code); if (pos == -1) { @@ -455,22 +440,18 @@ bool ScriptTextEditor::show_members_overview() { } void ScriptTextEditor::update_settings() { - code_editor->update_editor_settings(); } bool ScriptTextEditor::is_unsaved() { - return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version(); } Variant ScriptTextEditor::get_edit_state() { - return code_editor->get_edit_state(); } void ScriptTextEditor::set_edit_state(const Variant &p_state) { - code_editor->set_edit_state(p_state); Dictionary state = p_state; @@ -483,47 +464,38 @@ void ScriptTextEditor::set_edit_state(const Variant &p_state) { } void ScriptTextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) { - code_editor->convert_case(p_case); } void ScriptTextEditor::trim_trailing_whitespace() { - code_editor->trim_trailing_whitespace(); } void ScriptTextEditor::insert_final_newline() { - code_editor->insert_final_newline(); } void ScriptTextEditor::convert_indent_to_spaces() { - code_editor->convert_indent_to_spaces(); } void ScriptTextEditor::convert_indent_to_tabs() { - code_editor->convert_indent_to_tabs(); } void ScriptTextEditor::tag_saved_version() { - code_editor->get_text_edit()->tag_saved_version(); } void ScriptTextEditor::goto_line(int p_line, bool p_with_error) { - code_editor->goto_line(p_line); } void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { - code_editor->goto_line_selection(p_line, p_begin, p_end); } void ScriptTextEditor::goto_line_centered(int p_line) { - code_editor->goto_line_centered(p_line); } @@ -536,7 +508,6 @@ void ScriptTextEditor::clear_executing_line() { } void ScriptTextEditor::ensure_focus() { - code_editor->get_text_edit()->grab_focus(); } @@ -557,7 +528,6 @@ String ScriptTextEditor::get_name() { } Ref<Texture2D> ScriptTextEditor::get_theme_icon() { - 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"); } @@ -566,7 +536,6 @@ Ref<Texture2D> ScriptTextEditor::get_theme_icon() { } void ScriptTextEditor::_validate_script() { - String errortxt; int line = -1, col; TextEdit *te = code_editor->get_text_edit(); @@ -592,7 +561,6 @@ void ScriptTextEditor::_validate_script() { functions.clear(); for (List<String>::Element *E = fnc.front(); E; E = E->next()) { - functions.push_back(E->get()); } script_is_valid = true; @@ -682,7 +650,6 @@ void ScriptTextEditor::_validate_script() { } void ScriptTextEditor::_update_bookmark_list() { - bookmarks_menu->clear(); bookmarks_menu->set_size(Size2(1, 1)); @@ -714,7 +681,6 @@ void ScriptTextEditor::_update_bookmark_list() { } void ScriptTextEditor::_bookmark_item_pressed(int p_idx) { - if (p_idx < 4) { // Any item before the separator. _edit_option(bookmarks_menu->get_item_id(p_idx)); } else { @@ -724,7 +690,6 @@ void ScriptTextEditor::_bookmark_item_pressed(int p_idx) { } static Vector<Node *> _find_all_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) { - Vector<Node *> nodes; if (p_current->get_owner() != p_base && p_base != p_current) { @@ -745,7 +710,6 @@ 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 nullptr; Ref<Script> c = p_current->get_script(); @@ -761,7 +725,6 @@ static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Scri } 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; Ref<Script> c = p_current->get_script(); @@ -775,7 +738,6 @@ static void _find_changed_scripts_for_external_editor(Node *p_base, Node *p_curr } void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_for_script) { - if (!bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) return; @@ -789,14 +751,12 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } for (Set<Ref<Script>>::Element *E = scripts.front(); E; E = E->next()) { - Ref<Script> script = E->get(); if (p_for_script.is_valid() && p_for_script != script) continue; if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) { - continue; //internal script, who cares, though weird } @@ -804,7 +764,6 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo uint64_t date = FileAccess::get_modified_time(script->get_path()); if (last_date != date) { - 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()); @@ -815,13 +774,11 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) { - ScriptTextEditor *ste = (ScriptTextEditor *)p_ud; ste->_code_complete_script(p_code, r_options, r_force); } void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options, bool &r_force) { - if (color_panel->is_visible()) return; Node *base = get_tree()->get_edited_scene_root(); @@ -836,7 +793,6 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptCo } void ScriptTextEditor::_update_breakpoint_list() { - breakpoints_menu->clear(); breakpoints_menu->set_size(Size2(1, 1)); @@ -868,7 +824,6 @@ void ScriptTextEditor::_update_breakpoint_list() { } void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) { - if (p_idx < 4) { // Any item before the separator. _edit_option(breakpoints_menu->get_item_id(p_idx)); } else { @@ -878,12 +833,10 @@ void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) { } void ScriptTextEditor::_breakpoint_toggled(int p_row) { - EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row)); } void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) { - Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base, base, script); @@ -903,14 +856,12 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } } else if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK) { - _goto_line(p_row); result.class_name = result.class_name.trim_prefix("_"); switch (result.type) { case ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION: { - if (result.script.is_valid()) { emit_signal("request_open_script_at_line", result.script, result.location - 1); } else { @@ -922,7 +873,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal("go_to_help", "class_name:" + result.class_name); } break; case ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT: { - StringName cname = result.class_name; bool success; while (true) { @@ -943,7 +893,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } break; case ScriptLanguage::LookupResult::RESULT_CLASS_METHOD: { - StringName cname = result.class_name; while (true) { @@ -959,7 +908,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } break; case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: { - StringName cname = result.class_name; StringName success; while (true) { @@ -1003,7 +951,6 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c } void ScriptTextEditor::_validate_symbol(const String &p_symbol) { - TextEdit *text_edit = code_editor->get_text_edit(); Node *base = get_tree()->get_edited_scene_root(); @@ -1015,7 +962,6 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) { if (ScriptServer::is_global_class(p_symbol) || p_symbol.is_resource_file() || script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), p_symbol, script->get_path(), base, result) == OK || ProjectSettings::get_singleton()->has_setting("autoload/" + p_symbol)) { text_edit->set_highlighted_word(p_symbol); } else if (p_symbol.is_rel_path()) { - String path = _get_absolute_path(p_symbol); if (FileAccess::exists(path)) { text_edit->set_highlighted_word(p_symbol); @@ -1124,50 +1070,40 @@ void ScriptTextEditor::_lookup_connections(int p_row, String p_method) { } void ScriptTextEditor::_edit_option(int p_op) { - TextEdit *tx = code_editor->get_text_edit(); switch (p_op) { case EDIT_UNDO: { - tx->undo(); tx->call_deferred("grab_focus"); } break; case EDIT_REDO: { - tx->redo(); tx->call_deferred("grab_focus"); } break; case EDIT_CUT: { - tx->cut(); tx->call_deferred("grab_focus"); } break; case EDIT_COPY: { - tx->copy(); tx->call_deferred("grab_focus"); } break; case EDIT_PASTE: { - tx->paste(); tx->call_deferred("grab_focus"); } break; case EDIT_SELECT_ALL: { - tx->select_all(); tx->call_deferred("grab_focus"); } break; case EDIT_MOVE_LINE_UP: { - code_editor->move_lines_up(); } break; case EDIT_MOVE_LINE_DOWN: { - code_editor->move_lines_down(); } break; case EDIT_INDENT_LEFT: { - Ref<Script> scr = script; if (scr.is_null()) return; @@ -1175,7 +1111,6 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->indent_left(); } break; case EDIT_INDENT_RIGHT: { - Ref<Script> scr = script; if (scr.is_null()) return; @@ -1183,38 +1118,30 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->indent_right(); } break; case EDIT_DELETE_LINE: { - code_editor->delete_lines(); } break; case EDIT_CLONE_DOWN: { - code_editor->clone_lines_down(); } break; case EDIT_TOGGLE_FOLD_LINE: { - tx->toggle_fold_line(tx->cursor_get_line()); tx->update(); } break; case EDIT_FOLD_ALL_LINES: { - tx->fold_all_lines(); tx->update(); } break; case EDIT_UNFOLD_ALL_LINES: { - tx->unhide_all_lines(); tx->update(); } break; case EDIT_TOGGLE_COMMENT: { - _edit_option_toggle_inline_comment(); } break; case EDIT_COMPLETE: { - tx->query_code_comple(); } break; case EDIT_AUTO_INDENT: { - String text = tx->get_text(); Ref<Script> scr = script; if (scr.is_null()) @@ -1242,35 +1169,27 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { - trim_trailing_whitespace(); } break; case EDIT_CONVERT_INDENT_TO_SPACES: { - convert_indent_to_spaces(); } break; case EDIT_CONVERT_INDENT_TO_TABS: { - convert_indent_to_tabs(); } break; case EDIT_PICK_COLOR: { - color_panel->popup(); } break; case EDIT_TO_UPPERCASE: { - _convert_case(CodeTextEditor::UPPER); } break; case EDIT_TO_LOWERCASE: { - _convert_case(CodeTextEditor::LOWER); } break; case EDIT_CAPITALIZE: { - _convert_case(CodeTextEditor::CAPITALIZE); } break; case EDIT_EVALUATE: { - Expression expression; Vector<String> lines = code_editor->get_text_edit()->get_selection_text().split("\n"); PackedStringArray results; @@ -1296,23 +1215,18 @@ void ScriptTextEditor::_edit_option(int p_op) { code_editor->get_text_edit()->end_complex_operation(); } break; case SEARCH_FIND: { - code_editor->get_find_replace_bar()->popup_search(); } break; case SEARCH_FIND_NEXT: { - code_editor->get_find_replace_bar()->search_next(); } break; case SEARCH_FIND_PREV: { - code_editor->get_find_replace_bar()->search_prev(); } break; case SEARCH_REPLACE: { - code_editor->get_find_replace_bar()->popup_replace(); } break; case SEARCH_IN_FILES: { - String selected_text = code_editor->get_text_edit()->get_selection_text(); // Yep, because it doesn't make sense to instance this dialog for every single script open... @@ -1320,45 +1234,36 @@ void ScriptTextEditor::_edit_option(int p_op) { emit_signal("search_in_files_requested", selected_text); } break; case REPLACE_IN_FILES: { - String selected_text = code_editor->get_text_edit()->get_selection_text(); emit_signal("replace_in_files_requested", selected_text); } break; case SEARCH_LOCATE_FUNCTION: { - quick_open->popup_dialog(get_functions()); quick_open->set_title(TTR("Go to Function")); } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(tx); } break; case BOOKMARK_TOGGLE: { - code_editor->toggle_bookmark(); } break; case BOOKMARK_GOTO_NEXT: { - code_editor->goto_next_bookmark(); } break; case BOOKMARK_GOTO_PREV: { - code_editor->goto_prev_bookmark(); } break; case BOOKMARK_REMOVE_ALL: { - code_editor->remove_all_bookmarks(); } break; case DEBUG_TOGGLE_BREAKPOINT: { - int line = tx->cursor_get_line(); bool dobreak = !tx->is_line_set_as_breakpoint(line); tx->set_line_as_breakpoint(line, dobreak); EditorDebuggerNode::get_singleton()->set_breakpoint(script->get_path(), line + 1, dobreak); } break; case DEBUG_REMOVE_ALL_BREAKPOINTS: { - List<int> bpoints; tx->get_breakpoints(&bpoints); @@ -1370,7 +1275,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } } break; case DEBUG_GOTO_NEXT_BREAKPOINT: { - List<int> bpoints; tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { @@ -1398,7 +1302,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case DEBUG_GOTO_PREV_BREAKPOINT: { - List<int> bpoints; tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { @@ -1425,7 +1328,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case HELP_CONTEXTUAL: { - String text = tx->get_selection_text(); if (text == "") text = tx->get_word_under_cursor(); @@ -1434,7 +1336,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } } break; case LOOKUP_SYMBOL: { - String text = tx->get_word_under_cursor(); if (text == "") text = tx->get_selection_text(); @@ -1489,7 +1390,6 @@ void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { } void ScriptTextEditor::_bind_methods() { - ClassDB::bind_method("_update_connected_methods", &ScriptTextEditor::_update_connected_methods); ClassDB::bind_method("get_drag_data_fw", &ScriptTextEditor::get_drag_data_fw); @@ -1498,7 +1398,6 @@ void ScriptTextEditor::_bind_methods() { } Control *ScriptTextEditor::get_edit_menu() { - return edit_hb; } @@ -1507,7 +1406,6 @@ void ScriptTextEditor::clear_edit_menu() { } void ScriptTextEditor::reload(bool p_soft) { - TextEdit *te = code_editor->get_text_edit(); Ref<Script> scr = script; if (scr.is_null()) @@ -1519,12 +1417,10 @@ void ScriptTextEditor::reload(bool p_soft) { } void ScriptTextEditor::get_breakpoints(List<int> *p_breakpoints) { - code_editor->get_text_edit()->get_breakpoints(p_breakpoints); } void ScriptTextEditor::set_tooltip_request_func(String p_method, Object *p_obj) { - code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this); } @@ -1532,18 +1428,15 @@ void ScriptTextEditor::set_debugger_active(bool p_active) { } Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - return Variant(); } bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (d.has("type") && (String(d["type"]) == "resource" || String(d["type"]) == "files" || String(d["type"]) == "nodes" || String(d["type"]) == "files_and_dirs")) { - return true; } @@ -1551,7 +1444,6 @@ 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 nullptr; @@ -1570,7 +1462,6 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const } void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - Dictionary d = p_data; TextEdit *te = code_editor->get_text_edit(); @@ -1578,7 +1469,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data te->_get_mouse_pos(p_point, row, col); if (d.has("type") && String(d["type"]) == "resource") { - Ref<Resource> res = d["resource"]; if (!res.is_valid()) { return; @@ -1595,12 +1485,10 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) { - Array files = d["files"]; String text_to_drop; for (int i = 0; i < files.size(); i++) { - if (i > 0) text_to_drop += ","; text_to_drop += "\"" + String(files[i]).c_escape() + "\""; @@ -1612,7 +1500,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } if (d.has("type") && String(d["type"]) == "nodes") { - Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script); if (!sn) { @@ -1623,7 +1510,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data Array nodes = d["nodes"]; String text_to_drop; for (int i = 0; i < nodes.size(); i++) { - if (i > 0) text_to_drop += ","; @@ -1644,7 +1530,6 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { - Ref<InputEventMouseButton> mb = ev; Ref<InputEventKey> k = ev; Point2 local_pos; @@ -1763,7 +1648,6 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { } void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos) { - context_menu->clear(); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); @@ -1805,7 +1689,6 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p } ScriptTextEditor::ScriptTextEditor() { - theme_loaded = false; script_is_valid = false; @@ -1988,7 +1871,6 @@ ScriptTextEditor::~ScriptTextEditor() { } static ScriptEditorBase *create_editor(const RES &p_resource) { - if (Object::cast_to<Script>(*p_resource)) { return memnew(ScriptTextEditor); } @@ -1996,7 +1878,6 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { } void ScriptTextEditor::register_editor() { - ED_SHORTCUT("script_text_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z); ED_SHORTCUT("script_text_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y); ED_SHORTCUT("script_text_editor/cut", TTR("Cut"), KEY_MASK_CMD | KEY_X); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index a0dfba6cc8..adcd0218bc 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -37,7 +37,6 @@ #include "script_editor_plugin.h" class ConnectionInfoDialog : public AcceptDialog { - GDCLASS(ConnectionInfoDialog, AcceptDialog); Label *method; @@ -52,7 +51,6 @@ public: }; class ScriptTextEditor : public ScriptEditorBase { - GDCLASS(ScriptTextEditor, ScriptEditorBase); CodeTextEditor *code_editor; diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 9ef8148241..d1cadb6f67 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -44,11 +44,9 @@ /*** SHADER SCRIPT EDITOR ****/ Ref<Shader> ShaderTextEditor::get_edited_shader() const { - return shader; } void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { - if (shader == p_shader) { return; } @@ -84,7 +82,6 @@ void ShaderTextEditor::reload_text() { } void ShaderTextEditor::_load_theme_settings() { - get_text_edit()->clear_colors(); Color background_color = EDITOR_GET("text_editor/highlighting/background_color"); @@ -149,22 +146,18 @@ void ShaderTextEditor::_load_theme_settings() { ShaderLanguage::get_keyword_list(&keywords); if (shader.is_valid()) { - 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(RenderingServer::ShaderMode(shader->get_mode())).size(); i++) { - keywords.push_back(ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode()))[i]); } } for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - get_text_edit()->add_keyword_color(E->get(), keyword_color); } @@ -174,7 +167,6 @@ void ShaderTextEditor::_load_theme_settings() { } void ShaderTextEditor::_check_shader_mode() { - String type = ShaderLanguage::get_shader_type(get_text_edit()->get_text()); Shader::Mode mode; @@ -194,13 +186,11 @@ void ShaderTextEditor::_check_shader_mode() { } static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) { - RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable); return RS::global_variable_type_get_shader_datatype(gvt); } void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) { - _check_shader_mode(); ShaderLanguage sl; @@ -212,7 +202,6 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo } void ShaderTextEditor::_validate_script() { - _check_shader_mode(); String code = get_text_edit()->get_text(); @@ -249,7 +238,6 @@ ShaderTextEditor::ShaderTextEditor() { /*** SCRIPT EDITOR ******/ void ShaderEditor::_menu_option(int p_option) { - switch (p_option) { case EDIT_UNDO: { shader_editor->get_text_edit()->undo(); @@ -276,7 +264,6 @@ void ShaderEditor::_menu_option(int p_option) { shader_editor->move_lines_down(); } break; case EDIT_INDENT_LEFT: { - if (shader.is_null()) return; @@ -285,7 +272,6 @@ void ShaderEditor::_menu_option(int p_option) { } break; case EDIT_INDENT_RIGHT: { - if (shader.is_null()) return; @@ -300,7 +286,6 @@ void ShaderEditor::_menu_option(int p_option) { shader_editor->clone_lines_down(); } break; case EDIT_TOGGLE_COMMENT: { - if (shader.is_null()) return; @@ -308,43 +293,33 @@ void ShaderEditor::_menu_option(int p_option) { } break; case EDIT_COMPLETE: { - shader_editor->get_text_edit()->query_code_comple(); } break; case SEARCH_FIND: { - shader_editor->get_find_replace_bar()->popup_search(); } break; case SEARCH_FIND_NEXT: { - shader_editor->get_find_replace_bar()->search_next(); } break; case SEARCH_FIND_PREV: { - shader_editor->get_find_replace_bar()->search_prev(); } break; case SEARCH_REPLACE: { - shader_editor->get_find_replace_bar()->popup_replace(); } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(shader_editor->get_text_edit()); } break; case BOOKMARK_TOGGLE: { - shader_editor->toggle_bookmark(); } break; case BOOKMARK_GOTO_NEXT: { - shader_editor->goto_next_bookmark(); } break; case BOOKMARK_GOTO_PREV: { - shader_editor->goto_prev_bookmark(); } break; case BOOKMARK_REMOVE_ALL: { - shader_editor->remove_all_bookmarks(); } break; case HELP_DOCS: { @@ -357,19 +332,16 @@ void ShaderEditor::_menu_option(int p_option) { } void ShaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_FOCUS_IN) { _check_for_external_edit(); } } void ShaderEditor::_params_changed() { - shader_editor->_validate_script(); } void ShaderEditor::_editor_settings_changed() { - shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete")); shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file")); shader_editor->get_text_edit()->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size")); @@ -396,12 +368,10 @@ void ShaderEditor::_editor_settings_changed() { } void ShaderEditor::_bind_methods() { - ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed); } void ShaderEditor::ensure_select_current() { - /* if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { @@ -414,12 +384,10 @@ void ShaderEditor::ensure_select_current() { } void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) { - shader_editor->goto_line_selection(p_line, p_begin, p_end); } void ShaderEditor::_check_for_external_edit() { - if (shader.is_null() || !shader.is_valid()) { return; } @@ -440,7 +408,6 @@ void ShaderEditor::_check_for_external_edit() { } void ShaderEditor::_reload_shader_from_disk() { - Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true); ERR_FAIL_COND(!rel_shader.is_valid()); @@ -450,7 +417,6 @@ void ShaderEditor::_reload_shader_from_disk() { } void ShaderEditor::edit(const Ref<Shader> &p_shader) { - if (p_shader.is_null() || !p_shader->is_text_shader()) return; @@ -466,7 +432,6 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) { } void ShaderEditor::save_external_data(const String &p_str) { - if (shader.is_null()) { disk_changed->hide(); return; @@ -482,7 +447,6 @@ void ShaderEditor::save_external_data(const String &p_str) { } void ShaderEditor::apply_shaders() { - if (shader.is_valid()) { String shader_code = shader->get_code(); String editor_code = shader_editor->get_text_edit()->get_text(); @@ -494,13 +458,10 @@ void ShaderEditor::apply_shaders() { } void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { - Ref<InputEventMouseButton> mb = ev; if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - int col, row; TextEdit *tx = shader_editor->get_text_edit(); tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col); @@ -508,7 +469,6 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { if (tx->is_right_click_moving_caret()) { if (tx->is_selection_active()) { - int from_line = tx->get_selection_from_line(); int to_line = tx->get_selection_to_line(); int from_column = tx->get_selection_from_column(); @@ -537,7 +497,6 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } void ShaderEditor::_update_bookmark_list() { - bookmarks_menu->clear(); bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE); @@ -565,7 +524,6 @@ void ShaderEditor::_update_bookmark_list() { } void ShaderEditor::_bookmark_item_pressed(int p_idx) { - if (p_idx < 4) { // Any item before the separator. _menu_option(bookmarks_menu->get_item_id(p_idx)); } else { @@ -574,7 +532,6 @@ void ShaderEditor::_bookmark_item_pressed(int p_idx) { } void ShaderEditor::_make_context_menu(bool p_selection, Vector2 p_position) { - context_menu->clear(); if (p_selection) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); @@ -599,7 +556,6 @@ void ShaderEditor::_make_context_menu(bool p_selection, Vector2 p_position) { } ShaderEditor::ShaderEditor(EditorNode *p_node) { - shader_editor = memnew(ShaderTextEditor); shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); shader_editor->add_theme_constant_override("separation", 0); @@ -714,25 +670,21 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { } void ShaderEditorPlugin::edit(Object *p_object) { - Shader *s = Object::cast_to<Shader>(p_object); shader_editor->edit(s); } bool ShaderEditorPlugin::handles(Object *p_object) const { - Shader *shader = Object::cast_to<Shader>(p_object); return shader != nullptr && shader->is_text_shader(); } void ShaderEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { button->show(); editor->make_bottom_panel_item_visible(shader_editor); } else { - button->hide(); if (shader_editor->is_visible_in_tree()) editor->hide_bottom_panel(); @@ -741,22 +693,18 @@ void ShaderEditorPlugin::make_visible(bool p_visible) { } void ShaderEditorPlugin::selected_notify() { - shader_editor->ensure_select_current(); } void ShaderEditorPlugin::save_external_data() { - shader_editor->save_external_data(); } void ShaderEditorPlugin::apply_changes() { - shader_editor->apply_shaders(); } ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) { - editor = p_node; shader_editor = memnew(ShaderEditor(p_node)); diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index f02ed590fc..0208b43e13 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -42,7 +42,6 @@ #include "servers/rendering/shader_language.h" class ShaderTextEditor : public CodeTextEditor { - GDCLASS(ShaderTextEditor, CodeTextEditor); Ref<Shader> shader; @@ -66,7 +65,6 @@ public: }; class ShaderEditor : public PanelContainer { - GDCLASS(ShaderEditor, PanelContainer); enum { @@ -143,7 +141,6 @@ public: }; class ShaderEditorPlugin : public EditorPlugin { - GDCLASS(ShaderEditorPlugin, EditorPlugin); bool _2d; diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp index 9d5ffd6516..2f9b00ee56 100644 --- a/editor/plugins/shader_file_editor_plugin.cpp +++ b/editor/plugins/shader_file_editor_plugin.cpp @@ -49,7 +49,6 @@ void ShaderFileEditor::_update_version(const StringName &p_version_txt, const RD } void ShaderFileEditor::_version_selected(int p_option) { - int c = versions->get_current(); StringName version_txt = versions->get_item_metadata(c); @@ -106,7 +105,6 @@ void ShaderFileEditor::_version_selected(int p_option) { } void ShaderFileEditor::_update_options() { - ERR_FAIL_COND(shader_file.is_null()); if (shader_file->get_base_error() != String()) { @@ -202,7 +200,6 @@ void ShaderFileEditor::_update_options() { } void ShaderFileEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_FOCUS_IN) { if (is_visible_in_tree() && shader_file.is_valid()) { _update_options(); @@ -211,7 +208,6 @@ void ShaderFileEditor::_notification(int p_what) { } void ShaderFileEditor::_editor_settings_changed() { - if (is_visible_in_tree() && shader_file.is_valid()) { _update_options(); } @@ -221,7 +217,6 @@ void ShaderFileEditor::_bind_methods() { } void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) { - if (p_shader.is_null()) { if (shader_file.is_valid()) { shader_file->disconnect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed)); @@ -242,7 +237,6 @@ void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) { } void ShaderFileEditor::_shader_changed() { - if (is_visible_in_tree()) { _update_options(); } @@ -294,25 +288,21 @@ ShaderFileEditor::ShaderFileEditor(EditorNode *p_node) { } void ShaderFileEditorPlugin::edit(Object *p_object) { - RDShaderFile *s = Object::cast_to<RDShaderFile>(p_object); shader_editor->edit(s); } bool ShaderFileEditorPlugin::handles(Object *p_object) const { - RDShaderFile *shader = Object::cast_to<RDShaderFile>(p_object); return shader != nullptr; } void ShaderFileEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { button->show(); editor->make_bottom_panel_item_visible(shader_editor); } else { - button->hide(); if (shader_editor->is_visible_in_tree()) editor->hide_bottom_panel(); @@ -320,7 +310,6 @@ void ShaderFileEditorPlugin::make_visible(bool p_visible) { } ShaderFileEditorPlugin::ShaderFileEditorPlugin(EditorNode *p_node) { - editor = p_node; shader_editor = memnew(ShaderFileEditor(p_node)); diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h index 7df177a0d5..19617366b2 100644 --- a/editor/plugins/shader_file_editor_plugin.h +++ b/editor/plugins/shader_file_editor_plugin.h @@ -42,7 +42,6 @@ #include "servers/rendering/rendering_device_binds.h" class ShaderFileEditor : public PanelContainer { - GDCLASS(ShaderFileEditor, PanelContainer); Ref<RDShaderFile> shader_file; @@ -71,7 +70,6 @@ public: }; class ShaderFileEditorPlugin : public EditorPlugin { - GDCLASS(ShaderFileEditorPlugin, EditorPlugin); ShaderFileEditor *shader_editor; diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index c81d3f787e..a198e4ff8f 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -36,7 +36,6 @@ #include "thirdparty/misc/clipper.hpp" void Skeleton2DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; options->hide(); @@ -44,19 +43,16 @@ void Skeleton2DEditor::_node_removed(Node *p_node) { } void Skeleton2DEditor::edit(Skeleton2D *p_sprite) { - node = p_sprite; } void Skeleton2DEditor::_menu_option(int p_option) { - if (!node) { return; } switch (p_option) { case MENU_OPTION_MAKE_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(); @@ -95,7 +91,6 @@ void Skeleton2DEditor::_bind_methods() { } Skeleton2DEditor::Skeleton2DEditor() { - options = memnew(MenuButton); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); @@ -115,28 +110,23 @@ Skeleton2DEditor::Skeleton2DEditor() { } void Skeleton2DEditorPlugin::edit(Object *p_object) { - sprite_editor->edit(Object::cast_to<Skeleton2D>(p_object)); } bool Skeleton2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Skeleton2D"); } void Skeleton2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { sprite_editor->options->show(); } else { - sprite_editor->options->hide(); sprite_editor->edit(nullptr); } } Skeleton2DEditorPlugin::Skeleton2DEditorPlugin(EditorNode *p_node) { - editor = p_node; sprite_editor = memnew(Skeleton2DEditor); editor->get_viewport()->add_child(sprite_editor); diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h index ebc6746b81..f1ba1a3612 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.h +++ b/editor/plugins/skeleton_2d_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/spin_box.h" class Skeleton2DEditor : public Control { - GDCLASS(Skeleton2DEditor, Control); enum Menu { @@ -65,7 +64,6 @@ public: }; class Skeleton2DEditorPlugin : public EditorPlugin { - GDCLASS(Skeleton2DEditorPlugin, EditorPlugin); Skeleton2DEditor *sprite_editor; diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index fac4cb19d8..c256acd17b 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -63,22 +63,18 @@ void Skeleton3DEditor::create_physical_skeleton() { bones_infos.resize(bc); for (int bone_id = 0; bc > bone_id; ++bone_id) { - const int parent = skeleton->get_bone_parent(bone_id); if (parent < 0) { - bones_infos.write[bone_id].relative_rest = skeleton->get_bone_rest(bone_id); } else { - const int parent_parent = skeleton->get_bone_parent(parent); bones_infos.write[bone_id].relative_rest = bones_infos[parent].relative_rest * skeleton->get_bone_rest(bone_id); /// create physical bone on parent if (!bones_infos[parent].physical_bone) { - bones_infos.write[parent].physical_bone = create_physical_bone(parent, bone_id, bones_infos); ur->create_action(TTR("Create physical bones")); @@ -93,7 +89,6 @@ void Skeleton3DEditor::create_physical_skeleton() { /// Create joint between parent of parent if (-1 != parent_parent) { - bones_infos[parent].physical_bone->set_joint_type(PhysicalBone3D::JOINT_TYPE_PIN); } } @@ -102,7 +97,6 @@ void Skeleton3DEditor::create_physical_skeleton() { } 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); @@ -131,7 +125,6 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi } void Skeleton3DEditor::edit(Skeleton3D *p_node) { - skeleton = p_node; } @@ -142,7 +135,6 @@ void Skeleton3DEditor::_notification(int p_what) { } void Skeleton3DEditor::_node_removed(Node *p_node) { - if (p_node == skeleton) { skeleton = nullptr; options->hide(); @@ -180,7 +172,6 @@ void Skeleton3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { skeleton_editor->options->show(); } else { - skeleton_editor->options->hide(); skeleton_editor->edit(nullptr); } diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 1bcf27e2f2..af9ebb6246 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -75,7 +75,6 @@ public: }; class Skeleton3DEditorPlugin : public EditorPlugin { - GDCLASS(Skeleton3DEditorPlugin, EditorPlugin); EditorNode *editor; diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp index a22534eac0..170a777523 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp @@ -33,7 +33,6 @@ #include "scene/3d/skeleton_ik_3d.h" void SkeletonIK3DEditorPlugin::_play() { - if (!skeleton_ik) return; @@ -49,7 +48,6 @@ void SkeletonIK3DEditorPlugin::_play() { } void SkeletonIK3DEditorPlugin::edit(Object *p_object) { - if (p_object != skeleton_ik) { if (skeleton_ik) { play_btn->set_pressed(false); @@ -65,12 +63,10 @@ void SkeletonIK3DEditorPlugin::edit(Object *p_object) { } bool SkeletonIK3DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("SkeletonIK3D"); } void SkeletonIK3DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) play_btn->show(); else @@ -81,7 +77,6 @@ void SkeletonIK3DEditorPlugin::_bind_methods() { } SkeletonIK3DEditorPlugin::SkeletonIK3DEditorPlugin(EditorNode *p_node) { - editor = p_node; play_btn = memnew(Button); play_btn->set_icon(editor->get_gui_base()->get_theme_icon("Play", "EditorIcons")); diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h index 88472a2963..bd4c5ba93e 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.h +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h @@ -37,7 +37,6 @@ class SkeletonIK3D; class SkeletonIK3DEditorPlugin : public EditorPlugin { - GDCLASS(SkeletonIK3DEditorPlugin, EditorPlugin); SkeletonIK3D *skeleton_ik; diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index ab0f15d3d0..f09e4cb456 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -40,7 +40,6 @@ #include "thirdparty/misc/clipper.hpp" void Sprite2DEditor::_node_removed(Node *p_node) { - if (p_node == node) { node = nullptr; options->hide(); @@ -48,7 +47,6 @@ void Sprite2DEditor::_node_removed(Node *p_node) { } void Sprite2DEditor::edit(Sprite2D *p_sprite) { - node = p_sprite; } @@ -63,7 +61,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float ClipperLib::PolyTree out; for (int i = 0; i < points.size(); i++) { - subj << ClipperLib::IntPoint(points[i].x * PRECISION, points[i].y * PRECISION); } ClipperLib::ClipperOffset co; @@ -104,7 +101,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float int lasti = p2->Contour.size() - 1; Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION); for (uint64_t i = 0; i < p2->Contour.size(); i++) { - Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION); if (cur.distance_to(prev) > 0.5) { outPoints.push_back(cur); @@ -115,7 +111,6 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float } void Sprite2DEditor::_menu_option(int p_option) { - if (!node) { return; } @@ -124,7 +119,6 @@ void Sprite2DEditor::_menu_option(int p_option) { switch (p_option) { case MENU_OPTION_CONVERT_TO_MESH_2D: { - debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D")); debug_uv_dialog->set_title(TTR("Mesh2D Preview")); @@ -134,7 +128,6 @@ void Sprite2DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CONVERT_TO_POLYGON_2D: { - debug_uv_dialog->get_ok()->set_text(TTR("Create Polygon2D")); debug_uv_dialog->set_title(TTR("Polygon2D Preview")); @@ -143,7 +136,6 @@ void Sprite2DEditor::_menu_option(int p_option) { debug_uv->update(); } break; case MENU_OPTION_CREATE_COLLISION_POLY_2D: { - debug_uv_dialog->get_ok()->set_text(TTR("Create CollisionPolygon2D")); debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview")); @@ -153,7 +145,6 @@ void Sprite2DEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: { - debug_uv_dialog->get_ok()->set_text(TTR("Create LightOccluder2D")); debug_uv_dialog->set_title(TTR("LightOccluder2D Preview")); @@ -166,7 +157,6 @@ void Sprite2DEditor::_menu_option(int p_option) { } void Sprite2DEditor::_update_mesh_data() { - Ref<Texture2D> texture = node->get_texture(); if (texture.is_null()) { err_dialog->set_text(TTR("Sprite2D is empty!")); @@ -218,7 +208,6 @@ void Sprite2DEditor::_update_mesh_data() { } if (selected_menu_item == MENU_OPTION_CONVERT_TO_MESH_2D) { - for (int j = 0; j < lines.size(); j++) { int index_ofs = computed_vertices.size(); @@ -262,7 +251,6 @@ void Sprite2DEditor::_update_mesh_data() { outline_lines.resize(lines.size()); computed_outline_lines.resize(lines.size()); for (int pi = 0; pi < lines.size(); pi++) { - Vector<Vector2> ol; Vector<Vector2> col; @@ -314,7 +302,6 @@ void Sprite2DEditor::_create_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(); @@ -345,7 +332,6 @@ void Sprite2DEditor::_convert_to_mesh_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(); @@ -372,7 +358,6 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() { polys.resize(computed_outline_lines.size()); for (int i = 0; i < computed_outline_lines.size(); i++) { - Vector<Vector2> outline = computed_outline_lines[i]; Vector<Vector2> uv_outline = outline_lines[i]; @@ -404,7 +389,6 @@ void Sprite2DEditor::_convert_to_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(); @@ -412,7 +396,6 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() { } for (int i = 0; i < computed_outline_lines.size(); i++) { - Vector<Vector2> outline = computed_outline_lines[i]; CollisionPolygon2D *collision_polygon_2d_instance = memnew(CollisionPolygon2D); @@ -428,7 +411,6 @@ void Sprite2DEditor::_create_collision_polygon_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(); @@ -436,7 +418,6 @@ void Sprite2DEditor::_create_light_occluder_2d_node() { } for (int i = 0; i < computed_outline_lines.size(); i++) { - Vector<Vector2> outline = computed_outline_lines[i]; Ref<OccluderPolygon2D> polygon; @@ -475,7 +456,6 @@ void Sprite2DEditor::_add_as_sibling_or_child(Node *p_own_node, Node *p_new_node } void Sprite2DEditor::_debug_uv_draw() { - Ref<Texture2D> tex = node->get_texture(); ERR_FAIL_COND(!tex.is_valid()); @@ -503,12 +483,10 @@ void Sprite2DEditor::_debug_uv_draw() { } void Sprite2DEditor::_bind_methods() { - ClassDB::bind_method("_add_as_sibling_or_child", &Sprite2DEditor::_add_as_sibling_or_child); } Sprite2DEditor::Sprite2DEditor() { - options = memnew(MenuButton); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options); @@ -577,28 +555,23 @@ Sprite2DEditor::Sprite2DEditor() { } void Sprite2DEditorPlugin::edit(Object *p_object) { - sprite_editor->edit(Object::cast_to<Sprite2D>(p_object)); } bool Sprite2DEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("Sprite2D"); } void Sprite2DEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { sprite_editor->options->show(); } else { - sprite_editor->options->hide(); sprite_editor->edit(nullptr); } } Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) { - editor = p_node; sprite_editor = memnew(Sprite2DEditor); editor->get_viewport()->add_child(sprite_editor); diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index 0add77843b..c2b942fd82 100644 --- a/editor/plugins/sprite_2d_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -37,7 +37,6 @@ #include "scene/gui/spin_box.h" class Sprite2DEditor : public Control { - GDCLASS(Sprite2DEditor, Control); enum Menu { @@ -97,7 +96,6 @@ public: }; class Sprite2DEditorPlugin : public EditorPlugin { - GDCLASS(Sprite2DEditorPlugin, EditorPlugin); Sprite2DEditor *sprite_editor; diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 34ff34d45b..4162778fb9 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -41,7 +41,6 @@ void SpriteFramesEditor::_gui_input(Ref<InputEvent> p_event) { } void SpriteFramesEditor::_open_sprite_sheet() { - file_split_sheet->clear_filters(); List<String> extensions; ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); @@ -53,7 +52,6 @@ void SpriteFramesEditor::_open_sprite_sheet() { } void SpriteFramesEditor::_sheet_preview_draw() { - Size2i size = split_sheet_preview->get_size(); int h = split_sheet_h->get_value(); int v = split_sheet_v->get_value(); @@ -61,13 +59,11 @@ void SpriteFramesEditor::_sheet_preview_draw() { int height = size.height / v; const float a = 0.3; for (int i = 1; i < h; i++) { - int x = i * width; split_sheet_preview->draw_line(Point2(x, 0), Point2(x, size.height), Color(1, 1, 1, a)); split_sheet_preview->draw_line(Point2(x + 1, 0), Point2(x + 1, size.height), Color(0, 0, 0, a)); for (int j = 1; j < v; j++) { - int y = j * height; split_sheet_preview->draw_line(Point2(0, y), Point2(size.width, y), Color(1, 1, 1, a)); @@ -103,7 +99,6 @@ void SpriteFramesEditor::_sheet_preview_draw() { split_sheet_dialog->get_ok()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size())); } void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { @@ -145,7 +140,6 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } void SpriteFramesEditor::_sheet_add_frames() { - Size2i size = split_sheet_preview->get_size(); int h = split_sheet_h->get_value(); int v = split_sheet_v->get_value(); @@ -185,7 +179,6 @@ void SpriteFramesEditor::_sheet_add_frames() { } void SpriteFramesEditor::_sheet_select_clear_all_frames() { - bool should_clear = true; for (int i = 0; i < split_sheet_h->get_value() * split_sheet_v->get_value(); i++) { if (!frames_selected.has(i)) { @@ -201,14 +194,12 @@ void SpriteFramesEditor::_sheet_select_clear_all_frames() { } void SpriteFramesEditor::_sheet_spin_changed(double) { - frames_selected.clear(); last_frame_selected = -1; split_sheet_preview->update(); } void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { - Ref<Resource> texture = ResourceLoader::load(p_file); if (!texture.is_valid()) { EditorNode::get_singleton()->show_warning(TTR("Unable to load images")); @@ -227,7 +218,6 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { } void SpriteFramesEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { load->set_icon(get_theme_icon("Load", "EditorIcons")); @@ -253,13 +243,11 @@ void SpriteFramesEditor::_notification(int p_what) { } void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_at_pos) { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); List<Ref<Texture2D>> resources; for (int i = 0; i < p_path.size(); i++) { - Ref<Texture2D> resource; resource = ResourceLoader::load(p_path[i]); @@ -286,7 +274,6 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ int count = 0; for (List<Ref<Texture2D>>::Element *E = resources.front(); E; E = E->next()) { - undo_redo->add_do_method(frames, "add_frame", edited_anim, E->get(), p_at_pos == -1 ? -1 : p_at_pos + count); undo_redo->add_undo_method(frames, "remove_frame", edited_anim, p_at_pos == -1 ? fc : p_at_pos); count++; @@ -298,7 +285,6 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ } void SpriteFramesEditor::_load_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); loading_scene = false; @@ -314,7 +300,6 @@ void SpriteFramesEditor::_load_pressed() { } void SpriteFramesEditor::_paste_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); Ref<Texture2D> r = EditorSettings::get_singleton()->get_resource_clipboard(); @@ -349,13 +334,11 @@ void SpriteFramesEditor::_copy_pressed() { } void SpriteFramesEditor::_empty_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); int from = -1; if (tree->get_current() >= 0) { - from = tree->get_current(); sel = from; @@ -374,13 +357,11 @@ void SpriteFramesEditor::_empty_pressed() { } void SpriteFramesEditor::_empty2_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); int from = -1; if (tree->get_current() >= 0) { - from = tree->get_current(); sel = from; @@ -399,7 +380,6 @@ void SpriteFramesEditor::_empty2_pressed() { } void SpriteFramesEditor::_up_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); if (tree->get_current() < 0) @@ -423,7 +403,6 @@ void SpriteFramesEditor::_up_pressed() { } void SpriteFramesEditor::_down_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); if (tree->get_current() < 0) @@ -447,7 +426,6 @@ void SpriteFramesEditor::_down_pressed() { } void SpriteFramesEditor::_delete_pressed() { - ERR_FAIL_COND(!frames->has_animation(edited_anim)); if (tree->get_current() < 0) @@ -467,7 +445,6 @@ void SpriteFramesEditor::_delete_pressed() { } void SpriteFramesEditor::_animation_select() { - if (updating) return; @@ -484,7 +461,6 @@ void SpriteFramesEditor::_animation_select() { } static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFrames> p_sfames) { - Node *edited = EditorNode::get_singleton()->get_edited_scene(); if (!edited) return; @@ -511,7 +487,6 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr } void SpriteFramesEditor::_animation_name_edited() { - if (updating) return; @@ -544,7 +519,6 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->add_undo_method(frames, "rename_animation", name, edited_anim); for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); undo_redo->add_do_method(E->get(), "set_animation", name); undo_redo->add_undo_method(E->get(), "set_animation", edited_anim); @@ -559,7 +533,6 @@ void SpriteFramesEditor::_animation_name_edited() { } void SpriteFramesEditor::_animation_add() { - String name = "New Anim"; int counter = 0; while (frames->has_animation(name)) { @@ -577,7 +550,6 @@ void SpriteFramesEditor::_animation_add() { undo_redo->add_undo_method(this, "_update_library"); for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - String current = E->get()->call("get_animation"); undo_redo->add_do_method(E->get(), "set_animation", name); undo_redo->add_undo_method(E->get(), "set_animation", current); @@ -590,7 +562,6 @@ void SpriteFramesEditor::_animation_add() { } void SpriteFramesEditor::_animation_remove() { - if (updating) return; @@ -602,7 +573,6 @@ void SpriteFramesEditor::_animation_remove() { } void SpriteFramesEditor::_animation_remove_confirmed() { - undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(frames, "remove_animation", edited_anim); undo_redo->add_undo_method(frames, "add_animation", edited_anim); @@ -622,7 +592,6 @@ void SpriteFramesEditor::_animation_remove_confirmed() { } void SpriteFramesEditor::_animation_loop_changed() { - if (updating) return; @@ -635,7 +604,6 @@ void SpriteFramesEditor::_animation_loop_changed() { } void SpriteFramesEditor::_animation_fps_changed(double p_value) { - if (updating) return; @@ -649,7 +617,6 @@ void SpriteFramesEditor::_animation_fps_changed(double p_value) { } void SpriteFramesEditor::_update_library(bool p_skip_selector) { - updating = true; if (!p_skip_selector) { @@ -664,7 +631,6 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { anim_names.sort_custom<StringName::AlphCompare>(); for (List<StringName>::Element *E = anim_names.front(); E; E = E->next()) { - String name = E->get(); TreeItem *it = animations->create_item(anim_root); @@ -693,12 +659,10 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { sel = 0; for (int i = 0; i < frames->get_frame_count(edited_anim); i++) { - String name; Ref<Texture2D> icon; if (frames->get_frame(edited_anim, i).is_null()) { - name = itos(i) + ": " + TTR("(empty)"); } else { @@ -721,16 +685,13 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { } void SpriteFramesEditor::edit(SpriteFrames *p_frames) { - if (frames == p_frames) return; frames = p_frames; if (p_frames) { - if (!p_frames->has_animation(edited_anim)) { - List<StringName> anim_names; frames->get_animation_list(&anim_names); anim_names.sort_custom<StringName::AlphCompare>(); @@ -743,13 +704,11 @@ void SpriteFramesEditor::edit(SpriteFrames *p_frames) { _update_library(); } else { - hide(); } } Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - if (!frames->has_animation(edited_anim)) return false; @@ -769,7 +728,6 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f } bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type")) @@ -785,13 +743,11 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & Ref<Texture2D> texture = r; if (texture.is_valid()) { - return true; } } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; if (files.size() == 0) @@ -812,7 +768,6 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & } void SpriteFramesEditor::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; @@ -858,7 +813,6 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; _file_load_request(files, at_pos); @@ -866,7 +820,6 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } void SpriteFramesEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_library", "skipsel"), &SpriteFramesEditor::_update_library, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw); ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &SpriteFramesEditor::can_drop_data_fw); @@ -874,7 +827,6 @@ void SpriteFramesEditor::_bind_methods() { } SpriteFramesEditor::SpriteFramesEditor() { - VBoxContainer *vbc_animlist = memnew(VBoxContainer); add_child(vbc_animlist); vbc_animlist->set_custom_minimum_size(Size2(150, 0) * EDSCALE); @@ -1071,7 +1023,6 @@ SpriteFramesEditor::SpriteFramesEditor() { } void SpriteFramesEditorPlugin::edit(Object *p_object) { - frames_editor->set_undo_redo(&get_undo_redo()); SpriteFrames *s; @@ -1083,7 +1034,6 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) { if (animated_sprite_3d) { s = *animated_sprite_3d->get_sprite_frames(); } else { - s = Object::cast_to<SpriteFrames>(p_object); } } @@ -1092,7 +1042,6 @@ void SpriteFramesEditorPlugin::edit(Object *p_object) { } bool SpriteFramesEditorPlugin::handles(Object *p_object) const { - 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()) { @@ -1105,12 +1054,10 @@ bool SpriteFramesEditorPlugin::handles(Object *p_object) const { } void SpriteFramesEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { button->show(); editor->make_bottom_panel_item_visible(frames_editor); } else { - button->hide(); if (frames_editor->is_visible_in_tree()) editor->hide_bottom_panel(); @@ -1118,7 +1065,6 @@ void SpriteFramesEditorPlugin::make_visible(bool p_visible) { } SpriteFramesEditorPlugin::SpriteFramesEditorPlugin(EditorNode *p_node) { - editor = p_node; frames_editor = memnew(SpriteFramesEditor); frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 89d9bc6fd3..45646eb9e4 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -41,7 +41,6 @@ #include "scene/gui/tree.h" class SpriteFramesEditor : public HSplitContainer { - GDCLASS(SpriteFramesEditor, HSplitContainer); ToolButton *load; @@ -134,7 +133,6 @@ public: }; class SpriteFramesEditorPlugin : public EditorPlugin { - GDCLASS(SpriteFramesEditorPlugin, EditorPlugin); SpriteFramesEditor *frames_editor; diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index eb6e261305..333d95196e 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -33,12 +33,10 @@ #include "editor/editor_scale.h" bool EditorInspectorPluginStyleBox::can_handle(Object *p_object) { - return Object::cast_to<StyleBox>(p_object) != nullptr; } void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) { - Ref<StyleBox> sb = Ref<StyleBox>(Object::cast_to<StyleBox>(p_object)); StyleBoxPreview *preview = memnew(StyleBoxPreview); @@ -52,7 +50,6 @@ void EditorInspectorPluginStyleBox::parse_end() { } void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { - if (stylebox.is_valid()) stylebox->disconnect("changed", callable_mp(this, &StyleBoxPreview::_sb_changed)); stylebox = p_stylebox; @@ -64,7 +61,6 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) { } void StyleBoxPreview::_sb_changed() { - preview->update(); } @@ -93,7 +89,6 @@ StyleBoxPreview::StyleBoxPreview() { } StyleBoxEditorPlugin::StyleBoxEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginStyleBox> inspector_plugin; inspector_plugin.instance(); add_inspector_plugin(inspector_plugin); diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index 1eea9260b2..d9958d42e6 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -38,7 +38,6 @@ #include "scene/resources/style_box.h" class StyleBoxPreview : public VBoxContainer { - GDCLASS(StyleBoxPreview, VBoxContainer); Control *preview; @@ -67,7 +66,6 @@ public: }; class StyleBoxEditorPlugin : public EditorPlugin { - GDCLASS(StyleBoxEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 2786a568ea..f6603d268c 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -70,7 +70,6 @@ void TextEditor::_change_syntax_highlighter(int p_idx) { } void TextEditor::_load_theme_settings() { - TextEdit *text_edit = code_editor->get_text_edit(); text_edit->clear_colors(); @@ -164,7 +163,6 @@ String TextEditor::get_name() { } Ref<Texture2D> TextEditor::get_theme_icon() { - return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), ""); } @@ -195,7 +193,6 @@ void TextEditor::get_breakpoints(List<int> *p_breakpoints) { } void TextEditor::reload_text() { - ERR_FAIL_COND(text_file.is_null()); TextEdit *te = code_editor->get_text_edit(); @@ -221,7 +218,6 @@ void TextEditor::_validate_script() { } void TextEditor::_update_bookmark_list() { - bookmarks_menu->clear(); bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE); @@ -249,7 +245,6 @@ void TextEditor::_update_bookmark_list() { } void TextEditor::_bookmark_item_pressed(int p_idx) { - if (p_idx < 4) { // Any item before the separator. _edit_option(bookmarks_menu->get_item_id(p_idx)); } else { @@ -262,17 +257,14 @@ void TextEditor::apply_code() { } bool TextEditor::is_unsaved() { - return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version(); } Variant TextEditor::get_edit_state() { - return code_editor->get_edit_state(); } void TextEditor::set_edit_state(const Variant &p_state) { - code_editor->set_edit_state(p_state); Dictionary state = p_state; @@ -285,42 +277,34 @@ void TextEditor::set_edit_state(const Variant &p_state) { } void TextEditor::trim_trailing_whitespace() { - code_editor->trim_trailing_whitespace(); } void TextEditor::insert_final_newline() { - code_editor->insert_final_newline(); } void TextEditor::convert_indent_to_spaces() { - code_editor->convert_indent_to_spaces(); } void TextEditor::convert_indent_to_tabs() { - code_editor->convert_indent_to_tabs(); } void TextEditor::tag_saved_version() { - code_editor->get_text_edit()->tag_saved_version(); } void TextEditor::goto_line(int p_line, bool p_with_error) { - code_editor->goto_line(p_line); } void TextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { - code_editor->goto_line_selection(p_line, p_begin, p_end); } void TextEditor::set_executing_line(int p_line) { - code_editor->set_executing_line(p_line); } @@ -329,12 +313,10 @@ void TextEditor::clear_executing_line() { } void TextEditor::ensure_focus() { - code_editor->get_text_edit()->grab_focus(); } Vector<String> TextEditor::get_functions() { - return Vector<String>(); } @@ -343,17 +325,14 @@ bool TextEditor::show_members_overview() { } void TextEditor::update_settings() { - code_editor->update_editor_settings(); } void TextEditor::set_tooltip_request_func(String p_method, Object *p_obj) { - code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this); } Control *TextEditor::get_edit_menu() { - return edit_hb; } @@ -362,7 +341,6 @@ void TextEditor::clear_edit_menu() { } void TextEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: _load_theme_settings(); @@ -375,116 +353,90 @@ void TextEditor::_edit_option(int p_op) { switch (p_op) { case EDIT_UNDO: { - tx->undo(); tx->call_deferred("grab_focus"); } break; case EDIT_REDO: { - tx->redo(); tx->call_deferred("grab_focus"); } break; case EDIT_CUT: { - tx->cut(); tx->call_deferred("grab_focus"); } break; case EDIT_COPY: { - tx->copy(); tx->call_deferred("grab_focus"); } break; case EDIT_PASTE: { - tx->paste(); tx->call_deferred("grab_focus"); } break; case EDIT_SELECT_ALL: { - tx->select_all(); tx->call_deferred("grab_focus"); } break; case EDIT_MOVE_LINE_UP: { - code_editor->move_lines_up(); } break; case EDIT_MOVE_LINE_DOWN: { - code_editor->move_lines_down(); } break; case EDIT_INDENT_LEFT: { - tx->indent_left(); } break; case EDIT_INDENT_RIGHT: { - tx->indent_right(); } break; case EDIT_DELETE_LINE: { - code_editor->delete_lines(); } break; case EDIT_CLONE_DOWN: { - code_editor->clone_lines_down(); } break; case EDIT_TOGGLE_FOLD_LINE: { - tx->toggle_fold_line(tx->cursor_get_line()); tx->update(); } break; case EDIT_FOLD_ALL_LINES: { - tx->fold_all_lines(); tx->update(); } break; case EDIT_UNFOLD_ALL_LINES: { - tx->unhide_all_lines(); tx->update(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { - trim_trailing_whitespace(); } break; case EDIT_CONVERT_INDENT_TO_SPACES: { - convert_indent_to_spaces(); } break; case EDIT_CONVERT_INDENT_TO_TABS: { - convert_indent_to_tabs(); } break; case EDIT_TO_UPPERCASE: { - _convert_case(CodeTextEditor::UPPER); } break; case EDIT_TO_LOWERCASE: { - _convert_case(CodeTextEditor::LOWER); } break; case EDIT_CAPITALIZE: { - _convert_case(CodeTextEditor::CAPITALIZE); } break; case SEARCH_FIND: { - code_editor->get_find_replace_bar()->popup_search(); } break; case SEARCH_FIND_NEXT: { - code_editor->get_find_replace_bar()->search_next(); } break; case SEARCH_FIND_PREV: { - code_editor->get_find_replace_bar()->search_prev(); } break; case SEARCH_REPLACE: { - code_editor->get_find_replace_bar()->popup_replace(); } break; case SEARCH_IN_FILES: { - String selected_text = code_editor->get_text_edit()->get_selection_text(); // Yep, because it doesn't make sense to instance this dialog for every single script open... @@ -492,36 +444,29 @@ void TextEditor::_edit_option(int p_op) { emit_signal("search_in_files_requested", selected_text); } break; case REPLACE_IN_FILES: { - String selected_text = code_editor->get_text_edit()->get_selection_text(); emit_signal("replace_in_files_requested", selected_text); } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(tx); } break; case BOOKMARK_TOGGLE: { - code_editor->toggle_bookmark(); } break; case BOOKMARK_GOTO_NEXT: { - code_editor->goto_next_bookmark(); } break; case BOOKMARK_GOTO_PREV: { - code_editor->goto_prev_bookmark(); } break; case BOOKMARK_REMOVE_ALL: { - code_editor->remove_all_bookmarks(); } break; } } void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) { - code_editor->convert_case(p_case); } @@ -529,7 +474,6 @@ void TextEditor::_bind_methods() { } static ScriptEditorBase *create_editor(const RES &p_resource) { - if (Object::cast_to<TextFile>(*p_resource)) { return memnew(TextEditor); } @@ -537,17 +481,14 @@ static ScriptEditorBase *create_editor(const RES &p_resource) { } void TextEditor::register_editor() { - ScriptEditor::register_create_script_editor_function(create_editor); } void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { - Ref<InputEventMouseButton> mb = ev; if (mb.is_valid()) { if (mb->get_button_index() == BUTTON_RIGHT) { - int col, row; TextEdit *tx = code_editor->get_text_edit(); tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col); @@ -558,7 +499,6 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { if (tx->is_right_click_moving_caret()) { if (tx->is_selection_active()) { - int from_line = tx->get_selection_from_line(); int to_line = tx->get_selection_to_line(); int from_column = tx->get_selection_from_column(); @@ -591,7 +531,6 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position) { - context_menu->clear(); if (p_selection) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index b41e11c3aa..9d9025a2c4 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -34,7 +34,6 @@ #include "script_editor_plugin.h" class TextEditor : public ScriptEditorBase { - GDCLASS(TextEditor, ScriptEditorBase); private: diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 7a3e571f16..7c5a290537 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -38,14 +38,11 @@ void TextureEditor::_gui_input(Ref<InputEvent> p_event) { } void TextureEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); @@ -104,14 +101,12 @@ void TextureEditor::_notification(int p_what) { } void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) { - if (!is_visible()) return; update(); } void TextureEditor::edit(Ref<Texture2D> p_texture) { - if (!texture.is_null()) texture->remove_change_receptor(this); @@ -126,12 +121,10 @@ void TextureEditor::edit(Ref<Texture2D> p_texture) { } void TextureEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &TextureEditor::_gui_input); } TextureEditor::TextureEditor() { - set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED); set_custom_minimum_size(Size2(1, 150)); } @@ -143,12 +136,10 @@ TextureEditor::~TextureEditor() { } // bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture2D>(p_object) != nullptr || Object::cast_to<LargeTexture>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { - Texture2D *texture = Object::cast_to<Texture2D>(p_object); if (!texture) { return; @@ -161,7 +152,6 @@ void EditorInspectorPluginTexture::parse_begin(Object *p_object) { } TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginTexture> plugin; plugin.instance(); add_inspector_plugin(plugin); diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 29ad0183dc..63eea2b767 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/resources/texture.h" class TextureEditor : public Control { - GDCLASS(TextureEditor, Control); Ref<Texture2D> texture; @@ -62,7 +61,6 @@ public: }; class TextureEditorPlugin : public EditorPlugin { - GDCLASS(TextureEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp index 8ab17590f4..24a6103450 100644 --- a/editor/plugins/texture_layered_editor_plugin.cpp +++ b/editor/plugins/texture_layered_editor_plugin.cpp @@ -48,9 +48,7 @@ void TextureLayeredEditor::_texture_rect_draw() { } void TextureLayeredEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - //get_scene()->connect("node_removed",this,"_node_removed"); } if (p_what == NOTIFICATION_RESIZED) { @@ -58,7 +56,6 @@ void TextureLayeredEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_DRAW) { - Ref<Texture2D> checkerboard = get_theme_icon("Checkerboard", "EditorIcons"); Size2 size = get_size(); @@ -67,14 +64,12 @@ void TextureLayeredEditor::_notification(int p_what) { } void TextureLayeredEditor::_changed_callback(Object *p_changed, const char *p_prop) { - if (!is_visible()) return; update(); } void TextureLayeredEditor::_update_material() { - materials[0]->set_shader_param("layer", layer->get_value()); materials[2]->set_shader_param("layer", layer->get_value()); materials[texture->get_layered_type()]->set_shader_param("tex", texture->get_rid()); @@ -151,7 +146,6 @@ void TextureLayeredEditor::_make_shaders() { } void TextureLayeredEditor::_texture_rect_update_area() { - Size2 size = get_size(); int tex_width = texture->get_width() * size.height / texture->get_height(); int tex_height = size.height; @@ -175,14 +169,12 @@ void TextureLayeredEditor::_texture_rect_update_area() { } void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) { - if (!texture.is_null()) texture->remove_change_receptor(this); texture = p_texture; if (!texture.is_null()) { - if (shaders[0].is_null()) { _make_shaders(); } @@ -213,13 +205,11 @@ void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) { } void TextureLayeredEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_gui_input"), &TextureLayeredEditor::_gui_input); ClassDB::bind_method(D_METHOD("_layer_changed"), &TextureLayeredEditor::_layer_changed); } TextureLayeredEditor::TextureLayeredEditor() { - set_texture_repeat(TextureRepeat::TEXTURE_REPEAT_ENABLED); set_custom_minimum_size(Size2(1, 150)); texture_rect = memnew(Control); @@ -261,12 +251,10 @@ TextureLayeredEditor::~TextureLayeredEditor() { } // bool EditorInspectorPluginLayeredTexture::can_handle(Object *p_object) { - return Object::cast_to<TextureLayered>(p_object) != nullptr; } void EditorInspectorPluginLayeredTexture::parse_begin(Object *p_object) { - TextureLayered *texture = Object::cast_to<TextureLayered>(p_object); if (!texture) { return; @@ -279,7 +267,6 @@ void EditorInspectorPluginLayeredTexture::parse_begin(Object *p_object) { } TextureLayeredEditorPlugin::TextureLayeredEditorPlugin(EditorNode *p_node) { - Ref<EditorInspectorPluginLayeredTexture> plugin; plugin.instance(); add_inspector_plugin(plugin); diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h index 4339486061..a620b1443c 100644 --- a/editor/plugins/texture_layered_editor_plugin.h +++ b/editor/plugins/texture_layered_editor_plugin.h @@ -36,7 +36,6 @@ #include "scene/resources/shader.h" #include "scene/resources/texture.h" class TextureLayeredEditor : public Control { - GDCLASS(TextureLayeredEditor, Control); SpinBox *layer; @@ -83,7 +82,6 @@ public: }; class TextureLayeredEditorPlugin : public EditorPlugin { - GDCLASS(TextureLayeredEditorPlugin, EditorPlugin); public: diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 099c9ceb5d..7176e4aa19 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -152,7 +152,6 @@ void TextureRegionEditor::_region_draw() { }; Color color = get_theme_color("mono_color", "Editor"); for (int i = 0; i < 4; i++) { - int prev = (i + 3) % 4; int next = (i + 1) % 4; @@ -259,9 +258,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseButton> mb = p_input; if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_LEFT) { - if (mb->is_pressed()) { if (node_ninepatch || obj_styleBox.is_valid()) { edited_margin = -1; @@ -421,7 +418,6 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { } } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - if (drag) { drag = false; if (edited_margin >= 0) { @@ -448,15 +444,12 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseMotion> mm = p_input; if (mm.is_valid()) { - if (mm->get_button_mask() & BUTTON_MASK_MIDDLE || Input::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); vscroll->set_value(vscroll->get_value() - dragged.y); } else if (drag) { - if (edited_margin >= 0) { float new_margin = 0; if (edited_margin == 0) @@ -788,7 +781,6 @@ bool TextureRegionEditor::is_stylebox() { } bool TextureRegionEditor::is_atlas_texture() { - return atlas_tex.is_valid(); } @@ -842,7 +834,6 @@ void TextureRegionEditor::edit(Object *p_obj) { } void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) { - if (!is_visible()) return; if (p_prop == StringName("atlas") || p_prop == StringName("texture")) @@ -1063,7 +1054,6 @@ void TextureRegionEditorPlugin::make_visible(bool p_visible) { } Dictionary TextureRegionEditorPlugin::get_state() const { - Dictionary state; state["snap_offset"] = region_editor->snap_offset; state["snap_step"] = region_editor->snap_step; @@ -1073,7 +1063,6 @@ Dictionary TextureRegionEditorPlugin::get_state() const { } void TextureRegionEditorPlugin::set_state(const Dictionary &p_state) { - Dictionary state = p_state; if (state.has("snap_step")) { Vector2 s = state["snap_step"]; diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index c6cd648842..93da23fd50 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -45,7 +45,6 @@ */ class TextureRegionEditor : public VBoxContainer { - GDCLASS(TextureRegionEditor, VBoxContainer); enum SnapMode { diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index d9be2e32cb..90ef1e1507 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -36,14 +36,12 @@ #include "scene/gui/progress_bar.h" void ThemeEditor::edit(const Ref<Theme> &p_theme) { - theme = p_theme; main_panel->set_theme(p_theme); main_container->set_theme(p_theme); } void ThemeEditor::_propagate_redraw(Control *p_at) { - p_at->notification(NOTIFICATION_THEME_CHANGED); p_at->minimum_size_changed(); p_at->update(); @@ -55,25 +53,20 @@ void ThemeEditor::_propagate_redraw(Control *p_at) { } void ThemeEditor::_refresh_interval() { - _propagate_redraw(main_panel); _propagate_redraw(main_container); } void ThemeEditor::_type_menu_cbk(int p_option) { - type_edit->set_text(type_menu->get_popup()->get_item_text(p_option)); } void ThemeEditor::_name_menu_about_to_show() { - String fromtype = type_edit->get_text(); List<StringName> names; if (popup_mode == POPUP_ADD) { - switch (type_select->get_selected()) { - case 0: Theme::get_default()->get_icon_list(fromtype, &names); break; @@ -91,7 +84,6 @@ void ThemeEditor::_name_menu_about_to_show() { break; } } else if (popup_mode == POPUP_REMOVE) { - theme->get_icon_list(fromtype, &names); theme->get_stylebox_list(fromtype, &names); theme->get_font_list(fromtype, &names); @@ -102,21 +94,17 @@ void ThemeEditor::_name_menu_about_to_show() { name_menu->get_popup()->clear(); name_menu->get_popup()->set_size(Size2()); for (List<StringName>::Element *E = names.front(); E; E = E->next()) { - name_menu->get_popup()->add_item(E->get()); } } void ThemeEditor::_name_menu_cbk(int p_option) { - name_edit->set_text(name_menu->get_popup()->get_item_text(p_option)); } struct _TECategory { - template <class T> struct RefItem { - Ref<T> item; StringName name; bool operator<(const RefItem<T> &p) const { return item->get_instance_id() < p.item->get_instance_id(); } @@ -124,7 +112,6 @@ struct _TECategory { template <class T> struct Item { - T item; String name; bool operator<(const Item<T> &p) const { return name < p.name; } @@ -139,7 +126,6 @@ struct _TECategory { }; void ThemeEditor::_save_template_cbk(String fname) { - String filename = file_dialog->get_current_path(); Map<String, _TECategory> categories; @@ -153,7 +139,6 @@ void ThemeEditor::_save_template_cbk(String fname) { // Fill default theme. for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) { - _TECategory &tc = E->get(); List<StringName> stylebox_list; @@ -270,7 +255,6 @@ void ThemeEditor::_save_template_cbk(String fname) { // Write default theme. for (Map<String, _TECategory>::Element *E = categories.front(); E; E = E->next()) { - _TECategory &tc = E->get(); String underline = "; "; @@ -286,7 +270,6 @@ void ThemeEditor::_save_template_cbk(String fname) { file->store_line("\n; StyleBox Items:\n"); for (Set<_TECategory::RefItem<StyleBox>>::Element *F = tc.stylebox_items.front(); F; F = F->next()) { - file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -294,7 +277,6 @@ void ThemeEditor::_save_template_cbk(String fname) { file->store_line("\n; Font Items:\n"); for (Set<_TECategory::RefItem<Font>>::Element *F = tc.font_items.front(); F; F = F->next()) { - file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -302,7 +284,6 @@ void ThemeEditor::_save_template_cbk(String fname) { file->store_line("\n; Icon Items:\n"); for (Set<_TECategory::RefItem<Texture2D>>::Element *F = tc.icon_items.front(); F; F = F->next()) { - file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -310,7 +291,6 @@ void ThemeEditor::_save_template_cbk(String fname) { file->store_line("\n; Color Items:\n"); for (Set<_TECategory::Item<Color>>::Element *F = tc.color_items.front(); F; F = F->next()) { - file->store_line(E->key() + "." + F->get().name + " = default"); } @@ -318,7 +298,6 @@ void ThemeEditor::_save_template_cbk(String fname) { file->store_line("\n; Constant Items:\n"); for (Set<_TECategory::Item<int>>::Element *F = tc.constant_items.front(); F; F = F->next()) { - file->store_line(E->key() + "." + F->get().name + " = default"); } } @@ -328,12 +307,9 @@ void ThemeEditor::_save_template_cbk(String fname) { } void ThemeEditor::_dialog_cbk() { - switch (popup_mode) { case POPUP_ADD: { - switch (type_select->get_selected()) { - case 0: theme->set_icon(name_edit->get_text(), type_edit->get_text(), Ref<Texture2D>()); break; @@ -353,7 +329,6 @@ void ThemeEditor::_dialog_cbk() { } break; case POPUP_CLASS_ADD: { - StringName fromtype = type_edit->get_text(); List<StringName> names; @@ -395,7 +370,6 @@ void ThemeEditor::_dialog_cbk() { } break; case POPUP_REMOVE: { switch (type_select->get_selected()) { - case 0: theme->clear_icon(name_edit->get_text(), type_edit->get_text()); break; @@ -459,9 +433,7 @@ void ThemeEditor::_dialog_cbk() { } void ThemeEditor::_theme_menu_cbk(int p_option) { - if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) { - bool import = (p_option == POPUP_IMPORT_EDITOR_THEME); Ref<Theme> base_theme; @@ -473,7 +445,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { } { - List<StringName> types; base_theme->get_type_list(&types); @@ -555,7 +526,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { type_select->hide(); } else if (p_option == POPUP_REMOVE) { - add_del_dialog->set_title(TTR("Remove Item")); add_del_dialog->get_ok()->set_text(TTR("Remove")); add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE); @@ -563,7 +533,6 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme = theme; } else if (p_option == POPUP_CLASS_REMOVE) { - add_del_dialog->set_title(TTR("Remove All Items")); add_del_dialog->get_ok()->set_text(TTR("Remove All")); add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE); @@ -589,10 +558,8 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { List<StringName> new_types; theme->get_type_list(&new_types); for (List<StringName>::Element *F = new_types.front(); F; F = F->next()) { - bool found = false; for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - if (E->get() == F->get()) { found = true; break; @@ -606,13 +573,11 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { types.sort_custom<StringName::AlphCompare>(); for (List<StringName>::Element *E = types.front(); E; E = E->next()) { - type_menu->get_popup()->add_item(E->get()); } } void ThemeEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_PROCESS: { time_left -= get_process_delta_time(); @@ -631,7 +596,6 @@ void ThemeEditor::_bind_methods() { } ThemeEditor::ThemeEditor() { - time_left = 0; HBoxContainer *top_menu = memnew(HBoxContainer); @@ -901,7 +865,6 @@ ThemeEditor::ThemeEditor() { } void ThemeEditorPlugin::edit(Object *p_node) { - if (Object::cast_to<Theme>(p_node)) { theme_editor->edit(Object::cast_to<Theme>(p_node)); } else { @@ -910,12 +873,10 @@ void ThemeEditorPlugin::edit(Object *p_node) { } bool ThemeEditorPlugin::handles(Object *p_node) const { - return p_node->is_class("Theme"); } void ThemeEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { theme_editor->set_process(true); button->show(); @@ -930,7 +891,6 @@ void ThemeEditorPlugin::make_visible(bool p_visible) { } ThemeEditorPlugin::ThemeEditorPlugin(EditorNode *p_node) { - editor = p_node; theme_editor = memnew(ThemeEditor); theme_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index c51583593d..983bfb6b50 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -42,7 +42,6 @@ #include "editor/editor_node.h" class ThemeEditor : public VBoxContainer { - GDCLASS(ThemeEditor, VBoxContainer); Panel *main_panel; @@ -99,7 +98,6 @@ public: }; class ThemeEditorPlugin : public EditorPlugin { - GDCLASS(ThemeEditorPlugin, EditorPlugin); ThemeEditor *theme_editor; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index e22e0cc052..61eea6c15e 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -39,18 +39,14 @@ #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) { - case NOTIFICATION_PROCESS: { - if (bucket_queue.size()) { CanvasItemEditor::get_singleton()->update_viewport(); } @@ -58,13 +54,11 @@ void TileMapEditor::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { - get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed)); [[fallthrough]]; } case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - if (is_visible_in_tree()) { _update_palette(); } @@ -97,7 +91,6 @@ void TileMapEditor::_notification(int p_what) { } void TileMapEditor::_update_button_tool() { - ToolButton *tb[4] = { paint_button, bucket_fill_button, picker_button, select_button }; // Unpress all buttons for (int i = 0; i < 4; i++) { @@ -132,7 +125,6 @@ void TileMapEditor::_button_tool_select(int p_tool) { _update_button_tool(); switch (tool) { case TOOL_SELECTING: { - selection_active = false; } break; default: @@ -142,10 +134,8 @@ void TileMapEditor::_button_tool_select(int p_tool) { } void TileMapEditor::_menu_option(int p_option) { - switch (p_option) { case OPTION_COPY: { - _update_copydata(); if (selection_active) { @@ -155,7 +145,6 @@ void TileMapEditor::_menu_option(int p_option) { } } break; case OPTION_ERASE_SELECTION: { - if (!selection_active) return; @@ -169,7 +158,6 @@ void TileMapEditor::_menu_option(int p_option) { CanvasItemEditor::get_singleton()->update_viewport(); } break; case OPTION_FIX_INVALID: { - undo_redo->create_action(TTR("Fix Invalid Tiles")); undo_redo->add_undo_method(node, "set", "tile_data", node->get("tile_data")); node->fix_invalid_tiles(); @@ -178,7 +166,6 @@ void TileMapEditor::_menu_option(int p_option) { } break; case OPTION_CUT: { - if (selection_active) { _update_copydata(); @@ -206,19 +193,16 @@ void TileMapEditor::_palette_multi_selected(int index, bool selected) { } void TileMapEditor::_canvas_mouse_enter() { - mouse_over = true; CanvasItemEditor::get_singleton()->update_viewport(); } void TileMapEditor::_canvas_mouse_exit() { - mouse_over = false; CanvasItemEditor::get_singleton()->update_viewport(); } Vector<int> TileMapEditor::get_selected_tiles() const { - Vector<int> items = palette->get_selected_items(); if (items.size() == 0) { @@ -233,7 +217,6 @@ Vector<int> TileMapEditor::get_selected_tiles() const { } void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) { - palette->unselect_all(); for (int i = p_tiles.size() - 1; i >= 0; i--) { @@ -248,7 +231,6 @@ void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) { } Dictionary TileMapEditor::_create_cell_dictionary(int tile, bool flip_x, bool flip_y, bool transpose, Vector2 autotile_coord) { - Dictionary cell; cell["id"] = tile; @@ -261,7 +243,6 @@ Dictionary TileMapEditor::_create_cell_dictionary(int tile, bool flip_x, bool fl } void TileMapEditor::_create_set_cell_undo_redo(const Vector2 &p_vec, const CellOp &p_cell_old, const CellOp &p_cell_new) { - Dictionary cell_old = _create_cell_dictionary(p_cell_old.idx, p_cell_old.xf, p_cell_old.yf, p_cell_old.tr, p_cell_old.ac); Dictionary cell_new = _create_cell_dictionary(p_cell_new.idx, p_cell_new.xf, p_cell_new.yf, p_cell_new.tr, p_cell_new.ac); @@ -270,13 +251,11 @@ void TileMapEditor::_create_set_cell_undo_redo(const Vector2 &p_vec, const CellO } void TileMapEditor::_start_undo(const String &p_action) { - undo_data.clear(); undo_redo->create_action(p_action); } void TileMapEditor::_finish_undo() { - if (undo_data.size()) { for (Map<Point2i, CellOp>::Element *E = undo_data.front(); E; E = E->next()) { _create_set_cell_undo_redo(E->key(), E->get(), _get_op_from_cell(E->key())); @@ -289,7 +268,6 @@ void TileMapEditor::_finish_undo() { } void TileMapEditor::_set_cell(const Point2i &p_pos, Vector<int> p_values, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord) { - ERR_FAIL_COND(!node); if (p_values.size() == 0) @@ -360,7 +338,6 @@ void TileMapEditor::_priority_toggled(bool p_enabled) { } void TileMapEditor::_text_entered(const String &p_text) { - canvas_item_editor_viewport->grab_focus(); } @@ -369,14 +346,12 @@ void TileMapEditor::_text_changed(const String &p_text) { } void TileMapEditor::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; if (k.is_valid() && (k->get_keycode() == KEY_UP || k->get_keycode() == KEY_DOWN || k->get_keycode() == KEY_PAGEUP || k->get_keycode() == KEY_PAGEDOWN)) { - palette->call("_gui_input", k); search_box->accept_event(); } @@ -396,7 +371,6 @@ struct _PaletteEntry { } // namespace void TileMapEditor::_update_palette() { - if (!node) return; @@ -447,7 +421,6 @@ void TileMapEditor::_update_palette() { Vector<_PaletteEntry> entries; for (List<int>::Element *E = tiles.front(); E; E = E->next()) { - String name = tileset->tile_get_name(E->get()); if (name != "") { @@ -474,7 +447,6 @@ void TileMapEditor::_update_palette() { } for (int i = 0; i < entries.size(); i++) { - if (show_tile_names) { palette->add_item(entries[i].name); } else { @@ -526,7 +498,6 @@ void TileMapEditor::_update_palette() { } if (sel_tile != TileMap::INVALID_CELL && ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || (!priority_atlastile && tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE))) { - const Map<Vector2, uint32_t> &tiles2 = tileset->autotile_get_bitmask_map(sel_tile); Vector<Vector2> entries2; @@ -544,11 +515,9 @@ void TileMapEditor::_update_palette() { Ref<Texture2D> tex = tileset->tile_get_texture(sel_tile); for (int i = 0; i < entries2.size(); i++) { - manual_palette->add_item(String()); if (tex.is_valid()) { - Rect2 region = tileset->tile_get_region(sel_tile); int spacing = tileset->autotile_get_spacing(sel_tile); region.size = tileset->autotile_get_size(sel_tile); // !! @@ -583,7 +552,6 @@ void TileMapEditor::_update_palette() { } void TileMapEditor::_pick_tile(const Point2 &p_pos) { - int id = node->get_cell(p_pos.x, p_pos.y); if (id == TileMap::INVALID_CELL) @@ -612,7 +580,6 @@ void TileMapEditor::_pick_tile(const Point2 &p_pos) { } Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bool preview) { - int prev_id = node->get_cell(p_start.x, p_start.y); Vector<int> ids; ids.push_back(TileMap::INVALID_CELL); @@ -674,7 +641,6 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, bucket_queue.push_back(p_start); while (bucket_queue.size()) { - Point2i n = bucket_queue.front()->get(); bucket_queue.pop_front(); @@ -682,7 +648,6 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, continue; if (node->get_cell(n.x, n.y) == prev_id) { - if (preview) { int loc = (n.x - r.position.x) + (n.y - r.position.y) * r.get_size().x; if (bucket_cache_visited[loc]) @@ -712,7 +677,6 @@ Vector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool erase, } void TileMapEditor::_fill_points(const Vector<Vector2> &p_points, const Dictionary &p_op) { - int len = p_points.size(); const Vector2 *pr = p_points.ptr(); @@ -730,27 +694,22 @@ void TileMapEditor::_fill_points(const Vector<Vector2> &p_points, const Dictiona } void TileMapEditor::_erase_points(const Vector<Vector2> &p_points) { - int len = p_points.size(); const Vector2 *pr = p_points.ptr(); for (int i = 0; i < len; i++) { - _set_cell(pr[i], invalid_cell); } } void TileMapEditor::_select(const Point2i &p_from, const Point2i &p_to) { - Point2i begin = p_from; Point2i end = p_to; if (begin.x > end.x) { - SWAP(begin.x, end.x); } if (begin.y > end.y) { - SWAP(begin.y, end.y); } @@ -766,14 +725,12 @@ void TileMapEditor::_erase_selection() { for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { - _set_cell(Point2i(j, i), invalid_cell, false, false, false); } } } void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) { - Ref<Texture2D> t = node->get_tileset()->tile_get_texture(p_cell); if (t.is_null()) @@ -844,10 +801,8 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p if (compatibility_mode_enabled && !centered_texture) { if (node->get_tile_origin() == TileMap::TILE_ORIGIN_TOP_LEFT) { - rect.position += tile_ofs; } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_BOTTOM_LEFT) { - rect.position += tile_ofs; if (p_transpose) { @@ -863,7 +818,6 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p } } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) { - rect.position += tile_ofs; if (p_flip_h) @@ -894,7 +848,6 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p } void TileMapEditor::_draw_fill_preview(Control *p_viewport, int p_cell, const Point2i &p_point, bool p_flip_h, bool p_flip_v, bool p_transpose, const Point2i &p_autotile_coord, const Transform2D &p_xform) { - Vector<Vector2> points = _bucket_fill(p_point, false, true); const Vector2 *pr = points.ptr(); int len = points.size(); @@ -912,16 +865,13 @@ void TileMapEditor::_clear_bucket_cache() { } void TileMapEditor::_update_copydata() { - copydata.clear(); if (!selection_active) return; for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { - for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { - TileData tcd; tcd.cell = node->get_cell(j, i); @@ -939,7 +889,6 @@ void TileMapEditor::_update_copydata() { } static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) { - Vector<Point2i> points; float dx = ABS(x1 - x0); @@ -983,7 +932,6 @@ static inline Vector<Point2i> line(int x0, int x1, int y0, int y1) { } bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { - if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree() || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT) return false; @@ -994,16 +942,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid()) { if (mb->get_button_index() == BUTTON_LEFT) { - if (mb->is_pressed()) { - if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) return false; // Drag. if (tool == TOOL_NONE) { - if (mb->get_shift()) { - if (mb->get_command()) tool = TOOL_RECTANGLE_PAINT; else @@ -1029,20 +973,16 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (tool == TOOL_PAINTING) { - Vector<int> ids = get_selected_tiles(); if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) { - tool = TOOL_PAINTING; _start_undo(TTR("Paint TileMap")); } } else if (tool == TOOL_PICKING) { - _pick_tile(over_tile); } else if (tool == TOOL_SELECTING) { - selection_active = true; rectangle_begin = over_tile; } @@ -1053,27 +993,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } else { // Mousebutton was released. if (tool != TOOL_NONE) { - if (tool == TOOL_PAINTING) { - Vector<int> ids = get_selected_tiles(); if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) { - _set_cell(over_tile, ids, flip_h, flip_v, transpose); _finish_undo(); paint_undo.clear(); } } else if (tool == TOOL_LINE_PAINT) { - Vector<int> ids = get_selected_tiles(); if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) { - _start_undo(TTR("Line Draw")); for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - _set_cell(E->key(), ids, flip_h, flip_v, transpose); } _finish_undo(); @@ -1083,15 +1017,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_RECTANGLE_PAINT) { - Vector<int> ids = get_selected_tiles(); if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) { - _start_undo(TTR("Rectangle Paint")); for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { - _set_cell(Point2i(j, i), ids, flip_h, flip_v, transpose); } } @@ -1100,14 +1031,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { CanvasItemEditor::get_singleton()->update_viewport(); } } else if (tool == TOOL_PASTING) { - Point2 ofs = over_tile - rectangle.position; Vector<int> ids; _start_undo(TTR("Paste")); ids.push_back(0); for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) { - ids.write[0] = E->get().cell; _set_cell(E->get().pos + ofs, ids, E->get().flip_h, E->get().flip_v, E->get().transpose, E->get().autotile_coord); } @@ -1117,11 +1046,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; // We want to keep the Pasting tool. } else if (tool == TOOL_SELECTING) { - CanvasItemEditor::get_singleton()->update_viewport(); } else if (tool == TOOL_BUCKET) { - Vector<Vector2> points = _bucket_fill(over_tile); if (points.size() == 0) @@ -1153,11 +1080,8 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } } } else if (mb->get_button_index() == BUTTON_RIGHT) { - if (mb->is_pressed()) { - if (tool == TOOL_SELECTING || selection_active) { - tool = TOOL_NONE; selection_active = false; @@ -1168,7 +1092,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (tool == TOOL_PASTING) { - tool = TOOL_NONE; copydata.clear(); @@ -1179,7 +1102,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (tool == TOOL_NONE) { - paint_undo.clear(); Point2 local = node->world_to_map(xform_inv.xform(mb->get_position())); @@ -1195,7 +1117,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { selection_active = false; rectangle_begin = local; } else { - tool = TOOL_ERASING; _set_cell(local, invalid_cell); @@ -1207,7 +1128,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } else { if (tool == TOOL_ERASING || tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) { - _finish_undo(); if (tool == TOOL_RECTANGLE_ERASE || tool == TOOL_LINE_ERASE) { @@ -1220,7 +1140,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } else if (tool == TOOL_BUCKET) { - Vector<int> ids; ids.push_back(node->get_cell(over_tile.x, over_tile.y)); Dictionary pop; @@ -1248,12 +1167,10 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - Point2i new_over_tile = node->world_to_map(xform_inv.xform(mm->get_position())); Point2i old_over_tile = over_tile; if (new_over_tile != over_tile) { - over_tile = new_over_tile; CanvasItemEditor::get_singleton()->update_viewport(); } @@ -1267,14 +1184,12 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]"); if (tool == TOOL_PAINTING) { - // Paint using bresenham line to prevent holes in painting if the user moves fast. Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); Vector<int> ids = get_selected_tiles(); for (int i = 0; i < points.size(); ++i) { - Point2i pos = points[i]; if (!paint_undo.has(pos)) { @@ -1288,13 +1203,11 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (tool == TOOL_ERASING) { - // Erase using bresenham line to prevent holes in painting if the user moves fast. Vector<Point2i> points = line(old_over_tile.x, over_tile.x, old_over_tile.y, over_tile.y); for (int i = 0; i < points.size(); ++i) { - Point2i pos = points[i]; _set_cell(pos, invalid_cell); @@ -1304,23 +1217,19 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (tool == TOOL_SELECTING) { - _select(rectangle_begin, over_tile); return true; } if (tool == TOOL_LINE_PAINT || tool == TOOL_LINE_ERASE) { - Vector<int> ids = get_selected_tiles(); Vector<int> tmp_cell; bool erasing = (tool == TOOL_LINE_ERASE); tmp_cell.push_back(0); if (erasing && paint_undo.size()) { - for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - tmp_cell.write[0] = E->get().idx; _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr); } @@ -1329,11 +1238,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { paint_undo.clear(); if (ids.size() > 0 && ids[0] != TileMap::INVALID_CELL) { - Vector<Point2i> points = line(rectangle_begin.x, over_tile.x, rectangle_begin.y, over_tile.y); for (int i = 0; i < points.size(); i++) { - paint_undo[points[i]] = _get_op_from_cell(points[i]); if (erasing) @@ -1346,18 +1253,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } if (tool == TOOL_RECTANGLE_PAINT || tool == TOOL_RECTANGLE_ERASE) { - Vector<int> tmp_cell; tmp_cell.push_back(0); _select(rectangle_begin, over_tile); if (tool == TOOL_RECTANGLE_ERASE) { - if (paint_undo.size()) { - for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - tmp_cell.write[0] = E->get().idx; _set_cell(E->key(), tmp_cell, E->get().xf, E->get().yf, E->get().tr); } @@ -1367,7 +1270,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { - Point2i tile = Point2i(j, i); paint_undo[tile] = _get_op_from_cell(tile); @@ -1379,7 +1281,6 @@ 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)) { - _pick_tile(over_tile); return true; @@ -1389,7 +1290,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed()) { - if (last_tool == TOOL_NONE && tool == TOOL_PICKING && k->get_keycode() == KEY_SHIFT && k->get_command()) { // trying to draw a rectangle with the painting tool, so change to the correct tool tool = last_tool; @@ -1399,7 +1299,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } if (k->get_keycode() == KEY_ESCAPE) { - if (tool == TOOL_PASTING) copydata.clear(); else if (tool == TOOL_SELECTING || selection_active) @@ -1518,14 +1417,11 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } else if (k.is_valid()) { // Release event. if (tool == TOOL_NONE) { - if (k->get_keycode() == KEY_SHIFT && k->get_command()) { - tool = TOOL_PICKING; _update_button_tool(); } } else if (tool == TOOL_PICKING) { - #ifdef APPLE_STYLE_KEYS if (k->get_keycode() == KEY_META) { #else @@ -1543,7 +1439,6 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { } void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { - if (!node || CanvasItemEditor::get_singleton()->get_current_tool() != CanvasItemEditor::TOOL_SELECT) return; @@ -1561,11 +1456,9 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Rect2i si = aabb.grow(1.0); if (node->get_half_offset() != TileMap::HALF_OFFSET_X && node->get_half_offset() != TileMap::HALF_OFFSET_NEGATIVE_X) { - int max_lines = 2000; //avoid crash if size too small for (int i = (si.position.x) - 1; i <= (si.position.x + si.size.x); i++) { - Vector2 from = xform.xform(node->map_to_world(Vector2(i, si.position.y))); Vector2 to = xform.xform(node->map_to_world(Vector2(i, si.position.y + si.size.y + 1))); @@ -1575,13 +1468,10 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { break; } } else { - int max_lines = 10000; //avoid crash if size too small for (int i = (si.position.x) - 1; i <= (si.position.x + si.size.x); i++) { - for (int j = (si.position.y) - 1; j <= (si.position.y + si.size.y); j++) { - Vector2 ofs; if (ABS(j) & 1) { ofs = cell_xf[0] * (node->get_half_offset() == TileMap::HALF_OFFSET_X ? 0.5 : -0.5); @@ -1604,9 +1494,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { int max_lines = 10000; //avoid crash if size too small if (node->get_half_offset() != TileMap::HALF_OFFSET_Y && node->get_half_offset() != TileMap::HALF_OFFSET_NEGATIVE_Y) { - for (int i = (si.position.y) - 1; i <= (si.position.y + si.size.y); i++) { - Vector2 from = xform.xform(node->map_to_world(Vector2(si.position.x, i))); Vector2 to = xform.xform(node->map_to_world(Vector2(si.position.x + si.size.x + 1, i))); @@ -1617,11 +1505,8 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { break; } } else { - for (int i = (si.position.y) - 1; i <= (si.position.y + si.size.y); i++) { - for (int j = (si.position.x) - 1; j <= (si.position.x + si.size.x); j++) { - Vector2 ofs; if (ABS(j) & 1) { ofs = cell_xf[1] * (node->get_half_offset() == TileMap::HALF_OFFSET_Y ? 0.5 : -0.5); @@ -1643,7 +1528,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (selection_active) { - Vector<Vector2> points; points.push_back(xform.xform(node->map_to_world((rectangle.position)))); points.push_back(xform.xform(node->map_to_world((rectangle.position + Point2(rectangle.size.x + 1, 0))))); @@ -1654,7 +1538,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (mouse_over && node->get_tileset().is_valid()) { - Vector2 endpoints[4] = { node->map_to_world(over_tile, true), node->map_to_world((over_tile + Point2(1, 0)), true), @@ -1688,7 +1571,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } if (tool == TOOL_LINE_PAINT) { - if (paint_undo.empty()) return; @@ -1698,12 +1580,10 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { return; for (Map<Point2i, CellOp>::Element *E = paint_undo.front(); E; E = E->next()) { - _draw_cell(p_overlay, ids[0], E->key(), flip_h, flip_v, transpose, autotile_coord, xform); } } else if (tool == TOOL_RECTANGLE_PAINT) { - Vector<int> ids = get_selected_tiles(); if (ids.size() == 1 && ids[0] == TileMap::INVALID_CELL) @@ -1711,12 +1591,10 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { - _draw_cell(p_overlay, ids[0], Point2i(j, i), flip_h, flip_v, transpose, autotile_coord, xform); } } } else if (tool == TOOL_PASTING) { - if (copydata.empty()) return; @@ -1728,7 +1606,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { Point2 ofs = over_tile - rectangle.position; for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) { - if (!ts->has_tile(E->get().cell)) continue; @@ -1749,12 +1626,10 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { p_overlay->draw_colored_polygon(points, Color(0.2, 1.0, 0.8, 0.2)); } else if (tool == TOOL_BUCKET) { - Vector<int> tiles = get_selected_tiles(); _draw_fill_preview(p_overlay, tiles[0], over_tile, flip_h, flip_v, transpose, autotile_coord, xform); } else { - Vector<int> st = get_selected_tiles(); if (st.size() == 1 && st[0] == TileMap::INVALID_CELL) @@ -1766,7 +1641,6 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } void TileMapEditor::edit(Node *p_tile_map) { - search_box->set_text(""); if (!canvas_item_editor_viewport) { @@ -1776,7 +1650,6 @@ void TileMapEditor::edit(Node *p_tile_map) { if (node) node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed)); if (p_tile_map) { - node = Object::cast_to<TileMap>(p_tile_map); if (!canvas_item_editor_viewport->is_connected("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter))) canvas_item_editor_viewport->connect("mouse_entered", callable_mp(this, &TileMapEditor::_canvas_mouse_enter)); @@ -1803,7 +1676,6 @@ void TileMapEditor::edit(Node *p_tile_map) { } void TileMapEditor::_tileset_settings_changed() { - _update_palette(); CanvasItemEditor::get_singleton()->update_viewport(); } @@ -1817,7 +1689,6 @@ void TileMapEditor::_icon_size_changed(float p_value) { } void TileMapEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_fill_points"), &TileMapEditor::_fill_points); ClassDB::bind_method(D_METHOD("_erase_points"), &TileMapEditor::_erase_points); } @@ -1901,7 +1772,6 @@ void TileMapEditor::_clear_transform() { } TileMapEditor::TileMapEditor(EditorNode *p_editor) { - node = nullptr; manual_autotile = false; priority_atlastile = false; @@ -2112,9 +1982,7 @@ TileMapEditor::~TileMapEditor() { /////////////////////////////////////////////////////////////// void TileMapEditorPlugin::_notification(int p_what) { - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) { case 0: { // Left. CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0); @@ -2127,19 +1995,15 @@ void TileMapEditorPlugin::_notification(int p_what) { } void TileMapEditorPlugin::edit(Object *p_object) { - tile_map_editor->edit(Object::cast_to<Node>(p_object)); } bool TileMapEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("TileMap"); } void TileMapEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { - tile_map_editor->show(); tile_map_editor->get_toolbar()->show(); tile_map_editor->get_toolbar_right()->show(); @@ -2150,7 +2014,6 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { // Change to TOOL_SELECT when TileMap node is selected, to prevent accidental movement. CanvasItemEditor::get_singleton()->set_current_tool(CanvasItemEditor::TOOL_SELECT); } else { - tile_map_editor->hide(); tile_map_editor->get_toolbar()->hide(); tile_map_editor->get_toolbar_right()->hide(); @@ -2160,7 +2023,6 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { } TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { - EDITOR_DEF("editors/tile_map/preview_size", 64); EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8); EDITOR_DEF("editors/tile_map/show_tile_names", true); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index 28b0e9b6db..5f82d7bfb8 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -41,7 +41,6 @@ #include "scene/gui/tool_button.h" class TileMapEditor : public VBoxContainer { - GDCLASS(TileMapEditor, VBoxContainer); enum Tool { @@ -221,7 +220,6 @@ public: }; class TileMapEditorPlugin : public EditorPlugin { - GDCLASS(TileMapEditorPlugin, EditorPlugin); TileMapEditor *tile_map_editor; diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b0d325efc1..e096ed933e 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -38,7 +38,6 @@ #include "scene/2d/sprite_2d.h" void TileSetEditor::edit(const Ref<TileSet> &p_tileset) { - tileset = p_tileset; tileset->add_change_receptor(this); @@ -48,9 +47,7 @@ void TileSetEditor::edit(const Ref<TileSet> &p_tileset) { } void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { - for (int i = 0; i < p_node->get_child_count(); i++) { - Node *child = p_node->get_child(i); if (!Object::cast_to<Sprite2D>(child)) { @@ -71,7 +68,6 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { int id = p_library->find_tile_by_name(mi->get_name()); if (id < 0) { - id = p_library->get_last_unused_tile_id(); p_library->create_tile(id); p_library->tile_set_name(id, mi->get_name()); @@ -106,7 +102,6 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { bool found_collisions = false; for (int j = 0; j < mi->get_child_count(); j++) { - Node *child2 = mi->get_child(j); if (Object::cast_to<NavigationRegion2D>(child2)) @@ -135,7 +130,6 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { shape_transform[2] -= phys_offset; for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref<Shape2D> shape = sb->shape_owner_get_shape(E->get(), k); TileSet::ShapeData shape_data; shape_data.shape = shape; @@ -160,7 +154,6 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) { } void TileSetEditor::_import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge) { - if (!p_merge) p_library->clear(); @@ -168,23 +161,19 @@ void TileSetEditor::_import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_ } void TileSetEditor::_undo_redo_import_scene(Node *p_scene, bool p_merge) { - _import_scene(p_scene, tileset, p_merge); } Error TileSetEditor::update_library_file(Node *p_base_scene, Ref<TileSet> ml, bool p_merge) { - _import_scene(p_base_scene, ml, p_merge); return OK; } Variant TileSetEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - return false; } bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type")) @@ -199,13 +188,11 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat Ref<Texture2D> texture = r; if (texture.is_valid()) { - return true; } } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; if (files.size() == 0) @@ -226,7 +213,6 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat } void TileSetEditor::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; @@ -251,7 +237,6 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; _on_textures_added(files); @@ -259,7 +244,6 @@ void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, C } void TileSetEditor::_bind_methods() { - ClassDB::bind_method("_undo_redo_import_scene", &TileSetEditor::_undo_redo_import_scene); ClassDB::bind_method("_on_workspace_process", &TileSetEditor::_on_workspace_process); // Still used by some connect_compat. ClassDB::bind_method("_set_snap_step", &TileSetEditor::_set_snap_step); @@ -281,15 +265,12 @@ void TileSetEditor::_bind_methods() { } void TileSetEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: { - 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_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")); @@ -331,7 +312,6 @@ void TileSetEditor::_notification(int p_what) { } TileSetEditor::TileSetEditor(EditorNode *p_editor) { - editor = p_editor; undo_redo = EditorNode::get_undo_redo(); current_tile = -1; @@ -626,7 +606,6 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { ResourceLoader::get_recognized_extensions_for_type("Texture2D", &extensions); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - texture_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } add_child(texture_dialog); @@ -663,12 +642,10 @@ void TileSetEditor::_on_tileset_toolbar_button_pressed(int p_index) { } } break; case TOOL_TILESET_CREATE_SCENE: { - cd->set_text(TTR("Create from scene? This will overwrite all current tiles.")); cd->popup_centered(Size2(300, 60)); } break; case TOOL_TILESET_MERGE_SCENE: { - cd->set_text(TTR("Merge from scene?")); cd->popup_centered(Size2(300, 60)); } break; @@ -696,7 +673,6 @@ void TileSetEditor::_on_tileset_toolbar_confirm() { } break; case TOOL_TILESET_MERGE_SCENE: case TOOL_TILESET_CREATE_SCENE: { - EditorNode *en = editor; Node *scene = en->get_edited_scene(); if (!scene) @@ -895,7 +871,6 @@ void TileSetEditor::_on_workspace_mode_changed(int p_workspace_mode) { } void TileSetEditor::_on_workspace_draw() { - if (tileset.is_null() || !get_current_texture().is_valid()) return; @@ -1113,7 +1088,6 @@ 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 (!tile_names_visible) { tile_names_visible = true; @@ -1126,7 +1100,6 @@ void TileSetEditor::_on_workspace_process() { } void TileSetEditor::_on_workspace_overlay_draw() { - if (!tileset.is_valid() || !get_current_texture().is_valid()) return; @@ -1202,7 +1175,6 @@ bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_ } void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { - if (tileset.is_null() || !get_current_texture().is_valid()) return; @@ -1658,7 +1630,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { pos = snap_point(pos); if (creating_shape) { if (current_shape.size() > 2) { - if (is_within_grabbing_distance_of_first_point(mb->get_position(), grab_threshold)) { close_shape(shape_anchor); workspace->update(); @@ -1708,7 +1679,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) { } } else if (!mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { if (creating_shape) { - // if the first two corners are within grabbing distance of one another, expand the rect to fill the tile if (is_within_grabbing_distance_of_first_point(current_shape[1], grab_threshold)) { current_shape.set(0, snap_point(shape_anchor)); @@ -2404,7 +2374,6 @@ void TileSetEditor::_zoom_reset() { } void TileSetEditor::draw_highlight_current_tile() { - Color shadow_color = Color(0.3, 0.3, 0.3, 0.3); if ((workspace_mode == WORKSPACE_EDIT && get_current_tile() >= 0) || !edited_region.has_no_area()) { Rect2 region; @@ -2429,7 +2398,6 @@ void TileSetEditor::draw_highlight_current_tile() { } void TileSetEditor::draw_highlight_subtile(Vector2 coord, const Vector<Vector2> &other_highlighted) { - Color shadow_color = Color(0.3, 0.3, 0.3, 0.3); Vector2 size = tileset->autotile_get_size(get_current_tile()); int spacing = tileset->autotile_get_spacing(get_current_tile()); @@ -2579,7 +2547,6 @@ void TileSetEditor::draw_grid_snap() { } void TileSetEditor::draw_polygon_shapes() { - int t_id = get_current_tile(); if (t_id < 0) return; @@ -2848,7 +2815,6 @@ void TileSetEditor::draw_polygon_shapes() { } void TileSetEditor::close_shape(const Vector2 &shape_anchor) { - creating_shape = false; if (edit_mode == EDITMODE_COLLISION) { @@ -3137,7 +3103,6 @@ void TileSetEditor::update_texture_list() { } void TileSetEditor::update_texture_list_icon() { - for (int current_idx = 0; current_idx < texture_list->get_item_count(); current_idx++) { RID rid = texture_list->get_item_metadata(current_idx); texture_list->set_item_icon(current_idx, texture_map[rid]); @@ -3148,7 +3113,6 @@ void TileSetEditor::update_texture_list_icon() { } void TileSetEditor::update_workspace_tile_mode() { - if (!get_current_texture().is_valid()) { tool_workspacemode[WORKSPACE_EDIT]->set_pressed(true); workspace_mode = WORKSPACE_EDIT; @@ -3316,7 +3280,6 @@ Ref<Texture2D> TileSetEditor::get_current_texture() { } void TilesetEditorContext::set_tileset(const Ref<TileSet> &p_tileset) { - tileset = p_tileset; } @@ -3326,7 +3289,6 @@ void TilesetEditorContext::set_snap_options_visible(bool p_visible) { } bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name.operator String(); if (name == "options_offset") { @@ -3392,7 +3354,6 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value } bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name.operator String(); bool v = false; @@ -3458,7 +3419,6 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const } void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const { - if (snap_options_visible) { p_list->push_back(PropertyInfo(Variant::NIL, "Snap Options", PROPERTY_HINT_NONE, "options_", PROPERTY_USAGE_GROUP)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "options_offset")); @@ -3507,25 +3467,21 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const } void TilesetEditorContext::_bind_methods() { - ClassDB::bind_method("_hide_script_from_inspector", &TilesetEditorContext::_hide_script_from_inspector); } TilesetEditorContext::TilesetEditorContext(TileSetEditor *p_tileset_editor) { - tileset_editor = p_tileset_editor; snap_options_visible = false; } void TileSetEditorPlugin::edit(Object *p_node) { - if (Object::cast_to<TileSet>(p_node)) { tileset_editor->edit(Object::cast_to<TileSet>(p_node)); } } bool TileSetEditorPlugin::handles(Object *p_node) const { - return p_node->is_class("TileSet") || p_node->is_class("TilesetEditorContext"); } @@ -3542,7 +3498,6 @@ void TileSetEditorPlugin::make_visible(bool p_visible) { } Dictionary TileSetEditorPlugin::get_state() const { - Dictionary state; state["snap_offset"] = tileset_editor->snap_offset; state["snap_step"] = tileset_editor->snap_step; @@ -3554,7 +3509,6 @@ Dictionary TileSetEditorPlugin::get_state() const { } void TileSetEditorPlugin::set_state(const Dictionary &p_state) { - Dictionary state = p_state; if (state.has("snap_step")) { tileset_editor->_set_snap_step(state["snap_step"]); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index 53f8e8c4d6..827325cfd7 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -41,7 +41,6 @@ class TilesetEditorContext; class TileSetEditor : public HSplitContainer { - friend class TileSetEditorPlugin; friend class TilesetEditorContext; @@ -252,7 +251,6 @@ private: }; class TilesetEditorContext : public Object { - friend class TileSetEditor; GDCLASS(TilesetEditorContext, Object); @@ -278,7 +276,6 @@ public: }; class TileSetEditorPlugin : public EditorPlugin { - GDCLASS(TileSetEditorPlugin, EditorPlugin); TileSetEditor *tileset_editor; diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index fe8392593b..a1436e123d 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -38,7 +38,6 @@ VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr; void VersionControlEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("popup_vcs_set_up_dialog"), &VersionControlEditorPlugin::popup_vcs_set_up_dialog); // Used to track the status of files in the staging area @@ -50,20 +49,16 @@ void VersionControlEditorPlugin::_bind_methods() { } void VersionControlEditorPlugin::_selected_a_vcs(int p_id) { - List<StringName> available_addons = get_available_vcs_names(); const StringName selected_vcs = set_up_choice->get_item_text(p_id); } void VersionControlEditorPlugin::_populate_available_vcs_names() { - static bool called = false; if (!called) { - List<StringName> available_addons = get_available_vcs_names(); for (int i = 0; i < available_addons.size(); i++) { - set_up_choice->add_item(available_addons[i]); } @@ -72,16 +67,13 @@ void VersionControlEditorPlugin::_populate_available_vcs_names() { } VersionControlEditorPlugin *VersionControlEditorPlugin::get_singleton() { - return singleton ? singleton : memnew(VersionControlEditorPlugin); } void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) { - fetch_available_vcs_addon_names(); List<StringName> available_addons = get_available_vcs_names(); if (available_addons.size() >= 1) { - Size2 popup_size = Size2(400, 100); Size2 window_size = p_gui_base->get_viewport_rect().size; popup_size.x = MIN(window_size.x * 0.5, popup_size.x); @@ -91,13 +83,11 @@ void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_ba set_up_dialog->popup_centered_clamped(popup_size * EDSCALE); } else { - EditorNode::get_singleton()->show_warning(TTR("No VCS addons are available."), TTR("Error")); } } void VersionControlEditorPlugin::_initialize_vcs() { - register_editor(); ERR_FAIL_COND_MSG(EditorVCSInterface::get_singleton(), EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active"); @@ -129,18 +119,14 @@ void VersionControlEditorPlugin::_initialize_vcs() { } void VersionControlEditorPlugin::_send_commit_msg() { - String msg = commit_message->get_text(); if (msg == "") { - commit_status->set_text(TTR("No commit message was provided")); return; } if (EditorVCSInterface::get_singleton()) { - if (staged_files_count == 0) { - commit_status->set_text(TTR("No files added to stage")); return; } @@ -150,7 +136,6 @@ void VersionControlEditorPlugin::_send_commit_msg() { commit_message->set_text(""); version_control_dock_button->set_pressed(false); } else { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); } @@ -160,20 +145,16 @@ void VersionControlEditorPlugin::_send_commit_msg() { } void VersionControlEditorPlugin::_refresh_stage_area() { - if (EditorVCSInterface::get_singleton()) { - staged_files_count = 0; clear_stage_area(); Dictionary modified_file_paths = EditorVCSInterface::get_singleton()->get_modified_files_data(); String file_path; 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, nullptr, true); if (!found) { - ChangeType change_index = (ChangeType)(int)modified_file_paths.get_value_at_index(i); String change_text = file_path + " (" + change_type_to_strings[change_index] + ")"; Color &change_color = change_type_to_color[change_index]; @@ -185,24 +166,19 @@ void VersionControlEditorPlugin::_refresh_stage_area() { new_item->set_checked(0, true); new_item->set_editable(0, true); } else { - if (found->get_metadata(0) == diff_file_name->get_text()) { - _refresh_file_diff(); } } commit_status->set_text("New changes detected"); } } else { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); } } void VersionControlEditorPlugin::_stage_selected() { - if (!EditorVCSInterface::get_singleton()) { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); return; } @@ -210,17 +186,13 @@ void VersionControlEditorPlugin::_stage_selected() { staged_files_count = 0; TreeItem *root = stage_files->get_root(); if (root) { - TreeItem *file_entry = root->get_children(); while (file_entry) { - if (file_entry->is_checked(0)) { - EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); staged_files_count++; } else { - EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); } @@ -233,9 +205,7 @@ void VersionControlEditorPlugin::_stage_selected() { } void VersionControlEditorPlugin::_stage_all() { - if (!EditorVCSInterface::get_singleton()) { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); return; } @@ -243,10 +213,8 @@ void VersionControlEditorPlugin::_stage_all() { staged_files_count = 0; TreeItem *root = stage_files->get_root(); if (root) { - TreeItem *file_entry = root->get_children(); while (file_entry) { - EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); file_entry->set_checked(0, true); @@ -260,7 +228,6 @@ void VersionControlEditorPlugin::_stage_all() { } void VersionControlEditorPlugin::_view_file_diff() { - version_control_dock_button->set_pressed(true); String file_path = stage_files->get_selected()->get_metadata(0); @@ -269,7 +236,6 @@ void VersionControlEditorPlugin::_view_file_diff() { } void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { - Array diff_content = EditorVCSInterface::get_singleton()->get_file_diff(p_file_path); diff_file_name->set_text(p_file_path); @@ -277,17 +243,13 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { diff->clear(); 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_theme_color("success_color", "Editor")); } else if (line_result["status"] == "-") { - 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_theme_color("font_color", "Label")); } @@ -299,42 +261,33 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { } void VersionControlEditorPlugin::_refresh_file_diff() { - String open_file = diff_file_name->get_text(); if (open_file != "") { - _display_file_diff(diff_file_name->get_text()); } } void VersionControlEditorPlugin::_clear_file_diff() { - diff->clear(); diff_file_name->set_text(""); version_control_dock_button->set_pressed(false); } void VersionControlEditorPlugin::_update_stage_status() { - String status; if (staged_files_count == 1) { - status = "Stage contains 1 file"; } else { - status = "Stage contains " + String::num_int64(staged_files_count) + " files"; } commit_status->set_text(status); } void VersionControlEditorPlugin::_update_commit_status() { - String status; if (staged_files_count == 1) { - status = "Committed 1 file"; } else { - status = "Committed " + String::num_int64(staged_files_count) + " files "; } commit_status->set_text(status); @@ -342,9 +295,7 @@ void VersionControlEditorPlugin::_update_commit_status() { } void VersionControlEditorPlugin::register_editor() { - if (!EditorVCSInterface::get_singleton()) { - EditorNode::get_singleton()->add_control_to_dock(EditorNode::DOCK_SLOT_RIGHT_UL, version_commit_dock); TabContainer *dock_vbc = (TabContainer *)version_commit_dock->get_parent_control(); dock_vbc->set_tab_title(version_commit_dock->get_index(), TTR("Commit")); @@ -355,30 +306,25 @@ void VersionControlEditorPlugin::register_editor() { } void VersionControlEditorPlugin::fetch_available_vcs_addon_names() { - List<StringName> global_classes; ScriptServer::get_global_class_list(&global_classes); for (int i = 0; i != global_classes.size(); i++) { - String path = ScriptServer::get_global_class_path(global_classes[i]); Ref<Script> script = ResourceLoader::load(path); ERR_FAIL_COND(script.is_null()); if (script->get_instance_base_type() == "EditorVCSInterface") { - available_addons.push_back(global_classes[i]); } } } void VersionControlEditorPlugin::clear_stage_area() { - stage_files->get_root()->clear_children(); } void VersionControlEditorPlugin::shut_down() { - if (EditorVCSInterface::get_singleton()) { if (EditorFileSystem::get_singleton()->is_connected("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area))) { EditorFileSystem::get_singleton()->disconnect("filesystem_changed", callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); @@ -393,17 +339,14 @@ void VersionControlEditorPlugin::shut_down() { } bool VersionControlEditorPlugin::is_vcs_initialized() const { - return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->is_vcs_initialized() : false; } const String VersionControlEditorPlugin::get_vcs_name() const { - return EditorVCSInterface::get_singleton() ? EditorVCSInterface::get_singleton()->get_vcs_name() : ""; } VersionControlEditorPlugin::VersionControlEditorPlugin() { - singleton = this; staged_files_count = 0; @@ -570,7 +513,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { } VersionControlEditorPlugin::~VersionControlEditorPlugin() { - shut_down(); memdelete(version_control_dock); memdelete(version_commit_dock); diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h index 4a98c8580e..664e38d65f 100644 --- a/editor/plugins/version_control_editor_plugin.h +++ b/editor/plugins/version_control_editor_plugin.h @@ -39,7 +39,6 @@ #include "scene/gui/tree.h" class VersionControlEditorPlugin : public EditorPlugin { - GDCLASS(VersionControlEditorPlugin, EditorPlugin) public: diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 07251ad7ad..2cf18a4d13 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -48,7 +48,6 @@ #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); } @@ -56,14 +55,12 @@ Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_res } void VisualShaderNodePlugin::_bind_methods() { - BIND_VMETHOD(MethodInfo(Variant::OBJECT, "create_editor", PropertyInfo(Variant::OBJECT, "parent_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::OBJECT, "for_node", PROPERTY_HINT_RESOURCE_TYPE, "VisualShaderNode"))); } /////////////////// void VisualShaderEditor::edit(VisualShader *p_visual_shader) { - bool changed = false; if (p_visual_shader) { if (visual_shader.is_null()) { @@ -125,7 +122,6 @@ void VisualShaderEditor::clear_custom_types() { } void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) { - ERR_FAIL_COND(!p_name.is_valid_identifier()); ERR_FAIL_COND(!p_script.is_valid()); @@ -166,11 +162,9 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> } bool VisualShaderEditor::_is_available(int p_mode) { - int current_mode = edit_type->get_selected(); if (p_mode != -1) { - switch (current_mode) { case VisualShader::TYPE_VERTEX: current_mode = 1; @@ -215,7 +209,6 @@ void VisualShaderEditor::update_custom_nodes() { Dictionary added; for (int i = 0; i < class_list.size(); i++) { if (ScriptServer::get_global_class_native_base(class_list[i]) == "VisualShaderNodeCustom") { - String script_path = ScriptServer::get_global_class_path(class_list[i]); Ref<Resource> res = ResourceLoader::load(script_path); ERR_FAIL_COND(res.is_null()); @@ -285,7 +278,6 @@ void VisualShaderEditor::update_custom_nodes() { keys.sort(); for (int i = 0; i < keys.size(); i++) { - const Variant &key = keys.get(i); const Dictionary &value = (Dictionary)added[key]; @@ -301,7 +293,6 @@ String VisualShaderEditor::_get_description(int p_idx) { } void VisualShaderEditor::_update_options_menu() { - node_desc->set_text(""); members_dialog->get_ok()->set_disabled(true); @@ -411,12 +402,10 @@ void VisualShaderEditor::_update_options_menu() { } Size2 VisualShaderEditor::get_minimum_size() const { - return Size2(10, 200); } void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) { - Button *button = Object::cast_to<Button>(obj); if (!button) return; @@ -435,7 +424,6 @@ 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_theme_stylebox("frame", "GraphNode"); Color c = sb->get_border_color(); @@ -459,7 +447,6 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) { } void VisualShaderEditor::_update_graph() { - if (updating) return; @@ -472,7 +459,6 @@ void VisualShaderEditor::_update_graph() { graph->clear_connections(); //erase all nodes for (int i = 0; i < graph->get_child_count(); i++) { - if (Object::cast_to<GraphNode>(graph->get_child(i))) { Node *node = graph->get_child(i); graph->remove_child(node); @@ -500,7 +486,6 @@ void VisualShaderEditor::_update_graph() { Control *offset; for (int n_i = 0; n_i < nodes.size(); n_i++) { - Vector2 position = visual_shader->get_node_position(type, nodes[n_i]); Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]); @@ -592,7 +577,6 @@ void VisualShaderEditor::_update_graph() { if (custom_editor && !float_uniform.is_valid() && !int_uniform.is_valid() && !vec3_uniform.is_valid() && !bool_uniform.is_valid() && !transform_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) { //will be embedded in first port } else if (custom_editor) { - port_offset++; node->add_child(custom_editor); if (color_uniform.is_valid()) { @@ -606,7 +590,6 @@ void VisualShaderEditor::_update_graph() { } if (is_group) { - offset = memnew(Control); offset->set_custom_minimum_size(Size2(0, 6 * EDSCALE)); node->add_child(offset); @@ -631,7 +614,6 @@ void VisualShaderEditor::_update_graph() { } for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) { - if (vsnode->is_port_separator(i)) { node->add_child(memnew(HSeparator)); port_offset++; @@ -674,7 +656,6 @@ void VisualShaderEditor::_update_graph() { button->connect("pressed", callable_mp(this, &VisualShaderEditor::_edit_port_default_input), varray(button, nodes[n_i], i)); switch (default_value.get_type()) { - case Variant::COLOR: { button->set_custom_minimum_size(Size2(30, 0) * EDSCALE); button->connect("draw", callable_mp(this, &VisualShaderEditor::_draw_color_over_button), varray(button, default_value)); @@ -699,9 +680,7 @@ void VisualShaderEditor::_update_graph() { hb->add_child(custom_editor); custom_editor->set_h_size_flags(SIZE_EXPAND_FILL); } else { - if (valid_left) { - if (is_group) { OptionButton *type_box = memnew(OptionButton); hb->add_child(type_box); @@ -729,14 +708,12 @@ void VisualShaderEditor::_update_graph() { remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED); hb->add_child(remove_btn); } else { - Label *label = memnew(Label); label->set_text(name_left); 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_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit")); @@ -840,7 +817,6 @@ void VisualShaderEditor::_update_graph() { } if (is_expression) { - TextEdit *expression_box = memnew(TextEdit); expression_node->set_control(expression_box, 0); node->add_child(expression_box); @@ -855,7 +831,6 @@ void VisualShaderEditor::_update_graph() { 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); } @@ -881,7 +856,6 @@ void VisualShaderEditor::_update_graph() { } for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) { - int from = E->get().from_node; int from_idx = E->get().from_port; int to = E->get().to_node; @@ -892,7 +866,6 @@ void VisualShaderEditor::_update_graph() { } void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type, const String &p_name) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -910,7 +883,6 @@ void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type } void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_type, const String &p_name) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -928,7 +900,6 @@ void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_typ } void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -946,7 +917,6 @@ void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_p } void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -964,7 +934,6 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_ } void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id); @@ -979,7 +948,6 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *l } void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id); @@ -994,7 +962,6 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object * } void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1006,7 +973,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; int from_port = E->get().from_port; int to_node = E->get().to_node; @@ -1039,7 +1005,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) { } void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1051,7 +1016,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { - int from_node = E->get().from_node; int from_port = E->get().from_port; int to_node = E->get().to_node; @@ -1084,7 +1048,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) { } void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1112,7 +1075,6 @@ void VisualShaderEditor::_rebuild() { } void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p_size) { - VisualShader::Type type = VisualShader::Type(p_type); Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1159,7 +1121,6 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p } void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, int p_node) { - VisualShader::Type type = VisualShader::Type(p_type); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1173,7 +1134,6 @@ void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, in } void VisualShaderEditor::_preview_select_port(int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node); if (node.is_null()) { @@ -1192,7 +1152,6 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) { } void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_edit, int p_node_id) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id); @@ -1213,13 +1172,11 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e } void VisualShaderEditor::_line_edit_focus_out(Object *line_edit, int p_node_id) { - String text = Object::cast_to<LineEdit>(line_edit)->get_text(); _line_edit_changed(text, line_edit, p_node_id); } void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id); @@ -1267,7 +1224,6 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, } void VisualShaderEditor::_port_edited() { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Variant value = property_editor->get_variant(); @@ -1285,7 +1241,6 @@ void VisualShaderEditor::_port_edited() { } void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, int p_port) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNode> vsn = visual_shader->get_node(type, p_node); @@ -1301,7 +1256,6 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, } void VisualShaderEditor::_add_custom_node(const String &p_path) { - int idx = -1; for (int i = custom_node_option_idx; i < add_options.size(); i++) { @@ -1323,7 +1277,6 @@ 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(), nullptr); Ref<VisualShaderNode> vsnode; @@ -1342,7 +1295,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { } if (p_op_idx != -1) { - VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsn); if (input) { @@ -1463,7 +1415,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { if (to_node != -1 && to_slot != -1) { if (vsnode->get_output_port_count() > 0) { - int _from_node = id_to_use; int _from_slot = 0; @@ -1474,7 +1425,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { } } else if (from_node != -1 && from_slot != -1) { if (vsnode->get_input_port_count() > 0) { - int _to_node = id_to_use; int _to_slot = 0; @@ -1492,7 +1442,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) { } void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); updating = true; @@ -1506,7 +1455,6 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t } void VisualShaderEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); int from = p_from.to_int(); @@ -1536,7 +1484,6 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in } void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) { - graph->disconnect_node(p_from, p_from_index, p_to, p_to_index); VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); @@ -1567,7 +1514,6 @@ void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slo } void VisualShaderEditor::_delete_request(int which) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); Ref<VisualShaderNode> node = Ref<VisualShaderNode>(visual_shader->get_node(type, which)); @@ -1607,7 +1553,6 @@ void VisualShaderEditor::_delete_request(int which) { } void VisualShaderEditor::_node_selected(Object *p_node) { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); GraphNode *gn = Object::cast_to<GraphNode>(p_node); @@ -1623,7 +1568,6 @@ void VisualShaderEditor::_node_selected(Object *p_node) { } void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { @@ -1652,7 +1596,6 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) { } void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) { - if (at_mouse_pos) { saved_node_pos_dirty = true; saved_node_pos = graph->get_local_mouse_position(); @@ -1688,7 +1631,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { ie->get_keycode() == KEY_DOWN || ie->get_keycode() == KEY_ENTER || ie->get_keycode() == KEY_KP_ENTER)) { - members->call("_gui_input", ie); node_filter->accept_event(); } @@ -1696,7 +1638,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { void VisualShaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - node_filter->set_clear_button_enabled(true); // collapse tree by default @@ -1723,7 +1664,6 @@ void VisualShaderEditor::_notification(int p_what) { } if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - highend_label->set_modulate(get_theme_color("vulkan_color", "Editor")); error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); @@ -1743,7 +1683,6 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_theme_color_override("background_color", background_color); for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) { - preview_text->add_keyword_color(E->get(), keyword_color); } @@ -1786,7 +1725,6 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded) VisualShader::Type type = (VisualShader::Type)p_type; for (int i = 0; i < graph->get_child_count(); i++) { - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); if (gn) { int id = String(gn->get_name()).to_int(); @@ -1802,14 +1740,12 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded) } void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int> &r_excluded) { - VisualShader::Type type = (VisualShader::Type)p_type; selection_center.x = 0.0f; selection_center.y = 0.0f; for (int i = 0; i < graph->get_child_count(); i++) { - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); if (gn) { int id = String(gn->get_name()).to_int(); @@ -1832,7 +1768,6 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int } void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<int> &r_nodes, Set<int> &r_excluded, const Vector2 &p_offset, bool p_select) { - VisualShader::Type type = (VisualShader::Type)p_type; VisualShader::Type pasted_type = (VisualShader::Type)p_pasted_type; @@ -1842,7 +1777,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in Set<int> unsupported_set; for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) { - connection_remap[E->get()] = id_from; Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get()); @@ -1900,7 +1834,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in if (p_select) { // reselect duplicated nodes by excluding the other ones for (int i = 0; i < graph->get_child_count(); i++) { - GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i)); if (gn) { int id = String(gn->get_name()).to_int(); @@ -1915,13 +1848,11 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in } void VisualShaderEditor::_clear_buffer() { - copy_nodes_buffer.clear(); copy_nodes_excluded_buffer.clear(); } void VisualShaderEditor::_duplicate_nodes() { - int type = edit_type->get_selected(); List<int> nodes; @@ -1938,7 +1869,6 @@ void VisualShaderEditor::_duplicate_nodes() { } void VisualShaderEditor::_copy_nodes() { - copy_type = edit_type->get_selected(); _clear_buffer(); @@ -1947,7 +1877,6 @@ void VisualShaderEditor::_copy_nodes() { } void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) { - if (copy_nodes_buffer.empty()) return; @@ -1970,7 +1899,6 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 } void VisualShaderEditor::_delete_nodes() { - VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); List<int> to_erase; @@ -1989,7 +1917,6 @@ void VisualShaderEditor::_delete_nodes() { undo_redo->create_action(TTR("Delete Nodes")); for (List<int>::Element *F = to_erase.front(); F; F = F->next()) { - Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get()); undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get()); @@ -2020,7 +1947,6 @@ void VisualShaderEditor::_delete_nodes() { for (List<int>::Element *F = to_erase.front(); F; F = F->next()) { for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) { if (E->get().from_node == F->get() || E->get().to_node == F->get()) { - bool cancel = false; for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) { if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) { @@ -2042,13 +1968,11 @@ void VisualShaderEditor::_delete_nodes() { } void VisualShaderEditor::_mode_selected(int p_id) { - _update_options_menu(); _update_graph(); } void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> input, String name) { - String prev_name = input->get_input_name(); if (name == prev_name) @@ -2119,7 +2043,6 @@ void VisualShaderEditor::_member_cancel() { } void VisualShaderEditor::_tools_menu_option(int p_idx) { - TreeItem *category = members->get_root()->get_children(); switch (p_idx) { @@ -2176,7 +2099,6 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) { } Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - if (p_from == members) { TreeItem *it = members->get_item_at_position(p_point); if (!it) @@ -2204,9 +2126,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f } bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - if (p_from == graph) { - Dictionary d = p_data; if (d.has("id")) { @@ -2221,9 +2141,7 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant & } void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - if (p_from == graph) { - Dictionary d = p_data; if (d.has("id")) { @@ -2233,11 +2151,9 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da _add_node(idx, add_options[idx].sub_func); } else if (d.has("files")) { if (d["files"].get_type() == Variant::PACKED_STRING_ARRAY) { - int j = 0; PackedStringArray arr = d["files"]; for (int i = 0; i < arr.size(); i++) { - String type = ResourceLoader::get_resource_type(arr[i]); if (type == "GDScript") { Ref<Script> script = ResourceLoader::load(arr[i]); @@ -2271,13 +2187,11 @@ void VisualShaderEditor::_show_preview_text() { } static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) { - RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable); return RS::global_variable_type_get_shader_datatype(gvt); } void VisualShaderEditor::_update_preview() { - if (!preview_showed) { pending_update_preview = true; return; @@ -2327,7 +2241,6 @@ void VisualShaderEditor::_bind_methods() { VisualShaderEditor *VisualShaderEditor::singleton = nullptr; VisualShaderEditor::VisualShaderEditor() { - singleton = this; updating = false; saved_node_pos_dirty = false; @@ -2945,17 +2858,14 @@ VisualShaderEditor::VisualShaderEditor() { } void VisualShaderEditorPlugin::edit(Object *p_object) { - visual_shader_editor->edit(Object::cast_to<VisualShader>(p_object)); } bool VisualShaderEditorPlugin::handles(Object *p_object) const { - return p_object->is_class("VisualShader"); } void VisualShaderEditorPlugin::make_visible(bool p_visible) { - if (p_visible) { //editor->hide_animation_player_editors(); //editor->animation_panel_make_visible(true); @@ -2965,7 +2875,6 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) { visual_shader_editor->set_process_input(true); //visual_shader_editor->set_process(true); } else { - if (visual_shader_editor->is_visible_in_tree()) editor->hide_bottom_panel(); button->hide(); @@ -2975,7 +2884,6 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) { } VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) { - editor = p_node; visual_shader_editor = memnew(VisualShaderEditor); visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE); @@ -3037,7 +2945,6 @@ class VisualShaderNodePluginDefaultEditor : public VBoxContainer { public: void _property_changed(const String &p_property, const Variant &p_value, const String &p_field = "", bool p_changing = false) { - if (p_changing) return; @@ -3049,7 +2956,6 @@ public: undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property)); if (p_value.get_type() == Variant::OBJECT) { - RES prev_res = node->get(p_property); RES curr_res = p_value; @@ -3109,7 +3015,6 @@ public: properties = p_properties; for (int i = 0; i < p_properties.size(); i++) { - HBoxContainer *hbox = memnew(HBoxContainer); hbox->set_h_size_flags(SIZE_EXPAND_FILL); add_child(hbox); @@ -3147,7 +3052,6 @@ public: }; Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { - if (p_node->is_class("VisualShaderNodeInput")) { //create input VisualShaderNodePluginInputEditor *input_editor = memnew(VisualShaderNodePluginInputEditor); @@ -3166,7 +3070,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<PropertyInfo> pinfo; for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - for (int i = 0; i < properties.size(); i++) { if (E->get().name == String(properties[i])) { pinfo.push_back(E->get()); @@ -3183,7 +3086,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par Vector<EditorProperty *> editors; for (int i = 0; i < pinfo.size(); i++) { - 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 nullptr; @@ -3209,7 +3111,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par } void EditorPropertyShaderMode::_option_selected(int p_which) { - //will not use this, instead will do all the logic setting manually //emit_signal("property_changed", get_edited_property(), p_which); @@ -3227,7 +3128,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { //1. restore connections to output for (int i = 0; i < VisualShader::TYPE_MAX; i++) { - VisualShader::Type type = VisualShader::Type(i); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); @@ -3239,7 +3139,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { } //2. restore input indices for (int i = 0; i < VisualShader::TYPE_MAX; i++) { - VisualShader::Type type = VisualShader::Type(i); Vector<int> nodes = visual_shader->get_node_list(type); for (int j = 0; j < nodes.size(); j++) { @@ -3257,7 +3156,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { visual_shader->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) { undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name)); } @@ -3274,7 +3172,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { } void EditorPropertyShaderMode::update_property() { - int which = get_edited_object()->get(get_edited_property()); options->select(which); } @@ -3309,9 +3206,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) { } bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) { - if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) { - EditorPropertyShaderMode *editor = memnew(EditorPropertyShaderMode); Vector<String> options = p_hint_text.split(","); editor->setup(options); @@ -3355,7 +3250,6 @@ void VisualShaderNodePortPreview::_shader_changed() { continue; ShaderMaterial *src_mat = Object::cast_to<ShaderMaterial>(object); if (src_mat && src_mat->get_shader().is_valid()) { - List<PropertyInfo> params; src_mat->get_shader()->get_param_list(¶ms); for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { @@ -3368,7 +3262,6 @@ void VisualShaderNodePortPreview::_shader_changed() { } void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) { - shader = p_shader; shader->connect("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed)); type = p_type; @@ -3413,18 +3306,15 @@ VisualShaderNodePortPreview::VisualShaderNodePortPreview() { ////////////////////////////////// String VisualShaderConversionPlugin::converts_to() const { - return "Shader"; } bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const { - Ref<VisualShader> vshader = p_resource; return vshader.is_valid(); } Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const { - Ref<VisualShader> vshader = p_resource; ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>()); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index a495b09b5c..d2f10d9407 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -41,7 +41,6 @@ #include "scene/resources/visual_shader.h" class VisualShaderNodePlugin : public Reference { - GDCLASS(VisualShaderNodePlugin, Reference); protected: @@ -52,7 +51,6 @@ public: }; class VisualShaderEditor : public VBoxContainer { - GDCLASS(VisualShaderEditor, VBoxContainer); CustomPropertyEditor *property_editor; @@ -157,7 +155,6 @@ class VisualShaderEditor : public VBoxContainer { } }; struct _OptionComparator { - _FORCE_INLINE_ bool operator()(const AddOption &a, const AddOption &b) const { return a.category.count("/") > b.category.count("/") || (a.category + "/" + a.name).naturalnocasecmp_to(b.category + "/" + b.name) < 0; } @@ -290,7 +287,6 @@ public: }; class VisualShaderEditorPlugin : public EditorPlugin { - GDCLASS(VisualShaderEditorPlugin, EditorPlugin); VisualShaderEditor *visual_shader_editor; @@ -309,7 +305,6 @@ public: }; class VisualShaderNodePluginDefault : public VisualShaderNodePlugin { - GDCLASS(VisualShaderNodePluginDefault, VisualShaderNodePlugin); public: diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 86df069b8b..6060ef44bb 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -37,7 +37,6 @@ #include "servers/display_server.h" void BackgroundProgress::_add_task(const String &p_task, const String &p_label, int p_steps) { - _THREAD_SAFE_METHOD_ ERR_FAIL_COND_MSG(tasks.has(p_task), "Task '" + p_task + "' already exists."); BackgroundProgress::Task t; @@ -62,11 +61,9 @@ void BackgroundProgress::_add_task(const String &p_task, const String &p_label, } void BackgroundProgress::_update() { - _THREAD_SAFE_METHOD_ for (Map<String, int>::Element *E = updates.front(); E; E = E->next()) { - if (tasks.has(E->key())) { _task_step(E->key(), E->get()); } @@ -76,7 +73,6 @@ void BackgroundProgress::_update() { } void BackgroundProgress::_task_step(const String &p_task, int p_step) { - _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!tasks.has(p_task)); @@ -88,7 +84,6 @@ void BackgroundProgress::_task_step(const String &p_task, int p_step) { t.progress->set_value(p_step); } void BackgroundProgress::_end_task(const String &p_task) { - _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!tasks.has(p_task)); @@ -99,7 +94,6 @@ void BackgroundProgress::_end_task(const String &p_task) { } void BackgroundProgress::_bind_methods() { - ClassDB::bind_method("_add_task", &BackgroundProgress::_add_task); ClassDB::bind_method("_task_step", &BackgroundProgress::_task_step); ClassDB::bind_method("_end_task", &BackgroundProgress::_end_task); @@ -107,11 +101,9 @@ void BackgroundProgress::_bind_methods() { } void BackgroundProgress::add_task(const String &p_task, const String &p_label, int p_steps) { - MessageQueue::get_singleton()->push_call(this, "_add_task", p_task, p_label, p_steps); } void BackgroundProgress::task_step(const String &p_task, int p_step) { - //this code is weird, but it prevents deadlock. bool no_updates = true; { @@ -129,7 +121,6 @@ void BackgroundProgress::task_step(const String &p_task, int p_step) { } void BackgroundProgress::end_task(const String &p_task) { - MessageQueue::get_singleton()->push_call(this, "_end_task", p_task); } @@ -141,7 +132,6 @@ void ProgressDialog::_notification(int p_what) { } void ProgressDialog::_popup() { - Size2 ms = main->get_combined_minimum_size(); ms.width = MAX(500 * EDSCALE, ms.width); @@ -157,7 +147,6 @@ void ProgressDialog::_popup() { } void ProgressDialog::add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel) { - if (MessageQueue::get_singleton()->is_flushing()) { ERR_PRINT("Do not use progress dialog (task) while flushing the message queue or using call_deferred()!"); return; @@ -192,7 +181,6 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p } bool ProgressDialog::task_step(const String &p_task, const String &p_state, int p_step, bool p_force_redraw) { - ERR_FAIL_COND_V(!tasks.has(p_task), cancelled); if (!p_force_redraw) { @@ -218,7 +206,6 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int } void ProgressDialog::end_task(const String &p_task) { - ERR_FAIL_COND(!tasks.has(p_task)); Task &t = tasks[p_task]; @@ -239,7 +226,6 @@ void ProgressDialog::_bind_methods() { } ProgressDialog::ProgressDialog() { - main = memnew(VBoxContainer); add_child(main); main->set_anchors_and_margins_preset(Control::PRESET_WIDE); diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h index 82f479ae9d..753b6ac955 100644 --- a/editor/progress_dialog.h +++ b/editor/progress_dialog.h @@ -38,13 +38,11 @@ #include "scene/gui/progress_bar.h" class BackgroundProgress : public HBoxContainer { - GDCLASS(BackgroundProgress, HBoxContainer); _THREAD_SAFE_CLASS_ struct Task { - HBoxContainer *hb; ProgressBar *progress; }; @@ -69,10 +67,8 @@ public: }; class ProgressDialog : public PopupPanel { - GDCLASS(ProgressDialog, PopupPanel); struct Task { - String task; VBoxContainer *vb; ProgressBar *progress; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 04ec5ae043..3b115d7427 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -56,7 +56,6 @@ void ProjectExportDialog::_theme_changed() { 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()) { @@ -73,10 +72,8 @@ void ProjectExportDialog::_notification(int p_what) { } void ProjectExportDialog::popup_export() { - add_preset->get_popup()->clear(); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { - Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i); add_preset->get_popup()->add_icon_item(plat->get_logo(), plat->get_name()); @@ -97,7 +94,6 @@ void ProjectExportDialog::popup_export() { } void ProjectExportDialog::_add_preset(int p_platform) { - Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset(); ERR_FAIL_COND(!preset.is_valid()); @@ -105,7 +101,6 @@ void ProjectExportDialog::_add_preset(int p_platform) { bool make_runnable = true; int attempt = 1; while (true) { - bool valid = true; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { @@ -135,12 +130,10 @@ void ProjectExportDialog::_add_preset(int p_platform) { } void ProjectExportDialog::_update_current_preset() { - _edit_preset(presets->get_current()); } void ProjectExportDialog::_update_presets() { - updating = true; Ref<EditorExportPreset> current; @@ -169,7 +162,6 @@ void ProjectExportDialog::_update_presets() { } void ProjectExportDialog::_update_export_all() { - bool can_export = EditorExport::get_singleton()->get_export_preset_count() > 0; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { @@ -190,7 +182,6 @@ void ProjectExportDialog::_update_export_all() { } void ProjectExportDialog::_edit_preset(int p_index) { - if (p_index < 0 || p_index >= presets->get_item_count()) { name->set_text(""); name->set_editable(false); @@ -268,9 +259,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { bool needs_templates; String error; if (!current->get_platform()->can_export(current, error, needs_templates)) { - if (error != String()) { - Vector<String> items = error.split("\n", false); error = ""; for (int i = 0; i < items.size(); i++) { @@ -329,7 +318,6 @@ void ProjectExportDialog::_edit_preset(int p_index) { } void ProjectExportDialog::_update_feature_list() { - Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); @@ -363,7 +351,6 @@ void ProjectExportDialog::_update_feature_list() { } void ProjectExportDialog::_custom_features_changed(const String &p_text) { - if (updating) return; @@ -379,7 +366,6 @@ void ProjectExportDialog::_tab_changed(int) { } void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) { - TreeItem *ti = (TreeItem *)p_item; patch_index = ti->get_metadata(0); @@ -398,7 +384,6 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in } void ProjectExportDialog::_patch_edited() { - TreeItem *item = patches->get_edited(); if (!item) return; @@ -421,14 +406,12 @@ void ProjectExportDialog::_patch_edited() { } void ProjectExportDialog::_patch_selected(const String &p_path) { - Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); Vector<String> patches = current->get_patches(); if (patch_index >= patches.size()) { - current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*"); } else { String enabled = patches[patch_index].ends_with("*") ? String("*") : String(); @@ -439,25 +422,21 @@ void ProjectExportDialog::_patch_selected(const String &p_path) { } void ProjectExportDialog::_patch_deleted() { - Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); Vector<String> patches = current->get_patches(); if (patch_index < patches.size()) { - current->remove_patch(patch_index); _update_current_preset(); } } void ProjectExportDialog::_update_parameters(const String &p_edited_property) { - _update_current_preset(); } void ProjectExportDialog::_runnable_pressed() { - if (updating) return; @@ -465,7 +444,6 @@ void ProjectExportDialog::_runnable_pressed() { ERR_FAIL_COND(current.is_null()); if (runnable->is_pressed()) { - for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i); if (p->get_platform() == current->get_platform()) { @@ -473,7 +451,6 @@ void ProjectExportDialog::_runnable_pressed() { } } } else { - current->set_runnable(false); } @@ -481,7 +458,6 @@ void ProjectExportDialog::_runnable_pressed() { } void ProjectExportDialog::_name_changed(const String &p_string) { - if (updating) return; @@ -507,12 +483,10 @@ String ProjectExportDialog::get_export_path() { } Ref<EditorExportPreset> ProjectExportDialog::get_current_preset() const { - return EditorExport::get_singleton()->get_export_preset(presets->get_current()); } void ProjectExportDialog::_export_path_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) { - if (updating) return; @@ -524,7 +498,6 @@ void ProjectExportDialog::_export_path_changed(const StringName &p_property, con } void ProjectExportDialog::_script_export_mode_changed(int p_mode) { - if (updating) return; @@ -537,7 +510,6 @@ void ProjectExportDialog::_script_export_mode_changed(int p_mode) { } void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) { - if (updating) return; @@ -552,7 +524,6 @@ void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) { } bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) { - bool is_valid = false; if (!p_key.empty() && p_key.is_valid_hex_number(false) && p_key.length() == 64) { @@ -562,7 +533,6 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) { } void ProjectExportDialog::_duplicate_preset() { - Ref<EditorExportPreset> current = get_current_preset(); if (current.is_null()) return; @@ -573,7 +543,6 @@ void ProjectExportDialog::_duplicate_preset() { String name = current->get_name() + " (copy)"; bool make_runnable = true; while (true) { - bool valid = true; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { @@ -615,7 +584,6 @@ void ProjectExportDialog::_duplicate_preset() { } void ProjectExportDialog::_delete_preset() { - Ref<EditorExportPreset> current = get_current_preset(); if (current.is_null()) return; @@ -625,7 +593,6 @@ void ProjectExportDialog::_delete_preset() { } void ProjectExportDialog::_delete_preset_confirm() { - int idx = presets->get_current(); _edit_preset(-1); export_button->set_disabled(true); @@ -635,7 +602,6 @@ void ProjectExportDialog::_delete_preset_confirm() { } Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - if (p_from == presets) { int pos = presets->get_item_at_position(p_point, true); @@ -657,11 +623,9 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_ return d; } } else if (p_from == patches) { - TreeItem *item = patches->get_item_at_position(p_point); if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) { - int metadata = item->get_metadata(0); Dictionary d; d["type"] = "export_patch"; @@ -679,7 +643,6 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_ } bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - if (p_from == presets) { Dictionary d = p_data; if (!d.has("type") || String(d["type"]) != "export_preset") @@ -688,7 +651,6 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point)) return false; } else if (p_from == patches) { - Dictionary d = p_data; if (!d.has("type") || String(d["type"]) != "export_patch") return false; @@ -698,7 +660,6 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant TreeItem *item = patches->get_item_at_position(p_point); if (!item) { - return false; } } @@ -707,7 +668,6 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant } void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { - if (p_from == presets) { Dictionary d = p_data; int from_pos = d["preset"]; @@ -737,7 +697,6 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d else _edit_preset(presets->get_item_count() - 1); } else if (p_from == patches) { - Dictionary d = p_data; if (!d.has("type") || String(d["type"]) != "export_patch") return; @@ -766,7 +725,6 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d } void ProjectExportDialog::_export_type_changed(int p_which) { - if (updating) return; @@ -781,7 +739,6 @@ void ProjectExportDialog::_export_type_changed(int p_which) { } void ProjectExportDialog::_filter_changed(const String &p_filter) { - if (updating) return; @@ -794,7 +751,6 @@ void ProjectExportDialog::_filter_changed(const String &p_filter) { } void ProjectExportDialog::_fill_resource_tree() { - include_files->clear(); include_label->hide(); include_margin->hide(); @@ -818,13 +774,11 @@ 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, presets->get_theme_icon("folder", "FileDialog")); p_item->set_text(0, p_dir->get_name() + "/"); bool used = false; for (int i = 0; i < p_dir->get_subdir_count(); i++) { - TreeItem *subdir = include_files->create_item(p_item); if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes)) { used = true; @@ -834,7 +788,6 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem } for (int i = 0; i < p_dir->get_file_count(); i++) { - String type = p_dir->get_file_type(i); if (p_only_scenes && type != "PackedScene") continue; @@ -857,7 +810,6 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem } void ProjectExportDialog::_tree_changed() { - if (updating) return; @@ -880,12 +832,10 @@ void ProjectExportDialog::_tree_changed() { } void ProjectExportDialog::_export_pck_zip() { - export_pck_zip->popup_centered_ratio(); } void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) { - Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); Ref<EditorExportPlatform> platform = current->get_platform(); @@ -899,7 +849,6 @@ void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) { } void ProjectExportDialog::_open_export_template_manager() { - EditorNode::get_singleton()->open_export_template_manager(); hide(); } @@ -924,7 +873,6 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) { } void ProjectExportDialog::_export_project() { - Ref<EditorExportPreset> current = get_current_preset(); ERR_FAIL_COND(current.is_null()); Ref<EditorExportPlatform> platform = current->get_platform(); @@ -987,20 +935,17 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) { } void ProjectExportDialog::_export_all_dialog() { - export_all_dialog->show(); export_all_dialog->popup_centered(Size2(300, 80)); } void ProjectExportDialog::_export_all_dialog_action(const String &p_str) { - export_all_dialog->hide(); _export_all(p_str != "release"); } void ProjectExportDialog::_export_all(bool p_debug) { - String mode = p_debug ? TTR("Debug") : TTR("Release"); EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true); @@ -1027,7 +972,6 @@ void ProjectExportDialog::_export_all(bool p_debug) { } void ProjectExportDialog::_bind_methods() { - ClassDB::bind_method("get_drag_data_fw", &ProjectExportDialog::get_drag_data_fw); ClassDB::bind_method("can_drop_data_fw", &ProjectExportDialog::can_drop_data_fw); ClassDB::bind_method("drop_data_fw", &ProjectExportDialog::drop_data_fw); @@ -1040,7 +984,6 @@ void ProjectExportDialog::_bind_methods() { } ProjectExportDialog::ProjectExportDialog() { - set_title(TTR("Export")); VBoxContainer *main_vb = memnew(VBoxContainer); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 2d1eb54e9a..1e04b4e467 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -59,7 +59,6 @@ static inline String get_project_key_from_path(const String &dir) { } class ProjectDialog : public ConfirmationDialog { - GDCLASS(ProjectDialog, ConfirmationDialog); public: @@ -107,30 +106,25 @@ private: String created_folder_path; void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) { - msg->set_text(p_msg); Ref<Texture2D> current_path_icon = status_rect->get_texture(); Ref<Texture2D> current_install_icon = install_status_rect->get_texture(); Ref<Texture2D> new_icon; switch (p_type) { - case MESSAGE_ERROR: { - msg->add_theme_color_override("font_color", msg->get_theme_color("error_color", "Editor")); msg->set_modulate(Color(1, 1, 1, 1)); new_icon = msg->get_theme_icon("StatusError", "EditorIcons"); } break; case MESSAGE_WARNING: { - msg->add_theme_color_override("font_color", msg->get_theme_color("warning_color", "Editor")); msg->set_modulate(Color(1, 1, 1, 1)); new_icon = msg->get_theme_icon("StatusWarning", "EditorIcons"); } break; case MESSAGE_SUCCESS: { - msg->set_modulate(Color(1, 1, 1, 0)); new_icon = msg->get_theme_icon("StatusSuccess", "EditorIcons"); @@ -147,7 +141,6 @@ private: } String _test_path() { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String valid_path, valid_install_path; if (d->change_dir(project_path->get_text()) == OK) { @@ -187,16 +180,13 @@ private: } if (mode == MODE_IMPORT || mode == MODE_RENAME) { - if (valid_path != "" && !d->file_exists("project.godot")) { - if (valid_path.ends_with(".zip")) { FileAccess *src_f = nullptr; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); if (!pkg) { - set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR); memdelete(d); get_ok()->set_disabled(true); @@ -245,7 +235,6 @@ private: d->list_dir_end(); if (!is_empty) { - set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH); memdelete(d); get_ok()->set_disabled(true); @@ -261,7 +250,6 @@ private: } } else if (valid_path.ends_with("zip")) { - set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH); memdelete(d); get_ok()->set_disabled(true); @@ -269,7 +257,6 @@ private: } } else { - // check if the specified folder is empty, even though this is not an error, it is good to check here d->list_dir_begin(); bool is_empty = true; @@ -288,7 +275,6 @@ private: d->list_dir_end(); if (!is_empty) { - set_message(TTR("Please choose an empty folder."), MESSAGE_ERROR); memdelete(d); get_ok()->set_disabled(true); @@ -304,10 +290,8 @@ private: } void _path_text_changed(const String &p_path) { - String sp = _test_path(); if (sp != "") { - // If the project name is empty or default, infer the project name from the selected folder name if (project_name->get_text() == "" || project_name->get_text() == TTR("New Game Project")) { sp = sp.replace("\\", "/"); @@ -330,7 +314,6 @@ private: } void _file_selected(const String &p_path) { - String p = p_path; if (mode == MODE_IMPORT) { if (p.ends_with("project.godot")) { @@ -358,7 +341,6 @@ private: } void _path_selected(const String &p_path) { - String sp = p_path.simplify_path(); project_path->set_text(sp); _path_text_changed(sp); @@ -366,7 +348,6 @@ private: } void _install_path_selected(const String &p_path) { - String sp = p_path.simplify_path(); install_path->set_text(sp); _path_text_changed(sp); @@ -374,11 +355,9 @@ private: } void _browse_path() { - fdialog->set_current_dir(project_path->get_text()); if (mode == MODE_IMPORT) { - fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE); fdialog->clear_filters(); fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project"))); @@ -396,7 +375,6 @@ private: } void _create_folder() { - if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) { set_message(TTR("Invalid Project Name."), MESSAGE_WARNING); return; @@ -404,11 +382,8 @@ private: DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (d->change_dir(project_path->get_text()) == OK) { - if (!d->dir_exists(project_name->get_text())) { - if (d->make_dir(project_name->get_text()) == OK) { - d->change_dir(project_name->get_text()); String dir_str = d->get_current_dir(); project_path->set_text(dir_str); @@ -416,12 +391,10 @@ private: created_folder_path = d->get_current_dir(); create_dir->set_disabled(true); } else { - dialog_error->set_text(TTR("Couldn't create folder.")); 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(); } @@ -431,7 +404,6 @@ private: } void _text_changed(const String &p_text) { - if (mode != MODE_NEW) return; @@ -442,11 +414,9 @@ private: } void ok_pressed() { - String dir = project_path->get_text(); if (mode == MODE_RENAME) { - String dir2 = _test_path(); if (dir2 == "") { set_message(TTR("Invalid project path (changed anything?)."), MESSAGE_ERROR); @@ -471,11 +441,8 @@ private: emit_signal("projects_updated"); } else { - if (mode == MODE_IMPORT) { - if (project_path->get_text().ends_with(".zip")) { - mode = MODE_INSTALL; ok_pressed(); @@ -484,7 +451,6 @@ private: } else { if (mode == MODE_NEW) { - ProjectSettings::CustomMap initial_settings; if (rasterizer_button_group->get_pressed_button()->get_meta("driver_name") == "Vulkan") { initial_settings["rendering/quality/driver/driver_name"] = "Vulkan"; @@ -516,7 +482,6 @@ private: } } else if (mode == MODE_INSTALL) { - if (project_path->get_text().ends_with(".zip")) { dir = install_path->get_text(); zip_path = project_path->get_text(); @@ -527,7 +492,6 @@ private: 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(); return; @@ -539,7 +503,6 @@ private: int idx = 0; while (ret == UNZ_OK) { - //get filename unz_file_info info; char fname[16384]; @@ -570,7 +533,6 @@ private: memdelete(da); } else { - Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -598,7 +560,6 @@ private: if (failed_files.size()) { String msg = TTR("The following files failed extraction from package:") + "\n\n"; for (int i = 0; i < failed_files.size(); i++) { - if (i > 15) { msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; break; @@ -629,7 +590,6 @@ private: } void _remove_created_folder() { - if (created_folder_path != "") { DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); d->remove(created_folder_path); @@ -641,7 +601,6 @@ private: } void cancel_pressed() { - _remove_created_folder(); project_path->clear(); @@ -657,14 +616,12 @@ private: } void _notification(int p_what) { - if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) _remove_created_folder(); } protected: static void _bind_methods() { - ClassDB::bind_method("_browse_path", &ProjectDialog::_browse_path); ClassDB::bind_method("_create_folder", &ProjectDialog::_create_folder); ClassDB::bind_method("_text_changed", &ProjectDialog::_text_changed); @@ -686,7 +643,6 @@ public: } void set_mode(Mode p_mode) { - mode = p_mode; } @@ -695,9 +651,7 @@ public: } void show_dialog() { - if (mode == MODE_RENAME) { - project_path->set_editable(false); browse->hide(); install_browse->hide(); @@ -731,7 +685,6 @@ public: create_dir->hide(); } else { - fav_dir = EditorSettings::get_singleton()->get("filesystem/directories/default_project_path"); if (fav_dir != "") { project_path->set_text(fav_dir); @@ -765,7 +718,6 @@ public: project_path->grab_focus(); } else if (mode == MODE_NEW) { - set_title(TTR("Create New Project")); get_ok()->set_text(TTR("Create & Edit")); name_container->show(); @@ -775,7 +727,6 @@ public: project_name->call_deferred("select_all"); } else if (mode == MODE_INSTALL) { - set_title(TTR("Install Project:") + " " + zip_title); get_ok()->set_text(TTR("Install & Edit")); project_name->set_text(zip_title); @@ -792,7 +743,6 @@ public: } ProjectDialog() { - VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -1024,7 +974,6 @@ public: bool p_grayed, bool p_missing, int p_version) { - project_key = p_project; project_name = p_name; description = p_description; @@ -1137,7 +1086,6 @@ void ProjectList::update_icons_async() { void ProjectList::_notification(int p_what) { if (p_what == NOTIFICATION_PROCESS) { - // Load icons as a coroutine to speed up launch when you have hundreds of projects if (_icon_load_index < _projects.size()) { Item &item = _projects.write[_icon_load_index]; @@ -1162,7 +1110,6 @@ void ProjectList::load_project_icon(int p_index) { img.instance(); Error err = img->load(item.icon.replace_first("res://", item.path + "/")); if (err == OK) { - img->resize(default_icon->get_width(), default_icon->get_height(), Image::INTERPOLATE_LANCZOS); Ref<ImageTexture> it = memnew(ImageTexture); it->create_from_image(img); @@ -1178,7 +1125,6 @@ void ProjectList::load_project_icon(int p_index) { } void ProjectList::load_project_data(const String &p_property_key, Item &p_item, bool p_favorite) { - String path = EditorSettings::get_singleton()->get(p_property_key); String conf = path.plus_file("project.godot"); bool grayed = false; @@ -1289,7 +1235,6 @@ void ProjectList::load_projects() { } void ProjectList::update_dock_menu() { - if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { return; } @@ -1341,7 +1286,6 @@ void ProjectList::_global_menu_open_project(const Variant &p_tag) { } void ProjectList::create_project_item_control(int p_index) { - // Will be added last in the list, so make sure indexes match ERR_FAIL_COND(p_index != _scroll_children->get_child_count()); @@ -1442,7 +1386,6 @@ void ProjectList::set_order_option(ProjectListFilter::FilterOption p_option) { } void ProjectList::sort_projects() { - SortArray<Item, ProjectListComparator> sorter; sorter.compare.order_option = _order_option; sorter.sort(_projects.ptrw(), _projects.size()); @@ -1452,7 +1395,6 @@ void ProjectList::sort_projects() { bool visible = true; if (_search_term != "") { - String search_path; if (_search_term.find("/") != -1) { // Search path will match the whole path @@ -1568,7 +1510,6 @@ bool ProjectList::is_any_project_missing() const { } void ProjectList::erase_missing_projects() { - if (_projects.empty()) { return; } @@ -1669,7 +1610,6 @@ int ProjectList::get_project_count() const { } void ProjectList::select_project(int p_index) { - Vector<Item> previous_selected_items = get_selected_projects(); _selected_project_keys.clear(); @@ -1724,7 +1664,6 @@ void ProjectList::toggle_select(int p_index) { } void ProjectList::erase_selected_projects() { - if (_selected_project_keys.size() == 0) { return; } @@ -1732,7 +1671,6 @@ void ProjectList::erase_selected_projects() { for (int i = 0; i < _projects.size(); ++i) { Item &item = _projects.write[i]; if (_selected_project_keys.has(item.project_key) && item.control->is_visible()) { - EditorSettings::get_singleton()->erase("projects/" + item.project_key); EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key); @@ -1765,15 +1703,12 @@ void ProjectList::_panel_draw(Node *p_hb) { // Input for each item in the list void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { - Ref<InputEventMouseButton> mb = p_ev; int clicked_index = p_hb->get_index(); const Item &clicked_project = _projects[clicked_index]; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - if (mb->get_shift() && _selected_project_keys.size() > 0 && _last_clicked != "" && clicked_project.project_key != _last_clicked) { - int anchor_index = -1; for (int i = 0; i < _projects.size(); ++i) { const Item &p = _projects[i]; @@ -1802,7 +1737,6 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { } void ProjectList::_favorite_pressed(Node *p_hb) { - ProjectListItemControl *control = Object::cast_to<ProjectListItemControl>(p_hb); int index = control->get_index(); @@ -1836,7 +1770,6 @@ void ProjectList::_favorite_pressed(Node *p_hb) { } void ProjectList::_show_project(const String &p_path) { - OS::get_singleton()->shell_open(String("file://") + p_path); } @@ -1844,26 +1777,21 @@ const char *ProjectList::SIGNAL_SELECTION_CHANGED = "selection_changed"; const char *ProjectList::SIGNAL_PROJECT_ASK_OPEN = "project_ask_open"; void ProjectList::_bind_methods() { - ADD_SIGNAL(MethodInfo(SIGNAL_SELECTION_CHANGED)); ADD_SIGNAL(MethodInfo(SIGNAL_PROJECT_ASK_OPEN)); } void ProjectManager::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - Engine::get_singleton()->set_editor_hint(false); } break; case NOTIFICATION_RESIZED: { - if (open_templates->is_visible()) { open_templates->popup_centered(); } } break; case NOTIFICATION_READY: { - if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) open_templates->popup_centered(); @@ -1874,18 +1802,15 @@ void ProjectManager::_notification(int p_what) { } } break; case NOTIFICATION_VISIBILITY_CHANGED: { - set_process_unhandled_input(is_visible_in_tree()); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { - _dim_window(); } break; } } void ProjectManager::_dim_window() { - // This method must be called before calling `get_tree()->quit()`. // Otherwise, its effect won't be visible @@ -1897,7 +1822,6 @@ void ProjectManager::_dim_window() { } void ProjectManager::_update_project_buttons() { - Vector<ProjectList::Item> selected_projects = _project_list->get_selected_projects(); bool empty_selection = selected_projects.empty(); @@ -1918,11 +1842,9 @@ void ProjectManager::_update_project_buttons() { } void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { - Ref<InputEventKey> k = p_ev; if (k.is_valid()) { - if (!k->is_pressed()) { return; } @@ -1943,17 +1865,13 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { bool keycode_handled = true; switch (k->get_keycode()) { - case KEY_ENTER: { - _open_selected_projects_ask(); } break; case KEY_DELETE: { - _erase_project(); } break; case KEY_HOME: { - if (_project_list->get_project_count() > 0) { _project_list->select_project(0); _update_project_buttons(); @@ -1961,7 +1879,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { } break; case KEY_END: { - if (_project_list->get_project_count() > 0) { _project_list->select_project(_project_list->get_project_count() - 1); _update_project_buttons(); @@ -1969,7 +1886,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { } break; case KEY_UP: { - if (k->get_shift()) break; @@ -1983,7 +1899,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { break; } case KEY_DOWN: { - if (k->get_shift()) break; @@ -2013,7 +1928,6 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { } void ProjectManager::_load_recent_projects() { - _project_list->set_order_option(project_order_filter->get_filter_option()); _project_list->set_search_term(project_filter->get_search_term()); _project_list->load_projects(); @@ -2051,7 +1965,6 @@ void ProjectManager::_confirm_update_settings() { } void ProjectManager::_open_selected_projects() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); for (const Set<String>::Element *E = selected_list.front(); E; E = E->next()) { @@ -2090,7 +2003,6 @@ void ProjectManager::_open_selected_projects() { } void ProjectManager::_open_selected_projects_ask() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { @@ -2136,11 +2048,9 @@ void ProjectManager::_open_selected_projects_ask() { } void ProjectManager::_run_project_confirm() { - Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects(); for (int i = 0; i < selected_list.size(); ++i) { - const String &selected_main = selected_list[i].main_scene; if (selected_main == "") { run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category.")); @@ -2178,7 +2088,6 @@ void ProjectManager::_run_project_confirm() { // When you press the "Run" button void ProjectManager::_run_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() < 1) { @@ -2211,7 +2120,6 @@ void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) { } void ProjectManager::_scan_begin(const String &p_base) { - print_line("Scanning projects at: " + p_base); List<String> projects; _scan_dir(p_base, &projects); @@ -2226,24 +2134,20 @@ void ProjectManager::_scan_begin(const String &p_base) { } void ProjectManager::_scan_projects() { - scan_dir->popup_centered_ratio(); } void ProjectManager::_new_project() { - npdialog->set_mode(ProjectDialog::MODE_NEW); npdialog->show_dialog(); } void ProjectManager::_import_project() { - npdialog->set_mode(ProjectDialog::MODE_IMPORT); npdialog->show_dialog(); } void ProjectManager::_rename_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) { @@ -2270,7 +2174,6 @@ void ProjectManager::_erase_missing_projects_confirm() { } void ProjectManager::_erase_project() { - const Set<String> &selected_list = _project_list->get_selected_project_keys(); if (selected_list.size() == 0) @@ -2288,13 +2191,11 @@ void ProjectManager::_erase_project() { } 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(); } 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); @@ -2305,7 +2206,6 @@ void ProjectManager::_language_selected(int p_id) { } void ProjectManager::_restart_confirm() { - List<String> args = OS::get_singleton()->get_cmdline_args(); String exec = OS::get_singleton()->get_executable_path(); OS::ProcessID pid = 0; @@ -2317,13 +2217,11 @@ void ProjectManager::_restart_confirm() { } void ProjectManager::_exit_dialog() { - _dim_window(); get_tree()->quit(); } void ProjectManager::_install_project(const String &p_zip_path, const String &p_title) { - npdialog->set_mode(ProjectDialog::MODE_INSTALL); npdialog->set_zip_path(p_zip_path); npdialog->set_zip_title(p_title); @@ -2395,7 +2293,6 @@ void ProjectManager::_on_filter_option_changed() { } void ProjectManager::_bind_methods() { - ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog); ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input); ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons); @@ -2407,7 +2304,6 @@ void ProjectManager::_open_asset_library() { } ProjectManager::ProjectManager() { - // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); @@ -2730,13 +2626,11 @@ ProjectManager::ProjectManager() { } ProjectManager::~ProjectManager() { - if (EditorSettings::get_singleton()) EditorSettings::destroy(); } void ProjectListFilter::_setup_filters(Vector<String> options) { - filter_option->clear(); for (int i = 0; i < options.size(); i++) filter_option->add_item(options[i]); @@ -2769,7 +2663,6 @@ 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_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); @@ -2777,7 +2670,6 @@ void ProjectListFilter::_notification(int p_what) { } void ProjectListFilter::_bind_methods() { - ADD_SIGNAL(MethodInfo("filter_changed")); } @@ -2805,7 +2697,6 @@ void ProjectListFilter::set_filter_size(int h_size) { } ProjectListFilter::ProjectListFilter() { - _current_filter = FILTER_NAME; has_search_box = false; } diff --git a/editor/project_manager.h b/editor/project_manager.h index 6385000821..e5471bd392 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -43,7 +43,6 @@ class ProjectList; class ProjectListFilter; class ProjectManager : public Control { - GDCLASS(ProjectManager, Control); Button *erase_btn; @@ -126,7 +125,6 @@ public: }; class ProjectListFilter : public HBoxContainer { - GDCLASS(ProjectListFilter, HBoxContainer); public: diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index e5dd0c148e..60b9902f68 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -85,11 +85,9 @@ static const char *_axis_descriptions[JOY_AXIS_MAX * 2] = { }; void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) { - const Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed()) { - if (k->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) { if (search_button->is_pressed()) { search_box->grab_focus(); @@ -105,7 +103,6 @@ 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()) { @@ -133,14 +130,12 @@ void ProjectSettingsEditor::_notification(int p_what) { List<String> tfn; ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn); for (List<String>::Element *E = tfn.front(); E; E = E->next()) { - translation_file_open->add_filter("*." + E->get()); } List<String> rfn; ResourceLoader::get_recognized_extensions_for_type("Resource", &rfn); for (List<String>::Element *E = rfn.front(); E; E = E->next()) { - translation_res_file_open->add_filter("*." + E->get()); translation_res_option_file_open->add_filter("*." + E->get()); } @@ -176,7 +171,6 @@ static bool _validate_action_name(const String &p_name) { } void ProjectSettingsEditor::_action_selected() { - TreeItem *ti = input_editor->get_selected(); if (!ti || !ti->is_editable(0)) return; @@ -186,13 +180,11 @@ void ProjectSettingsEditor::_action_selected() { } void ProjectSettingsEditor::_action_edited() { - TreeItem *ti = input_editor->get_selected(); if (!ti) return; if (input_editor->get_selected_column() == 0) { - String new_name = ti->get_text(0); String old_name = add_at.substr(add_at.find("/") + 1, add_at.length()); @@ -200,7 +192,6 @@ void ProjectSettingsEditor::_action_edited() { return; if (new_name == "" || !_validate_action_name(new_name)) { - ti->set_text(0, old_name); add_at = "input/" + old_name; @@ -212,7 +203,6 @@ void ProjectSettingsEditor::_action_edited() { String action_prop = "input/" + new_name; if (ProjectSettings::get_singleton()->has_setting(action_prop)) { - ti->set_text(0, old_name); add_at = "input/" + old_name; @@ -241,7 +231,6 @@ void ProjectSettingsEditor::_action_edited() { add_at = action_prop; } else if (input_editor->get_selected_column() == 1) { - String name = "input/" + ti->get_text(0); Dictionary old_action = ProjectSettings::get_singleton()->get(name); Dictionary new_action = old_action.duplicate(); @@ -257,7 +246,6 @@ void ProjectSettingsEditor::_action_edited() { } void ProjectSettingsEditor::_device_input_add() { - Ref<InputEvent> ie; String name = add_at; int idx = edit_idx; @@ -266,16 +254,13 @@ void ProjectSettingsEditor::_device_input_add() { Array events = action["events"]; switch (add_type) { - case INPUT_MOUSE_BUTTON: { - Ref<InputEventMouseButton> mb; mb.instance(); mb->set_button_index(device_index->get_selected() + 1); mb->set_device(_get_current_device()); for (int i = 0; i < events.size(); i++) { - Ref<InputEventMouseButton> aie = events[i]; if (aie.is_null()) continue; @@ -288,7 +273,6 @@ void ProjectSettingsEditor::_device_input_add() { } break; case INPUT_JOY_MOTION: { - Ref<InputEventJoypadMotion> jm; jm.instance(); jm->set_axis(device_index->get_selected() >> 1); @@ -296,7 +280,6 @@ void ProjectSettingsEditor::_device_input_add() { jm->set_device(_get_current_device()); for (int i = 0; i < events.size(); i++) { - Ref<InputEventJoypadMotion> aie = events[i]; if (aie.is_null()) continue; @@ -310,7 +293,6 @@ void ProjectSettingsEditor::_device_input_add() { } break; case INPUT_JOY_BUTTON: { - Ref<InputEventJoypadButton> jb; jb.instance(); @@ -318,7 +300,6 @@ void ProjectSettingsEditor::_device_input_add() { jb->set_device(_get_current_device()); for (int i = 0; i < events.size(); i++) { - Ref<InputEventJoypadButton> aie = events[i]; if (aie.is_null()) continue; @@ -367,7 +348,6 @@ String ProjectSettingsEditor::_get_device_string(int i_device) { } void ProjectSettingsEditor::_press_a_key_confirm() { - if (last_wait_for_key.is_null()) return; @@ -393,7 +373,6 @@ void ProjectSettingsEditor::_press_a_key_confirm() { Array events = action["events"]; for (int i = 0; i < events.size(); i++) { - Ref<InputEventKey> aie = events[i]; if (aie.is_null()) continue; @@ -464,11 +443,9 @@ void ProjectSettingsEditor::_show_last_added(const Ref<InputEvent> &p_event, con } void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_keycode() != 0) { - last_wait_for_key = p_event; const String str = (press_a_key_physical) ? keycode_get_string(k->get_physical_keycode_with_modifiers()) + TTR(" (Physical)") : keycode_get_string(k->get_keycode_with_modifiers()); @@ -479,13 +456,10 @@ void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) { } void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { - add_type = InputType(p_item); switch (add_type) { - case INPUT_KEY: { - press_a_key_physical = false; press_a_key_label->set_text(TTR("Press a Key...")); press_a_key->get_ok()->set_disabled(true); @@ -495,7 +469,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } break; case INPUT_KEY_PHYSICAL: { - press_a_key_physical = true; press_a_key_label->set_text(TTR("Press a Key...")); @@ -505,7 +478,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } break; case INPUT_MOUSE_BUTTON: { - device_index_label->set_text(TTR("Mouse Button Index:")); device_index->clear(); device_index->add_item(TTR("Left Button")); @@ -531,7 +503,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } break; case INPUT_JOY_MOTION: { - device_index_label->set_text(TTR("Joypad Axis Index:")); device_index->clear(); for (int i = 0; i < JOY_AXIS_MAX * 2; i++) { @@ -553,7 +524,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } break; case INPUT_JOY_BUTTON: { - device_index_label->set_text(TTR("Joypad Button Index:")); device_index->clear(); for (int i = 0; i < JOY_BUTTON_MAX; i++) { @@ -581,7 +551,6 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even } void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) { - InputType ie_type; if ((Ref<InputEventKey>(p_exiting_event)).is_valid()) { @@ -607,7 +576,6 @@ void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) { _add_item(ie_type, p_exiting_event); } void ProjectSettingsEditor::_action_activated() { - TreeItem *ti = input_editor->get_selected(); if (!ti || ti->get_parent() == input_editor->get_root()) @@ -629,7 +597,6 @@ void ProjectSettingsEditor::_action_activated() { } void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) { - TreeItem *ti = Object::cast_to<TreeItem>(p_obj); ERR_FAIL_COND(!ti); @@ -717,7 +684,6 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, } void ProjectSettingsEditor::_update_actions() { - if (setting) return; @@ -737,7 +703,6 @@ void ProjectSettingsEditor::_update_actions() { ProjectSettings::get_singleton()->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); if (!pi.name.begins_with("input/")) continue; @@ -777,7 +742,6 @@ void ProjectSettingsEditor::_update_actions() { } for (int i = 0; i < events.size(); i++) { - Ref<InputEvent> event = events[i]; if (event.is_null()) continue; @@ -786,7 +750,6 @@ void ProjectSettingsEditor::_update_actions() { Ref<InputEventKey> k = event; if (k.is_valid()) { - const String str = (k->get_keycode() == 0) ? keycode_get_string(k->get_physical_keycode_with_modifiers()) + TTR(" (Physical)") : keycode_get_string(k->get_keycode_with_modifiers()); action2->set_text(0, str); @@ -800,7 +763,6 @@ void ProjectSettingsEditor::_update_actions() { Ref<InputEventJoypadButton> jb = event; if (jb.is_valid()) { - String str = _get_device_string(jb->get_device()) + ", " + TTR("Button") + " " + itos(jb->get_button_index()); if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_SDL_BUTTONS) { @@ -842,7 +804,6 @@ void ProjectSettingsEditor::_update_actions() { Ref<InputEventJoypadMotion> jm = event; if (jm.is_valid()) { - int ax = jm->get_axis(); int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1); String str = _get_device_string(jm->get_device()) + ", " + @@ -867,7 +828,6 @@ void ProjectSettingsEditor::_update_actions() { } void ProjectSettingsEditor::popup_project_settings() { - // Restore valid window bounds or pop up at default size. Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "project_settings", Rect2()); if (saved_size != Rect2()) { @@ -888,7 +848,6 @@ void ProjectSettingsEditor::update_plugins() { } void ProjectSettingsEditor::_item_selected(const String &p_path) { - const String &selected_path = p_path; if (selected_path == String()) return; @@ -898,12 +857,10 @@ void ProjectSettingsEditor::_item_selected(const String &p_path) { } void ProjectSettingsEditor::_item_adds(String) { - _item_add(); } 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; @@ -946,7 +903,6 @@ void ProjectSettingsEditor::_item_add() { } void ProjectSettingsEditor::_item_del() { - String path = globals_editor->get_inspector()->get_selected_path(); if (path == String()) { EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!")); @@ -984,21 +940,16 @@ void ProjectSettingsEditor::_item_del() { } void ProjectSettingsEditor::_action_check(String p_action) { - if (p_action == "") { - action_add->set_disabled(true); } else { - if (!_validate_action_name(p_action)) { - action_add_error->set_text(TTR("Invalid action name. It cannot be empty nor contain '/', ':', '=', '\\' or '\"'.")); action_add_error->show(); action_add->set_disabled(true); return; } if (ProjectSettings::get_singleton()->has_setting("input/" + p_action)) { - action_add_error->set_text(vformat(TTR("An action with the name '%s' already exists."), p_action)); action_add_error->show(); action_add->set_disabled(true); @@ -1012,14 +963,12 @@ void ProjectSettingsEditor::_action_check(String p_action) { } void ProjectSettingsEditor::_action_adds(String) { - if (!action_add->is_disabled()) { _action_add(); } } void ProjectSettingsEditor::_action_add() { - Dictionary action; action["events"] = Array(); action["deadzone"] = 0.5f; @@ -1053,20 +1002,17 @@ void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) { } void ProjectSettingsEditor::_save() { - Error err = ProjectSettings::get_singleton()->save(); message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK.")); message->popup_centered(Size2(300, 100) * EDSCALE); } void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) { - // Method needed to discard the mandatory argument of the property_edited signal _settings_changed(); } void ProjectSettingsEditor::_settings_changed() { - timer->start(); } @@ -1075,7 +1021,6 @@ void ProjectSettingsEditor::queue_save() { } void ProjectSettingsEditor::_copy_to_platform_about_to_show() { - Set<String> presets; presets.insert("bptc"); @@ -1101,7 +1046,6 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { } for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { - List<String> p; EditorExport::get_singleton()->get_export_preset(i)->get_platform()->get_preset_features(EditorExport::get_singleton()->get_export_preset(i), &p); for (List<String>::Element *E = p.front(); E; E = E->next()) { @@ -1126,7 +1070,6 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { } Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { - TreeItem *selected = input_editor->get_selected(); if (!selected || selected->get_parent() != input_editor->get_root()) return Variant(); @@ -1149,7 +1092,6 @@ Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control * } bool ProjectSettingsEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - Dictionary d = p_data; if (!d.has("type") || d["type"] != "nodes") return false; @@ -1163,7 +1105,6 @@ bool ProjectSettingsEditor::can_drop_data_fw(const Point2 &p_point, const Varian } void ProjectSettingsEditor::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; @@ -1184,7 +1125,6 @@ void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p undo_redo->create_action(TTR("Moved Input Action Event")); while (iterator != target) { - String iterator_name = "input/" + iterator->get_text(0); int iterator_order = ProjectSettings::get_singleton()->get_order(iterator_name); undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", iterator_name, order); @@ -1206,7 +1146,6 @@ void ProjectSettingsEditor::drop_data_fw(const Point2 &p_point, const Variant &p } void ProjectSettingsEditor::_copy_to_platform(int p_which) { - String path = globals_editor->get_inspector()->get_selected_path(); if (path == String()) { EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!")); @@ -1241,16 +1180,13 @@ void ProjectSettingsEditor::_copy_to_platform(int p_which) { } void ProjectSettingsEditor::add_translation(const String &p_translation) { - _translation_add(p_translation); } void ProjectSettingsEditor::_translation_add(const String &p_path) { - PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); for (int i = 0; i < translations.size(); i++) { - if (translations[i] == p_path) return; //exists } @@ -1267,12 +1203,10 @@ void ProjectSettingsEditor::_translation_add(const String &p_path) { } void ProjectSettingsEditor::_translation_file_open() { - translation_file_open->popup_centered_ratio(); } void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); ERR_FAIL_COND(!ti); @@ -1295,12 +1229,10 @@ void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, in } void ProjectSettingsEditor::_translation_res_file_open() { - translation_res_file_open->popup_centered_ratio(); } void ProjectSettingsEditor::_translation_res_add(const String &p_path) { - Variant prev; Dictionary remaps; @@ -1325,11 +1257,9 @@ void ProjectSettingsEditor::_translation_res_add(const String &p_path) { } void ProjectSettingsEditor::_translation_res_option_file_open() { - translation_res_option_file_open->popup_centered_ratio(); } void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) { - ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")); Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); @@ -1355,7 +1285,6 @@ void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) { } void ProjectSettingsEditor::_translation_res_select() { - if (updating_translations) return; @@ -1363,7 +1292,6 @@ void ProjectSettingsEditor::_translation_res_select() { } void ProjectSettingsEditor::_translation_res_option_changed() { - if (updating_translations) return; @@ -1409,7 +1337,6 @@ void ProjectSettingsEditor::_translation_res_option_changed() { } void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column, int p_button) { - if (updating_translations) return; @@ -1436,7 +1363,6 @@ void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column } void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button) { - if (updating_translations) return; @@ -1470,7 +1396,6 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p } void ProjectSettingsEditor::_translation_filter_option_changed() { - int sel_id = translation_locale_filter_mode->get_selected_id(); TreeItem *t = translation_filter->get_edited(); String locale = t->get_tooltip(0); @@ -1519,7 +1444,6 @@ void ProjectSettingsEditor::_translation_filter_option_changed() { } void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) { - int sel_id = translation_locale_filter_mode->get_selected_id(); Variant prev; @@ -1552,7 +1476,6 @@ void ProjectSettingsEditor::_translation_filter_mode_changed(int p_mode) { } void ProjectSettingsEditor::_update_translations() { - //update translations if (updating_translations) @@ -1564,10 +1487,8 @@ void ProjectSettingsEditor::_update_translations() { TreeItem *root = translation_list->create_item(nullptr); translation_list->set_hide_root(true); if (ProjectSettings::get_singleton()->has_setting("locale/translations")) { - PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); for (int i = 0; i < translations.size(); i++) { - TreeItem *t = translation_list->create_item(root); t->set_editable(0, false); t->set_text(0, translations[i].replace_first("res://", "")); @@ -1585,17 +1506,14 @@ void ProjectSettingsEditor::_update_translations() { bool is_arr_empty = true; if (ProjectSettings::get_singleton()->has_setting("locale/locale_filter")) { - l_filter_all = ProjectSettings::get_singleton()->get("locale/locale_filter"); if (l_filter_all.size() == 2) { - translation_locale_filter_mode->select(l_filter_all[0]); is_arr_empty = false; } } if (is_arr_empty) { - l_filter_all.append(0); l_filter_all.append(Array()); translation_locale_filter_mode->select(0); @@ -1610,7 +1528,6 @@ void ProjectSettingsEditor::_update_translations() { bool should_recreate_locales_list = is_short_list_when_show_all_selected || is_full_list_when_show_only_selected; if (!translation_locales_list_created || should_recreate_locales_list) { - translation_locales_list_created = true; translation_filter->clear(); root = translation_filter->create_item(nullptr); @@ -1660,10 +1577,8 @@ void ProjectSettingsEditor::_update_translations() { String langnames = ""; int l_idx = 0; for (int i = 0; i < names.size(); i++) { - if (filter_mode == SHOW_ONLY_SELECTED_LOCALES && fl_idx_count != 0) { if (l_filter.size() > 0) { - if (l_filter.find(langs[i]) != -1) { if (langnames.length() > 0) langnames += ","; @@ -1680,7 +1595,6 @@ void ProjectSettingsEditor::_update_translations() { } if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) { - Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; remaps.get_key_list(&rk); @@ -1691,7 +1605,6 @@ void ProjectSettingsEditor::_update_translations() { keys.sort(); for (int i = 0; i < keys.size(); i++) { - TreeItem *t = translation_remap->create_item(root); t->set_editable(0, false); t->set_text(0, keys[i].replace_first("res://", "")); @@ -1704,7 +1617,6 @@ void ProjectSettingsEditor::_update_translations() { PackedStringArray selected = remaps[keys[i]]; for (int j = 0; j < selected.size(); j++) { - String s2 = selected[j]; int qp = s2.find_last(":"); String path = s2.substr(0, qp); @@ -1726,10 +1638,8 @@ void ProjectSettingsEditor::_update_translations() { int f_idx = translation_locales_idxs_remap.find(idx); if (f_idx != -1 && fl_idx_count > 0 && filter_mode == SHOW_ONLY_SELECTED_LOCALES) { - t2->set_range(1, f_idx); } else { - t2->set_range(1, idx); } } @@ -1741,17 +1651,14 @@ void ProjectSettingsEditor::_update_translations() { } void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) { - globals_editor->get_inspector()->set_use_filter(p_pressed); if (p_pressed) { - search_bar->show(); add_prop_bar->hide(); search_box->grab_focus(); search_box->select_all(); } else { - search_box->clear(); search_bar->hide(); add_prop_bar->show(); @@ -1759,12 +1666,10 @@ void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) { } void ProjectSettingsEditor::set_plugins_page() { - tab_container->set_current_tab(plugin_settings->get_index()); } TabContainer *ProjectSettingsEditor::get_tabs() { - return tab_container; } @@ -1782,7 +1687,6 @@ void ProjectSettingsEditor::_editor_restart_close() { } void ProjectSettingsEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input"), &ProjectSettingsEditor::_unhandled_input); ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettingsEditor::_item_checked); ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save); @@ -1798,7 +1702,6 @@ void ProjectSettingsEditor::_bind_methods() { } ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { - singleton = this; set_title(TTR("Project Settings (project.godot)")); @@ -2052,7 +1955,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { translation_locales_list_created = false; { - VBoxContainer *tvb = memnew(VBoxContainer); translations->add_child(tvb); tvb->set_name(TTR("Translations")); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 5475bb5508..445ef58351 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -41,7 +41,6 @@ #include "scene/gui/tab_container.h" class ProjectSettingsEditor : public AcceptDialog { - GDCLASS(ProjectSettingsEditor, AcceptDialog); enum InputType { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 60329fb7bc..e14d842b98 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -59,7 +59,6 @@ #include "scene/scene_string_names.h" void EditorResourceConversionPlugin::_bind_methods() { - MethodInfo mi; mi.name = "_convert"; mi.return_val.type = Variant::OBJECT; @@ -78,7 +77,6 @@ void EditorResourceConversionPlugin::_bind_methods() { } String EditorResourceConversionPlugin::converts_to() const { - if (get_script_instance()) return get_script_instance()->call("_converts_to"); @@ -86,7 +84,6 @@ String EditorResourceConversionPlugin::converts_to() const { } bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) const { - if (get_script_instance()) return get_script_instance()->call("_handles", p_resource); @@ -94,7 +91,6 @@ bool EditorResourceConversionPlugin::handles(const Ref<Resource> &p_resource) co } Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_resource) const { - if (get_script_instance()) return get_script_instance()->call("_convert", p_resource); @@ -102,24 +98,18 @@ Ref<Resource> EditorResourceConversionPlugin::convert(const Ref<Resource> &p_res } void CustomPropertyEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) { hide(); } } void CustomPropertyEditor::_menu_option(int p_which) { - switch (type) { - case Variant::INT: { - if (hint == PROPERTY_HINT_FLAGS) { - int val = v; if (val & (1 << p_which)) { - val &= ~(1 << p_which); } else { val |= (1 << p_which); @@ -128,30 +118,24 @@ void CustomPropertyEditor::_menu_option(int p_which) { v = val; emit_signal("variant_changed"); } else if (hint == PROPERTY_HINT_ENUM) { - v = menu->get_item_metadata(p_which); emit_signal("variant_changed"); } } break; case Variant::STRING: { - if (hint == PROPERTY_HINT_ENUM) { - v = hint_text.get_slice(",", p_which); emit_signal("variant_changed"); } } break; case Variant::OBJECT: { - switch (p_which) { case OBJ_MENU_LOAD: { - file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String(); List<String> extensions; for (int i = 0; i < type.get_slice_count(","); i++) { - ResourceLoader::get_recognized_extensions_for_type(type.get_slice(",", i), &extensions); } @@ -162,7 +146,6 @@ void CustomPropertyEditor::_menu_option(int p_which) { file->clear_filters(); for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } @@ -170,24 +153,20 @@ void CustomPropertyEditor::_menu_option(int p_which) { } break; case OBJ_MENU_EDIT: { - REF r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); hide(); } } break; case OBJ_MENU_CLEAR: { - v = Variant(); emit_signal("variant_changed"); hide(); } break; case OBJ_MENU_MAKE_UNIQUE: { - Ref<Resource> res_orig = v; if (res_orig.is_null()) return; @@ -197,11 +176,9 @@ void CustomPropertyEditor::_menu_option(int p_which) { List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - Pair<String, Variant> p; PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { - p.first = pi.name; p.second = res_orig->get(pi.name); } @@ -218,7 +195,6 @@ void CustomPropertyEditor::_menu_option(int p_which) { ERR_FAIL_COND(res.is_null()); for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); } @@ -229,24 +205,20 @@ void CustomPropertyEditor::_menu_option(int p_which) { } break; case OBJ_MENU_COPY: { - EditorSettings::get_singleton()->set_resource_clipboard(v); } break; case OBJ_MENU_PASTE: { - v = EditorSettings::get_singleton()->get_resource_clipboard(); emit_signal("variant_changed"); } break; case OBJ_MENU_NEW_SCRIPT: { - if (Object::cast_to<Node>(owner)) EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), false); } break; case OBJ_MENU_EXTEND_SCRIPT: { - if (Object::cast_to<Node>(owner)) EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(Object::cast_to<Node>(owner), true); @@ -260,9 +232,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { tab_container->set_current_tab(file_system_dock->get_index()); } break; default: { - if (p_which >= CONVERT_BASE_ID) { - int to_type = p_which - CONVERT_BASE_ID; Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); @@ -280,7 +250,6 @@ void CustomPropertyEditor::_menu_option(int p_which) { String intype = inheritors_array[p_which - TYPE_BASE_ID]; if (intype == "ViewportTexture") { - scene_tree->set_title(TTR("Pick a Viewport")); scene_tree->popup_centered_ratio(); picking_viewport = true; @@ -322,17 +291,14 @@ void CustomPropertyEditor::hide_menu() { } Variant CustomPropertyEditor::get_variant() const { - return v; } String CustomPropertyEditor::get_name() const { - return name; } bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::Type p_type, const Variant &p_variant, int p_hint, String p_hint_text) { - owner = p_owner; updating = true; name = p_name; @@ -353,7 +319,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->set_size(Size2(1, 1) * EDSCALE); for (int i = 0; i < MAX_VALUE_EDITORS; i++) { - value_editor[i]->hide(); value_label[i]->hide(); if (i < 4) @@ -361,7 +326,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { - action_buttons[i]->hide(); } @@ -372,9 +336,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: type = (p_variant.get_type() != Variant::NIL && p_variant.get_type() != Variant::_RID && p_type != Variant::OBJECT) ? p_variant.get_type() : p_type; switch (type) { - case Variant::BOOL: { - checks20gc->show(); CheckBox *c = checks20[0]; @@ -389,24 +351,19 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::INT: case Variant::FLOAT: { - if (hint == PROPERTY_HINT_RANGE) { - int c = hint_text.get_slice_count(","); float min = 0, max = 100, step = type == Variant::FLOAT ? .01 : 1; if (c >= 1) { - if (!hint_text.get_slice(",", 0).empty()) min = hint_text.get_slice(",", 0).to_double(); } if (c >= 2) { - if (!hint_text.get_slice(",", 1).empty()) max = hint_text.get_slice(",", 1).to_double(); } if (c >= 3) { - if (!hint_text.get_slice(",", 2).empty()) step = hint_text.get_slice(",", 2).to_double(); } @@ -428,7 +385,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } } else if (hint == PROPERTY_HINT_ENUM) { - Vector<String> options = hint_text.split(","); int current_val = 0; for (int i = 0; i < options.size(); i++) { @@ -446,7 +402,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) { - String basename; switch (hint) { case PROPERTY_HINT_LAYERS_2D_RENDER: @@ -466,11 +421,9 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: checks20gc->show(); uint32_t flgs = v; for (int i = 0; i < 2; i++) { - Point2 ofs(4, 4); ofs.y += 22 * i; for (int j = 0; j < 10; j++) { - int idx = i * 10 + j; CheckBox *c = checks20[idx]; c->set_text(ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(idx + 1))); @@ -487,7 +440,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_position() + checks20gc->get_size()); } else if (hint == PROPERTY_HINT_EXP_EASING) { - 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); @@ -536,22 +488,18 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::STRING: { - if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) { - List<String> names; names.push_back(TTR("File...")); names.push_back(TTR("Clear")); config_action_buttons(names); } else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) { - List<String> names; names.push_back(TTR("Dir...")); names.push_back(TTR("Clear")); config_action_buttons(names); } else if (hint == PROPERTY_HINT_ENUM) { - Vector<String> options = hint_text.split(","); for (int i = 0; i < options.size(); i++) { menu->add_item(options[i], i); @@ -563,7 +511,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_MULTILINE_TEXT) { - text_edit->show(); text_edit->set_text(v); text_edit->deselect(); @@ -581,7 +528,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: action_buttons[0]->show(); } else if (hint == PROPERTY_HINT_TYPE_STRING) { - if (!create_dialog) { create_dialog = memnew(CreateDialog); create_dialog->connect("create", callable_mp(this, &CustomPropertyEditor::_create_dialog_callback)); @@ -630,7 +576,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) { - MAKE_PROPSELECT Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); @@ -651,7 +596,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE) { - MAKE_PROPSELECT Variant::Type type = Variant::NIL; String tname = hint_text; @@ -670,7 +614,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_PROPERTY_OF_BASE_TYPE) { - MAKE_PROPSELECT property_select->select_property_from_base_type(hint_text, v); @@ -679,7 +622,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: return false; } else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) { - MAKE_PROPSELECT Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64())); @@ -709,7 +651,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::VECTOR2: { - field_names.push_back("x"); field_names.push_back("y"); config_value_editors(2, 2, 10, field_names); @@ -718,7 +659,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[1]->set_text(String::num(vec.y)); } break; case Variant::RECT2: { - field_names.push_back("x"); field_names.push_back("y"); field_names.push_back("w"); @@ -731,7 +671,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[3]->set_text(String::num(r.size.y)); } break; case Variant::VECTOR3: { - field_names.push_back("x"); field_names.push_back("y"); field_names.push_back("z"); @@ -742,7 +681,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[2]->set_text(String::num(vec.z)); } break; case Variant::PLANE: { - field_names.push_back("x"); field_names.push_back("y"); field_names.push_back("z"); @@ -756,7 +694,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::QUAT: { - field_names.push_back("x"); field_names.push_back("y"); field_names.push_back("z"); @@ -770,7 +707,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::AABB: { - field_names.push_back("px"); field_names.push_back("py"); field_names.push_back("pz"); @@ -789,7 +725,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::TRANSFORM2D: { - field_names.push_back("xx"); field_names.push_back("xy"); field_names.push_back("yx"); @@ -800,13 +735,11 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Transform2D basis = v; for (int i = 0; i < 6; i++) { - value_editor[i]->set_text(String::num(basis.elements[i / 2][i % 2])); } } break; case Variant::BASIS: { - field_names.push_back("xx"); field_names.push_back("xy"); field_names.push_back("xz"); @@ -820,13 +753,11 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Basis basis = v; for (int i = 0; i < 9; i++) { - value_editor[i]->set_text(String::num(basis.elements[i / 3][i % 3])); } } break; case Variant::TRANSFORM: { - field_names.push_back("xx"); field_names.push_back("xy"); field_names.push_back("xz"); @@ -843,7 +774,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: Transform tr = v; for (int i = 0; i < 9; i++) { - value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3])); } @@ -853,7 +783,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::COLOR: { - if (!color_picker) { //late init for performance color_picker = memnew(ColorPicker); @@ -878,7 +807,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::NODE_PATH: { - List<String> names; names.push_back(TTR("Assign")); names.push_back(TTR("Clear")); @@ -890,7 +818,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::OBJECT: { - if (hint != PROPERTY_HINT_RESOURCE_TYPE) break; @@ -907,7 +834,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } for (int i = 0; i < hint_text.get_slice_count(","); i++) { - String base = hint_text.get_slice(",", i); Set<String> valid_inheritors; @@ -961,7 +887,6 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->add_item(TTR("Load"), OBJ_MENU_LOAD); if (!RES(v).is_null()) { - 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); @@ -990,18 +915,15 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->add_separator(); if (!RES(v).is_null()) { - menu->add_item(TTR("Copy"), OBJ_MENU_COPY); } if (paste_valid) { - menu->add_item(TTR("Paste"), OBJ_MENU_PASTE); } } if (!RES(v).is_null()) { - Vector<Ref<EditorResourceConversionPlugin>> conversions = EditorNode::get_singleton()->find_resource_conversion_plugin(RES(v)); if (conversions.size()) { menu->add_separator(); @@ -1020,31 +942,22 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } break; case Variant::DICTIONARY: { - } break; case Variant::PACKED_BYTE_ARRAY: { - } break; case Variant::PACKED_INT32_ARRAY: { - } break; case Variant::PACKED_FLOAT32_ARRAY: { - } break; case Variant::PACKED_INT64_ARRAY: { - } break; case Variant::PACKED_FLOAT64_ARRAY: { - } break; case Variant::PACKED_STRING_ARRAY: { - } break; case Variant::PACKED_VECTOR3_ARRAY: { - } break; case Variant::PACKED_COLOR_ARRAY: { - } break; default: { } @@ -1055,20 +968,15 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } void CustomPropertyEditor::_file_selected(String p_file) { - switch (type) { - case Variant::STRING: { - if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) { - v = ProjectSettings::get_singleton()->localize_path(p_file); emit_signal("variant_changed"); hide(); } if (hint == PROPERTY_HINT_GLOBAL_FILE || hint == PROPERTY_HINT_GLOBAL_DIR) { - v = p_file; emit_signal("variant_changed"); hide(); @@ -1076,7 +984,6 @@ void CustomPropertyEditor::_file_selected(String p_file) { } break; case Variant::OBJECT: { - String type = (hint == PROPERTY_HINT_RESOURCE_TYPE) ? hint_text : String(); RES res = ResourceLoader::load(p_file, type); @@ -1095,29 +1002,22 @@ void CustomPropertyEditor::_file_selected(String p_file) { } void CustomPropertyEditor::_type_create_selected(int p_idx) { - if (type == Variant::INT || type == Variant::FLOAT) { - float newval = 0; switch (p_idx) { - case EASING_LINEAR: { - newval = 1; } break; case EASING_EASE_IN: { - newval = 2.0; } break; case EASING_EASE_OUT: { newval = 0.5; } break; case EASING_ZERO: { - newval = 0; } break; case EASING_IN_OUT: { - newval = -0.5; } break; case EASING_OUT_IN: { @@ -1130,7 +1030,6 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { easing_draw->update(); } else if (type == Variant::OBJECT) { - ERR_FAIL_INDEX(p_idx, inheritors_array.size()); String intype = inheritors_array[p_idx]; @@ -1157,15 +1056,12 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) { } void CustomPropertyEditor::_color_changed(const Color &p_color) { - v = p_color; emit_signal("variant_changed"); } void CustomPropertyEditor::_node_path_selected(NodePath p_path) { - if (picking_viewport) { - Node *to_node = get_node(p_path); if (!Object::cast_to<Viewport>(to_node)) { EditorNode::get_singleton()->show_warning(TTR("Selected node is not a Viewport!")); @@ -1182,10 +1078,8 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } if (hint == PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE && hint_text != String()) { - Node *node = get_node(hint_text); if (node) { - Node *tonode = node->get_node(p_path); if (tonode) { p_path = node->get_path_to(tonode); @@ -1193,7 +1087,6 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } } else if (owner) { - Node *node = nullptr; if (owner->is_class("Node")) @@ -1221,7 +1114,6 @@ void CustomPropertyEditor::_node_path_selected(NodePath p_path) { } void CustomPropertyEditor::_action_pressed(int p_which) { - if (updating) return; @@ -1231,9 +1123,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { emit_signal("variant_changed"); } break; case Variant::INT: { - if (hint == PROPERTY_HINT_LAYERS_2D_PHYSICS || hint == PROPERTY_HINT_LAYERS_2D_RENDER || hint == PROPERTY_HINT_LAYERS_3D_PHYSICS || hint == PROPERTY_HINT_LAYERS_3D_RENDER) { - uint32_t f = v; if (checks20[p_which]->is_pressed()) f |= (1 << p_which); @@ -1246,14 +1136,11 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } break; case Variant::STRING: { - if (hint == PROPERTY_HINT_MULTILINE_TEXT) { - hide(); } else if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_GLOBAL_FILE) { if (p_which == 0) { - if (hint == PROPERTY_HINT_FILE) file->set_access(EditorFileDialog::ACCESS_RESOURCES); else @@ -1267,7 +1154,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) { if (hint_text != "") { Vector<String> extensions = hint_text.split(","); for (int i = 0; i < extensions.size(); i++) { - String filter = extensions[i]; if (filter.begins_with(".")) filter = "*" + extensions[i]; @@ -1279,16 +1165,13 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } file->popup_centered_ratio(); } else { - v = ""; emit_signal("variant_changed"); hide(); } } else if (hint == PROPERTY_HINT_DIR || hint == PROPERTY_HINT_GLOBAL_DIR) { - if (p_which == 0) { - if (hint == PROPERTY_HINT_DIR) file->set_access(EditorFileDialog::ACCESS_RESOURCES); else @@ -1297,7 +1180,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) { file->clear_filters(); file->popup_centered_ratio(); } else { - v = ""; emit_signal("variant_changed"); hide(); @@ -1306,22 +1188,17 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } break; case Variant::NODE_PATH: { - if (p_which == 0) { - picking_viewport = false; scene_tree->set_title(TTR("Pick a Node")); scene_tree->popup_centered_ratio(); } else if (p_which == 1) { - v = NodePath(); emit_signal("variant_changed"); hide(); } else if (p_which == 2) { - if (owner->is_class("Node") && (v.get_type() == Variant::NODE_PATH) && Object::cast_to<Node>(owner)->has_node(v)) { - Node *target_node = Object::cast_to<Node>(owner)->get_node(v); EditorNode::get_singleton()->get_editor_selection()->clear(); EditorNode::get_singleton()->get_scene_tree_dock()->set_selected(target_node); @@ -1332,15 +1209,12 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } break; case Variant::OBJECT: { - if (p_which == 0) { - ERR_FAIL_COND(inheritors_array.empty()); String intype = inheritors_array[0]; if (hint == PROPERTY_HINT_RESOURCE_TYPE) { - Object *obj = ClassDB::instance(intype); if (!obj) { @@ -1360,7 +1234,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) { hide(); } } else if (p_which == 1) { - file->set_access(EditorFileDialog::ACCESS_RESOURCES); file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); List<String> extensions; @@ -1369,29 +1242,24 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ResourceLoader::get_recognized_extensions_for_type(type, &extensions); file->clear_filters(); for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); } file->popup_centered_ratio(); } else if (p_which == 2) { - RES r = v; if (!r.is_null()) { - emit_signal("resource_edit_request"); hide(); } } else if (p_which == 3) { - v = Variant(); emit_signal("variant_changed"); hide(); } else if (p_which == 4) { - Ref<Resource> res_orig = v; if (res_orig.is_null()) return; @@ -1401,11 +1269,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) { List<Pair<String, Variant>> propvalues; for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) { - Pair<String, Variant> p; PropertyInfo &pi = E->get(); if (pi.usage & PROPERTY_USAGE_STORAGE) { - p.first = pi.name; p.second = res_orig->get(pi.name); } @@ -1418,7 +1284,6 @@ void CustomPropertyEditor::_action_pressed(int p_which) { ERR_FAIL_COND(res.is_null()); for (List<Pair<String, Variant>>::Element *E = propvalues.front(); E; E = E->next()) { - Pair<String, Variant> &p = E->get(); res->set(p.first, p.second); } @@ -1436,11 +1301,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) { - Ref<InputEventMouseMotion> mm = p_ev; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { - float rel = mm->get_relative().x; if (rel == 0) return; @@ -1471,7 +1334,6 @@ void CustomPropertyEditor::_drag_easing(const Ref<InputEvent> &p_ev) { } void CustomPropertyEditor::_draw_easing() { - RID ci = easing_draw->get_canvas_item(); Size2 s = easing_draw->get_size(); @@ -1489,7 +1351,6 @@ void CustomPropertyEditor::_draw_easing() { Color color = easing_draw->get_theme_color("font_color", "Label"); for (int i = 1; i <= points; i++) { - float ifl = i / float(points); float iflp = (i - 1) / float(points); @@ -1508,25 +1369,21 @@ void CustomPropertyEditor::_draw_easing() { } void CustomPropertyEditor::_text_edit_changed() { - v = text_edit->get_text(); emit_signal("variant_changed"); } void CustomPropertyEditor::_create_dialog_callback() { - v = create_dialog->get_selected_type(); emit_signal("variant_changed"); } void CustomPropertyEditor::_create_selected_property(const String &p_prop) { - v = p_prop; emit_signal("variant_changed"); } void CustomPropertyEditor::_modified(String p_string) { - if (updating) return; @@ -1547,7 +1404,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::FLOAT: { - if (hint != PROPERTY_HINT_EXP_EASING) { String text = value_editor[0]->get_text(); v = _parse_real_expression(text); @@ -1556,12 +1412,10 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::STRING: { - v = value_editor[0]->get_text(); emit_signal("variant_changed"); } break; case Variant::VECTOR2: { - Vector2 vec; vec.x = _parse_real_expression(value_editor[0]->get_text()); vec.y = _parse_real_expression(value_editor[1]->get_text()); @@ -1570,7 +1424,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::RECT2: { - Rect2 r2; r2.position.x = _parse_real_expression(value_editor[0]->get_text()); @@ -1583,7 +1436,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::VECTOR3: { - Vector3 vec; vec.x = _parse_real_expression(value_editor[0]->get_text()); vec.y = _parse_real_expression(value_editor[1]->get_text()); @@ -1593,7 +1445,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::PLANE: { - Plane pl; pl.normal.x = _parse_real_expression(value_editor[0]->get_text()); pl.normal.y = _parse_real_expression(value_editor[1]->get_text()); @@ -1604,7 +1455,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::QUAT: { - Quat q; q.x = _parse_real_expression(value_editor[0]->get_text()); q.y = _parse_real_expression(value_editor[1]->get_text()); @@ -1615,7 +1465,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::AABB: { - Vector3 pos; Vector3 size; @@ -1630,7 +1479,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::TRANSFORM2D: { - Transform2D m; for (int i = 0; i < 6; i++) { m.elements[i / 2][i % 2] = _parse_real_expression(value_editor[i]->get_text()); @@ -1641,7 +1489,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::BASIS: { - Basis m; for (int i = 0; i < 9; i++) { m.elements[i / 3][i % 3] = _parse_real_expression(value_editor[i]->get_text()); @@ -1652,7 +1499,6 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::TRANSFORM: { - Basis basis; for (int i = 0; i < 9; i++) { basis.elements[i / 3][i % 3] = _parse_real_expression(value_editor[(i / 3) * 4 + i % 3]->get_text()); @@ -1669,34 +1515,25 @@ void CustomPropertyEditor::_modified(String p_string) { } break; case Variant::COLOR: { - } break; case Variant::NODE_PATH: { - v = NodePath(value_editor[0]->get_text()); emit_signal("variant_changed"); } break; case Variant::DICTIONARY: { - } break; case Variant::PACKED_BYTE_ARRAY: { - } break; case Variant::PACKED_INT32_ARRAY: { - } break; case Variant::PACKED_FLOAT32_ARRAY: { - } break; case Variant::PACKED_STRING_ARRAY: { - } break; case Variant::PACKED_VECTOR3_ARRAY: { - } break; case Variant::PACKED_COLOR_ARRAY: { - } break; default: { } @@ -1719,7 +1556,6 @@ real_t CustomPropertyEditor::_parse_real_expression(String text) { } void CustomPropertyEditor::_emit_changed_whole_or_field() { - if (!Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { emit_signal("variant_changed"); } else { @@ -1781,7 +1617,6 @@ void CustomPropertyEditor::_focus_exit() { } void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) { - 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); @@ -1792,9 +1627,7 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) int height = 0; for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { - if (i < p_strings.size()) { - action_buttons[i]->show(); action_buttons[i]->set_text(p_strings[i]); @@ -1808,7 +1641,6 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) } for (int i = 0; i < p_strings.size(); i++) { - Size2 btn_m_size = action_buttons[i]->get_size(); action_buttons[i]->set_position(Point2(0, height) + Point2(margin_left, margin_top)); action_buttons[i]->set_size(Size2(max_width, btn_m_size.height)); @@ -1819,7 +1651,6 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) } void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int p_label_w, const List<String> &p_strings) { - int cell_width = 95; int cell_height = 25; int cell_margin = 5; @@ -1830,7 +1661,6 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int set_size(Size2(cell_margin + p_label_w + (cell_width + cell_margin + p_label_w) * p_columns, cell_margin + (cell_height + cell_margin) * rows) * EDSCALE); for (int i = 0; i < MAX_VALUE_EDITORS; i++) { - int c = i % p_columns; int r = i / p_columns; @@ -1850,19 +1680,16 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int } void CustomPropertyEditor::_bind_methods() { - ADD_SIGNAL(MethodInfo("variant_changed")); ADD_SIGNAL(MethodInfo("variant_field_changed", PropertyInfo(Variant::STRING, "field"))); ADD_SIGNAL(MethodInfo("resource_edit_request")); } CustomPropertyEditor::CustomPropertyEditor() { - read_only = false; updating = false; for (int i = 0; i < MAX_VALUE_EDITORS; i++) { - value_editor[i] = memnew(LineEdit); add_child(value_editor[i]); value_label[i] = memnew(Label); @@ -1876,7 +1703,6 @@ CustomPropertyEditor::CustomPropertyEditor() { focused_value_editor = -1; for (int i = 0; i < 4; i++) { - scroll[i] = memnew(HScrollBar); scroll[i]->hide(); scroll[i]->set_min(0); @@ -1914,7 +1740,6 @@ CustomPropertyEditor::CustomPropertyEditor() { text_edit->connect("text_changed", callable_mp(this, &CustomPropertyEditor::_text_edit_changed)); for (int i = 0; i < MAX_ACTION_BUTTONS; i++) { - action_buttons[i] = memnew(Button); action_buttons[i]->hide(); add_child(action_buttons[i]); diff --git a/editor/property_editor.h b/editor/property_editor.h index 45466eaa42..5b7db3b83f 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -51,7 +51,6 @@ class CreateDialog; class PropertySelector; class EditorResourceConversionPlugin : public Reference { - GDCLASS(EditorResourceConversionPlugin, Reference); protected: @@ -64,7 +63,6 @@ public: }; class CustomPropertyEditor : public PopupPanel { - GDCLASS(CustomPropertyEditor, PopupPanel); enum { diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 1960ecc604..37de0b51d9 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -35,22 +35,18 @@ #include "editor_scale.h" void PropertySelector::_text_changed(const String &p_newtext) { - _update_search(); } void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; if (k.is_valid()) { - switch (k->get_keycode()) { case KEY_UP: case KEY_DOWN: case KEY_PAGEUP: case KEY_PAGEDOWN: { - search_options->call("_gui_input", k); search_box->accept_event(); @@ -74,7 +70,6 @@ void PropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) { } void PropertySelector::_update_search() { - if (properties) set_title(TTR("Select Property")); else if (virtuals_only) @@ -88,7 +83,6 @@ void PropertySelector::_update_search() { TreeItem *root = search_options->create_item(); if (properties) { - List<PropertyInfo> props; if (instance) { @@ -100,10 +94,8 @@ void PropertySelector::_update_search() { v.get_property_list(&props); } else { - Object *obj = ObjectDB::get_instance(script); if (Object::cast_to<Script>(obj)) { - props.push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CATEGORY)); Object::cast_to<Script>(obj)->get_script_property_list(&props); } @@ -195,7 +187,6 @@ void PropertySelector::_update_search() { memdelete(category); //old category was unused } } else { - List<MethodInfo> methods; if (type != Variant::NIL) { @@ -204,10 +195,8 @@ void PropertySelector::_update_search() { v = Variant::construct(type, nullptr, 0, ce); v.get_method_list(&methods); } else { - Object *obj = ObjectDB::get_instance(script); if (Object::cast_to<Script>(obj)) { - methods.push_back(MethodInfo("*Script Methods")); Object::cast_to<Script>(obj)->get_script_method_list(&methods); } @@ -277,7 +266,6 @@ void PropertySelector::_update_search() { desc += " " + mi.name + " ( "; for (int i = 0; i < mi.arguments.size(); i++) { - if (i > 0) desc += ", "; @@ -319,7 +307,6 @@ void PropertySelector::_update_search() { } void PropertySelector::_confirmed() { - TreeItem *ti = search_options->get_selected(); if (!ti) return; @@ -328,7 +315,6 @@ void PropertySelector::_confirmed() { } void PropertySelector::_item_selected() { - help_bit->set_text(""); TreeItem *item = search_options->get_selected(); @@ -348,11 +334,9 @@ void PropertySelector::_item_selected() { String text; if (properties) { - String at_class = class_type; while (at_class != String()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class); if (E) { for (int i = 0; i < E->get().properties.size(); i++) { @@ -365,11 +349,9 @@ void PropertySelector::_item_selected() { at_class = ClassDB::get_parent_class(at_class); } } else { - String at_class = class_type; while (at_class != String()) { - Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class); if (E) { for (int i = 0; i < E->get().methods.size(); i++) { @@ -394,9 +376,7 @@ void PropertySelector::_hide_requested() { } void PropertySelector::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - connect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); } else if (p_what == NOTIFICATION_EXIT_TREE) { disconnect("confirmed", callable_mp(this, &PropertySelector::_confirmed)); @@ -404,7 +384,6 @@ void PropertySelector::_notification(int p_what) { } void PropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only) { - base_type = p_base; selected = p_current; type = Variant::NIL; @@ -420,7 +399,6 @@ void PropertySelector::select_method_from_base_type(const String &p_base, const } void PropertySelector::select_method_from_script(const Ref<Script> &p_script, const String &p_current) { - ERR_FAIL_COND(p_script.is_null()); base_type = p_script->get_instance_base_type(); selected = p_current; @@ -436,7 +414,6 @@ void PropertySelector::select_method_from_script(const Ref<Script> &p_script, co _update_search(); } void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const String &p_current) { - ERR_FAIL_COND(p_type == Variant::NIL); base_type = ""; selected = p_current; @@ -453,7 +430,6 @@ void PropertySelector::select_method_from_basic_type(Variant::Type p_type, const } void PropertySelector::select_method_from_instance(Object *p_instance, const String &p_current) { - base_type = p_instance->get_class(); selected = p_current; type = Variant::NIL; @@ -474,7 +450,6 @@ void PropertySelector::select_method_from_instance(Object *p_instance, const Str } void PropertySelector::select_property_from_base_type(const String &p_base, const String &p_current) { - base_type = p_base; selected = p_current; type = Variant::NIL; @@ -490,7 +465,6 @@ void PropertySelector::select_property_from_base_type(const String &p_base, cons } void PropertySelector::select_property_from_script(const Ref<Script> &p_script, const String &p_current) { - ERR_FAIL_COND(p_script.is_null()); base_type = p_script->get_instance_base_type(); @@ -508,7 +482,6 @@ void PropertySelector::select_property_from_script(const Ref<Script> &p_script, } void PropertySelector::select_property_from_basic_type(Variant::Type p_type, const String &p_current) { - ERR_FAIL_COND(p_type == Variant::NIL); base_type = ""; selected = p_current; @@ -525,7 +498,6 @@ void PropertySelector::select_property_from_basic_type(Variant::Type p_type, con } void PropertySelector::select_property_from_instance(Object *p_instance, const String &p_current) { - base_type = ""; selected = p_current; type = Variant::NIL; @@ -545,12 +517,10 @@ void PropertySelector::set_type_filter(const Vector<Variant::Type> &p_type_filte } void PropertySelector::_bind_methods() { - ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"))); } PropertySelector::PropertySelector() { - VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); //set_child_rect(vbc); diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 1363fe2942..8532ed23be 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -42,12 +42,10 @@ 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) { - String ttpath = EditorSettings::get_singleton()->get("filesystem/import/pvrtc_texture_tool"); if (ttpath.strip_edges() == "" || !FileAccess::exists(ttpath)) { switch (p_mode) { - case Image::COMPRESS_PVRTC2: if (_base_image_compress_pvrtc2_func) _base_image_compress_pvrtc2_func(p_image); @@ -125,17 +123,14 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { } static void _compress_pvrtc2(Image *p_image) { - _compress_image(Image::COMPRESS_PVRTC2, p_image); } static void _compress_pvrtc4(Image *p_image) { - _compress_image(Image::COMPRESS_PVRTC4, p_image); } void _pvrtc_register_compressors() { - _base_image_compress_pvrtc2_func = Image::_image_compress_pvrtc2_func; _base_image_compress_pvrtc4_func = Image::_image_compress_pvrtc4_func; diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index b872bc3dd4..e16b1f61fb 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -33,7 +33,6 @@ #include "core/os/keyboard.h" void EditorQuickOpen::popup_dialog(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { - add_directories = p_add_dirs; popup_centered_ratio(0.6); if (p_dontclear) @@ -50,7 +49,6 @@ void EditorQuickOpen::popup_dialog(const StringName &p_base, bool p_enable_multi } String EditorQuickOpen::get_selected() const { - TreeItem *ti = search_options->get_selected(); if (!ti) return String(); @@ -59,12 +57,10 @@ String EditorQuickOpen::get_selected() const { } Vector<String> EditorQuickOpen::get_selected_files() const { - Vector<String> files; TreeItem *item = search_options->get_next_selected(search_options->get_root()); while (item) { - files.push_back("res://" + item->get_text(0)); item = search_options->get_next_selected(item); @@ -74,21 +70,17 @@ Vector<String> EditorQuickOpen::get_selected_files() const { } void EditorQuickOpen::_text_changed(const String &p_newtext) { - _update_search(); } void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { - Ref<InputEventKey> k = p_ie; if (k.is_valid()) { - switch (k->get_keycode()) { case KEY_UP: case KEY_DOWN: case KEY_PAGEUP: case KEY_PAGEDOWN: { - search_options->call("_gui_input", k); search_box->accept_event(); @@ -112,7 +104,6 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) { } float EditorQuickOpen::_path_cmp(String search, String path) const { - // Exact match. if (search == path) { return 1.2f; @@ -129,10 +120,8 @@ float EditorQuickOpen::_path_cmp(String search, String path) const { } 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++) { - _parse_fs(efsd->get_subdir(i), list); } } @@ -151,7 +140,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str pair.second = search_options->get_theme_icon("folder", "FileDialog"); if (search_text != String() && list.size() > 0) { - float this_sim = _path_cmp(search_text, path); float other_sim = _path_cmp(list[0].first, path); int pos = 1; @@ -170,7 +158,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str } } for (int i = 0; i < efsd->get_file_count(); i++) { - String file = efsd->get_file_path(i); file = file.substr(6, file.length()); @@ -184,14 +171,12 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str if (add_directories) { for (int i = 0; i < efsd->get_subdir_count(); i++) { - _parse_fs(efsd->get_subdir(i), 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; @@ -204,7 +189,6 @@ Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<Strin scores.write[i] = _path_cmp(search_text, list[i].first); while (list.size() > 0) { - float best_score = 0.0f; int best_idx = 0; @@ -225,7 +209,6 @@ Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<Strin } void EditorQuickOpen::_update_search() { - search_options->clear(); TreeItem *root = search_options->create_item(); EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); @@ -251,7 +234,6 @@ void EditorQuickOpen::_update_search() { } void EditorQuickOpen::_confirmed() { - TreeItem *ti = search_options->get_selected(); if (!ti) return; @@ -260,12 +242,10 @@ void EditorQuickOpen::_confirmed() { } 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) { case NOTIFICATION_ENTER_TREE: { connect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); @@ -279,17 +259,14 @@ void EditorQuickOpen::_notification(int p_what) { } StringName EditorQuickOpen::get_base_type() const { - return base_type; } void EditorQuickOpen::_bind_methods() { - ADD_SIGNAL(MethodInfo("quick_open")); } EditorQuickOpen::EditorQuickOpen() { - VBoxContainer *vbc = memnew(VBoxContainer); vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed)); diff --git a/editor/quick_open.h b/editor/quick_open.h index c0e2cb85d8..e446ed6823 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -36,7 +36,6 @@ #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" class EditorQuickOpen : public ConfirmationDialog { - GDCLASS(EditorQuickOpen, ConfirmationDialog); LineEdit *search_box; diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 8ae8d0991d..fa44efda29 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -42,7 +42,6 @@ #include "scene/gui/tab_container.h" RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { - scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; preview_node = nullptr; @@ -341,12 +340,10 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und } void RenameDialog::_bind_methods() { - ClassDB::bind_method("rename", &RenameDialog::rename); } void RenameDialog::_update_substitute() { - 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); @@ -367,7 +364,6 @@ void RenameDialog::_update_substitute() { } void RenameDialog::_post_popup() { - EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); preview_node = nullptr; @@ -385,7 +381,6 @@ void RenameDialog::_update_preview_int(int new_value) { } void RenameDialog::_update_preview(String new_text) { - if (lock_preview_update || preview_node == nullptr) return; @@ -395,7 +390,6 @@ void RenameDialog::_update_preview(String new_text) { String new_name = _apply_rename(preview_node, spn_count_start->get_value()); if (!has_errors) { - lbl_preview_title->set_text(TTR("Preview")); lbl_preview->set_text(new_name); @@ -413,7 +407,6 @@ void RenameDialog::_update_preview(String new_text) { } String RenameDialog::_apply_rename(const Node *node, int count) { - String search = lne_search->get_text(); String replace = lne_replace->get_text(); String prefix = lne_prefix->get_text(); @@ -428,7 +421,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } if (cbut_regex->is_pressed()) { - new_name = _regex(search, new_name, replace); } else { new_name = new_name.replace(search, replace); @@ -444,7 +436,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } String RenameDialog::_substitute(const String &subject, const Node *node, int count) { - String result = subject.replace("${COUNTER}", vformat("%0" + itos(spn_count_padding->get_value()) + "d", count)); if (node) { @@ -474,7 +465,6 @@ String RenameDialog::_substitute(const String &subject, const Node *node, int co } void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) { - RenameDialog *self = (RenameDialog *)p_self; String source_file(p_file); @@ -496,14 +486,12 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * } String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) { - RegEx regex(pattern); return regex.sub(subject, replacement, true); } String RenameDialog::_postprocess(const String &subject) { - int style_id = opt_style->get_selected(); String result = subject; @@ -550,12 +538,10 @@ String RenameDialog::_postprocess(const String &subject) { } void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int *counter) { - if (!node) return; if (selection.has(node)) { - String new_name = _apply_rename(node, *counter); if (node->get_name() != new_name) { @@ -581,7 +567,6 @@ void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int } void RenameDialog::rename() { - // Editor selection is not ordered via scene tree. Instead iterate // over scene tree until all selected nodes are found in order. @@ -596,12 +581,10 @@ void RenameDialog::rename() { _iterate_scene(root_node, selected_node_list, &global_count); if (undo_redo && !to_rename.empty()) { - undo_redo->create_action(TTR("Batch Rename")); // Make sure to iterate reversed so that child nodes will find parents. for (int i = to_rename.size() - 1; i >= 0; --i) { - Node *n = root_node->get_node(to_rename[i].first); const String &new_name = to_rename[i].second; @@ -620,7 +603,6 @@ void RenameDialog::rename() { } void RenameDialog::reset() { - lock_preview_update = true; lne_prefix->clear(); @@ -651,7 +633,6 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) { } void RenameDialog::_insert_text(String text) { - LineEdit *focus_owner = Object::cast_to<LineEdit>(scene_tree_editor->get_focus_owner()); if (_is_main_field(focus_owner)) { diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 280bd00d95..dfdb1bcd76 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -44,7 +44,6 @@ */ class RenameDialog : public ConfirmationDialog { - GDCLASS(RenameDialog, ConfirmationDialog); virtual void ok_pressed() { rename(); }; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index b71c2bd078..cfcb5234dd 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -35,46 +35,37 @@ #include "scene/gui/label.h" void ReparentDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - connect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); } if (p_what == NOTIFICATION_EXIT_TREE) { - disconnect("confirmed", callable_mp(this, &ReparentDialog::_reparent)); } } void ReparentDialog::_cancel() { - hide(); } void ReparentDialog::_reparent() { - if (tree->get_selected()) { - emit_signal("reparent", tree->get_selected()->get_path(), keep_transform->is_pressed()); hide(); } } void ReparentDialog::set_current(const Set<Node *> &p_selection) { - tree->set_marked(p_selection, false, false); //tree->set_selected(p_node->get_parent()); } void ReparentDialog::_bind_methods() { - ClassDB::bind_method("_cancel", &ReparentDialog::_cancel); ADD_SIGNAL(MethodInfo("reparent", PropertyInfo(Variant::NODE_PATH, "path"), PropertyInfo(Variant::BOOL, "keep_global_xform"))); } ReparentDialog::ReparentDialog() { - set_title(TTR("Reparent Node")); VBoxContainer *vbc = memnew(VBoxContainer); diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h index 29db70baa5..4566e3a02a 100644 --- a/editor/reparent_dialog.h +++ b/editor/reparent_dialog.h @@ -41,7 +41,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ class ReparentDialog : public ConfirmationDialog { - GDCLASS(ReparentDialog, ConfirmationDialog); SceneTreeEditor *tree; diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp index a5ae1fd8a6..c113abb86d 100644 --- a/editor/run_settings_dialog.cpp +++ b/editor/run_settings_dialog.cpp @@ -31,26 +31,21 @@ #include "run_settings_dialog.h" void RunSettingsDialog::popup_run_settings() { - popup_centered(Size2(300, 150)); } void RunSettingsDialog::set_custom_arguments(const String &p_arguments) { - arguments->set_text(p_arguments); } String RunSettingsDialog::get_custom_arguments() const { - return arguments->get_text(); } void RunSettingsDialog::_bind_methods() { - //ClassDB::bind_method("_browse_selected_file",&RunSettingsDialog::_browse_selected_file); } void RunSettingsDialog::_run_mode_changed(int idx) { - if (idx == 0) arguments->set_editable(false); else @@ -58,18 +53,15 @@ void RunSettingsDialog::_run_mode_changed(int idx) { } int RunSettingsDialog::get_run_mode() const { - return run_mode->get_selected(); } void RunSettingsDialog::set_run_mode(int p_run_mode) { - run_mode->select(p_run_mode); arguments->set_editable(p_run_mode); } RunSettingsDialog::RunSettingsDialog() { - /* SNAP DIALOG */ VBoxContainer *vbc = memnew(VBoxContainer); diff --git a/editor/run_settings_dialog.h b/editor/run_settings_dialog.h index b812bbfa9e..4d6d842de0 100644 --- a/editor/run_settings_dialog.h +++ b/editor/run_settings_dialog.h @@ -37,7 +37,6 @@ #include "scene/gui/line_edit.h" class RunSettingsDialog : public AcceptDialog { - GDCLASS(RunSettingsDialog, AcceptDialog); public: diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 6e00e3c291..c385405a01 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -50,7 +50,6 @@ #include "servers/rendering_server.h" void SceneTreeDock::_nodes_drag_begin() { - if (restore_script_editor_on_drag) { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); restore_script_editor_on_drag = false; @@ -65,7 +64,6 @@ void SceneTreeDock::_quick_open() { } void SceneTreeDock::_input(Ref<InputEvent> p_event) { - Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { @@ -74,7 +72,6 @@ void SceneTreeDock::_input(Ref<InputEvent> p_event) { } void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { - if (get_focus_owner() && get_focus_owner()->is_text_field()) return; @@ -119,7 +116,6 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { } void SceneTreeDock::instance(const String &p_file) { - Node *parent = scene_tree->get_selected(); if (!parent) { @@ -127,7 +123,6 @@ void SceneTreeDock::instance(const String &p_file) { }; if (!edited_scene) { - current_option = -1; accept->set_text(TTR("No parent to instance a child at.")); accept->popup_centered(); @@ -142,7 +137,6 @@ void SceneTreeDock::instance(const String &p_file) { } void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_parent) { - Node *parent = p_parent; if (!parent) { @@ -150,7 +144,6 @@ 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(); return; @@ -160,7 +153,6 @@ void SceneTreeDock::instance_scenes(const Vector<String> &p_files, Node *p_paren } void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node *parent, int p_pos) { - ERR_FAIL_COND(!parent); Vector<Node *> instances; @@ -168,7 +160,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node bool error = false; for (int i = 0; i < p_files.size(); i++) { - Ref<PackedScene> sdata = ResourceLoader::load(p_files[i]); if (!sdata.is_valid()) { current_option = -1; @@ -188,9 +179,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node } if (edited_scene->get_filename() != "") { - 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(); error = true; @@ -213,7 +202,6 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node editor_data->get_undo_redo().create_action(TTR("Instance Scene(s)")); for (int i = 0; i < instances.size(); i++) { - Node *instanced_scene = instances[i]; editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene); @@ -331,11 +319,9 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de } void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { - current_option = p_tool; switch (p_tool) { - case TOOL_BATCH_RENAME: { if (!profile_allow_editing) { break; @@ -356,7 +342,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_NEW: case TOOL_REPARENT_TO_NEW_NODE: { - if (!profile_allow_editing) { break; } @@ -364,7 +349,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *current_edited_scene_root = EditorNode::get_singleton()->get_edited_scene(); if (current_edited_scene_root) { - 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(), "Node3D")) @@ -374,7 +358,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { create_dialog->popup_create(true); } break; case TOOL_INSTANCE: { - if (!profile_allow_editing) { break; } @@ -390,7 +373,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_EXPAND_COLLAPSE: { - if (!scene_tree->get_selected()) break; @@ -407,7 +389,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_REPLACE: { - if (!profile_allow_editing) { break; } @@ -427,7 +408,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { attach_script_to_selected(false); } break; case TOOL_DETACH_SCRIPT: { - if (!profile_allow_script_editing) { break; } @@ -441,7 +421,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor, "push_item", (Script *)nullptr); for (int i = 0; i < selection.size(); i++) { - Node *n = Object::cast_to<Node>(selection[i]); Ref<Script> existing = n->get_script(); Ref<Script> empty = EditorNode::get_singleton()->get_object_custom_type_base(n); @@ -458,7 +437,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_MOVE_UP: case TOOL_MOVE_DOWN: { - if (!profile_allow_editing) { break; } @@ -467,7 +445,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; if (scene_tree->get_selected() == edited_scene) { - current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); accept->popup_centered(); @@ -526,7 +503,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_DUPLICATE: { - if (!profile_allow_editing) { break; } @@ -535,7 +511,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; if (editor_selection->is_selected(edited_scene)) { - current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); accept->popup_centered(); @@ -560,7 +535,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { Node *add_below_node = selection.back()->get(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - Node *node = E->get(); Node *parent = node->get_parent(); @@ -582,9 +556,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(parent, "add_child_below_node", add_below_node, dup); for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - if (!duplimap.has(F->get())) { - continue; } Node *d = duplimap[F->get()]; @@ -612,7 +584,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_REPARENT: { - if (!profile_allow_editing) { break; } @@ -621,7 +592,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; if (editor_selection->is_selected(edited_scene)) { - current_option = -1; accept->set_text(TTR("This operation can't be done on the tree root.")); accept->popup_centered(); @@ -634,7 +604,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> nodes = editor_selection->get_selected_node_list(); Set<Node *> nodeset; for (List<Node *>::Element *E = nodes.front(); E; E = E->next()) { - nodeset.insert(E->get()); } reparent_dialog->popup_centered_ratio(); @@ -642,7 +611,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_MAKE_ROOT: { - if (!profile_allow_editing) { break; } @@ -701,7 +669,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().commit_action(); } break; case TOOL_MULTI_EDIT: { - if (!profile_allow_editing) { break; } @@ -719,7 +686,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_ERASE: { - if (!profile_allow_editing) { break; } @@ -756,7 +722,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_MERGE_FROM_SCENE: { - if (!profile_allow_editing) { break; } @@ -764,7 +729,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorNode::get_singleton()->merge_from_scene(); } break; case TOOL_NEW_SCENE_FROM: { - if (!profile_allow_editing) { break; } @@ -820,7 +784,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { new_scene_from_dialog->set_title(TTR("Save New Scene As...")); } break; case TOOL_COPY_NODE_PATH: { - List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); if (e) { @@ -840,7 +803,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); } break; case TOOL_SCENE_EDITABLE_CHILDREN: { - if (!profile_allow_editing) { break; } @@ -862,7 +824,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_SCENE_USE_PLACEHOLDER: { - if (!profile_allow_editing) { break; } @@ -893,7 +854,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_SCENE_MAKE_LOCAL: { - if (!profile_allow_editing) { break; } @@ -920,7 +880,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_SCENE_OPEN: { - List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); if (e) { @@ -954,7 +913,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } break; case TOOL_SCENE_OPEN_INHERITED: { - List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); if (e) { @@ -968,7 +926,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { case TOOL_CREATE_3D_SCENE: case TOOL_CREATE_USER_INTERFACE: case TOOL_CREATE_FAVORITE: { - Node *new_node = nullptr; if (TOOL_CREATE_FAVORITE == p_tool) { @@ -1019,9 +976,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; default: { - if (p_tool >= EDIT_SUBRESOURCE_BASE) { - int idx = p_tool - EDIT_SUBRESOURCE_BASE; ERR_FAIL_INDEX(idx, subresources.size()); @@ -1036,7 +991,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } void SceneTreeDock::_node_collapsed(Object *p_obj) { - TreeItem *ti = Object::cast_to<TreeItem>(p_obj); if (!ti) return; @@ -1047,10 +1001,8 @@ void SceneTreeDock::_node_collapsed(Object *p_obj) { } void SceneTreeDock::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_READY: { - if (!first_enter) break; first_enter = false; @@ -1154,7 +1106,6 @@ void SceneTreeDock::_notification(int p_what) { 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() == nullptr; if (show_create_root != create_root_dialog->is_visible_in_tree() && !remote_tree->is_visible()) { @@ -1172,7 +1123,6 @@ void SceneTreeDock::_notification(int p_what) { } void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode) { - if (p_node->get_owner() == p_base && p_node != p_root) { UndoRedo *undo_redo = &editor_data->get_undo_redo(); switch (p_mode) { @@ -1198,21 +1148,17 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root } void SceneTreeDock::_load_request(const String &p_path) { - editor->open_request(p_path); } void SceneTreeDock::_script_open_request(const Ref<Script> &p_script) { - editor->edit_resource(p_script); } void SceneTreeDock::_node_selected() { - Node *node = scene_tree->get_selected(); if (!node) { - editor->push_item(nullptr); return; } @@ -1225,14 +1171,11 @@ void SceneTreeDock::_node_selected() { } void SceneTreeDock::_node_renamed() { - _node_selected(); } void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { - for (int i = 0; i < p_nodes.size(); i++) { - Node *n = Object::cast_to<Node>(p_nodes[i]); if (!n) continue; @@ -1241,7 +1184,6 @@ 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) { - base_path.push_back(p_node->get_name()); if (new_base_path.size()) new_base_path.push_back(p_node->get_name()); @@ -1258,13 +1200,11 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri p_renames->push_back(npp); for (int i = 0; i < p_node->get_child_count(); i++) { - _fill_path_renames(base_path, new_base_path, p_node->get_child(i), p_renames); } } void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pair<NodePath, NodePath>> *p_renames) { - if (!bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true))) return; @@ -1291,14 +1231,12 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai } 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; if (!r_rem_anims) r_rem_anims = &rem_anims; if (!p_base) { - p_base = edited_scene; } @@ -1307,23 +1245,18 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP // Renaming node paths used in script instances if (p_base->get_script_instance()) { - ScriptInstance *si = p_base->get_script_instance(); if (si) { - List<PropertyInfo> properties; si->get_property_list(&properties); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - String propertyname = E->get().name; Variant p = p_base->get(propertyname); 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()) { - NodePath root_path = p_base->get_path(); NodePath rel_path_old = root_path.rel_path_to(F->get().first); @@ -1337,7 +1270,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP // if old path detected, then it needs to be replaced with the new one if (p == rel_path_old) { - editor_data->get_undo_redo().add_do_property(p_base, propertyname, rel_path_new); editor_data->get_undo_redo().add_undo_property(p_base, propertyname, rel_path_old); @@ -1353,19 +1285,16 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP bool autorename_animation_tracks = bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true)); if (autorename_animation_tracks && Object::cast_to<AnimationPlayer>(p_base)) { - AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_base); List<StringName> anims; ap->get_animation_list(&anims); Node *root = ap->get_node(ap->get_root()); if (root) { - NodePath root_path = root->get_path(); NodePath new_root_path = root_path; for (List<Pair<NodePath, NodePath>>::Element *E = p_renames->front(); E; E = E->next()) { - if (E->get().first == root_path) { new_root_path = E->get().second; break; @@ -1376,7 +1305,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP //will not be erased for (List<StringName>::Element *E = anims.front(); E; E = E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); if (!r_rem_anims->has(anim)) { r_rem_anims->insert(anim, Set<int>()); @@ -1391,7 +1319,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP continue; for (int i = 0; i < anim->get_track_count(); i++) { - NodePath track_np = anim->track_get_path(i); Node *n = root->get_node(track_np); if (!n) { @@ -1404,9 +1331,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP continue; //channel was removed for (List<Pair<NodePath, NodePath>>::Element *F = p_renames->front(); F; F = F->next()) { - if (F->get().first == old_np) { - if (F->get().second == NodePath()) { //will be erased @@ -1424,7 +1349,6 @@ void SceneTreeDock::perform_node_renames(Node *p_base, List<Pair<NodePath, NodeP editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_path", idx, track_np); editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_set_interpolation_type", idx, anim->track_get_interpolation_type(i)); for (int j = 0; j < anim->track_get_key_count(i); j++) { - editor_data->get_undo_redo().add_undo_method(anim.ptr(), "track_insert_key", idx, anim->track_get_key_time(i, j), anim->track_get_key_value(i, j), anim->track_get_key_transition(i, j)); } @@ -1453,7 +1377,6 @@ 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; Vector<StringName> base_path; @@ -1481,13 +1404,10 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) { } bool SceneTreeDock::_validate_no_foreign() { - List<Node *> selection = editor_selection->get_selected_node_list(); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - if (E->get() != edited_scene && E->get()->get_owner() != edited_scene) { - accept->set_text(TTR("Can't operate on nodes from a foreign scene!")); accept->popup_centered(); return false; @@ -1501,7 +1421,6 @@ 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(); return false; @@ -1512,7 +1431,6 @@ bool SceneTreeDock::_validate_no_foreign() { } void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { - Node *new_parent = scene_root->get_node(p_path); ERR_FAIL_COND(!new_parent); @@ -1531,7 +1449,6 @@ void SceneTreeDock::_node_reparent(NodePath p_path, bool p_keep_global_xform) { } void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform) { - Node *new_parent = p_new_parent; ERR_FAIL_COND(!new_parent); @@ -1542,7 +1459,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V bool no_change = true; for (int ni = 0; ni < p_nodes.size(); ni++) { - if (p_nodes[ni] == p_new_parent) return; // Attempt to reparent to itself. @@ -1555,7 +1471,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V Node *validate = new_parent; while (validate) { - ERR_FAIL_COND_MSG(p_nodes.find(validate) != -1, "Selection changed at some point. Can't reparent."); validate = validate->get_parent(); } @@ -1571,7 +1486,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V int inc = 0; for (int ni = 0; ni < p_nodes.size(); ni++) { - // No undo implemented for this yet. Node *node = p_nodes[ni]; @@ -1600,7 +1514,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V // Name was modified, fix the path renames. if (old_name.casecmp_to(new_name) != 0) { - // Fix the to name to have the new name. NodePath old_new_name = path_renames[ni].second; NodePath new_path; @@ -1644,14 +1557,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V // Add and move in a second step (so old order is preserved). for (int ni = 0; ni < p_nodes.size(); ni++) { - Node *node = p_nodes[ni]; List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); Array owners; for (List<Node *>::Element *E = owned.front(); E; E = E->next()) { - owners.push_back(E->get()); } @@ -1679,14 +1590,12 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V } bool SceneTreeDock::_is_collapsed_recursive(TreeItem *p_item) const { - bool is_branch_collapsed = false; List<TreeItem *> needs_check; needs_check.push_back(p_item); while (!needs_check.empty()) { - TreeItem *item = needs_check.back()->get(); needs_check.pop_back(); @@ -1705,12 +1614,10 @@ bool SceneTreeDock::_is_collapsed_recursive(TreeItem *p_item) const { } void SceneTreeDock::_set_collapsed_recursive(TreeItem *p_item, bool p_collapsed) { - List<TreeItem *> to_collapse; to_collapse.push_back(p_item); while (!to_collapse.empty()) { - TreeItem *item = to_collapse.back()->get(); to_collapse.pop_back(); @@ -1725,7 +1632,6 @@ void SceneTreeDock::_set_collapsed_recursive(TreeItem *p_item, bool p_collapsed) } void SceneTreeDock::_script_created(Ref<Script> p_script) { - List<Node *> selected = editor_selection->get_selected_node_list(); if (selected.empty()) @@ -1733,7 +1639,6 @@ void SceneTreeDock::_script_created(Ref<Script> p_script) { editor_data->get_undo_redo().create_action(TTR("Attach Script")); for (List<Node *>::Element *E = selected.front(); E; E = E->next()) { - Ref<Script> existing = E->get()->get_script(); editor_data->get_undo_redo().add_do_method(E->get(), "set_script", p_script); editor_data->get_undo_redo().add_undo_method(E->get(), "set_script", existing); @@ -1752,7 +1657,6 @@ void SceneTreeDock::_script_creation_closed() { } void SceneTreeDock::_toggle_editable_children_from_selection() { - List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); @@ -1762,7 +1666,6 @@ void SceneTreeDock::_toggle_editable_children_from_selection() { } void SceneTreeDock::_toggle_placeholder_from_selection() { - List<Node *> selection = editor_selection->get_selected_node_list(); List<Node *>::Element *e = selection.front(); @@ -1781,7 +1684,6 @@ void SceneTreeDock::_toggle_placeholder_from_selection() { } void SceneTreeDock::_toggle_editable_children(Node *p_node) { - if (p_node) { bool editable = !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node); EditorNode::get_singleton()->get_edited_scene()->set_editable_instance(p_node, editable); @@ -1795,7 +1697,6 @@ void SceneTreeDock::_toggle_editable_children(Node *p_node) { } void SceneTreeDock::_delete_confirm() { - List<Node *> remove_list = editor_selection->get_selected_node_list(); if (remove_list.empty()) @@ -1808,14 +1709,12 @@ void SceneTreeDock::_delete_confirm() { bool entire_scene = false; for (List<Node *>::Element *E = remove_list.front(); E; E = E->next()) { - if (E->get() == edited_scene) { entire_scene = true; } } if (entire_scene) { - 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()); @@ -1823,7 +1722,6 @@ void SceneTreeDock::_delete_confirm() { editor_data->get_undo_redo().add_undo_reference(edited_scene); } else { - remove_list.sort_custom<Node::Comparator>(); //sort nodes to keep positions List<Pair<NodePath, NodePath>> path_renames; @@ -1847,7 +1745,6 @@ void SceneTreeDock::_delete_confirm() { n->get_owned_by(n->get_owner(), &owned); Array owners; for (List<Node *>::Element *F = owned.front(); F; F = F->next()) { - owners.push_back(F->get()); } @@ -1879,9 +1776,7 @@ void SceneTreeDock::_delete_confirm() { } void SceneTreeDock::_update_script_button() { - if (!profile_allow_script_editing) { - button_create_script->hide(); button_detach_script->hide(); } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 0) { @@ -1911,7 +1806,6 @@ void SceneTreeDock::_update_script_button() { } void SceneTreeDock::_selection_changed() { - int selection_size = EditorNode::get_singleton()->get_editor_selection()->get_selection().size(); if (selection_size > 1) { //automatically turn on multi-edit @@ -1925,7 +1819,6 @@ void SceneTreeDock::_selection_changed() { } Node *SceneTreeDock::_get_selection_group_tail(Node *p_node, List<Node *> p_list) { - Node *tail = p_node; Node *parent = tail->get_parent(); @@ -1951,7 +1844,6 @@ void SceneTreeDock::_do_create(Node *p_parent) { editor_data->get_undo_redo().create_action(TTR("Create Node")); if (edited_scene) { - editor_data->get_undo_redo().add_do_method(p_parent, "add_child", child); editor_data->get_undo_redo().add_do_method(child, "set_owner", edited_scene); editor_data->get_undo_redo().add_do_method(editor_selection, "clear"); @@ -1965,7 +1857,6 @@ void SceneTreeDock::_do_create(Node *p_parent) { editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).plus_file(new_name))); } else { - 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); @@ -1990,9 +1881,7 @@ void SceneTreeDock::_do_create(Node *p_parent) { } void SceneTreeDock::_create() { - if (current_option == TOOL_NEW) { - Node *parent = nullptr; if (edited_scene) { @@ -2085,7 +1974,6 @@ void SceneTreeDock::_create() { } void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties, bool p_remove_old) { - Node *n = p_node; Node *newnode = p_by_node; @@ -2114,12 +2002,10 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop n->get_signal_list(&sl); for (List<MethodInfo>::Element *E = sl.front(); E; E = E->next()) { - List<Object::Connection> cl; n->get_signal_connection_list(E->get().name, &cl); for (List<Object::Connection>::Element *F = cl.front(); F; F = F->next()) { - Object::Connection &c = F->get(); if (!(c.flags & Object::CONNECT_PERSIST)) continue; @@ -2166,22 +2052,18 @@ void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_prop } void SceneTreeDock::set_edited_scene(Node *p_scene) { - edited_scene = p_scene; } void SceneTreeDock::set_selected(Node *p_node, bool p_emit_selected) { - scene_tree->set_selected(p_node, p_emit_selected); } void SceneTreeDock::import_subscene() { - import_subscene_dialog->popup_centered_clamped(Size2(500, 800) * EDSCALE, 0.8); } void SceneTreeDock::_import_subscene() { - Node *parent = scene_tree->get_selected(); if (!parent) { parent = editor_data->get_edited_scene_root(); @@ -2193,7 +2075,6 @@ void SceneTreeDock::_import_subscene() { } void SceneTreeDock::_new_scene_from(String p_file) { - List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() != 1) { @@ -2214,7 +2095,6 @@ void SceneTreeDock::_new_scene_from(String p_file) { reown[editor_data->get_edited_scene_root()] = base; Node *copy = base->duplicate_and_reown(reown); if (copy) { - Ref<PackedScene> sdata = memnew(PackedScene); Error err = sdata->pack(copy); memdelete(copy); @@ -2244,7 +2124,6 @@ void SceneTreeDock::_new_scene_from(String p_file) { } static bool _is_node_visible(Node *p_node) { - if (!p_node->get_owner()) return false; if (p_node->get_owner() != EditorNode::get_singleton()->get_edited_scene() && !EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node->get_owner())) @@ -2254,13 +2133,11 @@ static bool _is_node_visible(Node *p_node) { } static bool _has_visible_children(Node *p_node) { - bool collapsed = p_node->is_displayed_folded(); if (collapsed) return false; for (int i = 0; i < p_node->get_child_count(); i++) { - Node *child = p_node->get_child(i); if (!_is_node_visible(child)) continue; @@ -2272,7 +2149,6 @@ static bool _has_visible_children(Node *p_node) { } void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { - to_pos = -1; if (p_type == -1) { @@ -2315,7 +2191,6 @@ void SceneTreeDock::_normalize_drop(Node *&to_node, int &to_pos, int p_type) { } void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_type) { - Node *node = get_node(p_to); ERR_FAIL_COND(!node); @@ -2339,7 +2214,6 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { } void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { - List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.empty()) @@ -2361,14 +2235,12 @@ void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { } void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { - if (p_depth > 8) return; List<PropertyInfo> pinfo; p_obj->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_EDITOR)) continue; if (E->get().hint != PROPERTY_HINT_RESOURCE_TYPE) @@ -2396,9 +2268,7 @@ void SceneTreeDock::_add_children_to_popup(Object *p_obj, int p_depth) { } void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { - if (!EditorNode::get_singleton()->get_edited_scene()) { - menu->clear(); if (profile_allow_editing) { menu->add_icon_shortcut(get_theme_icon("Add", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_child_node"), TOOL_NEW); @@ -2422,7 +2292,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { Ref<Script> existing_script; bool existing_script_removable = true; if (selection.size() == 1) { - Node *selected = selection[0]; if (profile_allow_editing) { @@ -2498,7 +2367,6 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } } if (selection.size() == 1) { - if (profile_allow_editing) { menu->add_separator(); menu->add_icon_shortcut(get_theme_icon("Blend", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/merge_from_scene"), TOOL_MERGE_FROM_SCENE); @@ -2555,23 +2423,19 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } void SceneTreeDock::_filter_changed(const String &p_filter) { - scene_tree->set_filter(p_filter); } String SceneTreeDock::get_filter() { - return filter->get_text(); } void SceneTreeDock::set_filter(const String &p_filter) { - filter->set_text(p_filter); scene_tree->set_filter(p_filter); } void SceneTreeDock::_focus_node() { - Node *node = scene_tree->get_selected(); ERR_FAIL_COND(!node); @@ -2634,7 +2498,6 @@ void SceneTreeDock::attach_script_to_selected(bool p_extend) { } void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) { - scene_tree->set_selected(p_for_node, false); if (p_extend) { @@ -2652,27 +2515,22 @@ void SceneTreeDock::add_remote_tree_editor(Control *p_remote) { } void SceneTreeDock::show_remote_tree() { - _remote_tree_selected(); } void SceneTreeDock::hide_remote_tree() { - _local_tree_selected(); } void SceneTreeDock::show_tab_buttons() { - button_hb->show(); } void SceneTreeDock::hide_tab_buttons() { - button_hb->hide(); } void SceneTreeDock::_remote_tree_selected() { - scene_tree->hide(); create_root_dialog->hide(); if (remote_tree) @@ -2684,7 +2542,6 @@ void SceneTreeDock::_remote_tree_selected() { } void SceneTreeDock::_local_tree_selected() { - scene_tree->show(); if (remote_tree) remote_tree->hide(); @@ -2693,7 +2550,6 @@ void SceneTreeDock::_local_tree_selected() { } void SceneTreeDock::_update_create_root_dialog() { - BaseButton *toggle = Object::cast_to<BaseButton>(create_root_dialog->get_node(String("NodeShortcutsTopRow/NodeShortcutsToggle"))); Node *node_shortcuts = create_root_dialog->get_node(String("NodeShortcuts")); @@ -2709,7 +2565,6 @@ void SceneTreeDock::_update_create_root_dialog() { EditorSettings::get_singleton()->set_setting("_use_favorites_root_selection", toggle->is_pressed()); EditorSettings::get_singleton()->save(); if (toggle->is_pressed()) { - for (int i = 0; i < favorite_nodes->get_child_count(); i++) { favorite_nodes->get_child(i)->queue_delete(); } @@ -2717,7 +2572,6 @@ void SceneTreeDock::_update_create_root_dialog() { FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ); if (f) { - while (!f->eof_reached()) { String l = f->get_line().strip_edges(); @@ -2754,11 +2608,9 @@ void SceneTreeDock::_favorite_root_selected(const String &p_class) { } void SceneTreeDock::_feature_profile_changed() { - Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); if (profile.is_valid()) { - profile_allow_editing = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCENE_TREE); profile_allow_script_editing = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT); bool profile_allow_3d = !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D); @@ -2781,7 +2633,6 @@ void SceneTreeDock::_feature_profile_changed() { } void SceneTreeDock::_bind_methods() { - ClassDB::bind_method(D_METHOD("_set_owners"), &SceneTreeDock::_set_owners); ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &SceneTreeDock::_unhandled_key_input); ClassDB::bind_method(D_METHOD("_input"), &SceneTreeDock::_input); @@ -2795,7 +2646,6 @@ void SceneTreeDock::_bind_methods() { } SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data) { - set_name("Scene"); editor = p_editor; edited_scene = nullptr; diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 00b95c9853..72be3fb02f 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -53,7 +53,6 @@ class EditorNode; class SceneTreeDock : public VBoxContainer { - GDCLASS(SceneTreeDock, VBoxContainer); enum Tool { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 251c911038..7344c2b37e 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -41,14 +41,12 @@ #include "scene/resources/packed_scene.h" Node *SceneTreeEditor::get_scene_node() { - ERR_FAIL_COND_V(!is_inside_tree(), nullptr); return get_tree()->get_edited_scene_root(); } void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) { - if (connect_to_script_mode) { return; //don't do anything in this mode } @@ -93,7 +91,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->create_action(TTR("Unlock Node")); 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); undo_redo->add_do_method(this, "_update_tree", Variant()); @@ -103,7 +100,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i } undo_redo->commit_action(); } else if (p_id == BUTTON_PIN) { - if (n->is_class("AnimationPlayer")) { AnimationPlayerEditor::singleton->unpin(); _update_tree(); @@ -113,7 +109,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i undo_redo->create_action(TTR("Button Group")); 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); undo_redo->add_do_method(this, "_update_tree", Variant()); @@ -123,7 +118,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i } undo_redo->commit_action(); } else if (p_id == BUTTON_WARNING) { - String config_err = n->get_configuration_warning(); if (config_err == String()) return; @@ -132,7 +126,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i warning->popup_centered(); } else if (p_id == BUTTON_SIGNALS) { - editor_selection->clear(); editor_selection->add_node(n); @@ -142,7 +135,6 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i NodeDock::singleton->show_connections(); } else if (p_id == BUTTON_GROUPS) { - editor_selection->clear(); editor_selection->add_node(n); @@ -161,7 +153,6 @@ void SceneTreeEditor::_toggle_visible(Node *p_node) { } bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { - if (!p_node) return false; @@ -171,9 +162,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { bool part_of_subscene = false; if (!display_foreign && p_node->get_owner() != get_scene_node() && p_node != get_scene_node()) { - if ((show_enabled_subscene || can_open_instance) && p_node->get_owner() && (get_scene_node()->is_editable_instance(p_node->get_owner()))) { - part_of_subscene = true; //allow } else { @@ -229,12 +218,10 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_custom_color(0, accent); } } else if (part_of_subscene) { - if (valid_types.size() == 0) { item->set_custom_color(0, get_theme_color("disabled_font_color", "Editor")); } } else if (marked.has(p_node)) { - String node_name = p_node->get_name(); if (connecting_signal) { node_name += " " + TTR("(Connecting From)"); @@ -243,7 +230,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_selectable(0, marked_selectable); 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)) { @@ -335,7 +321,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } if (p_node->is_class("CanvasItem")) { - bool is_locked = p_node->has_meta("_edit_lock_"); //_edit_group_ if (is_locked) item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); @@ -355,7 +340,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { _update_visibility_color(p_node, item); } else if (p_node->is_class("Node3D")) { - bool is_locked = p_node->has_meta("_edit_lock_"); if (is_locked) item->add_button(0, get_theme_icon("Lock", "EditorIcons"), BUTTON_LOCK, false, TTR("Node is locked.\nClick to unlock it.")); @@ -375,7 +359,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { _update_visibility_color(p_node, item); } else if (p_node->is_class("AnimationPlayer")) { - bool is_pinned = AnimationPlayerEditor::singleton->get_player() == p_node && AnimationPlayerEditor::singleton->is_pinned(); if (is_pinned) { @@ -386,7 +369,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { if (editor_selection) { if (editor_selection->is_selected(p_node)) { - item->select(0); } } @@ -400,7 +382,6 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { bool keep = (filter.is_subsequence_ofi(String(p_node->get_name()))); for (int i = 0; i < p_node->get_child_count(); i++) { - bool child_keep = _add_nodes(p_node->get_child(i), item); keep = keep || child_keep; @@ -437,9 +418,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } void SceneTreeEditor::_node_visibility_changed(Node *p_node) { - if (!p_node || (p_node != get_scene_node() && !p_node->get_owner())) { - return; } @@ -482,7 +461,6 @@ void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) { } void SceneTreeEditor::_node_script_changed(Node *p_node) { - if (tree_dirty) return; @@ -491,7 +469,6 @@ void SceneTreeEditor::_node_script_changed(Node *p_node) { } void SceneTreeEditor::_node_removed(Node *p_node) { - if (EditorNode::get_singleton()->is_exiting()) return; //speed up exit @@ -510,7 +487,6 @@ void SceneTreeEditor::_node_removed(Node *p_node) { } void SceneTreeEditor::_node_renamed(Node *p_node) { - emit_signal("node_renamed"); if (!tree_dirty) { @@ -520,7 +496,6 @@ void SceneTreeEditor::_node_renamed(Node *p_node) { } void SceneTreeEditor::_update_tree() { - if (!is_inside_tree()) { tree_dirty = false; return; @@ -539,19 +514,16 @@ void SceneTreeEditor::_update_tree() { } void SceneTreeEditor::_compute_hash(Node *p_node, uint64_t &hash) { - hash = hash_djb2_one_64(p_node->get_instance_id(), hash); if (p_node->get_parent()) hash = hash_djb2_one_64(p_node->get_parent()->get_instance_id(), hash); //so a reparent still produces a different hash for (int i = 0; i < p_node->get_child_count(); i++) { - _compute_hash(p_node->get_child(i), hash); } } void SceneTreeEditor::_test_update_tree() { - pending_test_update = false; if (!is_inside_tree()) @@ -572,7 +544,6 @@ void SceneTreeEditor::_test_update_tree() { } void SceneTreeEditor::_tree_changed() { - if (EditorNode::get_singleton()->is_exiting()) return; //speed up exit if (pending_test_update) @@ -585,7 +556,6 @@ void SceneTreeEditor::_tree_changed() { } void SceneTreeEditor::_selected_changed() { - TreeItem *s = tree->get_selected(); ERR_FAIL_COND(!s); NodePath np = s->get_metadata(0); @@ -603,7 +573,6 @@ void SceneTreeEditor::_selected_changed() { } void SceneTreeEditor::_deselect_items() { - // Clear currently elected items in scene tree dock. if (editor_selection) { editor_selection->clear(); @@ -612,7 +581,6 @@ void SceneTreeEditor::_deselect_items() { } void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) { - TreeItem *item = Object::cast_to<TreeItem>(p_object); ERR_FAIL_COND(!item); @@ -636,10 +604,8 @@ void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_ } void SceneTreeEditor::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { - get_tree()->connect("tree_changed", callable_mp(this, &SceneTreeEditor::_tree_changed)); get_tree()->connect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed)); get_tree()->connect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed)); @@ -650,7 +616,6 @@ void SceneTreeEditor::_notification(int p_what) { _update_tree(); } break; case NOTIFICATION_EXIT_TREE: { - get_tree()->disconnect("tree_changed", callable_mp(this, &SceneTreeEditor::_tree_changed)); get_tree()->disconnect("node_removed", callable_mp(this, &SceneTreeEditor::_node_removed)); get_tree()->disconnect("node_renamed", callable_mp(this, &SceneTreeEditor::_node_renamed)); @@ -658,14 +623,12 @@ void SceneTreeEditor::_notification(int p_what) { get_tree()->disconnect("node_configuration_warning_changed", callable_mp(this, &SceneTreeEditor::_warning_changed)); } break; case NOTIFICATION_THEME_CHANGED: { - _update_tree(); } break; } } TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { - if (!p_node) return nullptr; @@ -675,7 +638,6 @@ TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { TreeItem *children = p_node->get_children(); while (children) { - TreeItem *n = _find(children, p_path); if (n) return n; @@ -686,7 +648,6 @@ TreeItem *SceneTreeEditor::_find(TreeItem *p_node, const NodePath &p_path) { } void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { - ERR_FAIL_COND(blocked > 0); if (pending_test_update) @@ -724,7 +685,6 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) { } void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) { - Object *o = ObjectDB::get_instance(p_node); ERR_FAIL_COND(!o); Node *n = Object::cast_to<Node>(o); @@ -738,7 +698,6 @@ void SceneTreeEditor::_rename_node(ObjectID p_node, const String &p_name) { } void SceneTreeEditor::_renamed() { - TreeItem *which = tree->get_edited(); ERR_FAIL_COND(!which); @@ -755,7 +714,6 @@ void SceneTreeEditor::_renamed() { String new_name = which->get_text(0); 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(); @@ -784,12 +742,10 @@ void SceneTreeEditor::_renamed() { } Node *SceneTreeEditor::get_selected() { - return selected; } void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, bool p_children_selectable) { - if (tree_dirty) _update_tree(); marked = p_marked; @@ -799,7 +755,6 @@ void SceneTreeEditor::set_marked(const Set<Node *> &p_marked, bool p_selectable, } void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_children_selectable) { - Set<Node *> s; if (p_marked) s.insert(p_marked); @@ -807,23 +762,19 @@ void SceneTreeEditor::set_marked(Node *p_marked, bool p_selectable, bool p_child } void SceneTreeEditor::set_filter(const String &p_filter) { - filter = p_filter; _update_tree(); } String SceneTreeEditor::get_filter() const { - return filter; } void SceneTreeEditor::set_display_foreign_nodes(bool p_display) { - display_foreign = p_display; _update_tree(); } bool SceneTreeEditor::get_display_foreign_nodes() const { - return display_foreign; } @@ -832,7 +783,6 @@ void SceneTreeEditor::set_valid_types(const Vector<StringName> &p_valid) { } void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) { - editor_selection = p_selection; tree->set_select_mode(Tree::SELECT_MULTI); tree->set_cursor_can_exit_tree(false); @@ -840,7 +790,6 @@ void SceneTreeEditor::set_editor_selection(EditorSelection *p_selection) { } void SceneTreeEditor::_update_selection(TreeItem *item) { - ERR_FAIL_COND(!item); NodePath np = item->get_metadata(0); @@ -861,14 +810,12 @@ void SceneTreeEditor::_update_selection(TreeItem *item) { TreeItem *c = item->get_children(); while (c) { - _update_selection(c); c = c->get_next(); } } void SceneTreeEditor::_selection_changed() { - if (!editor_selection) return; @@ -880,7 +827,6 @@ void SceneTreeEditor::_selection_changed() { } void SceneTreeEditor::_cell_collapsed(Object *p_obj) { - if (updating_tree) return; if (!can_rename) @@ -908,7 +854,6 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from Vector<Ref<Texture2D>> icons; TreeItem *next = tree->get_next_selected(nullptr); while (next) { - NodePath np = next->get_metadata(0); Node *n = get_node(np); @@ -931,7 +876,6 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from float opacity_step = 1.0f / list_max; float opacity_item = 1.0f; for (int i = 0; i < selected.size(); i++) { - if (i < list_max) { HBoxContainer *hb = memnew(HBoxContainer); TextureRect *tf = memnew(TextureRect); @@ -964,7 +908,6 @@ bool SceneTreeEditor::_is_script_type(const StringName &p_type) const { } bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { - if (!can_rename) return false; //not editable tree if (filter != String()) @@ -983,7 +926,6 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return false; if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; if (files.size() == 0) @@ -1020,7 +962,6 @@ bool SceneTreeEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_d return String(d["type"]) == "nodes"; } void SceneTreeEditor::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; @@ -1044,7 +985,6 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, } if (String(d["type"]) == "files") { - Vector<String> files = d["files"]; String ftype = EditorFileSystem::get_singleton()->get_file_type(files[0]); @@ -1067,12 +1007,10 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, } void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) { - emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos)); } void SceneTreeEditor::_warning_changed(Node *p_for_node) { - //should use a timer update_timer->start(); } @@ -1088,7 +1026,6 @@ void SceneTreeEditor::set_connecting_signal(bool p_enable) { } void SceneTreeEditor::_bind_methods() { - ClassDB::bind_method("_update_tree", &SceneTreeEditor::_update_tree); // Still used by some connect_compat. ClassDB::bind_method("_rename_node", &SceneTreeEditor::_rename_node); ClassDB::bind_method("_test_update_tree", &SceneTreeEditor::_test_update_tree); @@ -1114,7 +1051,6 @@ void SceneTreeEditor::_bind_methods() { } SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_open_instance) { - connect_to_script_mode = false; connecting_signal = false; undo_redo = nullptr; @@ -1184,17 +1120,14 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope } SceneTreeEditor::~SceneTreeEditor() { - memdelete(script_types); } /******** DIALOG *********/ void SceneTreeDialog::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { - if (is_visible()) tree->update_tree(); } break; @@ -1210,11 +1143,9 @@ void SceneTreeDialog::_notification(int p_what) { } void SceneTreeDialog::_cancel() { - hide(); } void SceneTreeDialog::_select() { - if (tree->get_selected()) { emit_signal("selected", tree->get_selected()->get_path()); hide(); @@ -1222,19 +1153,16 @@ void SceneTreeDialog::_select() { } void SceneTreeDialog::_filter_changed(const String &p_filter) { - tree->set_filter(p_filter); } void SceneTreeDialog::_bind_methods() { - ClassDB::bind_method("_cancel", &SceneTreeDialog::_cancel); ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::NODE_PATH, "path"))); } SceneTreeDialog::SceneTreeDialog() { - set_title(TTR("Select a Node")); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 17ee5ace66..106837f69a 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -39,7 +39,6 @@ #include "scene/gui/tree.h" class SceneTreeEditor : public Control { - GDCLASS(SceneTreeEditor, Control); EditorSelection *editor_selection; @@ -163,7 +162,6 @@ public: }; class SceneTreeDialog : public ConfirmationDialog { - GDCLASS(SceneTreeDialog, ConfirmationDialog); SceneTreeEditor *tree; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index f84b7e73ed..721384035f 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -68,7 +68,6 @@ void ScriptCreateDialog::_theme_changed() { status_panel->add_theme_style_override("panel", gc->get_theme_stylebox("bg", "Tree")); } void ScriptCreateDialog::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_TREE: { _theme_changed(); @@ -99,7 +98,6 @@ bool ScriptCreateDialog::_can_be_built_in() { } void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled, bool p_load_enabled) { - class_name->set_text(""); class_name->deselect(); parent_name->set_text(p_base_name); @@ -124,12 +122,10 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_ } void ScriptCreateDialog::set_inheritance_base_type(const String &p_base) { - base_type = p_base; } bool ScriptCreateDialog::_validate_parent(const String &p_string) { - if (p_string.length() == 0) return false; @@ -143,12 +139,10 @@ bool ScriptCreateDialog::_validate_parent(const String &p_string) { } bool ScriptCreateDialog::_validate_class(const String &p_string) { - if (p_string.length() == 0) return false; for (int i = 0; i < p_string.length(); i++) { - if (i == 0) { if (p_string[0] >= '0' && p_string[0] <= '9') return false; // no start with number plz @@ -164,7 +158,6 @@ bool ScriptCreateDialog::_validate_class(const String &p_string) { } String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must_exist) { - String p = p_path.strip_edges(); if (p == "") @@ -234,7 +227,6 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must } void ScriptCreateDialog::_class_name_changed(const String &p_name) { - if (_validate_class(class_name->get_text())) { is_class_name_valid = true; } else { @@ -244,7 +236,6 @@ void ScriptCreateDialog::_class_name_changed(const String &p_name) { } void ScriptCreateDialog::_parent_name_changed(const String &p_parent) { - if (_validate_parent(parent_name->get_text())) { is_parent_name_valid = true; } else { @@ -254,7 +245,6 @@ void ScriptCreateDialog::_parent_name_changed(const String &p_parent) { } void ScriptCreateDialog::_template_changed(int p_template) { - String selected_template = p_template == 0 ? "" : template_menu->get_item_text(p_template); EditorSettings::get_singleton()->set_project_metadata("script_setup", "last_selected_template", selected_template); if (p_template == 0) { @@ -274,7 +264,6 @@ void ScriptCreateDialog::_template_changed(int p_template) { } void ScriptCreateDialog::ok_pressed() { - if (is_new_script_created) { _create_new(); } else { @@ -286,7 +275,6 @@ void ScriptCreateDialog::ok_pressed() { } void ScriptCreateDialog::_create_new() { - String cname_param; if (has_named_classes) { @@ -331,7 +319,6 @@ void ScriptCreateDialog::_create_new() { } void ScriptCreateDialog::_load_exist() { - String path = file_path->get_text(); RES p_script = ResourceLoader::load(path, "Script"); if (p_script.is_null()) { @@ -345,7 +332,6 @@ void ScriptCreateDialog::_load_exist() { } void ScriptCreateDialog::_lang_changed(int l) { - ScriptLanguage *language = ScriptServer::get_language(l); has_named_classes = language->has_named_classes(); @@ -409,7 +395,6 @@ void ScriptCreateDialog::_lang_changed(int l) { // Populate script template items previously sorted and now grouped by origin for (int i = 0; i < template_list.size(); i++) { - if (int(templates[i].origin) != cur_origin) { template_menu->add_separator(); @@ -474,7 +459,6 @@ void ScriptCreateDialog::_lang_changed(int l) { } void ScriptCreateDialog::_update_script_templates(const String &p_extension) { - template_list.clear(); template_overrides.clear(); @@ -485,7 +469,6 @@ void ScriptCreateDialog::_update_script_templates(const String &p_extension) { dirs.push_back(EditorSettings::get_singleton()->get_script_templates_dir()); for (int i = 0; i < dirs.size(); i++) { - Vector<String> list = EditorSettings::get_singleton()->get_script_templates(p_extension, dirs[i]); for (int j = 0; j < list.size(); j++) { @@ -509,7 +492,6 @@ void ScriptCreateDialog::_update_script_templates(const String &p_extension) { } void ScriptCreateDialog::_built_in_pressed() { - if (internal->is_pressed()) { is_built_in = true; is_new_script_created = true; @@ -521,7 +503,6 @@ void ScriptCreateDialog::_built_in_pressed() { } void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { - is_browsing_parent = browse_parent; if (p_save) { @@ -549,7 +530,6 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { } void ScriptCreateDialog::_file_selected(const String &p_file) { - String p = ProjectSettings::get_singleton()->localize_path(p_file); if (is_browsing_parent) { parent_name->set_text("\"" + p + "\""); @@ -567,19 +547,16 @@ void ScriptCreateDialog::_file_selected(const String &p_file) { } void ScriptCreateDialog::_create() { - parent_name->set_text(select_class->get_selected_type().split(" ")[0]); _parent_name_changed(parent_name->get_text()); } void ScriptCreateDialog::_browse_class_in_tree() { - select_class->set_base_type(base_type); select_class->popup_create(true); } void ScriptCreateDialog::_path_changed(const String &p_path) { - if (is_built_in) { return; } @@ -612,7 +589,6 @@ void ScriptCreateDialog::_path_entered(const String &p_path) { } void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { - error_label->set_text("- " + TTR(p_msg)); if (valid) { error_label->add_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor")); @@ -622,7 +598,6 @@ void ScriptCreateDialog::_msg_script_valid(bool valid, const String &p_msg) { } 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_theme_color_override("font_color", gc->get_theme_color("success_color", "Editor")); @@ -632,7 +607,6 @@ void ScriptCreateDialog::_msg_path_valid(bool valid, const String &p_msg) { } void ScriptCreateDialog::_update_dialog() { - /* "Add Script Dialog" GUI logic and script checks. */ bool script_ok = true; @@ -737,14 +711,12 @@ void ScriptCreateDialog::_update_dialog() { } void ScriptCreateDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled", "load_enabled"), &ScriptCreateDialog::config, DEFVAL(true), DEFVAL(true)); ADD_SIGNAL(MethodInfo("script_created", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); } ScriptCreateDialog::ScriptCreateDialog() { - /* DIALOG */ /* Main Controls */ @@ -799,7 +771,6 @@ ScriptCreateDialog::ScriptCreateDialog() { default_language = 0; for (int i = 0; i < ScriptServer::get_language_count(); i++) { - String lang = ScriptServer::get_language(i)->get_name(); language_menu->add_item(lang); if (lang == "GDScript") { diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 8910e8ec3a..b86db7d073 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -41,7 +41,6 @@ #include "scene/gui/margin_container.h" void EditorSettingsDialog::ok_pressed() { - if (!EditorSettings::get_singleton()) return; @@ -50,12 +49,10 @@ void EditorSettingsDialog::ok_pressed() { } void EditorSettingsDialog::_settings_changed() { - timer->start(); } void EditorSettingsDialog::_settings_property_edited(const String &p_name) { - String full_name = inspector->get_full_item_path(p_name); if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") { @@ -66,13 +63,11 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) { } void EditorSettingsDialog::_settings_save() { - EditorSettings::get_singleton()->notify_changes(); EditorSettings::get_singleton()->save(); } void EditorSettingsDialog::cancel_pressed() { - if (!EditorSettings::get_singleton()) return; @@ -80,7 +75,6 @@ void EditorSettingsDialog::cancel_pressed() { } void EditorSettingsDialog::popup_edit_settings() { - if (!EditorSettings::get_singleton()) return; @@ -116,7 +110,6 @@ 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()) { @@ -142,11 +135,9 @@ void EditorSettingsDialog::_notification(int p_what) { } void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { - const Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed()) { - bool handled = false; if (ED_IS_SHORTCUT("editor/undo", p_event)) { @@ -177,7 +168,6 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); @@ -190,7 +180,6 @@ void EditorSettingsDialog::_update_icons() { } void EditorSettingsDialog::_update_shortcuts() { - Map<String, bool> collapsed; if (shortcuts->get_root() && shortcuts->get_root()->get_children()) { @@ -208,7 +197,6 @@ void EditorSettingsDialog::_update_shortcuts() { Map<String, TreeItem *> sections; for (List<String>::Element *E = slist.front(); E; E = E->next()) { - Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(E->get()); if (!sc->has_meta("original")) continue; @@ -270,7 +258,6 @@ void EditorSettingsDialog::_update_shortcuts() { } void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); ERR_FAIL_COND(!ti); @@ -316,11 +303,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column } void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_keycode() != 0) { - last_wait_for_key = k; const String str = keycode_get_string(k->get_keycode_with_modifiers()); @@ -330,7 +315,6 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_press_a_key_confirm() { - if (last_wait_for_key.is_null()) return; @@ -355,12 +339,10 @@ void EditorSettingsDialog::_press_a_key_confirm() { } void EditorSettingsDialog::_tabs_tab_changed(int p_tab) { - _focus_current_search_box(); } void EditorSettingsDialog::_focus_current_search_box() { - Control *tab = tabs->get_current_tab_control(); LineEdit *current_search_box = nullptr; if (tab == tab_general) @@ -388,13 +370,11 @@ void EditorSettingsDialog::_editor_restart_close() { } void EditorSettingsDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorSettingsDialog::_unhandled_input); ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts); } EditorSettingsDialog::EditorSettingsDialog() { - set_title(TTR("Editor Settings")); undo_redo = memnew(UndoRedo); diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h index 03dd18d23f..05566762fc 100644 --- a/editor/settings_config_dialog.h +++ b/editor/settings_config_dialog.h @@ -41,7 +41,6 @@ #include "scene/gui/tool_button.h" class EditorSettingsDialog : public AcceptDialog { - GDCLASS(EditorSettingsDialog, AcceptDialog); bool updating; diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index a013ba2ad3..de7a98535f 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -225,7 +225,6 @@ protected: pinfo.hint_string = "Cubemap"; } break; default: { - } break; } @@ -367,7 +366,6 @@ static Variant create_var(RS::GlobalVariableType p_type) { } void ShaderGlobalsEditor::_variable_added() { - String var = variable_name->get_text().strip_edges(); if (var == "" || !var.is_valid_identifier()) { EditorNode::get_singleton()->show_warning(TTR("Please specify a valid variable identifier name.")); @@ -406,7 +404,6 @@ void ShaderGlobalsEditor::_variable_added() { } void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { - print_line("deleted " + p_variable); UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); @@ -443,7 +440,6 @@ void ShaderGlobalsEditor::_notification(int p_what) { } ShaderGlobalsEditor::ShaderGlobalsEditor() { - HBoxContainer *add_menu_hb = memnew(HBoxContainer); add_child(add_menu_hb); diff --git a/editor/shader_globals_editor.h b/editor/shader_globals_editor.h index b3dbddc87e..33f527f314 100644 --- a/editor/shader_globals_editor.h +++ b/editor/shader_globals_editor.h @@ -42,7 +42,6 @@ class ShaderGlobalsEditorInterface; class ShaderGlobalsEditor : public VBoxContainer { - GDCLASS(ShaderGlobalsEditor, VBoxContainer) ShaderGlobalsEditorInterface *interface; |