diff options
Diffstat (limited to 'editor')
73 files changed, 1155 insertions, 401 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 7411af2280..ec411c6415 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -37,6 +37,7 @@ #include "editor/plugins/animation_player_editor_plugin.h" #include "editor_node.h" #include "editor_scale.h" +#include "scene/animation/animation_player.h" #include "scene/main/window.h" #include "servers/audio/audio_stream.h" @@ -2208,7 +2209,7 @@ void AnimationTrackEdit::draw_rect_clipped(const Rect2 &p_rect, const Color &p_c return; } Rect2 clip = Rect2(clip_left, 0, clip_right - clip_left, get_size().height); - draw_rect(clip.clip(p_rect), p_color, p_filled); + draw_rect(clip.intersection(p_rect), p_color, p_filled); } void AnimationTrackEdit::draw_bg(int p_clip_left, int p_clip_right) { @@ -2912,7 +2913,7 @@ void AnimationTrackEdit::append_to_selection(const Rect2 &p_box, bool p_deselect // Left Border including space occupied by keyframes on t=0. int limit_start_hitbox = timeline->get_name_limit() - type_icon->get_width(); Rect2 select_rect(limit_start_hitbox, 0, get_size().width - timeline->get_name_limit() - timeline->get_buttons_width(), get_size().height); - select_rect = select_rect.clip(p_box); + select_rect = select_rect.intersection(p_box); // 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--) { @@ -3299,6 +3300,19 @@ void AnimationTrackEditor::set_anim_pos(float p_pos) { bezier_edit->set_play_position(p_pos); } +static bool track_type_is_resettable(Animation::TrackType p_type) { + switch (p_type) { + case Animation::TYPE_VALUE: + [[fallthrough]]; + case Animation::TYPE_BEZIER: + [[fallthrough]]; + case Animation::TYPE_TRANSFORM: + return true; + default: + return false; + } +} + 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 @@ -3319,40 +3333,58 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { insert_data.push_back(p_id); + bool reset_allowed = true; + AnimationPlayer *player = AnimationPlayerEditor::singleton->get_player(); + if (player->has_animation("RESET") && player->get_animation("RESET") == animation) { + // Avoid messing with the reset animation itself + reset_allowed = false; + } else { + bool some_resettable = false; + for (int i = 0; i < insert_data.size(); i++) { + if (track_type_is_resettable(insert_data[i].type)) { + some_resettable = true; + break; + } + } + if (!some_resettable) { + reset_allowed = false; + } + } + if (p_id.track_idx == -1) { - if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true))) { - //potential new key, does not exist - int num_tracks = 0; - bool all_bezier = true; - for (int i = 0; i < insert_data.size(); i++) { - if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) { - all_bezier = false; - } + int num_tracks = 0; + bool all_bezier = true; + for (int i = 0; i < insert_data.size(); i++) { + if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) { + all_bezier = false; + } - if (insert_data[i].track_idx == -1) { - ++num_tracks; - } + if (insert_data[i].track_idx == -1) { + ++num_tracks; + } - if (insert_data[i].type != Animation::TYPE_VALUE) { - continue; - } + if (insert_data[i].type != Animation::TYPE_VALUE) { + continue; + } - switch (insert_data[i].value.get_type()) { - case Variant::INT: - case Variant::FLOAT: - case Variant::VECTOR2: - case Variant::VECTOR3: - case Variant::QUAT: - case Variant::PLANE: - case Variant::COLOR: { - // Valid. - } break; - default: { - all_bezier = false; - } + switch (insert_data[i].value.get_type()) { + case Variant::INT: + case Variant::FLOAT: + case Variant::VECTOR2: + case Variant::VECTOR3: + case Variant::QUAT: + case Variant::PLANE: + case Variant::COLOR: { + // Valid. + } break; + default: { + all_bezier = false; } } + } + if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true))) { + //potential new key, does not exist if (num_tracks == 1) { insert_confirm_text->set_text(vformat(TTR("Create new track for %s and insert key?"), p_id.query)); } else { @@ -3360,23 +3392,26 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } insert_confirm_bezier->set_visible(all_bezier); - insert_confirm->get_ok()->set_text(TTR("Create")); + insert_confirm_reset->set_visible(reset_allowed); + + insert_confirm->get_ok_button()->set_text(TTR("Create")); insert_confirm->popup_centered(); insert_query = true; } else { - call_deferred("_insert_delay"); + call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks")); insert_queue = true; } } else { if (!insert_query && !insert_queue) { - call_deferred("_insert_delay"); + // Create Beziers wouldn't make sense in this case, where no tracks are being created + call_deferred("_insert_delay", reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), false); insert_queue = true; } } } -void AnimationTrackEditor::_insert_delay() { +void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_beziers) { if (insert_query) { //discard since it's entered into query mode insert_queue = false; @@ -3385,13 +3420,18 @@ void AnimationTrackEditor::_insert_delay() { undo_redo->create_action(TTR("Anim Insert")); - int last_track = animation->get_track_count(); + Ref<Animation> reset_anim; + if (p_create_reset) { + reset_anim = _create_and_get_reset_animation(); + } + + TrackIndices next_tracks(animation.ptr(), reset_anim.ptr()); 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); + next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, p_create_reset, p_create_beziers); insert_data.pop_front(); } @@ -3682,12 +3722,34 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari } } +Ref<Animation> AnimationTrackEditor::_create_and_get_reset_animation() { + AnimationPlayer *player = AnimationPlayerEditor::singleton->get_player(); + if (player->has_animation("RESET")) { + return player->get_animation("RESET"); + } else { + Ref<Animation> reset_anim; + reset_anim.instance(); + reset_anim->set_length(ANIM_MIN_LENGTH); + undo_redo->add_do_method(player, "add_animation", "RESET", reset_anim); + undo_redo->add_do_method(AnimationPlayerEditor::singleton, "_animation_player_changed", player); + undo_redo->add_undo_method(player, "remove_animation", "RESET"); + undo_redo->add_undo_method(AnimationPlayerEditor::singleton, "_animation_player_changed", player); + return reset_anim; + } +} + void AnimationTrackEditor::_confirm_insert_list() { undo_redo->create_action(TTR("Anim Create & Insert")); - int last_track = animation->get_track_count(); + bool create_reset = insert_confirm_reset->is_visible() && insert_confirm_reset->is_pressed(); + Ref<Animation> reset_anim; + if (create_reset) { + reset_anim = _create_and_get_reset_animation(); + } + + TrackIndices next_tracks(animation.ptr(), reset_anim.ptr()); while (insert_data.size()) { - last_track = _confirm_insert(insert_data.front()->get(), last_track, insert_confirm_bezier->is_pressed()); + next_tracks = _confirm_insert(insert_data.front()->get(), next_tracks, create_reset, insert_confirm_bezier->is_pressed()); insert_data.pop_front(); } @@ -3807,11 +3869,7 @@ static Vector<String> _get_bezier_subindices_for_type(Variant::Type p_type, bool return subindices; } -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(); - } - +AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, bool p_create_beziers) { bool created = false; if (p_id.track_idx < 0) { if (p_create_beziers) { @@ -3823,10 +3881,10 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo id.type = Animation::TYPE_BEZIER; id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length())); id.path = String(p_id.path) + subindices[i]; - _confirm_insert(id, p_last_track + i); + p_next_tracks = _confirm_insert(id, p_next_tracks, p_create_reset, false); } - return p_last_track + subindices.size(); + return p_next_tracks; } } created = true; @@ -3863,7 +3921,7 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo } } - p_id.track_idx = p_last_track; + p_id.track_idx = p_next_tracks.normal; undo_redo->add_do_method(animation.ptr(), "add_track", p_id.type); undo_redo->add_do_method(animation.ptr(), "track_set_path", p_id.track_idx, p_id.path); @@ -3915,7 +3973,7 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo // 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++; + p_next_tracks.normal++; } 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); @@ -3926,9 +3984,27 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo } } + if (p_create_reset && track_type_is_resettable(p_id.type)) { + bool create_reset_track = true; + Animation *reset_anim = AnimationPlayerEditor::singleton->get_player()->get_animation("RESET").ptr(); + for (int i = 0; i < reset_anim->get_track_count(); i++) { + if (reset_anim->track_get_path(i) == p_id.path) { + create_reset_track = false; + break; + } + } + if (create_reset_track) { + undo_redo->add_do_method(reset_anim, "add_track", p_id.type); + undo_redo->add_do_method(reset_anim, "track_set_path", p_next_tracks.reset, p_id.path); + undo_redo->add_do_method(reset_anim, "track_insert_key", p_next_tracks.reset, 0.0f, value); + undo_redo->add_undo_method(reset_anim, "remove_track", reset_anim->get_track_count()); + p_next_tracks.reset++; + } + } + undo_redo->commit_action(); - return p_last_track; + return p_next_tracks; } void AnimationTrackEditor::show_select_node_warning(bool p_show) { @@ -4224,6 +4300,7 @@ void AnimationTrackEditor::_notification(int p_what) { selected_filter->set_icon(get_theme_icon("AnimationFilter", "EditorIcons")); imported_anim_warning->set_icon(get_theme_icon("NodeWarning", "EditorIcons")); main_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree")); + edit->get_popup()->set_item_icon(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), get_theme_icon("Reload", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { @@ -4947,7 +5024,7 @@ void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) { Rect2 rect(from, to - from); Rect2 scroll_rect = Rect2(scroll->get_global_position(), scroll->get_size()); - rect = scroll_rect.clip(rect); + rect = scroll_rect.intersection(rect); box_selection->set_position(rect.position); box_selection->set_size(rect.size); @@ -5056,6 +5133,11 @@ void AnimationTrackEditor::_anim_duplicate_keys(bool transpose) { } } +void AnimationTrackEditor::_edit_menu_about_to_popup() { + AnimationPlayer *player = AnimationPlayerEditor::singleton->get_player(); + edit->get_popup()->set_item_disabled(edit->get_popup()->get_item_index(EDIT_APPLY_RESET), !player->can_apply_reset()); +} + void AnimationTrackEditor::_edit_menu_pressed(int p_option) { last_menu_track_opt = p_option; switch (p_option) { @@ -5378,6 +5460,10 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { emit_signal("timeline_changed", pos, true); } break; + case EDIT_APPLY_RESET: { + AnimationPlayerEditor::singleton->get_player()->apply_reset(true); + + } break; case EDIT_OPTIMIZE_ANIMATION: { optimize_dialog->popup_centered(Size2(250, 180) * EDSCALE); @@ -5710,10 +5796,13 @@ AnimationTrackEditor::AnimationTrackEditor() { edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTR("Go to Next Step"), KEY_MASK_CMD | KEY_RIGHT), EDIT_GOTO_NEXT_STEP); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_prev_step", TTR("Go to Previous Step"), KEY_MASK_CMD | KEY_LEFT), EDIT_GOTO_PREV_STEP); edit->get_popup()->add_separator(); + edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/apply_reset", TTR("Apply Reset")), EDIT_APPLY_RESET); + edit->get_popup()->add_separator(); edit->get_popup()->add_item(TTR("Optimize Animation"), EDIT_OPTIMIZE_ANIMATION); edit->get_popup()->add_item(TTR("Clean-Up Animation"), EDIT_CLEAN_UP_ANIMATION); edit->get_popup()->connect("id_pressed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed)); + edit->get_popup()->connect("about_to_popup", callable_mp(this, &AnimationTrackEditor::_edit_menu_about_to_popup)); pick_track = memnew(SceneTreeDialog); add_child(pick_track); @@ -5739,9 +5828,16 @@ AnimationTrackEditor::AnimationTrackEditor() { insert_confirm->add_child(icvb); insert_confirm_text = memnew(Label); icvb->add_child(insert_confirm_text); + HBoxContainer *ichb = memnew(HBoxContainer); + icvb->add_child(ichb); insert_confirm_bezier = memnew(CheckBox); insert_confirm_bezier->set_text(TTR("Use Bezier Curves")); - icvb->add_child(insert_confirm_bezier); + insert_confirm_bezier->set_pressed(EDITOR_GET("editors/animation/default_create_bezier_tracks")); + ichb->add_child(insert_confirm_bezier); + insert_confirm_reset = memnew(CheckBox); + insert_confirm_reset->set_text(TTR("Create RESET Track(s)", "")); + insert_confirm_reset->set_pressed(EDITOR_GET("editors/animation/default_create_reset_tracks")); + ichb->add_child(insert_confirm_reset); keying = false; moving_selection = false; key_edit = nullptr; @@ -5789,7 +5885,7 @@ AnimationTrackEditor::AnimationTrackEditor() { optimize_max_angle->set_step(0.1); optimize_max_angle->set_value(22); - optimize_dialog->get_ok()->set_text(TTR("Optimize")); + optimize_dialog->get_ok_button()->set_text(TTR("Optimize")); optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_CLEAN_UP_ANIMATION_CONFIRM)); // @@ -5814,7 +5910,7 @@ AnimationTrackEditor::AnimationTrackEditor() { cleanup_vb->add_child(cleanup_all); cleanup_dialog->set_title(TTR("Clean-Up Animation(s) (NO UNDO!)")); - cleanup_dialog->get_ok()->set_text(TTR("Clean-Up")); + cleanup_dialog->get_ok_button()->set_text(TTR("Clean-Up")); cleanup_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_CLEAN_UP_ANIMATION_CONFIRM)); @@ -5834,7 +5930,7 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_dialog = memnew(ConfirmationDialog); add_child(track_copy_dialog); track_copy_dialog->set_title(TTR("Select Tracks to Copy")); - track_copy_dialog->get_ok()->set_text(TTR("Copy")); + track_copy_dialog->get_ok_button()->set_text(TTR("Copy")); VBoxContainer *track_vbox = memnew(VBoxContainer); track_copy_dialog->add_child(track_vbox); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 3cb31fe21e..7006959187 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -47,6 +47,8 @@ #include "scene/resources/animation.h" #include "scene_tree_editor.h" +class AnimationPlayer; + class AnimationTimelineEdit : public Range { GDCLASS(AnimationTimelineEdit, Range); @@ -285,6 +287,7 @@ class AnimationTrackEditor : public VBoxContainer { EDIT_DELETE_SELECTION, EDIT_GOTO_NEXT_STEP, EDIT_GOTO_PREV_STEP, + EDIT_APPLY_RESET, EDIT_OPTIMIZE_ANIMATION, EDIT_OPTIMIZE_ANIMATION_CONFIRM, EDIT_CLEAN_UP_ANIMATION, @@ -361,6 +364,7 @@ class AnimationTrackEditor : public VBoxContainer { Label *insert_confirm_text; CheckBox *insert_confirm_bezier; + CheckBox *insert_confirm_reset; ConfirmationDialog *insert_confirm; bool insert_queue; bool inserting; @@ -369,9 +373,19 @@ class AnimationTrackEditor : public VBoxContainer { uint64_t insert_frame; void _query_insert(const InsertData &p_id); + Ref<Animation> _create_and_get_reset_animation(); void _confirm_insert_list(); - int _confirm_insert(InsertData p_id, int p_last_track, bool p_create_beziers = false); - void _insert_delay(); + struct TrackIndices { + int normal; + int reset; + + TrackIndices(const Animation *p_anim = nullptr, const Animation *p_reset_anim = nullptr) { + normal = p_anim ? p_anim->get_track_count() : 0; + reset = p_reset_anim ? p_reset_anim->get_track_count() : 0; + } + }; + TrackIndices _confirm_insert(InsertData p_id, TrackIndices p_next_tracks, bool p_create_reset, bool p_create_beziers); + void _insert_delay(bool p_create_reset, bool p_create_beziers); void _root_removed(Node *p_root); @@ -447,6 +461,7 @@ class AnimationTrackEditor : public VBoxContainer { void _select_all_tracks_for_copy(); + void _edit_menu_about_to_popup(); void _edit_menu_pressed(int p_option); int last_menu_track_opt; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2630589912..473597b9b3 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -252,16 +252,16 @@ void ConnectDialog::_update_ok_enabled() { Node *target = tree->get_selected(); if (target == nullptr) { - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return; } if (!advanced->is_pressed() && target->get_script().is_null()) { - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return; } - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } void ConnectDialog::_notification(int p_what) { @@ -496,8 +496,8 @@ ConnectDialog::ConnectDialog() { error = memnew(AcceptDialog); add_child(error); error->set_title(TTR("Cannot connect signal")); - error->get_ok()->set_text(TTR("Close")); - get_ok()->set_text(TTR("Connect")); + error->get_ok_button()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Connect")); } ConnectDialog::~ConnectDialog() { diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 0f9c9bde7b..75d57b040f 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -57,10 +57,10 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St if (p_replace_mode) { set_title(vformat(TTR("Change %s Type"), base_type)); - get_ok()->set_text(TTR("Change")); + get_ok_button()->set_text(TTR("Change")); } else { set_title(vformat(TTR("Create New %s"), base_type)); - get_ok()->set_text(TTR("Create")); + get_ok_button()->set_text(TTR("Create")); } _load_favorites_and_history(); @@ -195,7 +195,7 @@ void CreateDialog::_update_search() { } else { favorite->set_disabled(true); help_bit->set_text(""); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); search_options->deselect_all(); } } @@ -396,7 +396,7 @@ void CreateDialog::select_type(const String &p_type) { favorite->set_disabled(false); favorite->set_pressed(favorite_list.find(p_type) != -1); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } String CreateDialog::get_selected_type() { diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 1a7a30ba4e..a27f196d49 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -553,7 +553,7 @@ void DependencyRemoveDialog::_bind_methods() { } DependencyRemoveDialog::DependencyRemoveDialog() { - get_ok()->set_text(TTR("Remove")); + get_ok_button()->set_text(TTR("Remove")); VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -619,8 +619,8 @@ DependencyErrorDialog::DependencyErrorDialog() { files->set_v_size_flags(Control::SIZE_EXPAND_FILL); set_min_size(Size2(500, 220) * EDSCALE); - get_ok()->set_text(TTR("Open Anyway")); - get_cancel()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Open Anyway")); + get_cancel_button()->set_text(TTR("Close")); text = memnew(Label); vb->add_child(text); @@ -756,7 +756,7 @@ void OrphanResourcesDialog::_bind_methods() { OrphanResourcesDialog::OrphanResourcesDialog() { set_title(TTR("Orphan Resource Explorer")); delete_confirm = memnew(ConfirmationDialog); - get_ok()->set_text(TTR("Delete")); + get_ok_button()->set_text(TTR("Delete")); add_child(delete_confirm); dep_edit = memnew(DependencyEditor); add_child(dep_edit); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 8aeeba52ed..aa6f7c8766 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -335,7 +335,7 @@ EditorAssetInstaller::EditorAssetInstaller() { error = memnew(AcceptDialog); add_child(error); - get_ok()->set_text(TTR("Install")); + get_ok_button()->set_text(TTR("Install")); set_title(TTR("Package Installer")); updating = false; diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 0888fecc67..d81dc05a75 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -851,15 +851,15 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { cc = 0; for (int i = 0; i < CHANNELS_MAX; i++) { - channel[i].vu_l = memnew(TextureProgress); - channel[i].vu_l->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP); + channel[i].vu_l = memnew(TextureProgressBar); + channel[i].vu_l->set_fill_mode(TextureProgressBar::FILL_BOTTOM_TO_TOP); hb->add_child(channel[i].vu_l); channel[i].vu_l->set_min(-80); channel[i].vu_l->set_max(24); channel[i].vu_l->set_step(0.1); - channel[i].vu_r = memnew(TextureProgress); - channel[i].vu_r->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP); + channel[i].vu_r = memnew(TextureProgressBar); + channel[i].vu_r->set_fill_mode(TextureProgressBar::FILL_BOTTOM_TO_TOP); hb->add_child(channel[i].vu_r); channel[i].vu_r->set_min(-80); channel[i].vu_r->set_max(24); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index f72541100d..b5f2f5af81 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -43,7 +43,7 @@ #include "scene/gui/panel_container.h" #include "scene/gui/scroll_container.h" #include "scene/gui/slider.h" -#include "scene/gui/texture_progress.h" +#include "scene/gui/texture_progress_bar.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tree.h" @@ -66,8 +66,8 @@ class EditorAudioBus : public PanelContainer { float peak_l = 0; float peak_r = 0; - TextureProgress *vu_l = nullptr; - TextureProgress *vu_r = nullptr; + TextureProgressBar *vu_l = nullptr; + TextureProgressBar *vu_r = nullptr; } channel[CHANNELS_MAX]; OptionButton *send; diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 206fdef7c9..17e0fd0fae 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -202,7 +202,7 @@ EditorDirDialog::EditorDirDialog() { mkdirerr->set_text(TTR("Could not create folder.")); add_child(mkdirerr); - get_ok()->set_text(TTR("Choose")); + get_ok_button()->set_text(TTR("Choose")); must_reload = false; } diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 7335563dd9..05bc2edefb 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -890,7 +890,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { add_child(new_profile_dialog); new_profile_dialog->connect("confirmed", callable_mp(this, &EditorFeatureProfileManager::_create_new_profile)); new_profile_dialog->register_text_enter(new_profile_name); - new_profile_dialog->get_ok()->set_text(TTR("Create")); + new_profile_dialog->get_ok_button()->set_text(TTR("Create")); erase_profile_dialog = memnew(ConfirmationDialog); add_child(erase_profile_dialog); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index ffdd7c7fa8..8ded47605c 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -212,14 +212,14 @@ void EditorFileDialog::update_dir() { dir->set_text(dir_access->get_current_dir(false)); // Disable "Open" button only when selecting file(s) mode. - get_ok()->set_disabled(_is_open_should_be_disabled()); + get_ok_button()->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")); + get_ok_button()->set_text(TTR("Open")); break; case FILE_MODE_OPEN_DIR: - get_ok()->set_text(TTR("Select Current Folder")); + get_ok_button()->set_text(TTR("Select Current Folder")); break; case FILE_MODE_OPEN_ANY: case FILE_MODE_SAVE_FILE: @@ -476,10 +476,10 @@ void EditorFileDialog::_item_selected(int p_item) { file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } else if (mode == FILE_MODE_OPEN_DIR) { - get_ok()->set_text(TTR("Select This Folder")); + get_ok_button()->set_text(TTR("Select This Folder")); } - get_ok()->set_disabled(_is_open_should_be_disabled()); + get_ok_button()->set_disabled(_is_open_should_be_disabled()); } void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { @@ -495,7 +495,7 @@ void EditorFileDialog::_multi_selected(int p_item, bool p_selected) { _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); } - get_ok()->set_disabled(_is_open_should_be_disabled()); + get_ok_button()->set_disabled(_is_open_should_be_disabled()); } void EditorFileDialog::_items_clear_selection() { @@ -505,13 +505,13 @@ void EditorFileDialog::_items_clear_selection() { switch (mode) { case FILE_MODE_OPEN_FILE: case FILE_MODE_OPEN_FILES: - get_ok()->set_text(TTR("Open")); - get_ok()->set_disabled(!item_list->is_anything_selected()); + get_ok_button()->set_text(TTR("Open")); + get_ok_button()->set_disabled(!item_list->is_anything_selected()); break; case FILE_MODE_OPEN_DIR: - get_ok()->set_disabled(false); - get_ok()->set_text(TTR("Select Current Folder")); + get_ok_button()->set_disabled(false); + get_ok_button()->set_text(TTR("Select Current Folder")); break; case FILE_MODE_OPEN_ANY: @@ -855,7 +855,7 @@ void EditorFileDialog::update_file_list() { favorite->set_pressed(false); fav_up->set_disabled(true); fav_down->set_disabled(true); - get_ok()->set_disabled(_is_open_should_be_disabled()); + get_ok_button()->set_disabled(_is_open_should_be_disabled()); for (int i = 0; i < favorites->get_item_count(); i++) { if (favorites->get_item_metadata(i) == cdir || favorites->get_item_metadata(i) == cdir + "/") { favorites->select(i); @@ -978,27 +978,27 @@ void EditorFileDialog::set_file_mode(FileMode p_mode) { mode = p_mode; switch (mode) { case FILE_MODE_OPEN_FILE: - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_text(TTR("Open")); set_title(TTR("Open a File")); can_create_dir = false; break; case FILE_MODE_OPEN_FILES: - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_text(TTR("Open")); set_title(TTR("Open File(s)")); can_create_dir = false; break; case FILE_MODE_OPEN_DIR: - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_text(TTR("Open")); set_title(TTR("Open a Directory")); can_create_dir = true; break; case FILE_MODE_OPEN_ANY: - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_text(TTR("Open")); set_title(TTR("Open a File or Directory")); can_create_dir = true; break; case FILE_MODE_SAVE_FILE: - get_ok()->set_text(TTR("Save")); + get_ok_button()->set_text(TTR("Save")); set_title(TTR("Save a File")); can_create_dir = true; break; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 43f0c9e2bb..a8a7262cf0 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1586,7 +1586,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector f->store_line("importer=\"" + importer->get_importer_name() + "\""); int version = importer->get_format_version(); if (version > 0) { - f->store_line("importer_version=" + itos(importer->get_format_version())); + f->store_line("importer_version=" + itos(version)); } if (importer->get_resource_type() != "") { f->store_line("type=\"" + importer->get_resource_type() + "\""); @@ -1725,7 +1725,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { importer = ResourceFormatImporter::get_singleton()->get_importer_by_extension(p_file.get_extension()); load_default = true; if (importer.is_null()) { - ERR_PRINT("BUG: File queued for import, but can't be imported!"); + ERR_PRINT("BUG: File queued for import, but can't be imported, importer for type '" + importer_name + "' not found."); ERR_FAIL(); } } @@ -1772,6 +1772,10 @@ void EditorFileSystem::_reimport_file(const String &p_file) { f->store_line("[remap]"); f->store_line(""); f->store_line("importer=\"" + importer->get_importer_name() + "\""); + int version = importer->get_format_version(); + if (version > 0) { + f->store_line("importer_version=" + itos(version)); + } if (importer->get_resource_type() != "") { f->store_line("type=\"" + importer->get_resource_type() + "\""); } diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index f5bb4921d4..23dc69af12 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -161,6 +161,14 @@ void editor_register_fonts(Ref<Theme> p_theme) { CustomFontSource->load_resource(custom_font_path_source, default_font_size); CustomFontSource->set_antialiased(font_antialiased); CustomFontSource->set_hinting(font_hinting); + + Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations")).split(","); + for (int i = 0; i < subtag.size(); i++) { + Vector<String> subtag_a = subtag[i].split("="); + if (subtag_a.size() == 2) { + CustomFontSource->set_variation(subtag_a[0], subtag_a[1].to_float()); + } + } } else { EditorSettings::get_singleton()->set_manually("interface/editor/code_font", ""); } @@ -282,6 +290,15 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_antialiased(font_antialiased); dfmono->set_hinting(font_hinting); + Vector<String> subtag = String(EditorSettings::get_singleton()->get("interface/editor/code_font_custom_variations")).split(","); + Dictionary ftrs; + for (int i = 0; i < subtag.size(); i++) { + Vector<String> subtag_a = subtag[i].split("="); + if (subtag_a.size() == 2) { + dfmono->set_variation(subtag_a[0], subtag_a[1].to_float()); + } + } + // Default font MAKE_DEFAULT_FONT(df); p_theme->set_default_theme_font(df); // Default theme font diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 4c553950a7..41010b6a86 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -230,7 +230,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview if (p_overview) { class_desc->push_cell(); - class_desc->push_align(RichTextLabel::ALIGN_RIGHT); + class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); } else { static const char32_t prefix[3] = { 0x25CF /* filled circle */, ' ', 0 }; class_desc->add_text(String(prefix)); @@ -528,7 +528,7 @@ void EditorHelp::_update_doc() { property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description class_desc->push_cell(); - class_desc->push_align(RichTextLabel::ALIGN_RIGHT); + class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); class_desc->push_font(doc_code_font); _add_type(cd.properties[i].type, cd.properties[i].enumeration); class_desc->pop(); @@ -729,7 +729,7 @@ void EditorHelp::_update_doc() { theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description class_desc->push_cell(); - class_desc->push_align(RichTextLabel::ALIGN_RIGHT); + class_desc->push_paragraph(RichTextLabel::ALIGN_RIGHT, Control::TEXT_DIRECTION_AUTO, ""); class_desc->push_font(doc_code_font); _add_type(cd.theme_properties[i].type); class_desc->pop(); @@ -1500,7 +1500,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { tag_stack.push_front(tag); } else if (tag == "center") { //align to center - p_rt->push_align(RichTextLabel::ALIGN_CENTER); + p_rt->push_paragraph(RichTextLabel::ALIGN_CENTER, Control::TEXT_DIRECTION_AUTO, ""); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "br") { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 4392538737..5e784ba051 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -105,7 +105,7 @@ void EditorHelpSearch::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { results_tree->call_deferred("clear"); // Wait for the Tree's mouse event propagation. - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size())); } } break; @@ -130,7 +130,7 @@ void EditorHelpSearch::_notification(int p_what) { old_search = false; } - get_ok()->set_disabled(!results_tree->get_selected()); + get_ok_button()->set_disabled(!results_tree->get_selected()); search = Ref<Runner>(); set_process(false); @@ -182,8 +182,8 @@ EditorHelpSearch::EditorHelpSearch() { set_title(TTR("Search Help")); - get_ok()->set_disabled(true); - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_disabled(true); + get_ok_button()->set_text(TTR("Open")); // Split search and results area. VBoxContainer *vbox = memnew(VBoxContainer); @@ -244,7 +244,7 @@ EditorHelpSearch::EditorHelpSearch() { results_tree->set_hide_root(true); results_tree->set_select_mode(Tree::SELECT_ROW); results_tree->connect("item_activated", callable_mp(this, &EditorHelpSearch::_confirmed)); - results_tree->connect("item_selected", callable_mp((BaseButton *)get_ok(), &BaseButton::set_disabled), varray(false)); + results_tree->connect("item_selected", callable_mp((BaseButton *)get_ok_button(), &BaseButton::set_disabled), varray(false)); vbox->add_child(results_tree, true); } @@ -412,8 +412,20 @@ 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; + bool constructor_created = false; for (int i = 0; i < match.methods.size(); i++) { - _create_method_item(parent, match.doc, match.methods[i]); + String text = match.methods[i]->name; + if (!constructor_created) { + if (match.doc->name == match.methods[i]->name) { + text += " " + TTR("(constructors)"); + constructor_created = true; + } + } else { + if (match.doc->name == match.methods[i]->name) { + continue; + } + } + _create_method_item(parent, match.doc, text, match.methods[i]); } for (int i = 0; i < match.signals.size(); i++) { _create_signal_item(parent, match.doc, match.signals[i]); @@ -508,7 +520,7 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const return item; } -TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { +TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, 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]; @@ -521,7 +533,7 @@ TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, cons } } tooltip += ")"; - return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, TTRC("Method"), "method", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip); } TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { @@ -537,32 +549,32 @@ TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, cons } } tooltip += ")"; - return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, TTRC("Signal"), "signal", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip); } 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); + return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, 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"; - return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, TTRC("Property"), "property", tooltip); + return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip); } 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); + return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, 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) { +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_text, const String &p_type, const String &p_metatype, const String &p_tooltip) { Ref<Texture2D> icon; String text; if (search_flags & SEARCH_SHOW_HIERARCHY) { icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); - text = p_name; + text = p_text; } else { icon = ui_service->get_theme_icon(p_icon, "EditorIcons"); /*// In flat mode, show the class icon. @@ -570,7 +582,7 @@ if (ui_service->has_icon(p_class_name, "EditorIcons")) icon = ui_service->get_icon(p_class_name, "EditorIcons"); else if (ClassDB::is_parent_class(p_class_name, "Object")) icon = ui_service->get_icon("Object", "EditorIcons");*/ - text = p_class_name + "." + p_name; + text = p_class_name + "." + p_text; } TreeItem *item = results_tree->create_item(p_parent); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index cb52c515de..d94066308a 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -140,12 +140,12 @@ class EditorHelpSearch::Runner : public Reference { void _match_item(TreeItem *p_item, const String &p_text); TreeItem *_create_class_hierarchy(const ClassMatch &p_match); TreeItem *_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray); - TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc); + TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc); TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc); TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc); TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc); TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc); - TreeItem *_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); + TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip); public: bool work(uint64_t slot = 100000); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 66c54c4267..a8dc14427d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -57,7 +57,7 @@ #include "scene/gui/split_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/tabs.h" -#include "scene/gui/texture_progress.h" +#include "scene/gui/texture_progress_bar.h" #include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" @@ -525,6 +525,9 @@ void EditorNode::_notification(int p_what) { scene_root->set_sdf_oversize(sdf_oversize); Viewport::SDFScale sdf_scale = Viewport::SDFScale(int(GLOBAL_GET("rendering/quality/2d_sdf/scale"))); scene_root->set_sdf_scale(sdf_scale); + + float lod_threshold = GLOBAL_GET("rendering/quality/mesh_lod/threshold_pixels"); + scene_root->set_lod_threshold(lod_threshold); } ResourceImporterTexture::get_singleton()->update_imports(); @@ -1416,6 +1419,17 @@ int EditorNode::_save_external_resources() { return saved; } +static void _reset_animation_players(Node *p_node, List<Ref<AnimatedValuesBackup>> *r_anim_backups) { + for (int i = 0; i < p_node->get_child_count(); i++) { + AnimationPlayer *player = Object::cast_to<AnimationPlayer>(p_node->get_child(i)); + if (player && player->is_reset_on_save_enabled() && player->can_apply_reset()) { + Ref<AnimatedValuesBackup> old_values = player->apply_reset(); + r_anim_backups->push_back(old_values); + } + _reset_animation_players(p_node->get_child(i), r_anim_backups); + } +} + void EditorNode::_save_scene(String p_file, int idx) { Node *scene = editor_data.get_edited_scene_root(idx); @@ -1430,6 +1444,8 @@ void EditorNode::_save_scene(String p_file, int idx) { } editor_data.apply_changes_in_editors(); + List<Ref<AnimatedValuesBackup>> anim_backups; + _reset_animation_players(scene, &anim_backups); _save_default_environment(); _set_scene_metadata(p_file, idx); @@ -1477,6 +1493,11 @@ void EditorNode::_save_scene(String p_file, int idx) { _save_external_resources(); editor_data.save_editor_external_data(); + + for (List<Ref<AnimatedValuesBackup>>::Element *E = anim_backups.front(); E; E = E->next()) { + E->get()->restore(); + } + if (err == OK) { scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file)); if (idx < 0 || idx == editor_data.get_edited_scene()) { @@ -2271,7 +2292,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) { String scene_filename = editor_data.get_edited_scene_root(tab_closing)->get_filename(); - save_confirmation->get_ok()->set_text(TTR("Save & Close")); + save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene_filename != "" ? scene_filename : "unsaved scene")); save_confirmation->popup_centered(); break; @@ -2362,8 +2383,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_SAVE_BEFORE_RUN: { if (!p_confirmed) { - confirmation->get_cancel()->set_text(TTR("No")); - confirmation->get_ok()->set_text(TTR("Yes")); + confirmation->get_cancel_button()->set_text(TTR("No")); + confirmation->get_ok_button()->set_text(TTR("Yes")); confirmation->set_text(TTR("This scene has never been saved. Save before running?")); confirmation->popup_centered(); break; @@ -2427,7 +2448,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_EXTERNAL_OPEN_SCENE: { if (unsaved_cache && !p_confirmed) { - confirmation->get_ok()->set_text(TTR("Open")); + confirmation->get_ok_button()->set_text(TTR("Open")); confirmation->set_text(TTR("Current scene not saved. Open anyway?")); confirmation->popup_centered(); break; @@ -2483,7 +2504,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } if (unsaved_cache && !p_confirmed) { - confirmation->get_ok()->set_text(TTR("Reload Saved Scene")); + confirmation->get_ok_button()->set_text(TTR("Reload Saved Scene")); confirmation->set_text( TTR("The current scene has unsaved changes.\nReload the saved scene anyway? This action cannot be undone.")); confirmation->popup_centered(); @@ -2587,7 +2608,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { 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->get_ok_button()->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(); } else { @@ -2605,7 +2626,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { i = _next_unsaved_scene(true, ++i); } - save_confirmation->get_ok()->set_text(TTR("Save & Quit")); + save_confirmation->get_ok_button()->set_text(TTR("Save & Quit")); save_confirmation->set_text((p_option == FILE_QUIT ? TTR("Save changes to the following scene(s) before quitting?") : TTR("Save changes the following scene(s) before opening Project Manager?")) + unsaved_scenes); save_confirmation->popup_centered(); } @@ -2743,16 +2764,13 @@ void EditorNode::_tool_menu_option(int p_idx) { } break; case TOOLS_CUSTOM: { if (tool_menu->get_item_submenu(p_idx) == "") { - Array params = tool_menu->get_item_metadata(p_idx); - - Object *handler = ObjectDB::get_instance(params[0]); - String callback = params[1]; - Variant *ud = ¶ms[2]; + Callable callback = tool_menu->get_item_metadata(p_idx); Callable::CallError ce; + Variant result; + callback.call(nullptr, 0, result, ce); - handler->call(callback, (const Variant **)&ud, 1, ce); if (ce.error != Callable::CallError::CALL_OK) { - String err = Variant::get_call_error_text(handler, callback, (const Variant **)&ud, 1, ce); + String err = Variant::get_callable_error_text(callback, nullptr, 0, ce); ERR_PRINT("Error calling function from tool menu: " + err); } } // else it's a submenu so don't do anything. @@ -3654,6 +3672,9 @@ void EditorNode::register_editor_types() { ClassDB::register_class<ScriptCreateDialog>(); ClassDB::register_class<EditorFeatureProfile>(); ClassDB::register_class<EditorSpinSlider>(); + ClassDB::register_class<EditorSceneImporterMesh>(); + ClassDB::register_class<EditorSceneImporterMeshNode>(); + ClassDB::register_virtual_class<FileSystemDock>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? @@ -3945,7 +3966,7 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo void EditorNode::show_accept(const String &p_text, const String &p_title) { current_option = -1; - accept->get_ok()->set_text(p_title); + accept->get_ok_button()->set_text(p_title); accept->set_text(p_text); accept->popup_centered(); } @@ -4644,14 +4665,14 @@ void EditorNode::_layout_menu_option(int 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")); + layout_dialog->get_ok_button()->set_text(TTR("Save")); layout_dialog->popup_centered(); 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")); + layout_dialog->get_ok_button()->set_text(TTR("Delete")); layout_dialog->popup_centered(); layout_dialog->set_name_line_enabled(false); } break; @@ -4693,7 +4714,7 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) { saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(p_tab) != 0; if (unsaved) { - save_confirmation->get_ok()->set_text(TTR("Save & Close")); + save_confirmation->get_ok_button()->set_text(TTR("Save & Close")); save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene")); save_confirmation->popup_centered(); } else { @@ -5083,17 +5104,10 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * return drag_data; } -void EditorNode::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) { - ERR_FAIL_NULL(p_handler); +void EditorNode::add_tool_menu_item(const String &p_name, const Callable &p_callback) { int idx = tool_menu->get_item_count(); tool_menu->add_item(p_name, TOOLS_CUSTOM); - - Array parameters; - parameters.push_back(p_handler->get_instance_id()); - parameters.push_back(p_callback); - parameters.push_back(p_ud); - - tool_menu->set_item_metadata(idx, parameters); + tool_menu->set_item_metadata(idx, p_callback); } void EditorNode::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) { @@ -5472,7 +5486,7 @@ 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_output_dialog->get_ok_button()->set_disabled(true); execute_outputs->clear(); execute_outputs->set_scroll_follow(true); execute_output_dialog->popup_centered_ratio(); @@ -5513,7 +5527,7 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p execute_output_dialog->hide(); } - execute_output_dialog->get_ok()->set_disabled(false); + execute_output_dialog->get_ok_button()->set_disabled(false); return eta.exitcode; } @@ -6385,7 +6399,7 @@ EditorNode::EditorNode() { #endif video_restart_dialog = memnew(ConfirmationDialog); video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor.")); - video_restart_dialog->get_ok()->set_text(TTR("Save & Restart")); + video_restart_dialog->get_ok_button()->set_text(TTR("Save & Restart")); video_restart_dialog->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SET_VIDEO_DRIVER_SAVE_AND_RESTART)); gui_base->add_child(video_restart_dialog); @@ -6532,19 +6546,19 @@ EditorNode::EditorNode() { custom_build_manage_templates = memnew(ConfirmationDialog); custom_build_manage_templates->set_text(TTR("Android build template is missing, please install relevant templates.")); - custom_build_manage_templates->get_ok()->set_text(TTR("Manage Templates")); + custom_build_manage_templates->get_ok_button()->set_text(TTR("Manage Templates")); custom_build_manage_templates->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_MANAGE_EXPORT_TEMPLATES)); gui_base->add_child(custom_build_manage_templates); install_android_build_template = memnew(ConfirmationDialog); install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset.")); - install_android_build_template->get_ok()->set_text(TTR("Install")); + install_android_build_template->get_ok_button()->set_text(TTR("Install")); install_android_build_template->connect("confirmed", callable_mp(this, &EditorNode::_menu_confirm_current)); gui_base->add_child(install_android_build_template); remove_android_build_template = memnew(ConfirmationDialog); remove_android_build_template->set_text(TTR("The Android build template is already installed in this project and it won't be overwritten.\nRemove the \"res://android/build\" directory manually before attempting this operation again.")); - remove_android_build_template->get_ok()->set_text(TTR("Show in File Manager")); + remove_android_build_template->get_ok_button()->set_text(TTR("Show in File Manager")); remove_android_build_template->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(FILE_EXPLORE_ANDROID_BUILD_TEMPLATES)); gui_base->add_child(remove_android_build_template); @@ -6747,7 +6761,7 @@ EditorNode::EditorNode() { set_process(true); open_imported = memnew(ConfirmationDialog); - open_imported->get_ok()->set_text(TTR("Open Anyway")); + open_imported->get_ok_button()->set_text(TTR("Open Anyway")); new_inherited_button = open_imported->add_button(TTR("New Inherited"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "inherit"); open_imported->connect("confirmed", callable_mp(this, &EditorNode::_open_imported)); open_imported->connect("custom_action", callable_mp(this, &EditorNode::_inherit_imported)); @@ -6797,7 +6811,7 @@ EditorNode::EditorNode() { pick_main_scene = memnew(ConfirmationDialog); gui_base->add_child(pick_main_scene); - pick_main_scene->get_ok()->set_text(TTR("Select")); + pick_main_scene->get_ok_button()->set_text(TTR("Select")); pick_main_scene->connect("confirmed", callable_mp(this, &EditorNode::_menu_option), varray(SETTINGS_PICK_MAIN_SCENE)); for (int i = 0; i < _init_callbacks.size(); i++) { diff --git a/editor/editor_node.h b/editor/editor_node.h index b727bce1e4..ab8d268801 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -81,7 +81,7 @@ class RunSettingsDialog; class ScriptCreateDialog; class TabContainer; class Tabs; -class TextureProgress; +class TextureProgressBar; class Button; class VSplitContainer; class Window; @@ -271,7 +271,7 @@ private: Button *play_scene_button; Button *play_custom_scene_button; Button *search_button; - TextureProgress *audio_vu; + TextureProgressBar *audio_vu; Timer *screenshot_timer; @@ -830,7 +830,7 @@ public: Variant drag_resource(const Ref<Resource> &p_res, Control *p_from); Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from); - void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant()); + void add_tool_menu_item(const String &p_name, const Callable &p_callback); void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); void remove_tool_menu_item(const String &p_name); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 49d8e58955..f974ba9998 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -489,8 +489,8 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati } } -void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) { - EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud); +void EditorPlugin::add_tool_menu_item(const String &p_name, const Callable &p_callable) { + EditorNode::get_singleton()->add_tool_menu_item(p_name, p_callable); } void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) { @@ -826,7 +826,7 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks); ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel); ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container); - ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"), &EditorPlugin::add_tool_menu_item, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "callable"), &EditorPlugin::add_tool_menu_item); ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item); ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item); ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 11063066d6..03908b43ca 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -174,7 +174,7 @@ public: void remove_control_from_docks(Control *p_control); void remove_control_from_bottom_panel(Control *p_control); - void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant()); + void add_tool_menu_item(const String &p_name, const Callable &p_callable); void add_tool_submenu_item(const String &p_name, Object *p_submenu); void remove_tool_menu_item(const String &p_name); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 2c4e403a81..523e65babe 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -68,9 +68,9 @@ void EditorPropertyText::_text_changed(const String &p_string) { } if (string_name) { - emit_changed(get_edited_property(), StringName(p_string), "", true); + emit_changed(get_edited_property(), StringName(p_string), "", false); } else { - emit_changed(get_edited_property(), p_string, "", true); + emit_changed(get_edited_property(), p_string, "", false); } } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 44df3926fc..73a191d317 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -336,6 +336,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/code_font_contextual_ligatures", 0); hints["interface/editor/code_font_contextual_ligatures"] = PropertyInfo(Variant::INT, "interface/editor/code_font_contextual_ligatures", PROPERTY_HINT_ENUM, "Default,Disable contextual alternates (coding ligatures),Use custom OpenType feature set", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/code_font_custom_opentype_features", ""); + _initial_set("interface/editor/code_font_custom_variations", ""); _initial_set("interface/editor/font_antialiased", true); _initial_set("interface/editor/font_hinting", 0); hints["interface/editor/font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/font_hinting", PROPERTY_HINT_ENUM, "Auto,None,Light,Normal", PROPERTY_USAGE_DEFAULT); @@ -548,9 +549,15 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/3d/grid_xy_plane", false); _initial_set("editors/3d/grid_yz_plane", false); + // Use a lower default FOV for the 3D camera compared to the + // Camera3D node as the 3D viewport doesn't span the whole screen. + // This means it's technically viewed from a further distance, which warrants a narrower FOV. _initial_set("editors/3d/default_fov", 70.0); + hints["editors/3d/default_fov"] = PropertyInfo(Variant::FLOAT, "editors/3d/default_fov", PROPERTY_HINT_RANGE, "1,179,0.1"); _initial_set("editors/3d/default_z_near", 0.05); - _initial_set("editors/3d/default_z_far", 500.0); + hints["editors/3d/default_z_near"] = PropertyInfo(Variant::FLOAT, "editors/3d/default_z_near", PROPERTY_HINT_RANGE, "0.01,10,0.01,or_greater"); + _initial_set("editors/3d/default_z_far", 4000.0); + hints["editors/3d/default_z_far"] = PropertyInfo(Variant::FLOAT, "editors/3d/default_z_far", PROPERTY_HINT_RANGE, "0.1,4000,0.1,or_greater"); // 3D: Navigation _initial_set("editors/3d/navigation/navigation_scheme", 0); @@ -621,6 +628,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Animation _initial_set("editors/animation/autorename_animation_tracks", true); _initial_set("editors/animation/confirm_insert_track", true); + _initial_set("editors/animation/default_create_bezier_tracks", false); + _initial_set("editors/animation/default_create_reset_tracks", true); _initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0)); _initial_set("editors/animation/onion_layers_future_color", Color(0, 1, 0)); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 723499ca9a..35de38fad2 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -85,6 +85,25 @@ static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, return style; } +static Ref<Texture2D> flip_icon(Ref<Texture2D> p_texture, bool p_flip_y = false, bool p_flip_x = false) { + if (!p_flip_y && !p_flip_x) { + return p_texture; + } + + Ref<ImageTexture> texture(memnew(ImageTexture)); + Ref<Image> img = p_texture->get_data(); + + if (p_flip_y) { + img->flip_y(); + } + if (p_flip_x) { + img->flip_x(); + } + + texture->create_from_image(img); + return texture; +} + #ifdef MODULE_SVG_ENABLED static 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); @@ -1074,11 +1093,33 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons")); theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons")); theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons")); + theme->set_icon("minimap", "GraphEdit", theme->get_icon("GridMinimap", "EditorIcons")); theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE); theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE); - // GraphNode + // GraphEditMinimap + theme->set_stylebox("bg", "GraphEditMinimap", make_flat_stylebox(dark_color_1, 0, 0, 0, 0)); + Ref<StyleBoxFlat> style_minimap_camera; + Ref<StyleBoxFlat> style_minimap_node; + if (dark_theme) { + style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0); + style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45)); + style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0); + } else { + style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0); + style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45)); + style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0); + } + style_minimap_camera->set_border_width_all(1); + style_minimap_node->set_corner_radius_all(1); + theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera); + theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node); + + Ref<Texture2D> resizer_icon = theme->get_icon("GuiResizer", "EditorIcons"); + theme->set_icon("resizer", "GraphEditMinimap", flip_icon(resizer_icon, true, true)); + theme->set_color("resizer_color", "GraphEditMinimap", Color(1, 1, 1, 0.65)); + // GraphNode const float mv = dark_theme ? 0.0 : 1.0; const float mv2 = 1.0 - mv; const int gn_margin_side = 28; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 84517f36ea..e9b6f6b5e9 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -661,8 +661,8 @@ ExportTemplateManager::ExportTemplateManager() { installed_scroll->set_enable_h_scroll(false); installed_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - get_cancel()->set_text(TTR("Close")); - get_ok()->set_text(TTR("Install From File")); + get_cancel_button()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Install From File")); remove_confirm = memnew(ConfirmationDialog); remove_confirm->set_title(TTR("Remove Template")); @@ -690,7 +690,7 @@ ExportTemplateManager::ExportTemplateManager() { template_downloader = memnew(AcceptDialog); template_downloader->set_title(TTR("Download Templates")); - template_downloader->get_ok()->set_text(TTR("Close")); + template_downloader->get_ok_button()->set_text(TTR("Close")); template_downloader->set_exclusive(true); add_child(template_downloader); template_downloader->connect("cancelled", callable_mp(this, &ExportTemplateManager::_window_template_downloader_closed)); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 364c52d633..6c8bd1901e 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2837,7 +2837,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { add_child(remove_dialog); move_dialog = memnew(EditorDirDialog); - move_dialog->get_ok()->set_text(TTR("Move")); + move_dialog->get_ok_button()->set_text(TTR("Move")); add_child(move_dialog); move_dialog->connect("dir_selected", callable_mp(this, &FileSystemDock::_move_operation_confirm), make_binds(false)); @@ -2847,13 +2847,13 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { rename_dialog_text = memnew(LineEdit); rename_dialog_vb->add_margin_child(TTR("Name:"), rename_dialog_text); - rename_dialog->get_ok()->set_text(TTR("Rename")); + rename_dialog->get_ok_button()->set_text(TTR("Rename")); add_child(rename_dialog); rename_dialog->register_text_enter(rename_dialog_text); rename_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_rename_operation_confirm)); overwrite_dialog = memnew(ConfirmationDialog); - overwrite_dialog->get_ok()->set_text(TTR("Overwrite")); + overwrite_dialog->get_ok_button()->set_text(TTR("Overwrite")); add_child(overwrite_dialog); overwrite_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_move_with_overwrite)); @@ -2863,7 +2863,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { duplicate_dialog_text = memnew(LineEdit); duplicate_dialog_vb->add_margin_child(TTR("Name:"), duplicate_dialog_text); - duplicate_dialog->get_ok()->set_text(TTR("Duplicate")); + duplicate_dialog->get_ok_button()->set_text(TTR("Duplicate")); add_child(duplicate_dialog); duplicate_dialog->register_text_enter(duplicate_dialog_text); duplicate_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_duplicate_operation_confirm)); diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index abcb7bbd93..076b873eac 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -383,7 +383,7 @@ FindInFilesDialog::FindInFilesDialog() { _replace_button = add_button(TTR("Replace..."), false, "replace"); _replace_button->set_disabled(true); - Button *cancel_button = get_ok(); + Button *cancel_button = get_ok_button(); cancel_button->set_text(TTR("Cancel")); _mode = SEARCH_MODE; @@ -779,7 +779,19 @@ void FindInFilesPanel::_on_item_edited() { } void FindInFilesPanel::_on_finished() { - _status_label->set_text(TTR("Search complete")); + String results_text; + int result_count = _result_items.size(); + int file_count = _file_items.size(); + + if (result_count == 1 && file_count == 1) { + results_text = vformat(TTR("%d match in %d file."), result_count, file_count); + } else if (result_count != 1 && file_count == 1) { + results_text = vformat(TTR("%d matches in %d file."), result_count, file_count); + } else { + results_text = vformat(TTR("%d matches in %d files."), result_count, file_count); + } + + _status_label->set_text(results_text); update_replace_buttons(); set_progress_visible(false); _refresh_button->show(); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index f3bad8d86d..32c50321d7 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -540,7 +540,7 @@ GroupDialog::GroupDialog() { error = memnew(ConfirmationDialog); add_child(error); - error->get_ok()->set_text(TTR("Close")); + error->get_ok_button()->set_text(TTR("Close")); } //////////////////////////////////////////////////////////////////////////////// diff --git a/editor/icons/GridMinimap.svg b/editor/icons/GridMinimap.svg new file mode 100644 index 0000000000..72f107066d --- /dev/null +++ b/editor/icons/GridMinimap.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 2.1992188v2.6152343l-2.625 1.3125v-2.6152343zm-12 4.0644531 2.625 1.3125v2.5507811l-2.625-1.3124999zm12 0v2.5507812l-2.625 1.3124999v-2.5507811zm-8 1.4550781h4v2.640625h-4zm-4 2.560547 2.625 1.3125v2.521484l-2.625-1.3125zm12 0v2.521484l-2.625 1.3125v-2.521484zm-8 1.455078h4v2.640625h-4zm1.7014535-8.109375h2.2985465v2.734375h-4.15625s-.7487346.647119-.8746377.640625c-.1310411-.0067594-1.5097373-1.4558594-1.5097373-1.4558594l-1.459375-.7296875v-2.6152343l.068419.034223s.026411-.4573464.062111-.6760553c.0346282-.2121439.1970747-.59225724.1970747-.59225724l-1.0483078-.52372301c-.0795772-.04012218-.1668141-.06276382-.2558594-.06640625-.35427845-.01325803-.64865004.27047362-.6484375.625v12c.00021484.236623.13402736.45284.34570312.558594l3.99999998 2c.086686.043505.1823067.06624.2792969.066406h6c.09699-.000166.192611-.0229.279297-.06641l4-2c.211676-.10575.345488-.321967.345703-.55859v-12c-.000468-.46423753-.488958-.76598317-.904297-.55859375l-3.869141 1.93359375h-2.9709527s.033448.4166167.015891.625c-.029188.3464401-.1950466.625-.1950468.625z" fill="#e0e0e0"/><path d="m5 6s-2.21875-2.1616704-2.21875-3.2425057c0-1.0808352 0-2.6072392 2.21875-2.6072392s2.21875 1.526404 2.21875 2.6072392c0 1.0808353-2.21875 3.2425057-2.21875 3.2425057z" fill="#fff" fill-opacity=".68627"/></svg> diff --git a/editor/icons/GuiToggleOn.svg b/editor/icons/GuiToggleOn.svg index 8ab0998f71..37b47e8de4 100644 --- a/editor/icons/GuiToggleOn.svg +++ b/editor/icons/GuiToggleOn.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 38 15.999999" width="38" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.878 0-7 3.122-7 7s3.122 7 7 7h22c3.878 0 7-3.122 7-7s-3.122-7-7-7zm22 2a5 5 0 0 1 5 5 5 5 0 0 1 -5 5 5 5 0 0 1 -5-5 5 5 0 0 1 5-5z" fill="#e0e0e0" stroke-width="55.8958"/></svg> +<svg height="16" viewBox="0 0 38 15.999999" width="38" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-4 0-7 3.0000002-7 7.0000002 0 3.9999998 3 6.9999998 7 6.9999998h22c4 0 7-3 7-6.9999998 0-4-3-7.0000002-7-7.0000002-7.333334 0-14.55609 0-22 0z" fill="#699ce8"/><circle cx="30" cy="8" fill="#fefefe" r="5"/></svg> diff --git a/editor/icons/GuiToggleOnMirrored.svg b/editor/icons/GuiToggleOnMirrored.svg index 7339b6efd2..fa7f602ee7 100644 --- a/editor/icons/GuiToggleOnMirrored.svg +++ b/editor/icons/GuiToggleOnMirrored.svg @@ -1 +1 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="42" height="26"><path fill="#e0e0e0" d="M31 5c4.986 0 9 3.568 9 8s-4.014 8-9 8H11c-4.986 0-9-3.568-9-8s4.014-8 9-8zM10 8a-5 5 0 0 0-5 5-5 5 0 0 0 5 5-5 5 0 0 0 5-5-5 5 0 0 0-5-5z"/></svg> +<svg height="26" width="42" xmlns="http://www.w3.org/2000/svg"><path d="m31 5c4.986 0 9 3.568 9 8s-4.014 8-9 8h-20c-4.986 0-9-3.568-9-8s4.014-8 9-8z" fill="#699ce8"/><circle cx="10" cy="13" fill="#fefefe" r="5"/></svg> diff --git a/editor/icons/Texture3D.svg b/editor/icons/Texture3D.svg index 6bdc599f6d..795dd62ba5 100644 --- a/editor/icons/Texture3D.svg +++ b/editor/icons/Texture3D.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m2 1c-.5522847 0-1 .4477153-1 1v12c0 .552285.4477153 1 1 1h12c.552285 0 1-.447715 1-1v-12c0-.5522847-.447715-1-1-1zm1 2h10v8h-10z" fill-opacity=".99608" transform="translate(.359546 -.287637)"/><g fill-opacity=".996078" stroke-width=".203212" transform="scale(.9167105 1.0908569)"><path d="m5.8175194 8.9717502q-.2194689 0-.4633233-.032514-.2438544-.0243854-.4714519-.0731562-.2275974-.0487709-.4145524-.1056703-.1869551-.0568993-.2926253-.1056702l.2357259-1.0079315q.2113405.089413.5364797.1950835.3332677.097542.8209765.097542.5608651 0 .8209764-.2113404.2601114-.2113405.2601114-.5689936 0-.219469-.097542-.3657816-.089413-.1544415-.2519826-.2438547-.1625696-.0975418-.3901671-.1300557-.2194689-.0406424-.4714518-.0406424h-.4714519v-.9754176h.5364797q.1788266 0 .3413962-.032514.1706981-.032514.3007537-.1056703.1300557-.081285.203212-.2113404.081285-.1381842.081285-.3413962 0-.1544411-.065028-.2682398-.0650278-.1137987-.1706981-.186955-.0975417-.0731563-.2357259-.1056702-.1300557-.0406424-.2682398-.0406424-.3495247 0-.6502784.1056702-.2926253.1056703-.5364797.2601114l-.4308095-.8860043q.1300557-.0812848.3007538-.1706981.1788266-.0894133.390167-.1625696.2113405-.0731563.4470664-.1219272.2438544-.048771.5120943-.048771.4958373 0 .8534904.1219272.3657816.1137987.6015075.3332677.2357259.2113405.3495246.5039657.1137987.2844968.1137987.625893 0 .3332677-.186955.6502784-.186955.3088822-.5039657.4714518.4389379.1788266.6746638.5364797.2438544.3495246.2438544.8453619 0 .3901671-.1300557.7234347-.1300557.3251393-.406424.5689937-.2763683.235726-.7071777.3739101-.422681.1300557-1.0079316.1300557z"/><path d="m10.502445 7.817506q.08941.00813.203212.016257.121927 0 .284497 0 .951032 0 1.406227-.4795803.463323-.4795803.463323-1.3249422 0-.8860044-.438938-1.3411992-.438938-.4551949-1.38997-.4551949-.130055 0-.26824.00813-.138184 0-.260111.016257zm3.665945-1.7882655q0 .7315631-.227598 1.2761713-.227597.5446082-.650278.9022613-.414553.3576531-1.01606.5364797-.601508.1788265-1.349328.1788265-.341396 0-.796591-.032514-.4551948-.0243853-.8941328-.1137986v-5.486724q.438938-.081285.9103898-.1056702.47958-.032514.820976-.032514.723435 0 1.308686.1625696.593379.1625696 1.01606.5120943.422681.3495246.650278.8941328.227598.5446081.227598 1.3086853z"/></g></g></svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" transform="translate(-.359546 .287637)"><path d="m2 1c-.5522847 0-1 .4477153-1 1v12c0 .552285.4477153 1 1 1h12c.552285 0 1-.447715 1-1v-12c0-.5522847-.447715-1-1-1zm1 2h10v8h-10z" fill-opacity=".99608" transform="translate(.359546 -.287637)"/><g fill-opacity=".996078" stroke-width=".203212" transform="scale(.9167105 1.0908569)"><path d="m5.8175194 8.9717502q-.2194689 0-.4633233-.032514-.2438544-.0243854-.4714519-.0731562-.2275974-.0487709-.4145524-.1056703-.1869551-.0568993-.2926253-.1056702l.2357259-1.0079315q.2113405.089413.5364797.1950835.3332677.097542.8209765.097542.5608651 0 .8209764-.2113404.2601114-.2113405.2601114-.5689936 0-.219469-.097542-.3657816-.089413-.1544415-.2519826-.2438547-.1625696-.0975418-.3901671-.1300557-.2194689-.0406424-.4714518-.0406424h-.4714519v-.9754176h.5364797q.1788266 0 .3413962-.032514.1706981-.032514.3007537-.1056703.1300557-.081285.203212-.2113404.081285-.1381842.081285-.3413962 0-.1544411-.065028-.2682398-.0650278-.1137987-.1706981-.186955-.0975417-.0731563-.2357259-.1056702-.1300557-.0406424-.2682398-.0406424-.3495247 0-.6502784.1056702-.2926253.1056703-.5364797.2601114l-.4308095-.8860043q.1300557-.0812848.3007538-.1706981.1788266-.0894133.390167-.1625696.2113405-.0731563.4470664-.1219272.2438544-.048771.5120943-.048771.4958373 0 .8534904.1219272.3657816.1137987.6015075.3332677.2357259.2113405.3495246.5039657.1137987.2844968.1137987.625893 0 .3332677-.186955.6502784-.186955.3088822-.5039657.4714518.4389379.1788266.6746638.5364797.2438544.3495246.2438544.8453619 0 .3901671-.1300557.7234347-.1300557.3251393-.406424.5689937-.2763683.235726-.7071777.3739101-.422681.1300557-1.0079316.1300557z"/><path d="m10.502445 7.817506q.08941.00813.203212.016257.121927 0 .284497 0 .951032 0 1.406227-.4795803.463323-.4795803.463323-1.3249422 0-.8860044-.438938-1.3411992-.438938-.4551949-1.38997-.4551949-.130055 0-.26824.00813-.138184 0-.260111.016257zm3.665945-1.7882655q0 .7315631-.227598 1.2761713-.227597.5446082-.650278.9022613-.414553.3576531-1.01606.5364797-.601508.1788265-1.349328.1788265-.341396 0-.796591-.032514-.4551948-.0243853-.8941328-.1137986v-5.486724q.438938-.081285.9103898-.1056702.47958-.032514.820976-.032514.723435 0 1.308686.1625696.593379.1625696 1.01606.5120943.422681.3495246.650278.8941328.227598.5446081.227598 1.3086853z"/></g></g></svg> diff --git a/editor/icons/TextureArray.svg b/editor/icons/TextureArray.svg index 86d4875e12..a71860023b 100644 --- a/editor/icons/TextureArray.svg +++ b/editor/icons/TextureArray.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0"><path d="m2 1c-.5522847 0-1 .4477153-1 1v12c0 .552285.4477153 1 1 1h12c.552285 0 1-.447715 1-1v-12c0-.5522847-.447715-1-1-1zm1 2h10v8h-10z" fill-opacity=".99608" transform="translate(.359546 -.287637)"/><g fill-opacity=".996078" stroke-width=".207395" transform="matrix(1.6197742 0 0 .750929 -3.723153 1.832957)"><path d="m4.7302951 2.4553483h2.2481639v.9872012h-1.0701592v6.0559397h1.0701592v.9872008h-2.2481639z"/><path d="m10.138643 10.48569h-2.2481636v-.9872008h1.0701592v-6.0559397h-1.0701592v-.9872012h2.2481636z"/></g></g></svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" transform="translate(-.359546 .287637)"><path d="m2 1c-.5522847 0-1 .4477153-1 1v12c0 .552285.4477153 1 1 1h12c.552285 0 1-.447715 1-1v-12c0-.5522847-.447715-1-1-1zm1 2h10v8h-10z" fill-opacity=".99608" transform="translate(.359546 -.287637)"/><g fill-opacity=".996078" stroke-width=".207395" transform="matrix(1.6197742 0 0 .750929 -3.723153 1.832957)"><path d="m4.9900159 2.5027746h1.85211v1.3316838h-.926055v5.3267353h.926055v1.3316833h-1.85211z"/><path d="m9.9289759 10.492877h-1.85211v-1.3316833h.926055v-5.3267353h-.926055v-1.3316838h1.85211z"/></g></g></svg> diff --git a/editor/icons/TextureProgress.svg b/editor/icons/TextureProgressBar.svg index 30d76e33b8..30d76e33b8 100644 --- a/editor/icons/TextureProgress.svg +++ b/editor/icons/TextureProgressBar.svg diff --git a/editor/import/collada.h b/editor/import/collada.h index 3b6b508b28..29d49d4aa7 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -96,8 +96,8 @@ public: }; float aspect = 1; - float z_near = 0.1; - float z_far = 100; + float z_near = 0.05; + float z_far = 4000; CameraData() {} }; diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 270bdc3821..4e93fe6f12 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -67,7 +67,7 @@ struct ColladaImport { Map<String, NodeMap> node_map; //map from collada node to engine node Map<String, String> node_name_map; //map from collada node to engine node - Map<String, Ref<ArrayMesh>> mesh_cache; + Map<String, Ref<EditorSceneImporterMesh>> mesh_cache; Map<String, Ref<Curve3D>> curve_cache; Map<String, Ref<Material>> material_cache; Map<Collada::Node *, Skeleton3D *> skeleton_map; @@ -83,7 +83,7 @@ struct ColladaImport { Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); - Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes = Vector<Ref<ArrayMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); + Error _create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &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<EditorSceneImporterMesh>> p_morph_meshes = Vector<Ref<EditorSceneImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false); void _fix_param_animation_tracks(); void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks); @@ -278,8 +278,8 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { node = memnew(Path3D); } else { //mesh since nothing else - node = memnew(MeshInstance3D); - //Object::cast_to<MeshInstance3D>(node)->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); + node = memnew(EditorSceneImporterMeshNode); + //Object::cast_to<EditorSceneImporterMeshNode>(node)->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { @@ -440,7 +440,7 @@ Error ColladaImport::_create_material(const String &p_target) { return OK; } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &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<EditorSceneImporterMesh>> 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) { @@ -457,9 +457,9 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me p_mesh->add_blend_shape(name); } if (p_morph_data->mode == "RELATIVE") { - p_mesh->set_blend_shape_mode(ArrayMesh::BLEND_SHAPE_MODE_RELATIVE); + p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_RELATIVE); } else if (p_morph_data->mode == "NORMALIZED") { - p_mesh->set_blend_shape_mode(ArrayMesh::BLEND_SHAPE_MODE_NORMALIZED); + p_mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED); } } @@ -897,7 +897,7 @@ 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); + Array a = p_morph_meshes[mi]->get_surface_arrays(surface); //add valid weight and bone arrays if they exist, TODO check if they are unique to shape (generally not) if (has_weights) { @@ -910,14 +910,15 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me mr.push_back(a); } - p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), 0); - + String surface_name; + Ref<Material> mat; if (material.is_valid()) { if (p_use_mesh_material) { - p_mesh->surface_set_material(surface, material); + mat = material; } - p_mesh->surface_set_name(surface, material->get_name()); + surface_name = material->get_name(); } + p_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), mat, surface_name); } /*****************/ @@ -1002,10 +1003,10 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } } - if (Object::cast_to<MeshInstance3D>(node)) { + if (Object::cast_to<EditorSceneImporterMeshNode>(node)) { Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node); - MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node); + EditorSceneImporterMeshNode *mi = Object::cast_to<EditorSceneImporterMeshNode>(node); ERR_FAIL_COND_V(!mi, ERR_BUG); @@ -1014,7 +1015,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres String meshid; Transform apply_xform; Vector<int> bone_remap; - Vector<Ref<ArrayMesh>> morphs; + Vector<Ref<EditorSceneImporterMesh>> morphs; if (ng2->controller) { String ngsource = ng2->source; @@ -1083,10 +1084,10 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres 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)); + Ref<EditorSceneImporterMesh> mesh = Ref<EditorSceneImporterMesh>(memnew(EditorSceneImporterMesh)); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2]; mesh->set_name(meshdata.name); - Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, nullptr, Vector<Ref<ArrayMesh>>(), false); + Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, nullptr, Vector<Ref<EditorSceneImporterMesh>>(), false); ERR_FAIL_COND_V(err, err); morphs.push_back(mesh); @@ -1109,7 +1110,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres meshid = ng2->source; } - Ref<ArrayMesh> mesh; + Ref<EditorSceneImporterMesh> mesh; if (mesh_cache.has(meshid)) { mesh = mesh_cache[meshid]; } else { @@ -1117,7 +1118,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres //bleh, must ignore invalid ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(meshid), ERR_INVALID_DATA); - mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); + mesh = Ref<EditorSceneImporterMesh>(memnew(EditorSceneImporterMesh)); const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid]; mesh->set_name(meshdata.name); Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, p_use_compression, use_mesh_builtin_materials); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index ac76f67ef9..1059692ca0 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -970,8 +970,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { return OK; } - uint32_t mesh_flags = 0; - Array meshes = state.json["meshes"]; for (GLTFMeshIndex i = 0; i < meshes.size(); i++) { print_verbose("glTF: Parsing mesh: " + itos(i)); @@ -979,6 +977,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { GLTFMesh mesh; mesh.mesh.instance(); + bool has_vertex_color = false; ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR); @@ -1034,6 +1033,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } if (a.has("COLOR_0")) { array[Mesh::ARRAY_COLOR] = _decode_accessor_as_color(state, a["COLOR_0"], true); + has_vertex_color = true; } if (a.has("JOINTS_0")) { array[Mesh::ARRAY_BONES] = _decode_accessor_as_ints(state, a["JOINTS_0"], true); @@ -1112,7 +1112,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { //ideally BLEND_SHAPE_MODE_RELATIVE since gltf2 stores in displacement //but it could require a larger refactor? - mesh.mesh->set_blend_shape_mode(ArrayMesh::BLEND_SHAPE_MODE_NORMALIZED); + mesh.mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED); if (j == 0) { const Array &target_names = extras.has("targetNames") ? (Array)extras["targetNames"] : Array(); @@ -1226,21 +1226,25 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } //just add it - mesh.mesh->add_surface_from_arrays(primitive, array, morphs, Dictionary(), mesh_flags); + Ref<Material> mat; if (p.has("material")) { const int material = p["material"]; ERR_FAIL_INDEX_V(material, state.materials.size(), ERR_FILE_CORRUPT); - const Ref<Material> &mat = state.materials[material]; - - mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat); - } else { - Ref<StandardMaterial3D> mat; - mat.instance(); - mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref<StandardMaterial3D> mat3d = state.materials[material]; + if (has_vertex_color) { + mat3d->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + } + mat = mat3d; - mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat); + } else if (has_vertex_color) { + Ref<StandardMaterial3D> mat3d; + mat3d.instance(); + mat3d->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat = mat3d; } + + mesh.mesh->add_surface(primitive, array, morphs, Dictionary(), mat); } mesh.blend_weights.resize(mesh.mesh->get_blend_shape_count()); @@ -1440,7 +1444,8 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("name")) { material->set_name(d["name"]); } - material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + //don't do this here only if vertex color exists + //material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); if (d.has("pbrMetallicRoughness")) { const Dictionary &mr = d["pbrMetallicRoughness"]; @@ -2586,12 +2591,12 @@ BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState & return bone_attachment; } -MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +EditorSceneImporterMeshNode *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr); - MeshInstance3D *mi = memnew(MeshInstance3D); + EditorSceneImporterMeshNode *mi = memnew(EditorSceneImporterMeshNode); print_verbose("glTF: Creating mesh for: " + gltf_node->name); GLTFMesh &mesh = state.meshes.write[gltf_node->mesh]; @@ -3058,7 +3063,7 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D * const GLTFSkinIndex skin_i = node->skin; Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i); - MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get()); + EditorSceneImporterMeshNode *mi = Object::cast_to<EditorSceneImporterMeshNode>(mi_element->get()); ERR_FAIL_COND(mi == nullptr); const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton; diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 5ea8bf17b8..e6163a46be 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -38,7 +38,7 @@ class AnimationPlayer; class BoneAttachment3D; -class MeshInstance3D; +class EditorSceneImporterMeshNode; class EditorSceneImporterGLTF : public EditorSceneImporter { GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter); @@ -199,15 +199,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; struct GLTFMesh { - Ref<ArrayMesh> mesh; + Ref<EditorSceneImporterMesh> mesh; Vector<float> blend_weights; }; struct GLTFCamera { bool perspective = true; - float fov_size = 64; - float zfar = 500; - float znear = 0.1; + float fov_size = 75; + float zfar = 4000; + float znear = 0.05; }; struct GLTFLight { @@ -262,7 +262,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Vector<GLTFAccessor> accessors; Vector<GLTFMesh> meshes; //meshes are loaded directly, no reason not to. - Vector<Ref<Material>> materials; + Vector<Ref<StandardMaterial3D>> materials; String scene_name; Vector<int> root_nodes; @@ -355,7 +355,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Error _parse_animations(GLTFState &state); BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index); - MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + EditorSceneImporterMeshNode *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); Light3D *_generate_light(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index d4560a2984..30c7b2920a 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -225,6 +225,8 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ String current_material_library; String current_material; String current_group; + uint32_t smooth_group = 0; + bool smoothing = true; while (true) { String l = f->get_line().strip_edges(); @@ -315,6 +317,10 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ Vector3 vertex = vertices[vtx]; //if (weld_vertices) // vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance)); + if (!smoothing) { + smooth_group++; + } + surf_tool->set_smooth_group(smooth_group); surf_tool->add_vertex(vertex); } @@ -322,10 +328,15 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_ } } else if (l.begins_with("s ")) { //smoothing String what = l.substr(2, l.length()).strip_edges(); + bool do_smooth; if (what == "off") { - surf_tool->add_smooth_group(false); + do_smooth = false; } else { - surf_tool->add_smooth_group(true); + do_smooth = true; + } + if (do_smooth != smoothing) { + smooth_group++; + smoothing = do_smooth; } } else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh //groups are too annoying @@ -426,8 +437,15 @@ 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()); + Ref<EditorSceneImporterMesh> mesh; + mesh.instance(); + Ref<Mesh> m = E->get(); + for (int i = 0; i < m->get_surface_count(); i++) { + mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i)); + } + + EditorSceneImporterMeshNode *mi = memnew(EditorSceneImporterMeshNode); + mi->set_mesh(mesh); mi->set_name(E->get()->get_name()); scene->add_child(mi); mi->set_owner(scene); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index fc4f673ec4..b591627660 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -44,6 +44,7 @@ #include "scene/resources/ray_shape_3d.h" #include "scene/resources/resource_format_text.h" #include "scene/resources/sphere_shape_3d.h" +#include "scene/resources/surface_tool.h" #include "scene/resources/world_margin_shape_3d.h" uint32_t EditorSceneImporter::get_import_flags() const { @@ -119,6 +120,345 @@ void EditorSceneImporter::_bind_methods() { BIND_CONSTANT(IMPORT_USE_COMPRESSION); } +//////////////////////////////////////////////// + +void EditorSceneImporterMesh::add_blend_shape(const String &p_name) { + ERR_FAIL_COND(surfaces.size() > 0); + blend_shapes.push_back(p_name); +} + +int EditorSceneImporterMesh::get_blend_shape_count() const { + return blend_shapes.size(); +} + +String EditorSceneImporterMesh::get_blend_shape_name(int p_blend_shape) const { + ERR_FAIL_INDEX_V(p_blend_shape, blend_shapes.size(), String()); + return blend_shapes[p_blend_shape]; +} + +void EditorSceneImporterMesh::set_blend_shape_mode(Mesh::BlendShapeMode p_blend_shape_mode) { + blend_shape_mode = p_blend_shape_mode; +} +Mesh::BlendShapeMode EditorSceneImporterMesh::get_blend_shape_mode() const { + return blend_shape_mode; +} + +void EditorSceneImporterMesh::add_surface(Mesh::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, const Dictionary &p_lods, const Ref<Material> &p_material, const String &p_name) { + ERR_FAIL_COND(p_blend_shapes.size() != blend_shapes.size()); + ERR_FAIL_COND(p_arrays.size() != Mesh::ARRAY_MAX); + Surface s; + s.primitive = p_primitive; + s.arrays = p_arrays; + s.name = p_name; + + for (int i = 0; i < blend_shapes.size(); i++) { + Array bsdata = p_blend_shapes[i]; + ERR_FAIL_COND(bsdata.size() != Mesh::ARRAY_MAX); + Surface::BlendShape bs; + bs.arrays = bsdata; + s.blend_shape_data.push_back(bs); + } + + List<Variant> lods; + p_lods.get_key_list(&lods); + for (List<Variant>::Element *E = lods.front(); E; E = E->next()) { + ERR_CONTINUE(!E->get().is_num()); + Surface::LOD lod; + lod.distance = E->get(); + lod.indices = p_lods[E->get()]; + ERR_CONTINUE(lod.indices.size() == 0); + s.lods.push_back(lod); + } + + s.material = p_material; + + surfaces.push_back(s); + mesh.unref(); +} +int EditorSceneImporterMesh::get_surface_count() const { + return surfaces.size(); +} + +Mesh::PrimitiveType EditorSceneImporterMesh::get_surface_primitive_type(int p_surface) { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Mesh::PRIMITIVE_MAX); + return surfaces[p_surface].primitive; +} +Array EditorSceneImporterMesh::get_surface_arrays(int p_surface) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array()); + return surfaces[p_surface].arrays; +} +String EditorSceneImporterMesh::get_surface_name(int p_surface) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), String()); + return surfaces[p_surface].name; +} +Array EditorSceneImporterMesh::get_surface_blend_shape_arrays(int p_surface, int p_blend_shape) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array()); + ERR_FAIL_INDEX_V(p_blend_shape, surfaces[p_surface].blend_shape_data.size(), Array()); + return surfaces[p_surface].blend_shape_data[p_blend_shape].arrays; +} +int EditorSceneImporterMesh::get_surface_lod_count(int p_surface) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), 0); + return surfaces[p_surface].lods.size(); +} +Vector<int> EditorSceneImporterMesh::get_surface_lod_indices(int p_surface, int p_lod) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Vector<int>()); + ERR_FAIL_INDEX_V(p_lod, surfaces[p_surface].lods.size(), Vector<int>()); + + return surfaces[p_surface].lods[p_lod].indices; +} + +float EditorSceneImporterMesh::get_surface_lod_size(int p_surface, int p_lod) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), 0); + ERR_FAIL_INDEX_V(p_lod, surfaces[p_surface].lods.size(), 0); + return surfaces[p_surface].lods[p_lod].distance; +} + +Ref<Material> EditorSceneImporterMesh::get_surface_material(int p_surface) const { + ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Ref<Material>()); + return surfaces[p_surface].material; +} + +void EditorSceneImporterMesh::generate_lods() { + if (!SurfaceTool::simplify_func) { + return; + } + + for (int i = 0; i < surfaces.size(); i++) { + if (surfaces[i].primitive != Mesh::PRIMITIVE_TRIANGLES) { + continue; + } + + surfaces.write[i].lods.clear(); + Vector<Vector3> vertices = surfaces[i].arrays[RS::ARRAY_VERTEX]; + Vector<int> indices = surfaces[i].arrays[RS::ARRAY_INDEX]; + if (indices.size() == 0) { + continue; //no lods if no indices + } + uint32_t vertex_count = vertices.size(); + const Vector3 *vertices_ptr = vertices.ptr(); + + int min_indices = 10; + int index_target = indices.size() / 2; + print_line("total: " + itos(indices.size())); + while (index_target > min_indices) { + float error; + Vector<int> new_indices; + new_indices.resize(indices.size()); + size_t new_len = SurfaceTool::simplify_func((unsigned int *)new_indices.ptrw(), (const unsigned int *)indices.ptr(), indices.size(), (const float *)vertices_ptr, vertex_count, sizeof(Vector3), index_target, 1e20, &error); + print_line("shoot for " + itos(index_target) + ", got " + itos(new_len) + " distance " + rtos(error)); + if ((int)new_len > (index_target * 120 / 100)) { + break; // 20 percent tolerance + } + new_indices.resize(new_len); + Surface::LOD lod; + lod.distance = error; + lod.indices = new_indices; + surfaces.write[i].lods.push_back(lod); + index_target /= 2; + } + } +} + +bool EditorSceneImporterMesh::has_mesh() const { + return mesh.is_valid(); +} + +Ref<ArrayMesh> EditorSceneImporterMesh::get_mesh() { + ERR_FAIL_COND_V(surfaces.size() == 0, Ref<ArrayMesh>()); + + if (mesh.is_null()) { + mesh.instance(); + for (int i = 0; i < blend_shapes.size(); i++) { + mesh->add_blend_shape(blend_shapes[i]); + } + mesh->set_blend_shape_mode(blend_shape_mode); + for (int i = 0; i < surfaces.size(); i++) { + Array bs_data; + if (surfaces[i].blend_shape_data.size()) { + for (int j = 0; j < surfaces[i].blend_shape_data.size(); j++) { + bs_data.push_back(surfaces[i].blend_shape_data[j].arrays); + } + } + Dictionary lods; + if (surfaces[i].lods.size()) { + for (int j = 0; j < surfaces[i].lods.size(); j++) { + lods[surfaces[i].lods[j].distance] = surfaces[i].lods[j].indices; + } + } + + mesh->add_surface_from_arrays(surfaces[i].primitive, surfaces[i].arrays, bs_data, lods); + if (surfaces[i].material.is_valid()) { + mesh->surface_set_material(mesh->get_surface_count() - 1, surfaces[i].material); + } + if (surfaces[i].name != String()) { + mesh->surface_set_name(mesh->get_surface_count() - 1, surfaces[i].name); + } + } + } + + return mesh; +} + +void EditorSceneImporterMesh::clear() { + surfaces.clear(); + blend_shapes.clear(); + mesh.unref(); +} + +void EditorSceneImporterMesh::_set_data(const Dictionary &p_data) { + clear(); + if (p_data.has("blend_shape_names")) { + blend_shapes = p_data["blend_shape_names"]; + } + if (p_data.has("surfaces")) { + Array surface_arr = p_data["surfaces"]; + for (int i = 0; i < surface_arr.size(); i++) { + Dictionary s = surface_arr[i]; + ERR_CONTINUE(!s.has("primitive")); + ERR_CONTINUE(!s.has("arrays")); + Mesh::PrimitiveType prim = Mesh::PrimitiveType(int(s["primitive"])); + ERR_CONTINUE(prim >= Mesh::PRIMITIVE_MAX); + Array arr = s["arrays"]; + Dictionary lods; + String name; + if (s.has("name")) { + name = s["name"]; + } + if (s.has("lods")) { + lods = s["lods"]; + } + Array blend_shapes; + if (s.has("blend_shapes")) { + blend_shapes = s["blend_shapes"]; + } + Ref<Material> material; + if (s.has("material")) { + material = s["material"]; + } + add_surface(prim, arr, blend_shapes, lods, material, name); + } + } +} +Dictionary EditorSceneImporterMesh::_get_data() const { + Dictionary data; + if (blend_shapes.size()) { + data["blend_shape_names"] = blend_shapes; + } + Array surface_arr; + for (int i = 0; i < surfaces.size(); i++) { + Dictionary d; + d["primitive"] = surfaces[i].primitive; + d["arrays"] = surfaces[i].arrays; + if (surfaces[i].blend_shape_data.size()) { + Array bs_data; + for (int j = 0; j < surfaces[i].blend_shape_data.size(); j++) { + bs_data.push_back(surfaces[i].blend_shape_data[j].arrays); + } + d["blend_shapes"] = bs_data; + } + if (surfaces[i].lods.size()) { + Dictionary lods; + for (int j = 0; j < surfaces[i].lods.size(); j++) { + lods[surfaces[i].lods[j].distance] = surfaces[i].lods[j].indices; + } + d["lods"] = lods; + } + + if (surfaces[i].material.is_valid()) { + d["material"] = surfaces[i].material; + } + + if (surfaces[i].name != String()) { + d["name"] = surfaces[i].name; + } + + surface_arr.push_back(d); + } + data["surfaces"] = surface_arr; + return data; +} + +void EditorSceneImporterMesh::_bind_methods() { + ClassDB::bind_method(D_METHOD("add_blend_shape", "name"), &EditorSceneImporterMesh::add_blend_shape); + ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &EditorSceneImporterMesh::get_blend_shape_count); + ClassDB::bind_method(D_METHOD("get_blend_shape_name", "blend_shape_idx"), &EditorSceneImporterMesh::get_blend_shape_name); + + ClassDB::bind_method(D_METHOD("set_blend_shape_mode", "mode"), &EditorSceneImporterMesh::set_blend_shape_mode); + ClassDB::bind_method(D_METHOD("get_blend_shape_mode"), &EditorSceneImporterMesh::get_blend_shape_mode); + + ClassDB::bind_method(D_METHOD("add_surface", "primitive", "arrays", "blend_shapes", "lods", "material"), &EditorSceneImporterMesh::add_surface, DEFVAL(Array()), DEFVAL(Dictionary()), DEFVAL(Ref<Material>()), DEFVAL(String())); + + ClassDB::bind_method(D_METHOD("get_surface_count"), &EditorSceneImporterMesh::get_surface_count); + ClassDB::bind_method(D_METHOD("get_surface_primitive_type", "surface_idx"), &EditorSceneImporterMesh::get_surface_primitive_type); + ClassDB::bind_method(D_METHOD("get_surface_name", "surface_idx"), &EditorSceneImporterMesh::get_surface_name); + ClassDB::bind_method(D_METHOD("get_surface_arrays", "surface_idx"), &EditorSceneImporterMesh::get_surface_arrays); + ClassDB::bind_method(D_METHOD("get_surface_blend_shape_arrays", "surface_idx", "blend_shape_idx"), &EditorSceneImporterMesh::get_surface_blend_shape_arrays); + ClassDB::bind_method(D_METHOD("get_surface_lod_count", "surface_idx"), &EditorSceneImporterMesh::get_surface_lod_count); + ClassDB::bind_method(D_METHOD("get_surface_lod_size", "surface_idx", "lod_idx"), &EditorSceneImporterMesh::get_surface_lod_size); + ClassDB::bind_method(D_METHOD("get_surface_lod_indices", "surface_idx", "lod_idx"), &EditorSceneImporterMesh::get_surface_lod_indices); + ClassDB::bind_method(D_METHOD("get_surface_material", "surface_idx"), &EditorSceneImporterMesh::get_surface_material); + + ClassDB::bind_method(D_METHOD("get_mesh"), &EditorSceneImporterMesh::get_mesh); + ClassDB::bind_method(D_METHOD("clear"), &EditorSceneImporterMesh::clear); + + ClassDB::bind_method(D_METHOD("_set_data", "data"), &EditorSceneImporterMesh::_set_data); + ClassDB::bind_method(D_METHOD("_get_data"), &EditorSceneImporterMesh::_get_data); + + ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data"); +} + +void EditorSceneImporterMeshNode::set_mesh(const Ref<EditorSceneImporterMesh> &p_mesh) { + mesh = p_mesh; +} +Ref<EditorSceneImporterMesh> EditorSceneImporterMeshNode::get_mesh() const { + return mesh; +} + +void EditorSceneImporterMeshNode::set_skin(const Ref<Skin> &p_skin) { + skin = p_skin; +} +Ref<Skin> EditorSceneImporterMeshNode::get_skin() const { + return skin; +} + +void EditorSceneImporterMeshNode::set_surface_material(int p_idx, const Ref<Material> &p_material) { + ERR_FAIL_COND(p_idx < 0); + if (p_idx >= surface_materials.size()) { + surface_materials.resize(p_idx + 1); + } + + surface_materials.write[p_idx] = p_material; +} +Ref<Material> EditorSceneImporterMeshNode::get_surface_material(int p_idx) const { + ERR_FAIL_COND_V(p_idx < 0, Ref<Material>()); + if (p_idx >= surface_materials.size()) { + return Ref<Material>(); + } + return surface_materials[p_idx]; +} + +void EditorSceneImporterMeshNode::set_skeleton_path(const NodePath &p_path) { + skeleton_path = p_path; +} +NodePath EditorSceneImporterMeshNode::get_skeleton_path() const { + return skeleton_path; +} + +void EditorSceneImporterMeshNode::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &EditorSceneImporterMeshNode::set_mesh); + ClassDB::bind_method(D_METHOD("get_mesh"), &EditorSceneImporterMeshNode::get_mesh); + + ClassDB::bind_method(D_METHOD("set_skin", "skin"), &EditorSceneImporterMeshNode::set_skin); + ClassDB::bind_method(D_METHOD("get_skin"), &EditorSceneImporterMeshNode::get_skin); + + ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &EditorSceneImporterMeshNode::set_skeleton_path); + ClassDB::bind_method(D_METHOD("get_skeleton_path"), &EditorSceneImporterMeshNode::get_skeleton_path); + + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "EditorSceneImporterMesh"), "set_mesh", "get_mesh"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin"); + ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path"); +} + ///////////////////////////////// void EditorScenePostImport::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::OBJECT, "post_import", PropertyInfo(Variant::OBJECT, "scene"))); @@ -1124,9 +1464,9 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), (meshes_out || materials_out) ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.material),Files (.tres)", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_on_reimport"), materials_out)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.mesh),Files (.tres)"), meshes_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/generate_lods"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/light_baking", PROPERTY_HINT_ENUM, "Disabled,Enable,Gen Lightmaps", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "meshes/lightmap_texel_size", PROPERTY_HINT_RANGE, "0.001,100,0.001"), 0.1)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "skins/use_named_skins"), true)); @@ -1219,6 +1559,37 @@ Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(Edito return importer->import_animation(p_path, p_flags, p_bake_fps); } +void ResourceImporterScene::_generate_meshes(Node *p_node, bool p_generate_lods) { + EditorSceneImporterMeshNode *src_mesh = Object::cast_to<EditorSceneImporterMeshNode>(p_node); + if (src_mesh != nullptr) { + //is mesh + MeshInstance3D *mesh_node = memnew(MeshInstance3D); + mesh_node->set_transform(src_mesh->get_transform()); + mesh_node->set_skin(src_mesh->get_skin()); + mesh_node->set_skeleton_path(src_mesh->get_skeleton_path()); + + Ref<ArrayMesh> mesh; + if (!src_mesh->get_mesh()->has_mesh()) { + if (p_generate_lods) { + src_mesh->get_mesh()->generate_lods(); + } + //do mesh processing + } + mesh = src_mesh->get_mesh()->get_mesh(); + mesh_node->set_mesh(mesh); + for (int i = 0; i < mesh->get_surface_count(); i++) { + mesh_node->set_surface_material(i, src_mesh->get_surface_material(i)); + } + + p_node->replace_by(mesh_node); + memdelete(p_node); + p_node = mesh_node; + } + + for (int i = 0; i < p_node->get_child_count(); i++) { + _generate_meshes(p_node->get_child(i), p_generate_lods); + } +} 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; @@ -1257,10 +1628,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p import_flags |= EditorSceneImporter::IMPORT_ANIMATION; } - if (int(p_options["meshes/compress"])) { - import_flags |= EditorSceneImporter::IMPORT_USE_COMPRESSION; - } - if (bool(p_options["meshes/ensure_tangents"])) { import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS; } @@ -1315,6 +1682,10 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p scene->set_name(p_save_path.get_file().get_basename()); } + bool gen_lods = bool(p_options["meshes/generate_lods"]); + + _generate_meshes(scene, gen_lods); + err = OK; String animation_filter = String(p_options["animation/filter_script"]).strip_edges(); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index cd61ec01f2..aef6c0ac50 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -32,9 +32,11 @@ #define RESOURCEIMPORTERSCENE_H #include "core/io/resource_importer.h" +#include "scene/3d/node_3d.h" #include "scene/resources/animation.h" #include "scene/resources/mesh.h" #include "scene/resources/shape_3d.h" +#include "scene/resources/skin.h" class Material; @@ -88,6 +90,92 @@ public: EditorScenePostImport(); }; +// The following classes are used by importers instead of ArrayMesh and MeshInstance3D +// so the data is not reginstered (hence, quality loss), importing happens faster and +// its easier to modify before saving + +class EditorSceneImporterMesh : public Resource { + GDCLASS(EditorSceneImporterMesh, Resource) + + struct Surface { + Mesh::PrimitiveType primitive; + Array arrays; + struct BlendShape { + Array arrays; + }; + Vector<BlendShape> blend_shape_data; + struct LOD { + Vector<int> indices; + float distance; + }; + Vector<LOD> lods; + Ref<Material> material; + String name; + }; + Vector<Surface> surfaces; + Vector<String> blend_shapes; + Mesh::BlendShapeMode blend_shape_mode = Mesh::BLEND_SHAPE_MODE_NORMALIZED; + + Ref<ArrayMesh> mesh; + +protected: + void _set_data(const Dictionary &p_data); + Dictionary _get_data() const; + + static void _bind_methods(); + +public: + void add_blend_shape(const String &p_name); + int get_blend_shape_count() const; + String get_blend_shape_name(int p_blend_shape) const; + + void add_surface(Mesh::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), const Dictionary &p_lods = Dictionary(), const Ref<Material> &p_material = Ref<Material>(), const String &p_name = String()); + int get_surface_count() const; + + void set_blend_shape_mode(Mesh::BlendShapeMode p_blend_shape_mode); + Mesh::BlendShapeMode get_blend_shape_mode() const; + + Mesh::PrimitiveType get_surface_primitive_type(int p_surface); + String get_surface_name(int p_surface) const; + Array get_surface_arrays(int p_surface) const; + Array get_surface_blend_shape_arrays(int p_surface, int p_blend_shape) const; + int get_surface_lod_count(int p_surface) const; + Vector<int> get_surface_lod_indices(int p_surface, int p_lod) const; + float get_surface_lod_size(int p_surface, int p_lod) const; + Ref<Material> get_surface_material(int p_surface) const; + + void generate_lods(); + + bool has_mesh() const; + Ref<ArrayMesh> get_mesh(); + void clear(); +}; + +class EditorSceneImporterMeshNode : public Node3D { + GDCLASS(EditorSceneImporterMeshNode, Node3D) + + Ref<EditorSceneImporterMesh> mesh; + Ref<Skin> skin; + NodePath skeleton_path; + Vector<Ref<Material>> surface_materials; + +protected: + static void _bind_methods(); + +public: + void set_mesh(const Ref<EditorSceneImporterMesh> &p_mesh); + Ref<EditorSceneImporterMesh> get_mesh() const; + + void set_skin(const Ref<Skin> &p_skin); + Ref<Skin> get_skin() const; + + void set_surface_material(int p_idx, const Ref<Material> &p_material); + Ref<Material> get_surface_material(int p_idx) const; + + void set_skeleton_path(const NodePath &p_path); + NodePath get_skeleton_path() const; +}; + class ResourceImporterScene : public ResourceImporter { GDCLASS(ResourceImporterScene, ResourceImporter); @@ -119,6 +207,7 @@ class ResourceImporterScene : public ResourceImporter { }; void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner); + void _generate_meshes(Node *p_node, bool p_generate_lods); public: static ResourceImporterScene *get_singleton() { return singleton; } diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 8ab2e0aef1..5582f9f5f0 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -536,7 +536,7 @@ ImportDock::ImportDock() { hb->add_spacer(); reimport_confirm = memnew(ConfirmationDialog); - reimport_confirm->get_ok()->set_text(TTR("Save Scenes, Re-Import, and Restart")); + reimport_confirm->get_ok_button()->set_text(TTR("Save Scenes, Re-Import, and Restart")); add_child(reimport_confirm); reimport_confirm->connect("confirmed", callable_mp(this, &ImportDock::_reimport_and_restart)); diff --git a/editor/input_map_editor.cpp b/editor/input_map_editor.cpp index 686fd4c08b..83adccb752 100644 --- a/editor/input_map_editor.cpp +++ b/editor/input_map_editor.cpp @@ -398,7 +398,7 @@ void InputMapEditor::_wait_for_key(const Ref<InputEvent> &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()); press_a_key_label->set_text(str); - press_a_key->get_ok()->set_disabled(false); + press_a_key->get_ok_button()->set_disabled(false); press_a_key->set_input_as_handled(); } } @@ -432,7 +432,7 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { 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); + press_a_key->get_ok_button()->set_disabled(true); last_wait_for_key = Ref<InputEvent>(); press_a_key->popup_centered(Size2(250, 80) * EDSCALE); //press_a_key->grab_focus(); @@ -465,10 +465,10 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { if (mb.is_valid()) { device_index->select(mb->get_button_index() - 1); _set_current_device(mb->get_device()); - device_input->get_ok()->set_text(TTR("Change")); + device_input->get_ok_button()->set_text(TTR("Change")); } else { _set_current_device(0); - device_input->get_ok()->set_text(TTR("Add")); + device_input->get_ok_button()->set_text(TTR("Add")); } } break; @@ -488,10 +488,10 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { if (jm.is_valid()) { device_index->select(jm->get_axis() * 2 + (jm->get_axis_value() > 0 ? 1 : 0)); _set_current_device(jm->get_device()); - device_input->get_ok()->set_text(TTR("Change")); + device_input->get_ok_button()->set_text(TTR("Change")); } else { _set_current_device(0); - device_input->get_ok()->set_text(TTR("Add")); + device_input->get_ok_button()->set_text(TTR("Add")); } } break; @@ -510,10 +510,10 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { if (jb.is_valid()) { device_index->select(jb->get_button_index()); _set_current_device(jb->get_device()); - device_input->get_ok()->set_text(TTR("Change")); + device_input->get_ok_button()->set_text(TTR("Change")); } else { _set_current_device(0); - device_input->get_ok()->set_text(TTR("Add")); + device_input->get_ok_button()->set_text(TTR("Add")); } } break; @@ -978,7 +978,7 @@ InputMapEditor::InputMapEditor() { add_child(popup_add); press_a_key = memnew(ConfirmationDialog); - press_a_key->get_ok()->set_disabled(true); + press_a_key->get_ok_button()->set_disabled(true); //press_a_key->set_focus_mode(Control::FOCUS_ALL); press_a_key->connect("window_input", callable_mp(this, &InputMapEditor::_wait_for_key)); press_a_key->connect("confirmed", callable_mp(this, &InputMapEditor::_press_a_key_confirm)); @@ -994,7 +994,7 @@ InputMapEditor::InputMapEditor() { press_a_key_label = l; device_input = memnew(ConfirmationDialog); - device_input->get_ok()->set_text(TTR("Add")); + device_input->get_ok_button()->set_text(TTR("Add")); device_input->connect("confirmed", callable_mp(this, &InputMapEditor::_device_input_add)); add_child(device_input); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 3ad6938498..a780750633 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -126,7 +126,7 @@ void PluginConfigDialog::_on_cancelled() { void PluginConfigDialog::_on_required_text_changed(const String &) { int lang_idx = script_option_edit->get_selected(); String ext = ScriptServer::get_language(lang_idx)->get_extension(); - get_ok()->set_disabled(script_edit->get_text().get_basename().empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().empty()); + get_ok_button()->set_disabled(script_edit->get_text().get_basename().empty() || script_edit->get_text().get_extension() != ext || name_edit->get_text().empty()); } void PluginConfigDialog::_notification(int p_what) { @@ -138,7 +138,7 @@ void PluginConfigDialog::_notification(int p_what) { } break; case NOTIFICATION_READY: { connect("confirmed", callable_mp(this, &PluginConfigDialog::_on_confirmed)); - get_cancel()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled)); + get_cancel_button()->connect("pressed", callable_mp(this, &PluginConfigDialog::_on_cancelled)); } break; } } @@ -171,8 +171,8 @@ void PluginConfigDialog::config(const String &p_config_path) { Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->show(); set_title(TTR("Create a Plugin")); } - get_ok()->set_disabled(!_edit_mode); - get_ok()->set_text(_edit_mode ? TTR("Update") : TTR("Create")); + get_ok_button()->set_disabled(!_edit_mode); + get_ok_button()->set_text(_edit_mode ? TTR("Update") : TTR("Create")); } void PluginConfigDialog::_bind_methods() { @@ -180,7 +180,7 @@ void PluginConfigDialog::_bind_methods() { } PluginConfigDialog::PluginConfigDialog() { - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); set_hide_on_ok(true); GridContainer *grid = memnew(GridContainer); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 0b61db6835..281b1d79af 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -724,7 +724,7 @@ AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wi create_resource = memnew(ConfirmationDialog); add_child(create_resource); - create_resource->get_ok()->set_text(TTR("Create")); + create_resource->get_ok_button()->set_text(TTR("Create")); mode = MODE_EDIT; } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 17cfb5f5f3..4b97dacbc1 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -116,6 +116,19 @@ void AnimationPlayerEditor::_notification(int p_what) { play_bw_from->set_icon(get_theme_icon("PlayBackwards", "EditorIcons")); autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons"); + reset_icon = get_theme_icon("Reload", "EditorIcons"); + { + Ref<Image> autoplay_img = autoplay_icon->get_data(); + Ref<Image> reset_img = reset_icon->get_data(); + Ref<Image> autoplay_reset_img; + Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height()); + autoplay_reset_img.instance(); + autoplay_reset_img->create(icon_size.x * 2, icon_size.y, false, autoplay_img->get_format()); + autoplay_reset_img->blit_rect(autoplay_img, Rect2(Point2(), icon_size), Point2()); + autoplay_reset_img->blit_rect(reset_img, Rect2(Point2(), icon_size), Point2(icon_size.x, 0)); + autoplay_reset_icon.instance(); + autoplay_reset_icon->create_from_image(autoplay_reset_img); + } stop->set_icon(get_theme_icon("Stop", "EditorIcons")); onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons")); @@ -817,11 +830,17 @@ 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 { - animation->add_item(E->get()); + Ref<Texture2D> icon; + if (E->get() == player->get_autoplay()) { + if (E->get() == "RESET") { + icon = autoplay_reset_icon; + } else { + icon = autoplay_icon; + } + } else if (E->get() == "RESET") { + icon = reset_icon; } + animation->add_icon_item(icon, E->get()); if (player->get_assigned_animation() == E->get()) { active_idx = animation->get_item_count() - 1; @@ -1375,7 +1394,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { } // Backup current animation state. - AnimatedValuesBackup values_backup = player->backup_animated_values(); + Ref<AnimatedValuesBackup> values_backup = player->backup_animated_values(); float cpos = player->get_current_animation_position(); // Render every past/future step with the capture shader. @@ -1405,7 +1424,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { if (valid) { player->seek(pos, true); get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds. - values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D). + values_backup->update_skeletons(); // Needed for Skeletons (2D & 3D). RS::get_singleton()->viewport_set_active(onion.captures[cidx], true); RS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]); @@ -1425,7 +1444,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // (Seeking with update=true wouldn't do the trick because the current value of the properties // may not match their value for the current point in the animation). player->seek(cpos, false); - player->restore_animated_values(values_backup); + values_backup->restore(); // Restore state of main editors. if (Node3DEditor::get_singleton()->is_visible()) { @@ -1642,7 +1661,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay name_dialog->register_text_enter(name); error_dialog = memnew(ConfirmationDialog); - error_dialog->get_ok()->set_text(TTR("Close")); + error_dialog->get_ok_button()->set_text(TTR("Close")); error_dialog->set_title(TTR("Error!")); add_child(error_dialog); @@ -1650,7 +1669,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay blend_editor.dialog = memnew(AcceptDialog); add_child(blend_editor.dialog); - blend_editor.dialog->get_ok()->set_text(TTR("Close")); + blend_editor.dialog->get_ok_button()->set_text(TTR("Close")); blend_editor.dialog->set_hide_on_ok(true); VBoxContainer *blend_vb = memnew(VBoxContainer); blend_editor.dialog->add_child(blend_vb); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 17e554ee0d..ab3feb115f 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -105,6 +105,8 @@ class AnimationPlayerEditor : public VBoxContainer { Label *name_title; UndoRedo *undo_redo; Ref<Texture2D> autoplay_icon; + Ref<Texture2D> reset_icon; + Ref<ImageTexture> autoplay_reset_icon; bool last_active; float timeline_position; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index f3aa11317e..ba798a7826 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -295,8 +295,8 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL); previews->add_child(preview_hb); - get_ok()->set_text(TTR("Download")); - get_cancel()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Download")); + get_cancel_button()->set_text(TTR("Close")); } /////////////////////////////////////////////////////////////////////////////////// diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4227482ccc..2a4cc691c3 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3074,15 +3074,18 @@ void CanvasItemEditor::_draw_ruler_tool() { int font_size = get_theme_font_size("bold_size", "EditorFonts"); Color font_color = get_theme_color("font_color", "Editor"); Color font_secondary_color = font_color; - font_secondary_color.a = 0.5; + font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3); + Color outline_color = font_color.inverted(); float text_height = font->get_height(font_size); + + const float outline_size = 2; const float text_width = 76; const float angle_text_width = 54; Point2 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 * 1.5, viewport->get_rect().size.y - text_height * 1.5); - viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color); + viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); if (draw_secondary_lines) { const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x); @@ -3092,16 +3095,16 @@ void CanvasItemEditor::_draw_ruler_tool() { Point2 text_pos2 = text_pos; text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); Point2 v_angle_text_pos = Point2(); v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5); - viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); text_pos2 = text_pos; text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); Point2 h_angle_text_pos = Point2(); h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width); @@ -3118,7 +3121,7 @@ void CanvasItemEditor::_draw_ruler_tool() { h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height)); } } - viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); // Angle arcs int arc_point_count = 8; @@ -3155,17 +3158,17 @@ void CanvasItemEditor::_draw_ruler_tool() { text_pos.y = CLAMP(text_pos.y, text_height * 2.5, viewport->get_rect().size.y - text_height / 2); if (draw_secondary_lines) { - viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("units"), (length_vector / grid_step).length())), HALIGN_LEFT, -1, font_size, font_color); + viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("units"), (length_vector / grid_step).length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); Point2 text_pos2 = text_pos; text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.y / grid_step.y))), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.y / grid_step.y))), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); text_pos2 = text_pos; text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y + text_height / 2) : MAX(text_pos.y + text_height * 2, end.y + text_height / 2); - viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.x / grid_step.x))), HALIGN_LEFT, -1, font_size, font_secondary_color); + viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.x / grid_step.x))), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color); } else { - viewport->draw_string(font, text_pos, TS->format_number(vformat("%d " + TTR("units"), roundf((length_vector / grid_step).length()))), HALIGN_LEFT, -1, font_size, font_color); + viewport->draw_string(font, text_pos, TS->format_number(vformat("%d " + TTR("units"), roundf((length_vector / grid_step).length()))), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color); } } } else { diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index c98ba25db5..0de52b3930 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -213,7 +213,7 @@ GPUParticles3DEditorBase::GPUParticles3DEditorBase() { emission_fill->add_item(TTR("Volume")); emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill); - emission_dialog->get_ok()->set_text(TTR("Create")); + emission_dialog->get_ok_button()->set_text(TTR("Create")); emission_dialog->connect("confirmed", callable_mp(this, &GPUParticles3DEditorBase::_generate_emission_points)); emission_tree_dialog = memnew(SceneTreeDialog); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 5b241deab0..2a08e3a8b5 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -457,7 +457,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() { outline_dialog = memnew(ConfirmationDialog); outline_dialog->set_title(TTR("Create Outline Mesh")); - outline_dialog->get_ok()->set_text(TTR("Create")); + outline_dialog->get_ok_button()->set_text(TTR("Create")); VBoxContainer *outline_dialog_vbc = memnew(VBoxContainer); outline_dialog->add_child(outline_dialog_vbc); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 9d3498efa1..b11a07365c 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -267,7 +267,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { editor = p_editor; cd = memnew(ConfirmationDialog); add_child(cd); - cd->get_ok()->connect("pressed", callable_mp(this, &MeshLibraryEditor::_menu_confirm)); + cd->get_ok_button()->connect("pressed", callable_mp(this, &MeshLibraryEditor::_menu_confirm)); } void MeshLibraryEditorPlugin::edit(Object *p_node) { diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index bd1384967f..b8a4f7bc5a 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -345,9 +345,9 @@ MultiMeshEditor::MultiMeshEditor() { populate_amount->set_value(128); vbc->add_margin_child(TTR("Amount:"), populate_amount); - populate_dialog->get_ok()->set_text(TTR("Populate")); + populate_dialog->get_ok_button()->set_text(TTR("Populate")); - populate_dialog->get_ok()->connect("pressed", callable_mp(this, &MultiMeshEditor::_populate)); + populate_dialog->get_ok_button()->connect("pressed", callable_mp(this, &MultiMeshEditor::_populate)); std = memnew(SceneTreeDialog); populate_dialog->add_child(std); std->connect("selected", callable_mp(this, &MultiMeshEditor::_browsed)); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 6493e0f953..4d7be66180 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2657,11 +2657,30 @@ void Node3DEditorViewport::_draw() { if (_edit.mode == TRANSFORM_ROTATE) { Point2 center = _point_to_screen(_edit.center); + + Color handle_color; + switch (_edit.plane) { + case TRANSFORM_X_AXIS: + handle_color = get_theme_color("axis_x_color", "Editor"); + break; + case TRANSFORM_Y_AXIS: + handle_color = get_theme_color("axis_y_color", "Editor"); + break; + case TRANSFORM_Z_AXIS: + handle_color = get_theme_color("axis_z_color", "Editor"); + break; + default: + handle_color = get_theme_color("accent_color", "Editor"); + break; + } + handle_color.a = 1.0; + handle_color *= Color(1.3, 1.3, 1.3, 1.0); + RenderingServer::get_singleton()->canvas_item_add_line( ci, _edit.mouse_pos, center, - get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6), + handle_color, Math::round(2 * EDSCALE)); } if (previewing) { @@ -2686,7 +2705,7 @@ void Node3DEditorViewport::_draw() { } break; } - draw_rect = Rect2(Vector2(), s).clip(draw_rect); + draw_rect = Rect2(Vector2(), s).intersection(draw_rect); surface->draw_rect(draw_rect, Color(0.6, 0.6, 0.1, 0.5), false, Math::round(2 * EDSCALE)); @@ -2998,7 +3017,8 @@ void Node3DEditorViewport::_menu_option(int p_option) { case VIEW_DISPLAY_DEBUG_DECAL_ATLAS: case VIEW_DISPLAY_DEBUG_SDFGI: case VIEW_DISPLAY_DEBUG_SDFGI_PROBES: - case VIEW_DISPLAY_DEBUG_GI_BUFFER: { + case VIEW_DISPLAY_DEBUG_GI_BUFFER: + case VIEW_DISPLAY_DEBUG_DISABLE_LOD: { static const int display_options[] = { VIEW_DISPLAY_NORMAL, VIEW_DISPLAY_WIREFRAME, @@ -3015,6 +3035,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE, VIEW_DISPLAY_DEBUG_SSAO, VIEW_DISPLAY_DEBUG_GI_BUFFER, + VIEW_DISPLAY_DEBUG_DISABLE_LOD, VIEW_DISPLAY_DEBUG_PSSM_SPLITS, VIEW_DISPLAY_DEBUG_DECAL_ATLAS, VIEW_DISPLAY_DEBUG_SDFGI, @@ -3037,6 +3058,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { Viewport::DEBUG_DRAW_SCENE_LUMINANCE, Viewport::DEBUG_DRAW_SSAO, Viewport::DEBUG_DRAW_GI_BUFFER, + Viewport::DEBUG_DRAW_DISABLE_LOD, Viewport::DEBUG_DRAW_PSSM_SPLITS, Viewport::DEBUG_DRAW_DECAL_ATLAS, Viewport::DEBUG_DRAW_SDFGI, @@ -3940,6 +3962,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito display_submenu->add_radio_check_item(TTR("SSAO"), VIEW_DISPLAY_DEBUG_SSAO); display_submenu->add_separator(); display_submenu->add_radio_check_item(TTR("GI Buffer"), VIEW_DISPLAY_DEBUG_GI_BUFFER); + display_submenu->add_separator(); + display_submenu->add_radio_check_item(TTR("Disable LOD"), VIEW_DISPLAY_DEBUG_DISABLE_LOD); display_submenu->set_name("display_advanced"); view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "display_advanced", VIEW_DISPLAY_ADVANCED); view_menu->get_popup()->add_separator(); @@ -5228,7 +5252,7 @@ void Node3DEditor::_init_indicators() { gizmo_color[i] = mat; Ref<StandardMaterial3D> mat_hl = mat->duplicate(); - mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); + mat_hl->set_albedo(Color(col.r * 1.3, col.g * 1.3, col.b * 1.3, 1.0)); gizmo_color_hl[i] = mat_hl; Vector3 ivec; @@ -5323,7 +5347,7 @@ void Node3DEditor::_init_indicators() { surftool->commit(move_plane_gizmo[i]); Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate(); - plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); + plane_mat_hl->set_albedo(Color(col.r * 1.3, col.g * 1.3, col.b * 1.3, 1.0)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } @@ -5406,7 +5430,7 @@ void Node3DEditor::_init_indicators() { rotate_gizmo[i]->surface_set_material(0, rotate_mat); Ref<ShaderMaterial> rotate_mat_hl = rotate_mat->duplicate(); - rotate_mat_hl->set_shader_param("albedo", Color(col.r, col.g, col.b, 1.0)); + rotate_mat_hl->set_shader_param("albedo", Color(col.r * 1.3, col.g * 1.3, col.b * 1.3, 1.0)); rotate_gizmo_color_hl[i] = rotate_mat_hl; if (i == 2) { // Rotation white outline @@ -5533,7 +5557,7 @@ void Node3DEditor::_init_indicators() { surftool->commit(scale_plane_gizmo[i]); Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate(); - plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); + plane_mat_hl->set_albedo(Color(col.r * 1.3, col.g * 1.3, col.b * 1.3, 1.0)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } } @@ -6157,9 +6181,9 @@ 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)); + settings_fov->set_value(EDITOR_GET("editors/3d/default_fov")); + settings_znear->set_value(EDITOR_GET("editors/3d/default_z_near")); + settings_zfar->set_value(EDITOR_GET("editors/3d/default_z_far")); for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { viewports[i]->reset(); @@ -6423,7 +6447,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { snap_dialog->set_title(TTR("Snap Settings")); add_child(snap_dialog); snap_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_snap_changed)); - snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update)); + snap_dialog->get_cancel_button()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update)); VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer); snap_dialog->add_child(snap_dialog_vbc); @@ -6451,22 +6475,22 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { settings_fov = memnew(SpinBox); settings_fov->set_max(MAX_FOV); settings_fov->set_min(MIN_FOV); - settings_fov->set_step(0.01); - settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0)); + settings_fov->set_step(0.1); + settings_fov->set_value(EDITOR_GET("editors/3d/default_fov")); settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov); settings_znear = memnew(SpinBox); settings_znear->set_max(MAX_Z); settings_znear->set_min(MIN_Z); settings_znear->set_step(0.01); - settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05)); + settings_znear->set_value(EDITOR_GET("editors/3d/default_z_near")); settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear); settings_zfar = memnew(SpinBox); settings_zfar->set_max(MAX_Z); settings_zfar->set_min(MIN_Z); - settings_zfar->set_step(0.01); - settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500)); + settings_zfar->set_step(0.1); + settings_zfar->set_value(EDITOR_GET("editors/3d/default_z_far")); settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar); for (uint32_t i = 0; i < VIEWPORTS_COUNT; ++i) { @@ -6541,8 +6565,8 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { add_to_group("_spatial_editor_group"); EDITOR_DEF("editors/3d/manipulator_gizmo_size", 80); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,1024,1")); - EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.4); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,160,1")); + EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.9); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01")); EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 66ee678154..079c86ceb4 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -212,6 +212,7 @@ class Node3DEditorViewport : public Control { VIEW_DISPLAY_DEBUG_SDFGI, VIEW_DISPLAY_DEBUG_SDFGI_PROBES, VIEW_DISPLAY_DEBUG_GI_BUFFER, + VIEW_DISPLAY_DEBUG_DISABLE_LOD, VIEW_LOCK_ROTATION, VIEW_CINEMATIC_PREVIEW, VIEW_AUTO_ORTHOGONAL, diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index f317aebe74..684d43e963 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -62,7 +62,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths) dialog->set_text(TTR("ERROR: Couldn't load resource!")); dialog->set_title(TTR("Error!")); //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text(TTR("Close")); + dialog->get_ok_button()->set_text(TTR("Close")); dialog->popup_centered(); return; ///beh should show an error i guess } @@ -144,7 +144,7 @@ void ResourcePreloaderEditor::_paste_pressed() { if (!r.is_valid()) { dialog->set_text(TTR("Resource clipboard is empty!")); dialog->set_title(TTR("Error!")); - dialog->get_ok()->set_text(TTR("Close")); + dialog->get_ok_button()->set_text(TTR("Close")); dialog->popup_centered(); return; ///beh should show an error i guess } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 5982074750..e0a6fe16f7 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -338,7 +338,7 @@ void ScriptEditorQuickOpen::_update_search() { } } - get_ok()->set_disabled(root->get_children() == nullptr); + get_ok_button()->set_disabled(root->get_children() == nullptr); } void ScriptEditorQuickOpen::_confirmed() { @@ -382,8 +382,8 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() { search_box->connect("gui_input", callable_mp(this, &ScriptEditorQuickOpen::_sbox_input)); search_options = memnew(Tree); vbc->add_margin_child(TTR("Matches:"), search_options, true); - get_ok()->set_text(TTR("Open")); - get_ok()->set_disabled(true); + get_ok_button()->set_text(TTR("Open")); + get_ok_button()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed)); @@ -3482,7 +3482,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { tab_container->connect("tab_changed", callable_mp(this, &ScriptEditor::_tab_changed)); erase_tab_confirm = memnew(ConfirmationDialog); - erase_tab_confirm->get_ok()->set_text(TTR("Save")); + erase_tab_confirm->get_ok_button()->set_text(TTR("Save")); erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard"); erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab)); erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab)); @@ -3515,7 +3515,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL); disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts)); - disk_changed->get_ok()->set_text(TTR("Reload")); + disk_changed->get_ok_button()->set_text(TTR("Reload")); disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts)); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 6e174653f6..d24dcdef83 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -661,7 +661,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { vbc->add_child(dl); disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk)); - disk_changed->get_ok()->set_text(TTR("Reload")); + disk_changed->get_ok_button()->set_text(TTR("Reload")); disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave"); disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data)); diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index f5fafb68a5..1be6b979b1 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -120,7 +120,7 @@ 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->get_ok_button()->set_text(TTR("Create Mesh2D")); debug_uv_dialog->set_title(TTR("Mesh2D Preview")); _update_mesh_data(); @@ -129,7 +129,7 @@ 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->get_ok_button()->set_text(TTR("Create Polygon2D")); debug_uv_dialog->set_title(TTR("Polygon2D Preview")); _update_mesh_data(); @@ -137,7 +137,7 @@ 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->get_ok_button()->set_text(TTR("Create CollisionPolygon2D")); debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview")); _update_mesh_data(); @@ -146,7 +146,7 @@ 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->get_ok_button()->set_text(TTR("Create LightOccluder2D")); debug_uv_dialog->set_title(TTR("LightOccluder2D Preview")); _update_mesh_data(); @@ -515,7 +515,7 @@ Sprite2DEditor::Sprite2DEditor() { add_child(err_dialog); debug_uv_dialog = memnew(ConfirmationDialog); - debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D")); + debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D")); debug_uv_dialog->set_title("Mesh 2D Preview"); VBoxContainer *vb = memnew(VBoxContainer); debug_uv_dialog->add_child(vb); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 69a8a8d92c..b79d829c34 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -74,8 +74,8 @@ void SpriteFramesEditor::_sheet_preview_draw() { } if (frames_selected.size() == 0) { - split_sheet_dialog->get_ok()->set_disabled(true); - split_sheet_dialog->get_ok()->set_text(TTR("No Frames Selected")); + split_sheet_dialog->get_ok_button()->set_disabled(true); + split_sheet_dialog->get_ok_button()->set_text(TTR("No Frames Selected")); return; } @@ -97,8 +97,8 @@ void SpriteFramesEditor::_sheet_preview_draw() { split_sheet_preview->draw_rect(Rect2(x + 5, y + 5, width - 10, height - 10), Color(0, 0, 0, 1), false); } - split_sheet_dialog->get_ok()->set_disabled(false); - split_sheet_dialog->get_ok()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size())); + split_sheet_dialog->get_ok_button()->set_disabled(false); + split_sheet_dialog->get_ok_button()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size())); } void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { @@ -310,7 +310,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_ dialog->set_title(TTR("Error!")); //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text(TTR("Close")); + dialog->get_ok_button()->set_text(TTR("Close")); dialog->popup_centered(); return; ///beh should show an error i guess } @@ -361,7 +361,7 @@ void SpriteFramesEditor::_paste_pressed() { dialog->set_text(TTR("Resource clipboard is empty or not a texture!")); dialog->set_title(TTR("Error!")); //dialog->get_cancel()->set_text("Close"); - dialog->get_ok()->set_text(TTR("Close")); + dialog->get_ok_button()->set_text(TTR("Close")); dialog->popup_centered(); return; ///beh should show an error i guess } diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index dd53f60014..e6fb6ba22a 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -556,7 +556,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { if (p_option == POPUP_ADD) { // Add. add_del_dialog->set_title(TTR("Add Item")); - add_del_dialog->get_ok()->set_text(TTR("Add")); + add_del_dialog->get_ok_button()->set_text(TTR("Add")); add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE); base_theme = Theme::get_default(); @@ -564,7 +564,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { } else if (p_option == POPUP_CLASS_ADD) { // Add. add_del_dialog->set_title(TTR("Add All Items")); - add_del_dialog->get_ok()->set_text(TTR("Add All")); + add_del_dialog->get_ok_button()->set_text(TTR("Add All")); add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE); base_theme = Theme::get_default(); @@ -576,14 +576,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { } 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->get_ok_button()->set_text(TTR("Remove")); add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE); 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->get_ok_button()->set_text(TTR("Remove All")); add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE); base_theme = Theme::get_default(); @@ -908,7 +908,7 @@ ThemeEditor::ThemeEditor() { dialog_vbc->add_child(type_select); - add_del_dialog->get_ok()->connect("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk)); + add_del_dialog->get_ok_button()->connect("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk)); file_dialog = memnew(EditorFileDialog); file_dialog->add_filter("*.theme ; " + TTR("Theme File")); diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 5e98b2d98b..7747c740df 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -119,19 +119,13 @@ 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; } - EditorVCSInterface::get_singleton()->commit(msg); + EditorVCSInterface::get_singleton()->commit(commit_message->get_text()); commit_message->set_text(""); version_control_dock_button->set_pressed(false); @@ -294,6 +288,10 @@ void VersionControlEditorPlugin::_update_commit_status() { staged_files_count = 0; } +void VersionControlEditorPlugin::_update_commit_button() { + commit_button->set_disabled(commit_message->get_text().strip_edges() == ""); +} + void VersionControlEditorPlugin::register_editor() { if (!EditorVCSInterface::get_singleton()) { EditorNode::get_singleton()->add_control_to_dock(EditorNode::DOCK_SLOT_RIGHT_UL, version_commit_dock); @@ -357,7 +355,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { set_up_dialog->set_min_size(Size2(400, 100)); version_control_actions->add_child(set_up_dialog); - set_up_ok_button = set_up_dialog->get_ok(); + set_up_ok_button = set_up_dialog->get_ok_button(); set_up_ok_button->set_text(TTR("Close")); set_up_vbc = memnew(VBoxContainer); @@ -463,11 +461,12 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { commit_message->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END); commit_message->set_custom_minimum_size(Size2(200, 100)); commit_message->set_wrap_enabled(true); - commit_message->set_text(TTR("Add a commit message")); + commit_message->connect("text_changed", callable_mp(this, &VersionControlEditorPlugin::_update_commit_button)); commit_box_vbc->add_child(commit_message); commit_button = memnew(Button); commit_button->set_text(TTR("Commit Changes")); + commit_button->set_disabled(true); commit_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_send_commit_msg)); commit_box_vbc->add_child(commit_button); diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h index 34643e85e4..3f107ddffb 100644 --- a/editor/plugins/version_control_editor_plugin.h +++ b/editor/plugins/version_control_editor_plugin.h @@ -110,6 +110,7 @@ private: void _clear_file_diff(); void _update_stage_status(); void _update_commit_status(); + void _update_commit_button(); friend class EditorVCSInterface; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 07061a4bc5..da664109dc 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1009,7 +1009,7 @@ String VisualShaderEditor::_get_description(int p_idx) { void VisualShaderEditor::_update_options_menu() { node_desc->set_text(""); - members_dialog->get_ok()->set_disabled(true); + members_dialog->get_ok_button()->set_disabled(true); members->clear(); TreeItem *root = members->create_item(); @@ -2613,12 +2613,12 @@ void VisualShaderEditor::_member_selected() { TreeItem *item = members->get_selected(); if (item != nullptr && item->has_meta("id")) { - members_dialog->get_ok()->set_disabled(false); + members_dialog->get_ok_button()->set_disabled(false); highend_label->set_visible(add_options[item->get_meta("id")].highend); node_desc->set_text(_get_description(item->get_meta("id"))); } else { highend_label->set_visible(false); - members_dialog->get_ok()->set_disabled(true); + members_dialog->get_ok_button()->set_disabled(true); node_desc->set_text(""); } } @@ -3068,9 +3068,9 @@ VisualShaderEditor::VisualShaderEditor() { members_dialog->set_title(TTR("Create Shader Node")); members_dialog->set_exclusive(false); members_dialog->add_child(members_vb); - members_dialog->get_ok()->set_text(TTR("Create")); - members_dialog->get_ok()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create)); - members_dialog->get_ok()->set_disabled(true); + members_dialog->get_ok_button()->set_text(TTR("Create")); + members_dialog->get_ok_button()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create)); + members_dialog->get_ok_button()->set_disabled(true); members_dialog->connect("cancelled", callable_mp(this, &VisualShaderEditor::_member_cancel)); add_child(members_dialog); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 8435dccf4a..68710920a5 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -262,13 +262,13 @@ void ProjectExportDialog::_edit_preset(int p_index) { } export_button->set_disabled(true); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); } else { export_error->hide(); export_templates_error->hide(); export_button->set_disabled(false); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } custom_features->set_text(current->get_custom_features()); @@ -586,7 +586,7 @@ void ProjectExportDialog::_delete_preset_confirm() { int idx = presets->get_current(); _edit_preset(-1); export_button->set_disabled(true); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); EditorExport::get_singleton()->remove_export_preset(idx); _update_presets(); } @@ -856,18 +856,18 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) { bool invalid_path = (p_path.get_file().get_basename() == ""); // Check if state change before needlessly messing with signals - if (invalid_path && export_project->get_ok()->is_disabled()) { + if (invalid_path && export_project->get_ok_button()->is_disabled()) { return; } - if (!invalid_path && !export_project->get_ok()->is_disabled()) { + if (!invalid_path && !export_project->get_ok_button()->is_disabled()) { return; } if (invalid_path) { - export_project->get_ok()->set_disabled(true); + export_project->get_ok_button()->set_disabled(true); export_project->get_line_edit()->disconnect("text_entered", Callable(export_project, "_file_entered")); } else { - export_project->get_ok()->set_disabled(false); + export_project->get_ok_button()->set_disabled(false); export_project->get_line_edit()->connect("text_entered", Callable(export_project, "_file_entered")); } } @@ -901,7 +901,7 @@ void ProjectExportDialog::_export_project() { // FIXME: This is a hack, we should instead change EditorFileDialog to allow // disabling validation by the "text_entered" signal. if (!export_project->get_line_edit()->is_connected("text_entered", Callable(export_project, "_file_entered"))) { - export_project->get_ok()->set_disabled(false); + export_project->get_ok_button()->set_disabled(false); export_project->get_line_edit()->connect("text_entered", Callable(export_project, "_file_entered")); } @@ -1184,26 +1184,26 @@ ProjectExportDialog::ProjectExportDialog() { delete_confirm = memnew(ConfirmationDialog); add_child(delete_confirm); - delete_confirm->get_ok()->set_text(TTR("Delete")); + delete_confirm->get_ok_button()->set_text(TTR("Delete")); delete_confirm->connect("confirmed", callable_mp(this, &ProjectExportDialog::_delete_preset_confirm)); // Export buttons, dialogs and errors. updating = false; - get_cancel()->set_text(TTR("Close")); - get_ok()->set_text(TTR("Export PCK/Zip")); + get_cancel_button()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Export PCK/Zip")); export_button = add_button(TTR("Export Project"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "export"); export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project)); // Disable initially before we select a valid preset export_button->set_disabled(true); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); export_all_dialog = memnew(ConfirmationDialog); add_child(export_all_dialog); export_all_dialog->set_title("Export All"); export_all_dialog->set_text(TTR("Export mode?")); - export_all_dialog->get_ok()->hide(); + export_all_dialog->get_ok_button()->hide(); export_all_dialog->add_button(TTR("Debug"), true, "debug"); export_all_dialog->add_button(TTR("Release"), true, "release"); export_all_dialog->connect("custom_action", callable_mp(this, &ProjectExportDialog::_export_all_dialog_action)); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 3ec0c5a6a4..ad0c9532d8 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -160,7 +160,7 @@ private: if (valid_path == "") { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR); memdelete(d); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return ""; } @@ -174,7 +174,7 @@ private: if (valid_install_path == "") { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH); memdelete(d); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return ""; } } @@ -189,7 +189,7 @@ private: if (!pkg) { set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR); memdelete(d); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); unzClose(pkg); return ""; } @@ -210,7 +210,7 @@ private: if (ret == UNZ_END_OF_LIST_OF_FILE) { set_message(TTR("Invalid \".zip\" project file; it doesn't contain a \"project.godot\" file."), MESSAGE_ERROR); memdelete(d); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); unzClose(pkg); return ""; } @@ -237,7 +237,7 @@ private: if (!is_folder_empty) { set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH); memdelete(d); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return ""; } @@ -245,14 +245,14 @@ private: set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR); memdelete(d); install_path_container->hide(); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return ""; } } 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); + get_ok_button()->set_disabled(true); return ""; } @@ -277,7 +277,7 @@ private: if (!is_folder_empty) { set_message(TTR("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING); memdelete(d); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); return valid_path; } } @@ -285,7 +285,7 @@ private: set_message(""); set_message("", MESSAGE_SUCCESS, INSTALL_PATH); memdelete(d); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); return valid_path; } @@ -320,14 +320,14 @@ private: if (p.ends_with("project.godot")) { p = p.get_base_dir(); install_path_container->hide(); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } else if (p.ends_with(".zip")) { install_path->set_text(p.get_base_dir()); install_path_container->show(); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } else { set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); return; } } @@ -338,7 +338,7 @@ private: if (p.ends_with(".zip")) { install_path->call_deferred("grab_focus"); } else { - get_ok()->call_deferred("grab_focus"); + get_ok_button()->call_deferred("grab_focus"); } } @@ -346,14 +346,14 @@ private: String sp = p_path.simplify_path(); project_path->set_text(sp); _path_text_changed(sp); - get_ok()->call_deferred("grab_focus"); + get_ok_button()->call_deferred("grab_focus"); } void _install_path_selected(const String &p_path) { String sp = p_path.simplify_path(); install_path->set_text(sp); _path_text_changed(sp); - get_ok()->call_deferred("grab_focus"); + get_ok_button()->call_deferred("grab_focus"); } void _browse_path() { @@ -466,7 +466,7 @@ private: ConfirmationDialog *cd = memnew(ConfirmationDialog); cd->set_title(TTR("Warning: This folder is not empty")); cd->set_text(TTR("You are about to create a Godot project in a non-empty folder.\nThe entire contents of this folder will be imported as project resources!\n\nAre you sure you wish to continue?")); - cd->get_ok()->connect("pressed", callable_mp(this, &ProjectDialog::_nonempty_confirmation_ok_pressed)); + cd->get_ok_button()->connect("pressed", callable_mp(this, &ProjectDialog::_nonempty_confirmation_ok_pressed)); get_parent()->add_child(cd); cd->popup_centered(); cd->grab_focus(); @@ -684,14 +684,14 @@ public: install_browse->hide(); set_title(TTR("Rename Project")); - get_ok()->set_text(TTR("Rename")); + get_ok_button()->set_text(TTR("Rename")); name_container->show(); status_rect->hide(); msg->hide(); install_path_container->hide(); install_status_rect->hide(); rasterizer_container->hide(); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); ProjectSettings *current = memnew(ProjectSettings); @@ -700,7 +700,7 @@ public: set_message(vformat(TTR("Couldn't load project.godot in project path (error %d). It may be missing or corrupted."), err), MESSAGE_ERROR); status_rect->show(); msg->show(); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); } else if (current->has_setting("application/config/name")) { String proj = current->get("application/config/name"); project_name->set_text(proj); @@ -738,7 +738,7 @@ public: if (mode == MODE_IMPORT) { set_title(TTR("Import Existing Project")); - get_ok()->set_text(TTR("Import & Edit")); + get_ok_button()->set_text(TTR("Import & Edit")); name_container->hide(); install_path_container->hide(); rasterizer_container->hide(); @@ -746,7 +746,7 @@ public: } else if (mode == MODE_NEW) { set_title(TTR("Create New Project")); - get_ok()->set_text(TTR("Create & Edit")); + get_ok_button()->set_text(TTR("Create & Edit")); name_container->show(); install_path_container->hide(); rasterizer_container->show(); @@ -755,7 +755,7 @@ public: } else if (mode == MODE_INSTALL) { set_title(TTR("Install Project:") + " " + zip_title); - get_ok()->set_text(TTR("Install & Edit")); + get_ok_button()->set_text(TTR("Install & Edit")); project_name->set_text(zip_title); name_container->show(); install_path_container->hide(); @@ -2321,8 +2321,8 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { memdelete(dir); } if (confirm) { - multi_scan_ask->get_ok()->disconnect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders)); - multi_scan_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders), varray(folders)); + multi_scan_ask->get_ok_button()->disconnect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders)); + multi_scan_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders), varray(folders)); multi_scan_ask->set_text( vformat(TTR("Are you sure to scan %s folders for existing Godot projects?\nThis could take a while."), folders.size())); multi_scan_ask->popup_centered(); @@ -2629,9 +2629,9 @@ ProjectManager::ProjectManager() { { // Dialogs language_restart_ask = memnew(ConfirmationDialog); - language_restart_ask->get_ok()->set_text(TTR("Restart Now")); - language_restart_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_restart_confirm)); - language_restart_ask->get_cancel()->set_text(TTR("Continue")); + language_restart_ask->get_ok_button()->set_text(TTR("Restart Now")); + language_restart_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_restart_confirm)); + language_restart_ask->get_cancel_button()->set_text(TTR("Continue")); add_child(language_restart_ask); scan_dir = memnew(FileDialog); @@ -2643,31 +2643,31 @@ ProjectManager::ProjectManager() { scan_dir->connect("dir_selected", callable_mp(this, &ProjectManager::_scan_begin)); erase_missing_ask = memnew(ConfirmationDialog); - erase_missing_ask->get_ok()->set_text(TTR("Remove All")); - erase_missing_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_erase_missing_projects_confirm)); + erase_missing_ask->get_ok_button()->set_text(TTR("Remove All")); + erase_missing_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_erase_missing_projects_confirm)); add_child(erase_missing_ask); erase_ask = memnew(ConfirmationDialog); - erase_ask->get_ok()->set_text(TTR("Remove")); - erase_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_erase_project_confirm)); + erase_ask->get_ok_button()->set_text(TTR("Remove")); + erase_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_erase_project_confirm)); add_child(erase_ask); multi_open_ask = memnew(ConfirmationDialog); - multi_open_ask->get_ok()->set_text(TTR("Edit")); - multi_open_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_open_selected_projects)); + multi_open_ask->get_ok_button()->set_text(TTR("Edit")); + multi_open_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_open_selected_projects)); add_child(multi_open_ask); multi_run_ask = memnew(ConfirmationDialog); - multi_run_ask->get_ok()->set_text(TTR("Run")); - multi_run_ask->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_run_project_confirm)); + multi_run_ask->get_ok_button()->set_text(TTR("Run")); + multi_run_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_run_project_confirm)); add_child(multi_run_ask); multi_scan_ask = memnew(ConfirmationDialog); - multi_scan_ask->get_ok()->set_text(TTR("Scan")); + multi_scan_ask->get_ok_button()->set_text(TTR("Scan")); add_child(multi_scan_ask); ask_update_settings = memnew(ConfirmationDialog); - ask_update_settings->get_ok()->connect("pressed", callable_mp(this, &ProjectManager::_confirm_update_settings)); + ask_update_settings->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_confirm_update_settings)); add_child(ask_update_settings); npdialog = memnew(ProjectDialog); @@ -2684,7 +2684,7 @@ ProjectManager::ProjectManager() { open_templates = memnew(ConfirmationDialog); open_templates->set_text(TTR("You currently don't have any projects.\nWould you like to explore official example projects in the Asset Library?")); - open_templates->get_ok()->set_text(TTR("Open Asset Library")); + open_templates->get_ok_button()->set_text(TTR("Open Asset Library")); open_templates->connect("confirmed", callable_mp(this, &ProjectManager::_open_asset_library)); add_child(open_templates); } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 55d80021c8..9995c6ad65 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -478,6 +478,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { del_confirmation->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(true)); add_child(del_confirmation); - get_ok()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Close")); set_hide_on_ok(true); } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 1ff73f25c5..220031d2dc 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -321,7 +321,7 @@ void PropertySelector::_update_search() { } } - get_ok()->set_disabled(root->get_children() == nullptr); + get_ok_button()->set_disabled(root->get_children() == nullptr); } void PropertySelector::_confirmed() { @@ -553,8 +553,8 @@ PropertySelector::PropertySelector() { search_box->connect("gui_input", callable_mp(this, &PropertySelector::_sbox_input)); search_options = memnew(Tree); vbc->add_margin_child(TTR("Matches:"), search_options, true); - get_ok()->set_text(TTR("Open")); - get_ok()->set_disabled(true); + get_ok_button()->set_text(TTR("Open")); + get_ok_button()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated", callable_mp(this, &PropertySelector::_confirmed)); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index e1308b4895..7ffe5bc9a7 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -107,11 +107,11 @@ void EditorQuickOpen::_update_search() { to_select->set_as_cursor(0); search_options->scroll_to_item(to_select); - get_ok()->set_disabled(false); + get_ok_button()->set_disabled(false); } else { search_options->deselect_all(); - get_ok()->set_disabled(true); + get_ok_button()->set_disabled(true); } } @@ -256,6 +256,6 @@ EditorQuickOpen::EditorQuickOpen() { search_options->add_theme_constant_override("draw_guides", 1); vbc->add_margin_child(TTR("Matches:"), search_options, true); - get_ok()->set_text(TTR("Open")); + get_ok_button()->set_text(TTR("Open")); set_hide_on_ok(false); } diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 318324e56d..a60937a86b 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -286,7 +286,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und // ---- Dialog related set_min_size(Size2(383, 0)); - get_ok()->set_text(TTR("Rename")); + get_ok_button()->set_text(TTR("Rename")); Button *but_reset = add_button(TTR("Reset")); eh.errfunc = _error_handler; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index 0ff27af7c1..c7f1a1b45d 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -87,7 +87,7 @@ ReparentDialog::ReparentDialog() { //cancel->connect("pressed", this,"_cancel"); - get_ok()->set_text(TTR("Reparent")); + get_ok_button()->set_text(TTR("Reparent")); } ReparentDialog::~ReparentDialog() { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 91dffb504f..72703623ab 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2982,7 +2982,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel clear_inherit_confirm = memnew(ConfirmationDialog); clear_inherit_confirm->set_text(TTR("Clear Inheritance? (No Undo!)")); - clear_inherit_confirm->get_ok()->set_text(TTR("Clear")); + clear_inherit_confirm->get_ok_button()->set_text(TTR("Clear")); add_child(clear_inherit_confirm); set_process_input(true); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index b5f11fc6f9..9c3e381dc8 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -522,7 +522,7 @@ void ScriptCreateDialog::_browse_path(bool browse_parent, bool p_save) { if (p_save) { file_browse->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); file_browse->set_title(TTR("Open Script / Choose Location")); - file_browse->get_ok()->set_text(TTR("Open")); + file_browse->get_ok_button()->set_text(TTR("Open")); } else { file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); file_browse->set_title(TTR("Open Script")); @@ -686,7 +686,7 @@ void ScriptCreateDialog::_update_dialog() { builtin_warning_label->set_visible(is_built_in); if (is_built_in) { - get_ok()->set_text(TTR("Create")); + get_ok_button()->set_text(TTR("Create")); parent_name->set_editable(true); parent_search_button->set_disabled(false); parent_browse_button->set_disabled(!can_inherit_from_file); @@ -694,7 +694,7 @@ void ScriptCreateDialog::_update_dialog() { } else if (is_new_script_created) { // New script created. - get_ok()->set_text(TTR("Create")); + get_ok_button()->set_text(TTR("Create")); parent_name->set_editable(true); parent_search_button->set_disabled(false); parent_browse_button->set_disabled(!can_inherit_from_file); @@ -704,7 +704,7 @@ void ScriptCreateDialog::_update_dialog() { } else if (load_enabled) { // Script loaded. - get_ok()->set_text(TTR("Load")); + get_ok_button()->set_text(TTR("Load")); parent_name->set_editable(false); parent_search_button->set_disabled(true); parent_browse_button->set_disabled(true); @@ -712,7 +712,7 @@ void ScriptCreateDialog::_update_dialog() { _msg_path_valid(true, TTR("Will load an existing script file.")); } } else { - get_ok()->set_text(TTR("Create")); + get_ok_button()->set_text(TTR("Create")); parent_name->set_editable(true); parent_search_button->set_disabled(false); parent_browse_button->set_disabled(!can_inherit_from_file); @@ -721,7 +721,7 @@ void ScriptCreateDialog::_update_dialog() { script_ok = false; } - get_ok()->set_disabled(!script_ok); + get_ok_button()->set_disabled(!script_ok); Callable entered_call = callable_mp(this, &ScriptCreateDialog::_path_entered); if (script_ok) { @@ -878,7 +878,7 @@ ScriptCreateDialog::ScriptCreateDialog() { file_browse->connect("file_selected", callable_mp(this, &ScriptCreateDialog::_file_selected)); file_browse->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); add_child(file_browse); - get_ok()->set_text(TTR("Create")); + get_ok_button()->set_text(TTR("Create")); alert = memnew(AcceptDialog); alert->get_label()->set_autowrap(true); alert->get_label()->set_align(Label::ALIGN_CENTER); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 864e5976b2..a29b6aded7 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -275,8 +275,8 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column last_wait_for_key = Ref<InputEventKey>(); press_a_key->popup_centered(Size2(250, 80) * EDSCALE); //press_a_key->grab_focus(); - press_a_key->get_ok()->set_focus_mode(Control::FOCUS_NONE); - press_a_key->get_cancel()->set_focus_mode(Control::FOCUS_NONE); + press_a_key->get_ok_button()->set_focus_mode(Control::FOCUS_NONE); + press_a_key->get_cancel_button()->set_focus_mode(Control::FOCUS_NONE); shortcut_configured = item; } else if (p_idx == 1) { //erase @@ -488,7 +488,7 @@ EditorSettingsDialog::EditorSettingsDialog() { timer->set_one_shot(true); add_child(timer); EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorSettingsDialog::_settings_changed)); - get_ok()->set_text(TTR("Close")); + get_ok_button()->set_text(TTR("Close")); updating = false; } |