diff options
Diffstat (limited to 'editor')
113 files changed, 1146 insertions, 750 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 92d53cc005..aab9743c43 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -1122,8 +1122,6 @@ void ActionMapEditor::use_external_search_box(LineEdit *p_searchbox) { } ActionMapEditor::ActionMapEditor() { - show_builtin_actions = false; - // Main Vbox Container VBoxContainer *main_vbox = memnew(VBoxContainer); main_vbox->set_anchors_and_offsets_preset(PRESET_WIDE); diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index de24d3ee1f..34c70c942e 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -164,7 +164,7 @@ private: // Filtering and Adding actions - bool show_builtin_actions; + bool show_builtin_actions = false; CheckButton *show_builtin_actions_checkbutton; LineEdit *action_list_search; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 11995e8cb4..e61a1aae9c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1814,13 +1814,6 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { - if (hsize_rect.has_point(mm->get_position())) { - // Change the cursor to indicate that the track name column's width can be adjusted - set_default_cursor_shape(Control::CURSOR_HSIZE); - } else { - set_default_cursor_shape(Control::CURSOR_ARROW); - } - if (dragging_hsize) { int ofs = mm->get_position().x - dragging_hsize_from; name_limit = dragging_hsize_at + ofs; @@ -1836,6 +1829,15 @@ void AnimationTimelineEdit::gui_input(const Ref<InputEvent> &p_event) { } } +Control::CursorShape AnimationTimelineEdit::get_cursor_shape(const Point2 &p_pos) const { + if (dragging_hsize || hsize_rect.has_point(p_pos)) { + // Indicate that the track name column's width can be adjusted + return Control::CURSOR_HSIZE; + } else { + return get_default_cursor_shape(); + } +} + void AnimationTimelineEdit::_scroll_callback(Vector2 p_scroll_vec, bool p_alt) { // Timeline has no vertical scroll, so we change it to horizontal. p_scroll_vec.x += p_scroll_vec.y; @@ -1884,8 +1886,6 @@ void AnimationTimelineEdit::_bind_methods() { } AnimationTimelineEdit::AnimationTimelineEdit() { - use_fps = false; - editing = false; name_limit = 150 * EDSCALE; zoom = nullptr; track_edit = nullptr; @@ -1933,9 +1933,6 @@ AnimationTimelineEdit::AnimationTimelineEdit() { add_track->get_popup()->connect("index_pressed", callable_mp(this, &AnimationTimelineEdit::_track_added)); len_hb->hide(); - dragging_timeline = false; - dragging_hsize = false; - panner.instantiate(); panner->set_callbacks(callable_mp(this, &AnimationTimelineEdit::_scroll_callback), callable_mp(this, &AnimationTimelineEdit::_pan_callback), callable_mp(this, &AnimationTimelineEdit::_zoom_callback)); @@ -3149,13 +3146,8 @@ AnimationTrackEdit::AnimationTrackEdit() { path = nullptr; path_popup = nullptr; menu = nullptr; - clicking_on_name = false; dropping_at = 0; - in_group = false; - - moving_selection_attempt = false; - moving_selection = false; select_single_attempt = -1; play_position_pos = 0; @@ -6314,8 +6306,6 @@ AnimationTrackEditor::AnimationTrackEditor() { add_child(method_selector); method_selector->connect("selected", callable_mp(this, &AnimationTrackEditor::_add_method_key)); - insert_queue = false; - insert_confirm = memnew(ConfirmationDialog); add_child(insert_confirm); insert_confirm->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_confirm_insert_list)); @@ -6333,8 +6323,6 @@ AnimationTrackEditor::AnimationTrackEditor() { 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; multi_key_edit = nullptr; @@ -6344,7 +6332,6 @@ AnimationTrackEditor::AnimationTrackEditor() { box_selection->set_mouse_filter(MOUSE_FILTER_IGNORE); box_selection->hide(); box_selection->connect("draw", callable_mp(this, &AnimationTrackEditor::_box_selection_draw)); - box_selecting = false; // Default Plugins. @@ -6441,7 +6428,6 @@ AnimationTrackEditor::AnimationTrackEditor() { track_copy_select->set_hide_root(true); track_vbox->add_child(track_copy_select); track_copy_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_COPY_TRACKS_CONFIRM)); - animation_changing_awaiting_update = false; } AnimationTrackEditor::~AnimationTrackEditor() { diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 5f803ae796..1baebc469e 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -77,16 +77,16 @@ class AnimationTimelineEdit : public Range { UndoRedo *undo_redo; Rect2 hsize_rect; - bool editing; - bool use_fps; + bool editing = false; + bool use_fps = false; Ref<ViewPanner> panner; void _scroll_callback(Vector2 p_scroll_vec, bool p_alt); void _pan_callback(Vector2 p_scroll_vec); void _zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt); - bool dragging_timeline; - bool dragging_hsize; + bool dragging_timeline = false; + bool dragging_hsize = false; float dragging_hsize_from; float dragging_hsize_at; @@ -121,6 +121,8 @@ public: void set_hscroll(HScrollBar *p_hscroll); + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; + AnimationTimelineEdit(); }; @@ -169,7 +171,7 @@ class AnimationTrackEdit : public Control { PopupMenu *menu; - bool clicking_on_name; + bool clicking_on_name = false; void _zoom_changed(); @@ -186,12 +188,12 @@ class AnimationTrackEdit : public Control { mutable int dropping_at; float insert_at_pos; - bool moving_selection_attempt; + bool moving_selection_attempt = false; int select_single_attempt; - bool moving_selection; + bool moving_selection = false; float moving_selection_from_ofs; - bool in_group; + bool in_group = false; AnimationTrackEditor *editor; protected: @@ -310,7 +312,7 @@ class AnimationTrackEditor : public VBoxContainer { Vector<AnimationTrackEdit *> track_edits; Vector<AnimationTrackEditGroup *> groups; - bool animation_changing_awaiting_update; + bool animation_changing_awaiting_update = false; void _animation_update(); int _get_track_selected(); void _animation_changed(); @@ -340,7 +342,7 @@ class AnimationTrackEditor : public VBoxContainer { int adding_track_type; NodePath adding_track_path; - bool keying; + bool keying = false; struct InsertData { Animation::TrackType type; @@ -355,7 +357,7 @@ class AnimationTrackEditor : public VBoxContainer { CheckBox *insert_confirm_bezier; CheckBox *insert_confirm_reset; ConfirmationDialog *insert_confirm; - bool insert_queue; + bool insert_queue = false; List<InsertData> insert_data; void _query_insert(const InsertData &p_id); @@ -410,7 +412,7 @@ class AnimationTrackEditor : public VBoxContainer { void _key_selected(int p_key, bool p_single, int p_track); void _key_deselected(int p_key, int p_track); - bool moving_selection; + bool moving_selection = false; float moving_selection_offset; void _move_selection_begin(); void _move_selection(float p_offset); @@ -425,7 +427,7 @@ class AnimationTrackEditor : public VBoxContainer { Control *box_selection; void _box_selection_draw(); - bool box_selecting; + bool box_selecting = false; Vector2 box_selecting_from; Rect2 box_select_rect; void _scroll_input(const Ref<InputEvent> &p_event); diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index e87678a51b..2ad8b2d2a4 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1080,12 +1080,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { len_resizing_index = i; } } - - if (use_hsize_cursor) { - set_default_cursor_shape(CURSOR_HSIZE); - } else { - set_default_cursor_shape(CURSOR_ARROW); - } + over_drag_position = use_hsize_cursor; } if (len_resizing && mm.is_valid()) { @@ -1097,7 +1092,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { } Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && get_default_cursor_shape() == CURSOR_HSIZE) { + if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT && over_drag_position) { len_resizing = true; len_resizing_start = mb->is_shift_pressed(); len_resizing_from_px = mb->get_position().x; @@ -1124,7 +1119,6 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { get_undo_redo()->commit_action(); } - len_resizing = false; len_resizing_index = -1; update(); accept_event(); @@ -1134,6 +1128,14 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) { AnimationTrackEdit::gui_input(p_event); } +Control::CursorShape AnimationTrackEditTypeAudio::get_cursor_shape(const Point2 &p_pos) const { + if (over_drag_position || len_resizing) { + return Control::CURSOR_HSIZE; + } else { + return get_default_cursor_shape(); + } +} + //////////////////// /// SUB ANIMATION /// diff --git a/editor/animation_track_editor_plugins.h b/editor/animation_track_editor_plugins.h index 271c1a000b..adfe517356 100644 --- a/editor/animation_track_editor_plugins.h +++ b/editor/animation_track_editor_plugins.h @@ -81,7 +81,7 @@ class AnimationTrackEditSpriteFrame : public AnimationTrackEdit { GDCLASS(AnimationTrackEditSpriteFrame, AnimationTrackEdit); ObjectID id; - bool is_coords; + bool is_coords = false; public: virtual int get_key_height() const override; @@ -92,7 +92,7 @@ public: void set_node(Object *p_object); void set_as_coords(); - AnimationTrackEditSpriteFrame() { is_coords = false; } + AnimationTrackEditSpriteFrame() {} }; class AnimationTrackEditSubAnim : public AnimationTrackEdit { @@ -114,11 +114,12 @@ class AnimationTrackEditTypeAudio : public AnimationTrackEdit { void _preview_changed(ObjectID p_which); - bool len_resizing; + bool len_resizing = false; bool len_resizing_start; int len_resizing_index; float len_resizing_from_px; float len_resizing_rel; + bool over_drag_position = false; protected: static void _bind_methods(); @@ -134,6 +135,8 @@ public: virtual bool is_key_selectable_by_distance() const override; virtual void draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) override; + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; + AnimationTrackEditTypeAudio(); }; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 22d3155159..2896fda2d2 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -618,8 +618,6 @@ void FindReplaceBar::_bind_methods() { FindReplaceBar::FindReplaceBar() { results_count = -1; - replace_all_mode = false; - preserve_cursor = false; vbc_lineedit = memnew(VBoxContainer); add_child(vbc_lineedit); @@ -1887,8 +1885,6 @@ CodeTextEditor::CodeTextEditor() { error_button->set_default_cursor_shape(CURSOR_POINTING_HAND); error_button->connect("pressed", callable_mp(this, &CodeTextEditor::_error_button_pressed)); error_button->set_tooltip(TTR("Errors")); - - is_errors_panel_opened = false; set_error_count(0); // Warnings @@ -1899,8 +1895,6 @@ CodeTextEditor::CodeTextEditor() { warning_button->set_default_cursor_shape(CURSOR_POINTING_HAND); warning_button->connect("pressed", callable_mp(this, &CodeTextEditor::_warning_button_pressed)); warning_button->set_tooltip(TTR("Warnings")); - - is_warnings_panel_opened = false; set_warning_count(0); // Line and column diff --git a/editor/code_editor.h b/editor/code_editor.h index 24316bf8b0..d7025e7fd9 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -86,8 +86,8 @@ class FindReplaceBar : public HBoxContainer { int result_col; int results_count; - bool replace_all_mode; - bool preserve_cursor; + bool replace_all_mode = false; + bool preserve_cursor = false; void _get_search_from(int &r_line, int &r_col); void _update_results_count(); @@ -206,8 +206,8 @@ protected: void _notification(int); static void _bind_methods(); - bool is_warnings_panel_opened; - bool is_errors_panel_opened; + bool is_warnings_panel_opened = false; + bool is_errors_panel_opened = false; public: void trim_trailing_whitespace(); diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 32e3c3679a..4e2e8634e5 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -396,6 +396,7 @@ void EditorProfiler::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons"))); clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 885d8bd5c4..2f33a0bc31 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -67,7 +67,7 @@ void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { updating_frame = true; cursor_metric_edit->set_max(frame_metrics[last_metric].frame_number); - cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0)); + cursor_metric_edit->set_min(MAX(frame_metrics[last_metric].frame_number - frame_metrics.size(), 0u)); if (!seeking) { cursor_metric_edit->set_value(frame_metrics[last_metric].frame_number); @@ -426,6 +426,7 @@ void EditorVisualProfiler::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: + case NOTIFICATION_THEME_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { if (is_layout_rtl()) { activate->set_icon(get_theme_icon(SNAME("PlayBackwards"), SNAME("EditorIcons"))); diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 453e9e3a0c..f6fdd5fc57 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -779,18 +779,20 @@ void ScriptEditorDebugger::_set_reason_text(const String &p_reason, MessageType void ScriptEditorDebugger::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - skip_breakpoints->set_icon(get_theme_icon(SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); - copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); - - step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); - next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); - dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); - docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); le_set->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_set)); le_clear->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_live_edit_clear)); error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected)); error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated)); breakpoints_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_breakpoint_tree_clicked)); + [[fallthrough]]; + } + case NOTIFICATION_THEME_CHANGED: { + skip_breakpoints->set_icon(get_theme_icon(skip_breakpoints_value ? SNAME("DebugSkipBreakpointsOn") : SNAME("DebugSkipBreakpointsOff"), SNAME("EditorIcons"))); + copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); + step->set_icon(get_theme_icon(SNAME("DebugStep"), SNAME("EditorIcons"))); + next->set_icon(get_theme_icon(SNAME("DebugNext"), SNAME("EditorIcons"))); + dobreak->set_icon(get_theme_icon(SNAME("Pause"), SNAME("EditorIcons"))); + docontinue->set_icon(get_theme_icon(SNAME("DebugContinue"), SNAME("EditorIcons"))); vmem_refresh->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); vmem_export->set_icon(get_theme_icon(SNAME("Save"), SNAME("EditorIcons"))); search->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 1802bdec93..95b3a02631 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -749,12 +749,11 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path } void OrphanResourcesDialog::_delete_confirm() { - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); for (const String &E : paths) { da->remove(E); EditorFileSystem::get_singleton()->update_file(E); } - memdelete(da); refresh(); } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index a9d18e9dcc..adad8fdba8 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -685,6 +685,11 @@ void DocTools::generate(bool p_basic_types) { for (int j = 0; j < Variant::OP_AND; j++) { // Showing above 'and' is pretty confusing and there are a lot of variations. for (int k = 0; k < Variant::VARIANT_MAX; k++) { + // Prevent generating for comparison with null. + if (Variant::Type(k) == Variant::NIL && (Variant::Operator(j) == Variant::OP_EQUAL || Variant::Operator(j) == Variant::OP_NOT_EQUAL)) { + continue; + } + Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(j), Variant::Type(i), Variant::Type(k)); if (rt != Variant::NIL) { // Has operator. // Skip String % operator as it's registered separately for each Variant arg type, diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 3835399c99..f1674c47c5 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -277,10 +277,8 @@ void EditorAssetInstaller::ok_pressed() { dirpath = dirpath.substr(0, dirpath.length() - 1); } - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); da->make_dir(dirpath); - memdelete(da); - } else { Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -358,7 +356,5 @@ EditorAssetInstaller::EditorAssetInstaller() { get_ok_button()->set_text(TTR("Install")); set_title(TTR("Asset Installer")); - updating = false; - set_hide_on_ok(true); } diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index f5993f73e7..58c232f351 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -42,7 +42,7 @@ class EditorAssetInstaller : public ConfirmationDialog { String asset_name; AcceptDialog *error; Map<String, TreeItem *> status_map; - bool updating; + bool updating = false; void _item_edited(); void _check_propagated_to_item(Object *p_obj, int column); virtual void ok_pressed() override; diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index e1198026b6..4474d6893a 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -771,9 +771,7 @@ void EditorAudioBus::_bind_methods() { EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { buses = p_buses; - updating_bus = false; is_master = p_is_master; - hovering_drop = false; set_tooltip(TTR("Drag & drop to rearrange.")); @@ -925,7 +923,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { String name = E.operator String().replace("AudioEffect", ""); effect_options->add_item(name); - effect_options->set_item_metadata(effect_options->get_item_count() - 1, E); + effect_options->set_item_metadata(-1, E); } bus_options = memnew(MenuButton); @@ -992,7 +990,6 @@ void EditorAudioBusDrop::_bind_methods() { } EditorAudioBusDrop::EditorAudioBusDrop() { - hovering_drop = false; } void EditorAudioBuses::_update_buses() { diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index a830a2719d..0020b61370 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -85,9 +85,9 @@ class EditorAudioBus : public PanelContainer { Tree *effects; - bool updating_bus; + bool updating_bus = false; bool is_master; - mutable bool hovering_drop; + mutable bool hovering_drop = false; virtual void gui_input(const Ref<InputEvent> &p_event) override; void _effects_gui_input(Ref<InputEvent> p_event); @@ -140,7 +140,7 @@ class EditorAudioBusDrop : public Control { virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override; virtual void drop_data(const Point2 &p_point, const Variant &p_data) override; - mutable bool hovering_drop; + mutable bool hovering_drop = false; protected: static void _bind_methods(); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 829948d3cb..b37b06748d 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -35,6 +35,7 @@ #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/filesystem_dock.h" #include "project_settings_editor.h" #include "scene/main/window.h" #include "scene/resources/packed_scene.h" @@ -63,6 +64,28 @@ void EditorAutoloadSettings::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } break; + + case NOTIFICATION_VISIBILITY_CHANGED: { + FileSystemDock *dock = FileSystemDock::get_singleton(); + + if (dock != nullptr) { + ScriptCreateDialog *dialog = dock->get_script_create_dialog(); + + if (dialog != nullptr) { + Callable script_created = callable_mp(this, &EditorAutoloadSettings::_script_created); + + if (is_visible_in_tree()) { + if (!dialog->is_connected(SNAME("script_created"), script_created)) { + dialog->connect("script_created", script_created); + } + } else { + if (dialog->is_connected(SNAME("script_created"), script_created)) { + dialog->disconnect("script_created", script_created); + } + } + } + } + } break; } } @@ -134,12 +157,22 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin } void EditorAutoloadSettings::_autoload_add() { - if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) { - autoload_add_path->set_text(""); - } + if (autoload_add_path->get_text().is_empty()) { + ScriptCreateDialog *dialog = FileSystemDock::get_singleton()->get_script_create_dialog(); + String fpath = path; + if (!fpath.ends_with("/")) { + fpath = fpath.get_base_dir(); + } + dialog->config("Node", fpath.plus_file(vformat("%s.gd", autoload_add_name->get_text().camelcase_to_underscore())), false, false); + dialog->popup_centered(); + } else { + if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) { + autoload_add_path->set_text(""); + } - autoload_add_name->set_text(""); - add_autoload->set_disabled(true); + autoload_add_name->set_text(""); + add_autoload->set_disabled(true); + } } void EditorAutoloadSettings::_autoload_selected() { @@ -351,14 +384,13 @@ void EditorAutoloadSettings::_autoload_text_submitted(const String p_name) { } void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { - add_autoload->set_disabled( - p_path.is_empty() || !_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); + add_autoload->set_disabled(!_autoload_name_is_valid(autoload_add_name->get_text(), nullptr)); } void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { String error_string; bool is_name_valid = _autoload_name_is_valid(p_name, &error_string); - add_autoload->set_disabled(autoload_add_path->get_text().is_empty() || !is_name_valid); + add_autoload->set_disabled(!is_name_valid); error_message->set_text(error_string); error_message->set_visible(!autoload_add_name->get_text().is_empty() && !is_name_valid); } @@ -540,6 +572,14 @@ void EditorAutoloadSettings::update_autoload() { updating_autoload = false; } +void EditorAutoloadSettings::_script_created(Ref<Script> p_script) { + FileSystemDock::get_singleton()->get_script_create_dialog()->hide(); + path = p_script->get_path().get_base_dir(); + autoload_add_path->set_text(p_script->get_path()); + autoload_add_name->set_text(p_script->get_path().get_file().get_basename().capitalize().replace(" ", "")); + _autoload_add(); +} + Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) { if (autoload_cache.size() <= 1) { return false; @@ -833,11 +873,6 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } } - autoload_changed = "autoload_changed"; - - updating_autoload = false; - selected_autoload = ""; - HBoxContainer *hbc = memnew(HBoxContainer); add_child(hbc); @@ -854,6 +889,8 @@ EditorAutoloadSettings::EditorAutoloadSettings() { autoload_add_path = memnew(LineEdit); hbc->add_child(autoload_add_path); autoload_add_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); + autoload_add_path->set_clear_button_enabled(true); + autoload_add_path->set_placeholder(vformat(TTR(R"(Set path or press "%s" to create a script.)"), TTR("Add"))); autoload_add_path->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed)); browse_button = memnew(Button); diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index 044eea4245..380cadbebb 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -47,7 +47,8 @@ class EditorAutoloadSettings : public VBoxContainer { BUTTON_DELETE }; - String autoload_changed; + String path = "res://"; + String autoload_changed = "autoload_changed"; struct AutoloadInfo { String name; @@ -64,17 +65,16 @@ class EditorAutoloadSettings : public VBoxContainer { List<AutoloadInfo> autoload_cache; - bool updating_autoload; - int number_of_autoloads; + bool updating_autoload = false; String selected_autoload; - Tree *tree; - LineEdit *autoload_add_name; - Button *add_autoload; - LineEdit *autoload_add_path; - Label *error_message; - Button *browse_button; - EditorFileDialog *file_dialog; + Tree *tree = nullptr; + LineEdit *autoload_add_name = nullptr; + Button *add_autoload = nullptr; + LineEdit *autoload_add_path = nullptr; + Label *error_message = nullptr; + Button *browse_button = nullptr; + EditorFileDialog *file_dialog = nullptr; bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr); @@ -90,6 +90,8 @@ class EditorAutoloadSettings : public VBoxContainer { void _autoload_file_callback(const String &p_path); Node *_create_autoload(const String &p_path); + void _script_created(Ref<Script> p_script); + Variant get_drag_data_fw(const Point2 &p_point, Control *p_control); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 69c7e9d52c..c16451f3c6 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -1206,9 +1206,6 @@ void EditorSelection::clear() { } EditorSelection::EditorSelection() { - emitted = false; - changed = false; - nl_changed = false; } EditorSelection::~EditorSelection() { diff --git a/editor/editor_data.h b/editor/editor_data.h index 0d1efc9b62..79f8227e5c 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -239,9 +239,9 @@ class EditorSelection : public Object { private: Map<Node *, Object *> selection; - bool emitted; - bool changed; - bool nl_changed; + bool emitted = false; + bool changed = false; + bool nl_changed = false; void _node_removed(Node *p_node); diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index f181c04004..32ef87a4ab 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -175,8 +175,6 @@ void EditorDirDialog::_bind_methods() { } EditorDirDialog::EditorDirDialog() { - updating = false; - set_title(TTR("Choose a Directory")); set_hide_on_ok(false); @@ -206,6 +204,4 @@ EditorDirDialog::EditorDirDialog() { add_child(mkdirerr); get_ok_button()->set_text(TTR("Choose")); - - must_reload = false; } diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 053c1f5503..e97b5ce8af 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -47,7 +47,7 @@ class EditorDirDialog : public ConfirmationDialog { Set<String> opened_paths; Tree *tree; - bool updating; + bool updating = false; void _item_collapsed(Object *p_item); void _item_activated(); @@ -58,7 +58,7 @@ class EditorDirDialog : public ConfirmationDialog { void ok_pressed() override; - bool must_reload; + bool must_reload = false; protected: void _notification(int p_what); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index d081ee05a0..02495252bc 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -566,8 +566,8 @@ void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p extra_files.push_back(ef); } -void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &tags) { - shared_objects.push_back(SharedObject(p_path, tags)); +void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &p_tags, const String &p_target) { + shared_objects.push_back(SharedObject(p_path, p_tags, p_target)); } void EditorExportPlugin::add_ios_framework(const String &p_path) { @@ -660,7 +660,7 @@ void EditorExportPlugin::skip() { } void EditorExportPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags", "target"), &EditorExportPlugin::add_shared_object); ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); @@ -678,10 +678,9 @@ void EditorExportPlugin::_bind_methods() { } EditorExportPlugin::EditorExportPlugin() { - skipped = false; } -EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset) { +EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) { Ref<EditorExportPlatform> platform = p_preset->get_platform(); List<String> feature_list; platform->get_platform_features(&feature_list); @@ -693,6 +692,14 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai result.features_pv.push_back(E); } + if (p_debug) { + result.features.insert("debug"); + result.features_pv.push_back("debug"); + } else { + result.features.insert("release"); + result.features_pv.push_back("release"); + } + if (!p_preset->get_custom_features().is_empty()) { Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); @@ -709,7 +716,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai } EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - FeatureContainers features = p_platform.get_feature_containers(p_preset); + FeatureContainers features = p_platform.get_feature_containers(p_preset, p_debug); Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); //initial export plugin callback for (int i = 0; i < export_plugins.size(); i++) { @@ -731,7 +738,7 @@ EditorExportPlatform::ExportNotifier::~ExportNotifier() { } } -Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) { +Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) { //figure out paths of files that will be exported Set<String> paths; Vector<String> path_remaps; @@ -865,7 +872,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & export_plugins.write[i]->_clear(); } - FeatureContainers feature_containers = get_feature_containers(p_preset); + FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); Set<String> &features = feature_containers.features; Vector<String> &features_pv = feature_containers.features_pv; @@ -1119,7 +1126,7 @@ Error EditorExportPlatform::_add_shared_object(void *p_userdata, const SharedObj return OK; } -Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) { +Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files, bool p_embed, int64_t *r_embedded_start, int64_t *r_embedded_size) { EditorProgress ep("savepack", TTR("Packing"), 102, true); // Create the temporary export directory if it doesn't exist. @@ -1135,7 +1142,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c pd.f = ftmp; pd.so_files = p_so_files; - Error err = export_project_files(p_preset, _save_pack_file, &pd, _add_shared_object); + Error err = export_project_files(p_preset, p_debug, _save_pack_file, &pd, _add_shared_object); memdelete(ftmp); //close tmp file @@ -1325,7 +1332,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c return OK; } -Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path) { +Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) { EditorProgress ep("savezip", TTR("Packing"), 102, true); FileAccess *src_f; @@ -1336,7 +1343,7 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co zd.ep = &ep; zd.zip = zip; - Error err = export_project_files(p_preset, _save_zip_file, &zd); + Error err = export_project_files(p_preset, p_debug, _save_zip_file, &zd); if (err != OK && err != ERR_SKIP) { ERR_PRINT("Failed to export project files"); } @@ -1348,12 +1355,12 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co Error EditorExportPlatform::export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - return save_pack(p_preset, p_path); + return save_pack(p_preset, p_debug, p_path); } Error EditorExportPlatform::export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - return save_zip(p_preset, p_path); + return save_zip(p_preset, p_debug, p_path); } void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) { @@ -1722,7 +1729,6 @@ EditorExport::EditorExport() { save_timer->set_wait_time(0.8); save_timer->set_one_shot(true); save_timer->connect("timeout", callable_mp(this, &EditorExport::_save)); - block_save = false; _export_presets_updated = "export_presets_updated"; @@ -1875,7 +1881,7 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr int64_t embedded_pos; int64_t embedded_size; - err = save_pack(p_preset, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size); + err = save_pack(p_preset, p_debug, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size); if (err == OK && p_preset->get("binary_format/embed_pck")) { if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) { EditorNode::get_singleton()->show_warning(TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB.")); @@ -1889,12 +1895,27 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr } if (err == OK && !so_files.is_empty()) { - //if shared object files, copy them + // If shared object files, copy them. da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < so_files.size() && err == OK; i++) { - err = da->copy(so_files[i].path, p_path.get_base_dir().plus_file(so_files[i].path.get_file())); - if (err == OK) { - err = sign_shared_object(p_preset, p_debug, p_path.get_base_dir().plus_file(so_files[i].path.get_file())); + String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path); + String target_path; + if (so_files[i].target.is_empty()) { + target_path = p_path.get_base_dir().plus_file(src_path.get_file()); + } else { + target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file()); + } + + if (da->dir_exists(src_path)) { + err = da->make_dir_recursive(target_path); + if (err == OK) { + err = da->copy_dir(src_path, target_path, -1, true); + } + } else { + err = da->copy(src_path, target_path); + if (err == OK) { + err = sign_shared_object(p_preset, p_debug, target_path); + } } } } diff --git a/editor/editor_export.h b/editor/editor_export.h index 796fb12793..d9039f601e 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -152,10 +152,12 @@ public: struct SharedObject { String path; Vector<String> tags; + String target; - SharedObject(const String &p_path, const Vector<String> &p_tags) : + SharedObject(const String &p_path, const Vector<String> &p_tags, const String &p_target) : path(p_path), - tags(p_tags) { + tags(p_tags), + target(p_target) { } SharedObject() {} @@ -216,7 +218,7 @@ protected: ~ExportNotifier(); }; - FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset); + FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug); bool exists_export_template(String template_file_name, String *err) const; String find_export_template(String template_file_name, String *err = nullptr) const; @@ -246,10 +248,10 @@ public: virtual String get_name() const = 0; virtual Ref<Texture2D> get_logo() const = 0; - Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); + Error export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); - Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); - Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path); + Error save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); + Error save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); virtual bool poll_export() { return false; } virtual int get_options_count() const { return 0; } @@ -297,7 +299,7 @@ class EditorExportPlugin : public RefCounted { bool remap = false; }; Vector<ExtraFile> extra_files; - bool skipped; + bool skipped = false; Vector<String> ios_frameworks; Vector<String> ios_embedded_frameworks; @@ -334,7 +336,7 @@ protected: Ref<EditorExportPreset> get_export_preset() const; void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap); - void add_shared_object(const String &p_path, const Vector<String> &tags); + void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String()); void add_ios_framework(const String &p_path); void add_ios_embedded_framework(const String &p_path); @@ -379,7 +381,7 @@ class EditorExport : public Node { StringName _export_presets_updated; Timer *save_timer; - bool block_save; + bool block_save = false; static EditorExport *singleton; diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index b1708e756a..3d5ca7de42 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -1010,7 +1010,5 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { update_timer->connect("timeout", callable_mp(this, &EditorFeatureProfileManager::_emit_current_profile_changed)); update_timer->set_one_shot(true); - updating_features = false; - singleton = this; } diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 7ea40502a6..881f14638f 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -155,7 +155,7 @@ class EditorFeatureProfileManager : public AcceptDialog { void _import_profiles(const Vector<String> &p_paths); void _export_profile(const String &p_path); - bool updating_features; + bool updating_features = false; void _class_list_item_selected(); void _class_list_item_edited(); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 0fef4597be..31f2f24066 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -214,7 +214,7 @@ void EditorFileDialog::update_dir() { if (dir_access->get_current_dir().is_network_share_path()) { _update_drives(false); drives->add_item(RTR("Network")); - drives->set_item_disabled(drives->get_item_count() - 1, true); + drives->set_item_disabled(-1, true); drives->select(drives->get_item_count() - 1); } else { drives->select(dir_access->get_current_drive()); @@ -314,8 +314,8 @@ void EditorFileDialog::_post_popup() { recentd.remove_at(i--); } else { recent->add_item(name, folder); - recent->set_item_metadata(recent->get_item_count() - 1, recentd[i]); - recent->set_item_icon_modulate(recent->get_item_count() - 1, folder_color); + recent->set_item_metadata(-1, recentd[i]); + recent->set_item_icon_modulate(-1, folder_color); } } EditorSettings::get_singleton()->set_recent_dirs(recentd); @@ -800,9 +800,9 @@ void EditorFileDialog::update_file_list() { item_list->add_item(dir_name); if (display_mode == DISPLAY_THUMBNAILS) { - item_list->set_item_icon(item_list->get_item_count() - 1, folder_thumbnail); + item_list->set_item_icon(-1, folder_thumbnail); } else { - item_list->set_item_icon(item_list->get_item_count() - 1, folder); + item_list->set_item_icon(-1, folder); } Dictionary d; @@ -810,8 +810,8 @@ void EditorFileDialog::update_file_list() { d["path"] = cdir.plus_file(dir_name); d["dir"] = true; - item_list->set_item_metadata(item_list->get_item_count() - 1, d); - item_list->set_item_icon_modulate(item_list->get_item_count() - 1, folder_color); + item_list->set_item_metadata(-1, d); + item_list->set_item_icon_modulate(-1, folder_color); dirs.pop_front(); } @@ -858,10 +858,10 @@ void EditorFileDialog::update_file_list() { if (get_icon_func) { Ref<Texture2D> icon = get_icon_func(cdir.plus_file(files.front()->get())); if (display_mode == DISPLAY_THUMBNAILS) { - item_list->set_item_icon(item_list->get_item_count() - 1, file_thumbnail); - item_list->set_item_tag_icon(item_list->get_item_count() - 1, icon); + item_list->set_item_icon(-1, file_thumbnail); + item_list->set_item_tag_icon(-1, icon); } else { - item_list->set_item_icon(item_list->get_item_count() - 1, icon); + item_list->set_item_icon(-1, icon); } } @@ -870,7 +870,7 @@ void EditorFileDialog::update_file_list() { d["dir"] = false; String fullpath = cdir.plus_file(files.front()->get()); d["path"] = fullpath; - item_list->set_item_metadata(item_list->get_item_count() - 1, d); + item_list->set_item_metadata(-1, d); if (display_mode == DISPLAY_THUMBNAILS && previews_enabled) { EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath, this, "_thumbnail_result", fullpath); @@ -1321,8 +1321,8 @@ void EditorFileDialog::_update_favorites() { continue; // We don't handle favorite files here. } - favorites->set_item_metadata(favorites->get_item_count() - 1, favorited[i]); - favorites->set_item_icon_modulate(favorites->get_item_count() - 1, folder_color); + favorites->set_item_metadata(-1, favorited[i]); + favorites->set_item_icon_modulate(-1, folder_color); if (setthis) { favorite->set_pressed(true); @@ -1471,9 +1471,9 @@ void EditorFileDialog::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access"); ADD_PROPERTY(PropertyInfo(Variant::INT, "display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List"), "set_display_mode", "get_display_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "file_mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_file_mode", "get_file_mode"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_dir", PROPERTY_HINT_DIR), "set_current_dir", "get_current_dir"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_file", PROPERTY_HINT_FILE, "*"), "set_current_file", "get_current_file"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_path"), "set_current_path", "get_current_path"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_dir", PROPERTY_HINT_DIR, "", PROPERTY_USAGE_NONE), "set_current_dir", "get_current_dir"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_file", PROPERTY_HINT_FILE, "*", PROPERTY_USAGE_NONE), "set_current_file", "get_current_file"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_current_path", "get_current_path"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_overwrite_warning"), "set_disable_overwrite_warning", "is_overwrite_warning_disabled"); @@ -1557,7 +1557,6 @@ EditorFileDialog::EditorFileDialog() { show_hidden_files = default_show_hidden_files; display_mode = default_display_mode; local_history_pos = 0; - disable_overwrite_warning = false; VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); @@ -1814,15 +1813,12 @@ EditorFileDialog::EditorFileDialog() { set_hide_on_ok(false); vbox = vbc; - invalidated = true; if (register_func) { register_func(this); } - previews_enabled = true; preview_wheel_timeout = 0; preview_wheel_index = 0; - preview_waiting = false; } EditorFileDialog::~EditorFileDialog() { diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 65a4c9e544..a747255ce8 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -135,8 +135,8 @@ private: Vector<String> filters; - bool previews_enabled; - bool preview_waiting; + bool previews_enabled = true; + bool preview_waiting = false; int preview_wheel_index; float preview_wheel_timeout; @@ -145,8 +145,8 @@ private: bool show_hidden_files; DisplayMode display_mode; - bool disable_overwrite_warning; - bool invalidated; + bool disable_overwrite_warning = false; + bool invalidated = true; void update_dir(); void update_file_name(); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 0c46cebec0..98ba3ae3d8 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -194,7 +194,6 @@ void EditorFileSystemDirectory::_bind_methods() { EditorFileSystemDirectory::EditorFileSystemDirectory() { modified_time = 0; parent = nullptr; - verified = false; } EditorFileSystemDirectory::~EditorFileSystemDirectory() { @@ -1094,12 +1093,11 @@ void EditorFileSystem::_delete_internal_files(String p_file) { if (FileAccess::exists(p_file + ".import")) { List<String> paths; ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); for (const String &E : paths) { da->remove(E); } da->remove(p_file + ".import"); - memdelete(da); } } @@ -2384,24 +2382,14 @@ EditorFileSystem::EditorFileSystem() { filesystem = memnew(EditorFileSystemDirectory); //like, empty filesystem->parent = nullptr; - scanning = false; - importing = false; - use_threads = true; new_filesystem = nullptr; - abort_scan = false; - scanning_changes = false; - scanning_changes_done = false; - // This should probably also work on Unix and use the string it returns for FAT32 or exFAT DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); using_fat32_or_exfat = (da->get_filesystem_type() == "FAT32" || da->get_filesystem_type() == "exFAT"); scan_total = 0; update_script_classes_queued.clear(); - first_scan = true; - scan_changes_pending = false; - revalidate_import_files = false; import_threads.init(); ResourceUID::get_singleton()->clear(); //will be updated on scan ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 0c1bfbca47..0ec0094030 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -47,7 +47,7 @@ class EditorFileSystemDirectory : public Object { String name; uint64_t modified_time; - bool verified; //used for checking changes + bool verified = false; //used for checking changes EditorFileSystemDirectory *parent; Vector<EditorFileSystemDirectory *> subdirs; @@ -132,20 +132,20 @@ class EditorFileSystem : public Node { EditorFileSystemDirectory::FileInfo *new_file = nullptr; }; - bool use_threads; + bool use_threads = true; Thread thread; static void _thread_func(void *_userdata); EditorFileSystemDirectory *new_filesystem; - bool abort_scan; - bool scanning; - bool importing; - bool first_scan; - bool scan_changes_pending; + bool abort_scan = false; + bool scanning = false; + bool importing = false; + bool first_scan = true; + bool scan_changes_pending = false; float scan_total; String filesystem_settings_version_for_import; - bool revalidate_import_files; + bool revalidate_import_files = false; void _scan_filesystem(); @@ -197,8 +197,8 @@ class EditorFileSystem : public Node { void _scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress); Thread thread_sources; - bool scanning_changes; - bool scanning_changes_done; + bool scanning_changes = false; + bool scanning_changes_done = false; static void _thread_func_sources(void *_userdata); diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index d80ee1d569..7b72e09bd7 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -64,8 +64,8 @@ m_name->add_data(FontTamilBold); \ m_name->add_data(FontTeluguBold); \ m_name->add_data(FontThaiBold); \ - m_name->add_data(FontJapanese); \ - m_name->add_data(FontFallback); + m_name->add_data(FontJapaneseBold); \ + m_name->add_data(FontFallbackBold); #define MAKE_DEFAULT_FONT(m_name, m_variations) \ Ref<Font> m_name; \ @@ -174,7 +174,7 @@ Ref<FontData> load_cached_internal_font(const uint8_t *p_data, size_t p_size, Te } void editor_register_fonts(Ref<Theme> p_theme) { - DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); /* Custom font */ @@ -206,7 +206,8 @@ void editor_register_fonts(Ref<Theme> p_theme) { break; } - int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; + const int default_font_size = int(EDITOR_GET("interface/editor/main_font_size")) * EDSCALE; + const float embolden_strength = 0.6; String custom_font_path = EditorSettings::get_singleton()->get("interface/editor/main_font"); Ref<FontData> CustomFont; @@ -226,6 +227,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { EditorSettings::get_singleton()->set_manually("interface/editor/main_font_bold", ""); } + if (CustomFont.is_valid() && !CustomFontBold.is_valid()) { + CustomFontBold = CustomFont->duplicate(); + CustomFontBold->set_embolden(embolden_strength); + } + /* Custom source code font */ String custom_font_path_source = EditorSettings::get_singleton()->get("interface/editor/code_font"); @@ -236,8 +242,6 @@ void editor_register_fonts(Ref<Theme> p_theme) { EditorSettings::get_singleton()->set_manually("interface/editor/code_font", ""); } - memdelete(dir); - /* Noto Sans */ Ref<FontData> DefaultFont = load_cached_internal_font(_font_NotoSans_Regular, _font_NotoSans_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning); @@ -270,6 +274,11 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<FontData> FontFallback = load_cached_internal_font(_font_DroidSansFallback, _font_DroidSansFallback_size, font_hinting, font_antialiased, true, font_subpixel_positioning); Ref<FontData> FontJapanese = load_cached_internal_font(_font_DroidSansJapanese, _font_DroidSansJapanese_size, font_hinting, font_antialiased, true, font_subpixel_positioning); + Ref<FontData> FontFallbackBold = FontFallback->duplicate(); + FontFallbackBold->set_embolden(embolden_strength); + Ref<FontData> FontJapaneseBold = FontJapanese->duplicate(); + FontJapaneseBold->set_embolden(embolden_strength); + /* Hack */ Ref<FontData> dfmono = load_cached_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_hinting, font_antialiased, true, font_subpixel_positioning); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 39c8509148..622547f0a8 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1897,8 +1897,6 @@ EditorHelp::EditorHelp() { class_desc->set_selection_enabled(true); - scroll_locked = false; - select_locked = false; class_desc->hide(); } diff --git a/editor/editor_help.h b/editor/editor_help.h index 10281a764c..b40d1709b6 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -98,7 +98,7 @@ class EditorHelp : public VBoxContainer { }; - bool select_locked; + bool select_locked = false; String prev_search; @@ -144,7 +144,7 @@ class EditorHelp : public VBoxContainer { void _help_callback(const String &p_topic); void _add_text(const String &p_bbcode); - bool scroll_locked; + bool scroll_locked = false; //void _button_pressed(int p_idx); void _add_type(const String &p_type, const String &p_enum = String()); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index eab62349d1..8e03c55712 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -180,8 +180,6 @@ void EditorHelpSearch::popup_dialog(const String &p_term) { } EditorHelpSearch::EditorHelpSearch() { - old_search = false; - set_hide_on_ok(false); set_title(TTR("Search Help")); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index 7d918d0c68..bf69fe1693 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -60,7 +60,7 @@ class EditorHelpSearch : public ConfirmationDialog { Button *hierarchy_button; OptionButton *filter_combo; Tree *results_tree; - bool old_search; + bool old_search = false; String old_term; class Runner; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index f5d318a227..9efd942a51 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -882,7 +882,7 @@ void EditorProperty::menu_option(int p_option) { emit_changed(property, InspectorDock::get_inspector_singleton()->get_property_clipboard()); } break; case MENU_COPY_PROPERTY_PATH: { - DisplayServer::get_singleton()->clipboard_set(property); + DisplayServer::get_singleton()->clipboard_set(property_path); } break; case MENU_PIN_VALUE: { emit_signal(SNAME("property_pinned"), property, !pinned); @@ -948,31 +948,13 @@ void EditorProperty::_bind_methods() { } EditorProperty::EditorProperty() { - draw_top_bg = true; object = nullptr; split_ratio = 0.5; - selectable = true; text_size = 0; - read_only = false; - checkable = false; - checked = false; - draw_warning = false; - keying = false; - deletable = false; - keying_hover = false; - revert_hover = false; - check_hover = false; - can_revert = false; - can_pin = false; - pin_hidden = false; - pinned = false; - use_folding = false; property_usage = 0; - selected = false; selected_focusable = -1; label_reference = nullptr; bottom_editor = nullptr; - delete_hover = false; menu = nullptr; set_process_unhandled_key_input(true); } @@ -2332,6 +2314,7 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, Ref<Edit if (F.properties.size() == 1) { //since it's one, associate: ep->property = F.properties[0]; + ep->property_path = property_prefix + F.properties[0]; ep->property_usage = 0; } @@ -2892,6 +2875,7 @@ void EditorInspector::update_tree() { if (F.properties.size() == 1) { //since it's one, associate: ep->property = F.properties[0]; + ep->property_path = property_prefix + F.properties[0]; ep->property_usage = p.usage; //and set label? } @@ -3675,25 +3659,11 @@ EditorInspector::EditorInspector() { add_child(main_vbox); set_horizontal_scroll_mode(SCROLL_MODE_DISABLED); - wide_editors = false; - show_categories = false; - hide_script = true; - use_doc_hints = false; - capitalize_paths = true; - use_filter = false; - autoclear = false; changing = 0; - use_folding = false; - update_all_pending = false; - update_tree_pending = false; - read_only = false; search_box = nullptr; - keying = false; _prop_edited = "property_edited"; set_process(false); property_focusable = -1; - sub_inspector = false; - deletable_properties = false; property_clipboard = Variant(); get_v_scroll_bar()->connect("value_changed", callable_mp(this, &EditorInspector::_vscroll_changed)); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 43f71740e3..3c482a07e7 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -68,15 +68,16 @@ private: friend class EditorInspector; Object *object; StringName property; + String property_path; int property_usage; - bool read_only; - bool checkable; - bool checked; - bool draw_warning; - bool keying; - bool deletable; + bool read_only = false; + bool checkable = false; + bool checked = false; + bool draw_warning = false; + bool keying = false; + bool deletable = false; Rect2 right_child_rect; Rect2 bottom_child_rect; @@ -90,19 +91,19 @@ private: Rect2 delete_rect; bool delete_hover = false; - bool can_revert; - bool can_pin; - bool pin_hidden; - bool pinned; + bool can_revert = false; + bool can_pin = false; + bool pin_hidden = false; + bool pinned = false; - bool use_folding; - bool draw_top_bg; + bool use_folding = false; + bool draw_top_bg = true; void _update_popup(); void _focusable_focused(int p_index); - bool selectable; - bool selected; + bool selectable = true; + bool selected = false; int selected_focusable; float split_ratio; @@ -442,23 +443,23 @@ class EditorInspector : public ScrollContainer { // LineEdit *search_box; - bool show_categories; - bool hide_script; - bool use_doc_hints; - bool capitalize_paths; - bool use_filter; - bool autoclear; - bool use_folding; + bool show_categories = false; + bool hide_script = true; + bool use_doc_hints = false; + bool capitalize_paths = true; + bool use_filter = false; + bool autoclear = false; + bool use_folding = false; int changing; - bool update_all_pending; - bool read_only; - bool keying; - bool sub_inspector; - bool wide_editors; - bool deletable_properties; + bool update_all_pending = false; + bool read_only = false; + bool keying = false; + bool sub_inspector = false; + bool wide_editors = false; + bool deletable_properties = false; float refresh_countdown; - bool update_tree_pending; + bool update_tree_pending = false; StringName _prop_edited; StringName property_selected; int property_focusable; diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index d9ba4139c2..54a55286e9 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -80,6 +80,11 @@ void EditorLog::_update_theme() { type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_icon(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"))); + type_filter_map[MSG_TYPE_STD]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_ERROR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_WARNING]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + type_filter_map[MSG_TYPE_EDITOR]->toggle_button->set_theme_type_variation("EditorLogFilterButton"); + clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons"))); copy_button->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); collapse_button->set_icon(get_theme_icon(SNAME("CombineLines"), SNAME("EditorIcons"))); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 17b219f8dc..b6a7e51807 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -146,6 +146,7 @@ #include "editor/plugins/editor_debugger_plugin.h" #include "editor/plugins/editor_preview_plugins.h" #include "editor/plugins/font_editor_plugin.h" +#include "editor/plugins/gdextension_export_plugin.h" #include "editor/plugins/gpu_particles_2d_editor_plugin.h" #include "editor/plugins/gpu_particles_3d_editor_plugin.h" #include "editor/plugins/gpu_particles_collision_sdf_editor_plugin.h" @@ -701,7 +702,7 @@ void EditorNode::_notification(int p_what) { } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + scene_tabs->set_tab_close_display_policy((TabBar::CloseButtonDisplayPolicy)EDITOR_GET("interface/scene_tabs/display_close_button").operator int()); bool theme_changed = EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") || @@ -5841,16 +5842,7 @@ EditorNode::EditorNode() { } singleton = this; - exiting = false; - dimmed = false; last_checked_version = 0; - changing_scene = false; - _initializing_addons = false; - docks_visible = true; - restoring_scenes = false; - cmdline_export_mode = false; - scene_distraction = false; - script_distraction = false; TranslationServer::get_singleton()->set_enabled(false); // load settings @@ -6025,7 +6017,6 @@ EditorNode::EditorNode() { ClassDB::set_class_enabled("RootMotionView", true); // defs here, use EDITOR_GET in logic - EDITOR_DEF_RST("interface/scene_tabs/always_show_close_button", false); EDITOR_DEF("interface/editor/save_on_focus_loss", false); EDITOR_DEF("interface/editor/show_update_spinner", false); EDITOR_DEF("interface/editor/update_continuously", false); @@ -6251,7 +6242,7 @@ EditorNode::EditorNode() { scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_alignment(TabBar::ALIGNMENT_LEFT); - scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + scene_tabs->set_tab_close_display_policy((TabBar::CloseButtonDisplayPolicy)EDITOR_GET("interface/scene_tabs/display_close_button").operator int()); scene_tabs->set_max_tab_width(int(EDITOR_GET("interface/scene_tabs/maximum_width")) * EDSCALE); scene_tabs->set_drag_to_rearrange_enabled(true); scene_tabs->connect("tab_changed", callable_mp(this, &EditorNode::_scene_tab_changed)); @@ -6301,7 +6292,7 @@ EditorNode::EditorNode() { scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); scene_root = memnew(SubViewport); - scene_root->set_embed_subwindows_hint(true); + scene_root->set_embedding_subwindows(true); scene_root->set_disable_3d(true); scene_root->set_disable_input(true); @@ -6516,7 +6507,7 @@ EditorNode::EditorNode() { ED_SHORTCUT_OVERRIDE("editor/take_screenshot", "macos", KeyModifierMask::CMD | Key::F12); p->add_shortcut(ED_GET_SHORTCUT("editor/take_screenshot"), EDITOR_SCREENSHOT); - p->set_item_tooltip(p->get_item_count() - 1, TTR("Screenshots are stored in the Editor Data/Settings Folder.")); + p->set_item_tooltip(-1, TTR("Screenshots are stored in the Editor Data/Settings Folder.")); ED_SHORTCUT_AND_COMMAND("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KeyModifierMask::SHIFT | Key::F11); ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "macos", KeyModifierMask::CMD | KeyModifierMask::CTRL | Key::F); @@ -7104,6 +7095,11 @@ EditorNode::EditorNode() { EditorExport::get_singleton()->add_export_plugin(export_text_to_binary_plugin); + Ref<GDExtensionExportPlugin> gdextension_export_plugin; + gdextension_export_plugin.instantiate(); + + EditorExport::get_singleton()->add_export_plugin(gdextension_export_plugin); + Ref<PackedSceneEditorTranslationParserPlugin> packed_scene_translation_parser_plugin; packed_scene_translation_parser_plugin.instantiate(); EditorTranslationParser::get_singleton()->add_parser(packed_scene_translation_parser_plugin, EditorTranslationParser::STANDARD); @@ -7112,9 +7108,6 @@ EditorNode::EditorNode() { current = nullptr; saving_resource = Ref<Resource>(); - reference_resource_mem = true; - save_external_resources_mem = true; - set_process(true); open_imported = memnew(ConfirmationDialog); @@ -7125,7 +7118,6 @@ EditorNode::EditorNode() { gui_base->add_child(open_imported); saved_version = 1; - unsaved_cache = true; _last_instantiated_scene = nullptr; quick_open = memnew(EditorQuickOpen); @@ -7139,10 +7131,7 @@ EditorNode::EditorNode() { _update_recent_scenes(); editor_data.restore_editor_global_states(); - convert_old = false; - opening_prev = false; set_process_unhandled_input(true); - _playing_edited = false; load_errors = memnew(RichTextLabel); load_error_dialog = memnew(AcceptDialog); @@ -7183,8 +7172,6 @@ EditorNode::EditorNode() { FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify); - waiting_for_first_scan = true; - print_handler.printfunc = _print_handler; print_handler.userdata = this; add_print_handler(&print_handler); diff --git a/editor/editor_node.h b/editor/editor_node.h index c05e6cd281..0b6dbaec49 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -263,8 +263,8 @@ private: TextureRect *tab_preview; int tab_closing; - bool exiting; - bool dimmed; + bool exiting = false; + bool dimmed = false; int old_split_ofs; VSplitContainer *top_split; @@ -380,15 +380,15 @@ private: Button *dock_tab_move_right; int dock_popup_selected; Timer *dock_drag_timer; - bool docks_visible; + bool docks_visible = true; HBoxContainer *tabbar_container; Button *distraction_free; Button *scene_tab_add; Control *scene_tab_add_ph; - bool scene_distraction; - bool script_distraction; + bool scene_distraction = false; + bool script_distraction = false; String _tmp_import_path; @@ -397,18 +397,15 @@ private: Object *current; Ref<Resource> saving_resource; - bool _playing_edited; + bool _playing_edited = false; String run_custom_filename; - bool reference_resource_mem; - bool save_external_resources_mem; + bool reference_resource_mem = true; uint64_t saved_version; uint64_t last_checked_version; - bool unsaved_cache; + bool unsaved_cache = true; String open_navigate; - bool changing_scene; - bool waiting_for_first_scan; - - bool waiting_for_sources_changed; + bool changing_scene = false; + bool waiting_for_first_scan = true; uint64_t update_spinner_step_msec; uint64_t update_spinner_step_frame; @@ -457,7 +454,7 @@ private: String external_file; List<String> previous_scenes; - bool opening_prev; + bool opening_prev = false; void _dialog_action(String p_file); @@ -534,7 +531,7 @@ private: void _exit_editor(int p_exit_code); - bool convert_old; + bool convert_old = false; virtual void unhandled_input(const Ref<InputEvent> &p_event) override; @@ -551,7 +548,7 @@ private: Map<String, Ref<Texture2D>> icon_type_cache; void _build_icon_type_cache(); - bool _initializing_addons; + bool _initializing_addons = false; Map<String, EditorPlugin *> plugin_addons; static Ref<Texture2D> _file_dialog_get_icon(const String &p_path); @@ -587,7 +584,7 @@ private: bool pack_only = false; } export_defer; - bool cmdline_export_mode; + bool cmdline_export_mode = false; static EditorNode *singleton; @@ -627,7 +624,7 @@ private: void _update_dock_slots_visibility(); void _dock_tab_changed(int p_tab); - bool restoring_scenes; + bool restoring_scenes = false; void _save_open_scenes_to_config(Ref<ConfigFile> p_layout, const String &p_section); void _load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section); diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 401414ae50..b6f48c7536 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -240,6 +240,4 @@ EditorPluginSettings::EditorPluginSettings() { mc->set_h_size_flags(SIZE_EXPAND_FILL); add_child(mc); - - updating = false; } diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index 4648d105f7..c239b735de 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -48,7 +48,7 @@ class EditorPluginSettings : public VBoxContainer { Button *create_plugin; Button *update_list; Tree *plugin_list; - bool updating; + bool updating = false; void _plugin_activity_changed(); void _create_clicked(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 1a4d507eef..b495d29911 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -110,9 +110,6 @@ EditorPropertyText::EditorPropertyText() { add_focusable(text); text->connect("text_changed", callable_mp(this, &EditorPropertyText::_text_changed)); text->connect("text_submitted", callable_mp(this, &EditorPropertyText::_text_submitted)); - - string_name = false; - updating = false; } ///////////////////// MULTILINE TEXT ///////////////////////// @@ -500,9 +497,6 @@ EditorPropertyPath::EditorPropertyPath() { add_focusable(path); dialog = nullptr; path_edit->connect("pressed", callable_mp(this, &EditorPropertyPath::_path_pressed)); - folder = false; - global = false; - save_mode = false; } ///////////////////// CLASS NAME ///////////////////////// @@ -1278,7 +1272,6 @@ EditorPropertyInteger::EditorPropertyInteger() { add_child(spin); add_focusable(spin); spin->connect("value_changed", callable_mp(this, &EditorPropertyInteger::_value_changed)); - setting = false; } ///////////////////// OBJECT ID ///////////////////////// @@ -1587,10 +1580,6 @@ EditorPropertyEasing::EditorPropertyEasing() { spin->get_line_edit()->connect("focus_exited", callable_mp(this, &EditorPropertyEasing::_spin_focus_exited)); spin->hide(); add_child(spin); - - dragging = false; - flip = false; - full = false; } ///////////////////// VECTOR2 ///////////////////////// @@ -1680,7 +1669,6 @@ EditorPropertyVector2::EditorPropertyVector2(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// RECT2 ///////////////////////// @@ -1784,7 +1772,6 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// VECTOR3 ///////////////////////// @@ -1993,7 +1980,6 @@ EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// RECT2i ///////////////////////// @@ -2097,7 +2083,6 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// VECTOR3i ///////////////////////// @@ -2188,7 +2173,6 @@ EditorPropertyVector3i::EditorPropertyVector3i(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// PLANE ///////////////////////// @@ -2282,7 +2266,6 @@ EditorPropertyPlane::EditorPropertyPlane(bool p_force_wide) { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// QUATERNION ///////////////////////// @@ -2373,7 +2356,6 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { if (!horizontal) { set_label_reference(spin[0]); //show text and buttons around this } - setting = false; } ///////////////////// AABB ///////////////////////// @@ -2457,7 +2439,6 @@ EditorPropertyAABB::EditorPropertyAABB() { spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyAABB::_value_changed), varray(desc[i])); } set_bottom_editor(g); - setting = false; } ///////////////////// TRANSFORM2D ///////////////////////// @@ -2547,7 +2528,6 @@ EditorPropertyTransform2D::EditorPropertyTransform2D(bool p_include_origin) { spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyTransform2D::_value_changed), varray(desc[i])); } set_bottom_editor(g); - setting = false; } ///////////////////// BASIS ///////////////////////// @@ -2636,7 +2616,6 @@ EditorPropertyBasis::EditorPropertyBasis() { spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyBasis::_value_changed), varray(desc[i])); } set_bottom_editor(g); - setting = false; } ///////////////////// TRANSFORM ///////////////////////// @@ -2733,7 +2712,6 @@ EditorPropertyTransform3D::EditorPropertyTransform3D() { spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyTransform3D::_value_changed), varray(desc[i])); } set_bottom_editor(g); - setting = false; } ////////////// COLOR PICKER ////////////////////// @@ -2969,7 +2947,6 @@ EditorPropertyNodePath::EditorPropertyNodePath() { clear->set_flat(true); clear->connect("pressed", callable_mp(this, &EditorPropertyNodePath::_node_clear)); hbc->add_child(clear); - use_path_from_scene_root = false; scene_tree = nullptr; //do not allocate unnecessarily } @@ -3738,8 +3715,13 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::DICTIONARY: { - EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary); - return editor; + if (p_hint == PROPERTY_HINT_LOCALIZABLE_STRING) { + EditorPropertyLocalizableString *editor = memnew(EditorPropertyLocalizableString); + return editor; + } else { + EditorPropertyDictionary *editor = memnew(EditorPropertyDictionary); + return editor; + } } break; case Variant::ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 9a16a78ff8..c21e0e0b4d 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -54,8 +54,8 @@ class EditorPropertyText : public EditorProperty { GDCLASS(EditorPropertyText, EditorProperty); LineEdit *text; - bool updating; - bool string_name; + bool updating = false; + bool string_name = false; void _text_changed(const String &p_string); void _text_submitted(const String &p_string); @@ -131,9 +131,9 @@ public: class EditorPropertyPath : public EditorProperty { GDCLASS(EditorPropertyPath, EditorProperty); Vector<String> extensions; - bool folder; - bool global; - bool save_mode; + bool folder = false; + bool global = false; + bool save_mode = false; EditorFileDialog *dialog; LineEdit *path; Button *path_edit; @@ -359,7 +359,7 @@ public: class EditorPropertyInteger : public EditorProperty { GDCLASS(EditorPropertyInteger, EditorProperty); EditorSpinSlider *spin; - bool setting; + bool setting = false; void _value_changed(int64_t p_val); protected: @@ -410,11 +410,11 @@ class EditorPropertyEasing : public EditorProperty { Control *easing_draw; PopupMenu *preset; EditorSpinSlider *spin; - bool setting; + bool setting = false; - bool dragging; - bool full; - bool flip; + bool dragging = false; + bool full = false; + bool flip = false; enum { EASING_ZERO, @@ -450,7 +450,7 @@ public: class EditorPropertyVector2 : public EditorProperty { GDCLASS(EditorPropertyVector2, EditorProperty); EditorSpinSlider *spin[2]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -467,7 +467,7 @@ public: class EditorPropertyRect2 : public EditorProperty { GDCLASS(EditorPropertyRect2, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -504,7 +504,7 @@ public: class EditorPropertyVector2i : public EditorProperty { GDCLASS(EditorPropertyVector2i, EditorProperty); EditorSpinSlider *spin[2]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -521,7 +521,7 @@ public: class EditorPropertyRect2i : public EditorProperty { GDCLASS(EditorPropertyRect2i, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -538,7 +538,7 @@ public: class EditorPropertyVector3i : public EditorProperty { GDCLASS(EditorPropertyVector3i, EditorProperty); EditorSpinSlider *spin[3]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -555,7 +555,7 @@ public: class EditorPropertyPlane : public EditorProperty { GDCLASS(EditorPropertyPlane, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -572,7 +572,7 @@ public: class EditorPropertyQuaternion : public EditorProperty { GDCLASS(EditorPropertyQuaternion, EditorProperty); EditorSpinSlider *spin[4]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -589,7 +589,7 @@ public: class EditorPropertyAABB : public EditorProperty { GDCLASS(EditorPropertyAABB, EditorProperty); EditorSpinSlider *spin[6]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -606,7 +606,7 @@ public: class EditorPropertyTransform2D : public EditorProperty { GDCLASS(EditorPropertyTransform2D, EditorProperty); EditorSpinSlider *spin[6]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -623,7 +623,7 @@ public: class EditorPropertyBasis : public EditorProperty { GDCLASS(EditorPropertyBasis, EditorProperty); EditorSpinSlider *spin[9]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -640,7 +640,7 @@ public: class EditorPropertyTransform3D : public EditorProperty { GDCLASS(EditorPropertyTransform3D, EditorProperty); EditorSpinSlider *spin[12]; - bool setting; + bool setting = false; void _value_changed(double p_val, const String &p_name); protected: @@ -681,7 +681,7 @@ class EditorPropertyNodePath : public EditorProperty { Button *clear; SceneTreeDialog *scene_tree; NodePath base_hint; - bool use_path_from_scene_root; + bool use_path_from_scene_root = false; Vector<StringName> valid_types; void _node_selected(const NodePath &p_path); diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index d354be9af5..f59ba66862 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -253,6 +253,7 @@ void EditorPropertyArray::update_property() { if (vbox) { set_bottom_editor(nullptr); memdelete(vbox); + button_add_item = nullptr; vbox = nullptr; } return; @@ -408,6 +409,7 @@ void EditorPropertyArray::update_property() { if (vbox) { set_bottom_editor(nullptr); memdelete(vbox); + button_add_item = nullptr; vbox = nullptr; } } @@ -714,7 +716,6 @@ EditorPropertyArray::EditorPropertyArray() { size_slider = nullptr; button_add_item = nullptr; paginator = nullptr; - updating = false; change_type = memnew(PopupMenu); add_child(change_type); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyArray::_change_type_menu)); @@ -723,8 +724,6 @@ EditorPropertyArray::EditorPropertyArray() { subtype = Variant::NIL; subtype_hint = PROPERTY_HINT_NONE; subtype_hint_string = ""; - - dropping = false; } ///////////////////// DICTIONARY /////////////////////////// @@ -742,7 +741,7 @@ void EditorPropertyDictionary::_property_changed(const String &p_property, Varia emit_changed(get_edited_property(), dict, "", true); - dict = dict.duplicate(); // Duplicate, so undo/redo works better\. + dict = dict.duplicate(); // Duplicate, so undo/redo works better. object->set_dict(dict); } } @@ -805,7 +804,7 @@ void EditorPropertyDictionary::_change_type_menu(int p_index) { emit_changed(get_edited_property(), dict, "", false); - dict = dict.duplicate(); // Duplicate, so undo/redo works better\. + dict = dict.duplicate(); // Duplicate, so undo/redo works better. object->set_dict(dict); update_property(); } @@ -814,11 +813,12 @@ void EditorPropertyDictionary::update_property() { Variant updated_val = get_edited_object()->get(get_edited_property()); if (updated_val.get_type() == Variant::NIL) { - edit->set_text("Dictionary (Nil)"); // This provides symmetry with the array property. + edit->set_text(TTR("Dictionary (Nil)")); // This provides symmetry with the array property. edit->set_pressed(false); if (vbox) { set_bottom_editor(nullptr); memdelete(vbox); + button_add_item = nullptr; vbox = nullptr; } return; @@ -826,7 +826,7 @@ void EditorPropertyDictionary::update_property() { Dictionary dict = updated_val; - edit->set_text("Dictionary (size " + itos(dict.size()) + ")"); + edit->set_text(vformat(TTR("Dictionary (size %d)"), dict.size())); bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property()); if (edit->is_pressed() != unfolded) { @@ -1144,6 +1144,7 @@ void EditorPropertyDictionary::update_property() { if (vbox) { set_bottom_editor(nullptr); memdelete(vbox); + button_add_item = nullptr; vbox = nullptr; } } @@ -1210,9 +1211,232 @@ EditorPropertyDictionary::EditorPropertyDictionary() { vbox = nullptr; button_add_item = nullptr; paginator = nullptr; - updating = false; change_type = memnew(PopupMenu); add_child(change_type); change_type->connect("id_pressed", callable_mp(this, &EditorPropertyDictionary::_change_type_menu)); changing_type_index = -1; } + +///////////////////// LOCALIZABLE STRING /////////////////////////// + +void EditorPropertyLocalizableString::_property_changed(const String &p_property, Variant p_value, const String &p_name, bool p_changing) { + if (p_property.begins_with("indices")) { + int index = p_property.get_slice("/", 1).to_int(); + Dictionary dict = object->get_dict(); + Variant key = dict.get_key_at_index(index); + dict[key] = p_value; + + emit_changed(get_edited_property(), dict, "", true); + + dict = dict.duplicate(); // Duplicate, so undo/redo works better. + object->set_dict(dict); + } +} + +void EditorPropertyLocalizableString::_add_locale_popup() { + locale_select->popup_locale_dialog(); +} + +void EditorPropertyLocalizableString::_add_locale(const String &p_locale) { + Dictionary dict = object->get_dict(); + + object->set_new_item_key(p_locale); + object->set_new_item_value(String()); + dict[object->get_new_item_key()] = object->get_new_item_value(); + + emit_changed(get_edited_property(), dict, "", false); + + dict = dict.duplicate(); // Duplicate, so undo/redo works better. + object->set_dict(dict); + update_property(); +} + +void EditorPropertyLocalizableString::_remove_item(Object *p_button, int p_index) { + Dictionary dict = object->get_dict(); + + Variant key = dict.get_key_at_index(p_index); + dict.erase(key); + + emit_changed(get_edited_property(), dict, "", false); + + dict = dict.duplicate(); // Duplicate, so undo/redo works better. + object->set_dict(dict); + update_property(); +} + +void EditorPropertyLocalizableString::update_property() { + Variant updated_val = get_edited_object()->get(get_edited_property()); + + if (updated_val.get_type() == Variant::NIL) { + edit->set_text(TTR("Localizable String (Nil)")); // This provides symmetry with the array property. + edit->set_pressed(false); + if (vbox) { + set_bottom_editor(nullptr); + memdelete(vbox); + button_add_item = nullptr; + vbox = nullptr; + } + return; + } + + Dictionary dict = updated_val; + + edit->set_text(vformat(TTR("Localizable String (size %d)"), dict.size())); + + bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property()); + if (edit->is_pressed() != unfolded) { + edit->set_pressed(unfolded); + } + + if (unfolded) { + updating = true; + + if (!vbox) { + vbox = memnew(VBoxContainer); + add_child(vbox); + set_bottom_editor(vbox); + + property_vbox = memnew(VBoxContainer); + property_vbox->set_h_size_flags(SIZE_EXPAND_FILL); + vbox->add_child(property_vbox); + + paginator = memnew(EditorPaginator); + paginator->connect("page_changed", callable_mp(this, &EditorPropertyLocalizableString::_page_changed)); + vbox->add_child(paginator); + } else { + // Queue children for deletion, deleting immediately might cause errors. + for (int i = property_vbox->get_child_count() - 1; i >= 0; i--) { + property_vbox->get_child(i)->queue_delete(); + } + } + + int size = dict.size(); + + int max_page = MAX(0, size - 1) / page_length; + page_index = MIN(page_index, max_page); + + paginator->update(page_index, max_page); + paginator->set_visible(max_page > 0); + + int offset = page_index * page_length; + + int amount = MIN(size - offset, page_length); + + dict = dict.duplicate(); + + object->set_dict(dict); + + for (int i = 0; i < amount; i++) { + String prop_name; + Variant key; + Variant value; + + prop_name = "indices/" + itos(i + offset); + key = dict.get_key_at_index(i + offset); + value = dict.get_value_at_index(i + offset); + + EditorProperty *prop = memnew(EditorPropertyText); + + prop->set_object_and_property(object.ptr(), prop_name); + int remove_index = 0; + + String cs = key.get_construct_string(); + prop->set_label(cs); + prop->set_tooltip(cs); + remove_index = i + offset; + + prop->set_selectable(false); + prop->connect("property_changed", callable_mp(this, &EditorPropertyLocalizableString::_property_changed)); + prop->connect("object_id_selected", callable_mp(this, &EditorPropertyLocalizableString::_object_id_selected)); + + HBoxContainer *hbox = memnew(HBoxContainer); + property_vbox->add_child(hbox); + hbox->add_child(prop); + prop->set_h_size_flags(SIZE_EXPAND_FILL); + Button *edit = memnew(Button); + edit->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + hbox->add_child(edit); + edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_remove_item), varray(edit, remove_index)); + + prop->update_property(); + } + + if (page_index == max_page) { + button_add_item = memnew(Button); + button_add_item->set_text(TTR("Add Translation")); + button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + button_add_item->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup)); + property_vbox->add_child(button_add_item); + } + + updating = false; + + } else { + if (vbox) { + set_bottom_editor(nullptr); + memdelete(vbox); + button_add_item = nullptr; + vbox = nullptr; + } + } +} + +void EditorPropertyLocalizableString::_object_id_selected(const StringName &p_property, ObjectID p_id) { + emit_signal(SNAME("object_id_selected"), p_property, p_id); +} + +void EditorPropertyLocalizableString::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_THEME_CHANGED: + case NOTIFICATION_ENTER_TREE: { + if (Object::cast_to<Button>(button_add_item)) { + button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons"))); + } + } break; + } +} + +void EditorPropertyLocalizableString::_edit_pressed() { + Variant prop_val = get_edited_object()->get(get_edited_property()); + if (prop_val.get_type() == Variant::NIL) { + Callable::CallError ce; + Variant::construct(Variant::DICTIONARY, prop_val, nullptr, 0, ce); + get_edited_object()->set(get_edited_property(), prop_val); + } + + get_edited_object()->editor_set_section_unfold(get_edited_property(), edit->is_pressed()); + update_property(); +} + +void EditorPropertyLocalizableString::_page_changed(int p_page) { + if (updating) { + return; + } + page_index = p_page; + update_property(); +} + +void EditorPropertyLocalizableString::_bind_methods() { +} + +EditorPropertyLocalizableString::EditorPropertyLocalizableString() { + object.instantiate(); + page_length = int(EDITOR_GET("interface/inspector/max_array_dictionary_items_per_page")); + + edit = memnew(Button); + edit->set_h_size_flags(SIZE_EXPAND_FILL); + edit->set_clip_text(true); + edit->connect("pressed", callable_mp(this, &EditorPropertyLocalizableString::_edit_pressed)); + edit->set_toggle_mode(true); + add_child(edit); + add_focusable(edit); + + vbox = nullptr; + button_add_item = nullptr; + paginator = nullptr; + updating = false; + + locale_select = memnew(EditorLocaleDialog); + locale_select->connect("locale_selected", callable_mp(this, &EditorPropertyLocalizableString::_add_locale)); + add_child(locale_select); +} diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 292de6d6db..3d9fe90b20 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -32,6 +32,7 @@ #define EDITOR_PROPERTIES_ARRAY_DICT_H #include "editor/editor_inspector.h" +#include "editor/editor_locale_dialog.h" #include "editor/editor_spin_slider.h" #include "editor/filesystem_dock.h" #include "scene/gui/button.h" @@ -80,8 +81,8 @@ class EditorPropertyArray : public EditorProperty { GDCLASS(EditorPropertyArray, EditorProperty); PopupMenu *change_type; - bool updating; - bool dropping; + bool updating = false; + bool dropping = false; Ref<EditorPropertyArrayObject> object; int page_length = 20; @@ -138,7 +139,7 @@ class EditorPropertyDictionary : public EditorProperty { GDCLASS(EditorPropertyDictionary, EditorProperty); PopupMenu *change_type; - bool updating; + bool updating = false; Ref<EditorPropertyDictionaryObject> object; int page_length = 20; @@ -169,4 +170,39 @@ public: EditorPropertyDictionary(); }; +class EditorPropertyLocalizableString : public EditorProperty { + GDCLASS(EditorPropertyLocalizableString, EditorProperty); + + EditorLocaleDialog *locale_select; + + bool updating; + + Ref<EditorPropertyDictionaryObject> object; + int page_length = 20; + int page_index = 0; + Button *edit; + VBoxContainer *vbox; + VBoxContainer *property_vbox; + EditorSpinSlider *size_slider; + Button *button_add_item; + EditorPaginator *paginator; + + void _page_changed(int p_page); + void _edit_pressed(); + void _remove_item(Object *p_button, int p_index); + void _property_changed(const String &p_property, Variant p_value, const String &p_name = "", bool p_changing = false); + + void _add_locale_popup(); + void _add_locale(const String &p_locale); + void _object_id_selected(const StringName &p_property, ObjectID p_id); + +protected: + static void _bind_methods(); + void _notification(int p_what); + +public: + virtual void update_property() override; + EditorPropertyLocalizableString(); +}; + #endif // EDITOR_PROPERTIES_ARRAY_DICT_H diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index 38003ab2f4..20327cb867 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -69,7 +69,9 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { // The map name and value definition format should be kept synced with the regex. capitalize_string_remaps["2d"] = "2D"; capitalize_string_remaps["3d"] = "3D"; + capitalize_string_remaps["Aa"] = "AA"; capitalize_string_remaps["Adb"] = "ADB"; + capitalize_string_remaps["Ao"] = "AO"; capitalize_string_remaps["Bptc"] = "BPTC"; capitalize_string_remaps["Bvh"] = "BVH"; capitalize_string_remaps["Csg"] = "CSG"; @@ -81,21 +83,27 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["Fbx"] = "FBX"; capitalize_string_remaps["Fps"] = "FPS"; capitalize_string_remaps["Fov"] = "FOV"; + capitalize_string_remaps["Fsr"] = "FSR"; capitalize_string_remaps["Fs"] = "FS"; capitalize_string_remaps["Fxaa"] = "FXAA"; capitalize_string_remaps["Ggx"] = "GGX"; + capitalize_string_remaps["Gi"] = "GI"; capitalize_string_remaps["Gdscript"] = "GDScript"; capitalize_string_remaps["Gles 2"] = "GLES2"; capitalize_string_remaps["Gles 3"] = "GLES3"; - capitalize_string_remaps["Gi Probe"] = "GI Probe"; + capitalize_string_remaps["Gpu"] = "GPU"; + capitalize_string_remaps["Gui"] = "GUI"; capitalize_string_remaps["Hdr"] = "HDR"; capitalize_string_remaps["Hidpi"] = "hiDPI"; + capitalize_string_remaps["Http"] = "HTTP"; capitalize_string_remaps["Ik"] = "IK"; capitalize_string_remaps["Ios"] = "iOS"; capitalize_string_remaps["Kb"] = "KB"; + capitalize_string_remaps["Lod"] = "LOD"; capitalize_string_remaps["Msaa"] = "MSAA"; capitalize_string_remaps["Macos"] = "macOS"; capitalize_string_remaps["Opentype"] = "OpenType"; + capitalize_string_remaps["Openxr"] = "OpenXR"; capitalize_string_remaps["Png"] = "PNG"; capitalize_string_remaps["Pvs"] = "PVS"; capitalize_string_remaps["Pvrtc"] = "PVRTC"; @@ -104,16 +112,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["Srgb"] = "sRGB"; capitalize_string_remaps["Ssao"] = "SSAO"; capitalize_string_remaps["Ssl"] = "SSL"; + capitalize_string_remaps["Ssil"] = "SSIL"; capitalize_string_remaps["Ssh"] = "SSH"; + capitalize_string_remaps["Sdf"] = "SDF"; capitalize_string_remaps["Sdk"] = "SDK"; capitalize_string_remaps["Tcp"] = "TCP"; + capitalize_string_remaps["Url"] = "URL"; capitalize_string_remaps["Uv 1"] = "UV1"; capitalize_string_remaps["Uv 2"] = "UV2"; + capitalize_string_remaps["Uv"] = "UV"; + capitalize_string_remaps["Uwp"] = "UWP"; capitalize_string_remaps["Vram"] = "VRAM"; capitalize_string_remaps["Vsync"] = "V-Sync"; capitalize_string_remaps["Vector 2"] = "Vector2"; + capitalize_string_remaps["Webp"] = "WebP"; capitalize_string_remaps["Webrtc"] = "WebRTC"; capitalize_string_remaps["Websocket"] = "WebSocket"; + capitalize_string_remaps["Xr"] = "XR"; } EditorPropertyNameProcessor::~EditorPropertyNameProcessor() { diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 85d304ec5d..5db7b8673f 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -83,7 +83,7 @@ void EditorRunNative::_notification(int p_what) { mb->set_tooltip(eep->get_options_tooltip()); for (int i = 0; i < dc; i++) { mb->get_popup()->add_icon_item(eep->get_option_icon(i), eep->get_option_label(i)); - mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_option_tooltip(i)); + mb->get_popup()->set_item_tooltip(-1, eep->get_option_tooltip(i)); } } } @@ -168,7 +168,6 @@ bool EditorRunNative::is_deploy_debug_remote_enabled() const { EditorRunNative::EditorRunNative() { set_process(true); - first = true; resume_idx = 0; resume_platform = 0; } diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h index 199d094e55..4cb5779350 100644 --- a/editor/editor_run_native.h +++ b/editor/editor_run_native.h @@ -38,7 +38,7 @@ class EditorRunNative : public HBoxContainer { GDCLASS(EditorRunNative, HBoxContainer); Map<int, MenuButton *> menus; - bool first; + bool first = true; int resume_idx; int resume_platform; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 45685b8fb2..2d80fe85f8 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -460,6 +460,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "interface/theme/custom_theme", "", "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) // Scene tabs + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/scene_tabs/display_close_button", 1, "Never,If Tab Active,Always"); // TabBar::CloseButtonDisplayPolicy _initial_set("interface/scene_tabs/show_thumbnail_on_hover", true); EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_RANGE, "interface/scene_tabs/maximum_width", 350, "0,9999,1", PROPERTY_USAGE_DEFAULT) _initial_set("interface/scene_tabs/show_script_button", false); @@ -1222,7 +1223,7 @@ bool EditorSettings::is_dark_theme() { void EditorSettings::list_text_editor_themes() { String themes = "Default,Godot 2,Custom"; - DirAccess *d = DirAccess::open(get_text_editor_themes_dir()); + DirAccessRef d = DirAccess::open(get_text_editor_themes_dir()); if (d) { List<String> custom_themes; d->list_dir_begin(); @@ -1234,7 +1235,6 @@ void EditorSettings::list_text_editor_themes() { file = d->get_next(); } d->list_dir_end(); - memdelete(d); custom_themes.sort(); for (const String &E : custom_themes) { @@ -1289,10 +1289,9 @@ bool EditorSettings::import_text_editor_theme(String p_file) { return false; } - DirAccess *d = DirAccess::open(get_text_editor_themes_dir()); + DirAccessRef d = DirAccess::open(get_text_editor_themes_dir()); if (d) { d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file())); - memdelete(d); return true; } } @@ -1342,7 +1341,7 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c if (!p_custom_path.is_empty()) { template_dir = p_custom_path; } - DirAccess *d = DirAccess::open(template_dir); + DirAccessRef d = DirAccess::open(template_dir); if (d) { d->list_dir_begin(); String file = d->get_next(); @@ -1353,7 +1352,6 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c file = d->get_next(); } d->list_dir_end(); - memdelete(d); } return templates; } @@ -1663,8 +1661,6 @@ void EditorSettings::_bind_methods() { EditorSettings::EditorSettings() { last_order = 0; - optimize_save = true; - save_changed_setting = true; _load_defaults(); } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 65723a24f8..4f25259a01 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -92,8 +92,8 @@ private: Vector<String> favorites; Vector<String> recent_dirs; - bool save_changed_setting; - bool optimize_save; //do not save stuff that came from config but was not set from engine + bool save_changed_setting = true; + bool optimize_save = true; //do not save stuff that came from config but was not set from engine bool _set(const StringName &p_name, const Variant &p_value); bool _set_only(const StringName &p_name, const Variant &p_value); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 1ec6d4a3a6..eb3cf08578 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -764,8 +764,6 @@ EditorSettingsDialog::EditorSettingsDialog() { add_child(timer); EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorSettingsDialog::_settings_changed)); get_ok_button()->set_text(TTR("Close")); - - updating = false; } EditorSettingsDialog::~EditorSettingsDialog() { diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h index 4b90506b4b..e3139bb07a 100644 --- a/editor/editor_settings_dialog.h +++ b/editor/editor_settings_dialog.h @@ -43,7 +43,7 @@ class EditorSettingsDialog : public AcceptDialog { GDCLASS(EditorSettingsDialog, AcceptDialog); - bool updating; + bool updating = false; TabContainer *tabs; Control *tab_general; diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 509a316ef3..2fd4f3d6e6 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -443,6 +443,7 @@ void EditorSpinSlider::_notification(int p_what) { case NOTIFICATION_WM_WINDOW_FOCUS_IN: case NOTIFICATION_WM_WINDOW_FOCUS_OUT: + case NOTIFICATION_WM_CLOSE_REQUEST: case NOTIFICATION_EXIT_TREE: { if (grabbing_spinner) { grabber->hide(); @@ -655,14 +656,10 @@ void EditorSpinSlider::_ensure_input_popup() { } EditorSpinSlider::EditorSpinSlider() { - flat = false; - grabbing_spinner_attempt = false; - grabbing_spinner = false; grabbing_spinner_dist_cache = 0; pre_grab_value = 0; set_focus_mode(FOCUS_ALL); updown_offset = -1; - hover_updown = false; grabber = memnew(TextureRect); add_child(grabber); grabber->hide(); @@ -671,12 +668,5 @@ EditorSpinSlider::EditorSpinSlider() { grabber->connect("mouse_entered", callable_mp(this, &EditorSpinSlider::_grabber_mouse_entered)); grabber->connect("mouse_exited", callable_mp(this, &EditorSpinSlider::_grabber_mouse_exited)); grabber->connect("gui_input", callable_mp(this, &EditorSpinSlider::_grabber_gui_input)); - mouse_over_spin = false; - mouse_over_grabber = false; - mousewheel_over_grabber = false; - grabbing_grabber = false; grabber_range = 1; - value_input_just_closed = false; - hide_slider = false; - read_only = false; } diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 4e52980804..405c3bfc22 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -41,24 +41,24 @@ class EditorSpinSlider : public Range { String label; String suffix; int updown_offset; - bool hover_updown; - bool mouse_hover; + bool hover_updown = false; + bool mouse_hover = false; TextureRect *grabber; int grabber_range; - bool mouse_over_spin; - bool mouse_over_grabber; - bool mousewheel_over_grabber; + bool mouse_over_spin = false; + bool mouse_over_grabber = false; + bool mousewheel_over_grabber = false; - bool grabbing_grabber; + bool grabbing_grabber = false; int grabbing_from; float grabbing_ratio; - bool grabbing_spinner_attempt; - bool grabbing_spinner; + bool grabbing_spinner_attempt = false; + bool grabbing_spinner = false; - bool read_only; + bool read_only = false; float grabbing_spinner_dist_cache; Vector2 grabbing_spinner_mouse_pos; double pre_grab_value; @@ -73,8 +73,8 @@ class EditorSpinSlider : public Range { void _value_input_submitted(const String &); void _value_focus_exited(); void _value_input_gui_input(const Ref<InputEvent> &p_event); - bool hide_slider; - bool flat; + bool hide_slider = false; + bool flat = false; void _evaluate_input_text(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7eceebb38b..28feac5d2b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -702,6 +702,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("icon_focus_color", "Button", icon_focus_color); theme->set_color("icon_pressed_color", "Button", icon_pressed_color); + // Variation for Editor Log filter buttons + theme->set_type_variation("EditorLogFilterButton", "Button"); + // When pressed, don't tint the icons with the accent color, just leave them normal. + theme->set_color("icon_pressed_color", "EditorLogFilterButton", icon_normal_color); + // When unpressed, dim the icons. + theme->set_color("icon_normal_color", "EditorLogFilterButton", font_disabled_color); + // When pressed, add a small bottom border to the buttons to better show their active state, + // similar to active tabs. + Ref<StyleBoxFlat> editor_log_button_pressed = style_widget_pressed->duplicate(); + editor_log_button_pressed->set_border_width(SIDE_BOTTOM, 2 * EDSCALE); + editor_log_button_pressed->set_border_color(accent_color); + theme->set_stylebox("pressed", "EditorLogFilterButton", editor_log_button_pressed); + // OptionButton theme->set_stylebox("focus", "OptionButton", style_widget_focus); @@ -1519,6 +1532,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("Information3dViewport", "EditorStyles", style_info_3d_viewport); // Asset Library. + theme->set_stylebox("bg", "AssetLib", style_empty); theme->set_stylebox("panel", "AssetLib", style_content_panel); theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5)); theme->set_icon("dismiss", "AssetLib", theme->get_icon(SNAME("Close"), SNAME("EditorIcons"))); diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 97611d9786..0954779300 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -153,7 +153,6 @@ String EditorVCSInterface::get_vcs_name() { } EditorVCSInterface::EditorVCSInterface() { - is_initialized = false; } EditorVCSInterface::~EditorVCSInterface() { diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index 091936dadc..487625e84c 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -38,7 +38,7 @@ class EditorVCSInterface : public Object { GDCLASS(EditorVCSInterface, Object) - bool is_initialized; + bool is_initialized = false; protected: static EditorVCSInterface *singleton; diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 0a8d35aff1..df3e73267e 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -44,7 +44,7 @@ void ExportTemplateManager::_update_template_status() { // Fetch installed templates from the file system. - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir(); Error err = da->change_dir(templates_dir); @@ -62,7 +62,6 @@ void ExportTemplateManager::_update_template_status() { } } da->list_dir_end(); - memdelete(da); // Update the state of the current version. String current_version = VERSION_FULL_CONFIG; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index e8a2a46dd2..038cc2ab2f 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -525,16 +525,14 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa if (target_path.ends_with("/")) { target_path = target_path.substr(0, target_path.length() - 1); } - DirAccess *dirAccess = DirAccess::create(DirAccess::ACCESS_RESOURCES); - if (dirAccess->file_exists(p_path)) { + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + if (da->file_exists(p_path)) { path = target_path; - } else if (dirAccess->dir_exists(p_path)) { + } else if (da->dir_exists(p_path)) { path = target_path + "/"; } else { - memdelete(dirAccess); ERR_FAIL_MSG(vformat("Cannot navigate to '%s' as it has not been found in the file system!", p_path)); } - memdelete(dirAccess); } _set_current_path_text(path); @@ -781,14 +779,14 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { icon = folder_icon; if (searched_string.length() == 0 || text.to_lower().find(searched_string) >= 0) { files->add_item(text, icon, true); - files->set_item_metadata(files->get_item_count() - 1, favorite); + files->set_item_metadata(-1, favorite); } } else if (favorite.ends_with("/")) { text = favorite.substr(0, favorite.length() - 1).get_file(); icon = folder_icon; if (searched_string.length() == 0 || text.to_lower().find(searched_string) >= 0) { files->add_item(text, icon, true); - files->set_item_metadata(files->get_item_count() - 1, favorite); + files->set_item_metadata(-1, favorite); } } else { int index; @@ -842,9 +840,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { bd += "/"; } - files->set_item_metadata(files->get_item_count() - 1, bd); - files->set_item_selectable(files->get_item_count() - 1, false); - files->set_item_icon_modulate(files->get_item_count() - 1, folder_color); + files->set_item_metadata(-1, bd); + files->set_item_selectable(-1, false); + files->set_item_icon_modulate(-1, folder_color); } bool reversed = file_sort == FILE_SORT_NAME_REVERSE; @@ -854,8 +852,8 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String dname = efd->get_subdir(i)->get_name(); files->add_item(dname, folder_icon, true); - files->set_item_metadata(files->get_item_count() - 1, directory.plus_file(dname) + "/"); - files->set_item_icon_modulate(files->get_item_count() - 1, folder_color); + files->set_item_metadata(-1, directory.plus_file(dname) + "/"); + files->set_item_icon_modulate(-1, folder_color); if (cselection.has(dname)) { files->select(files->get_item_count() - 1, false); @@ -1171,7 +1169,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_ _get_all_items_in_dir(EditorFileSystem::get_singleton()->get_filesystem_path(old_path), file_changed_paths, folder_changed_paths); } - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); print_verbose("Moving " + old_path + " -> " + new_path); Error err = da->rename(old_path, new_path); if (err == OK) { @@ -1211,7 +1209,6 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_ } else { EditorNode::get_singleton()->add_io_error(TTR("Error moving:") + "\n" + old_path + "\n"); } - memdelete(da); } void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const String &p_new_path) const { @@ -1230,7 +1227,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin return; } - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); print_verbose("Duplicating " + old_path + " -> " + new_path); Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path); if (err == OK) { @@ -1268,7 +1265,6 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin } else { EditorNode::get_singleton()->add_io_error(TTR("Error duplicating:") + "\n" + old_path + "\n"); } - memdelete(da); } void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const { @@ -1418,12 +1414,11 @@ void FileSystemDock::_make_dir_confirm() { directory = directory.get_base_dir(); } print_verbose("Making folder " + dir_name + " in " + directory); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); Error err = da->change_dir(directory); if (err == OK) { err = da->make_dir(dir_name); } - memdelete(da); if (err == OK) { print_verbose("FileSystem: calling rescan."); @@ -1464,13 +1459,11 @@ void FileSystemDock::_make_scene_confirm() { scene_name = directory.plus_file(scene_name); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists(scene_name)) { EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists.")); - memdelete(da); return; } - memdelete(da); int idx = EditorNode::get_singleton()->new_scene(); EditorNode::get_singleton()->get_editor_data().set_scene_path(idx, scene_name); @@ -1533,7 +1526,7 @@ void FileSystemDock::_rename_operation_confirm() { } // Present a more user friendly warning for name conflict. - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); #if defined(WINDOWS_ENABLED) || defined(UWP_ENABLED) // Workaround case insensitivity on Windows. if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) { @@ -1541,10 +1534,8 @@ void FileSystemDock::_rename_operation_confirm() { if (da->file_exists(new_path) || da->dir_exists(new_path)) { #endif EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists.")); - memdelete(da); return; } - memdelete(da); Map<String, String> file_renames; Map<String, String> folder_renames; @@ -1588,13 +1579,11 @@ void FileSystemDock::_duplicate_operation_confirm() { String new_path = base_dir.plus_file(new_name); // Present a more user friendly warning for name conflict - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists(new_path) || da->dir_exists(new_path)) { EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists.")); - memdelete(da); return; } - memdelete(da); _try_duplicate_item(to_duplicate, new_path); @@ -2098,6 +2087,10 @@ void FileSystemDock::focus_on_filter() { } } +ScriptCreateDialog *FileSystemDock::get_script_create_dialog() const { + return make_script_dialog; +} + void FileSystemDock::set_file_list_display_mode(FileListDisplayMode p_mode) { if (p_mode == file_list_display_mode) { return; @@ -2818,7 +2811,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f return; } - DirAccess *da = DirAccess::open(p_path); + DirAccessRef da = DirAccess::open(p_path); da->list_dir_begin(); String n = da->get_next(); while (!n.is_empty()) { @@ -3179,10 +3172,7 @@ FileSystemDock::FileSystemDock() { searched_string = String(); uncollapsed_paths_before_search = Vector<String>(); - updating_tree = false; tree_update_id = 0; - initialized = false; - import_dock_needs_update = false; history_pos = 0; history_max_size = 20; @@ -3191,8 +3181,6 @@ FileSystemDock::FileSystemDock() { display_mode = DISPLAY_MODE_TREE_ONLY; old_display_mode = DISPLAY_MODE_TREE_ONLY; file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS; - - always_show_folders = false; } FileSystemDock::~FileSystemDock() { diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index d457c6acd4..92dac374ec 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -154,7 +154,7 @@ private: ShaderCreateDialog *make_shader_dialog; CreateDialog *new_resource_dialog; - bool always_show_folders; + bool always_show_folders = false; class FileOrFolder { public: @@ -177,13 +177,13 @@ private: String path; - bool initialized; + bool initialized = false; - bool updating_tree; + bool updating_tree = false; int tree_update_id; Tree *tree; ItemList *files; - bool import_dock_needs_update; + bool import_dock_needs_update = false; bool holding_branch = false; Vector<TreeItem *> tree_items_selected_on_drag_begin; @@ -320,6 +320,8 @@ public: void navigate_to_path(const String &p_path); void focus_on_filter(); + ScriptCreateDialog *get_script_create_dialog() const; + void fix_dependencies(const String &p_for_file); int get_split_offset() { return split_box->get_split_offset(); } diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index eff9185c71..1ce363c651 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -612,8 +612,6 @@ FindInFilesPanel::FindInFilesPanel() { _results_display->create_item(); // Root vbc->add_child(_results_display); - _with_replace = false; - { _replace_container = memnew(HBoxContainer); diff --git a/editor/find_in_files.h b/editor/find_in_files.h index 1b6666b554..cf14f3d5c3 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -210,7 +210,7 @@ private: ProgressBar *_progress_bar; Map<String, TreeItem *> _file_items; Map<TreeItem *, Result> _result_items; - bool _with_replace; + bool _with_replace = false; HBoxContainer *_replace_container; LineEdit *_replace_line_edit; diff --git a/editor/icons/StreamTexture.svg b/editor/icons/CompressedTexture2D.svg index 068f65dead..068f65dead 100644 --- a/editor/icons/StreamTexture.svg +++ b/editor/icons/CompressedTexture2D.svg diff --git a/editor/icons/ViewportSpeed.svg b/editor/icons/ViewportSpeed.svg index 8fceaffd52..57292e2e91 100644 --- a/editor/icons/ViewportSpeed.svg +++ b/editor/icons/ViewportSpeed.svg @@ -1 +1 @@ -<svg height="16" viewBox="0 0 4.2333333 4.2333333" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1.5875 0c-.28858 0-.52917.24059-.52917.52917v.61132c-.085589-.051-.18113-.0891-.28525-.0853-.34849.0127-.5952.37346-.48059.70278l.26355.79066c.048664.14623.15979.24805.29249.30644l-.60927.40669c-.13121.0845-.22102.22389-.24133.3633-.020312.13941.017471.26985.087333.37465s.17614.19045.31264.22532c.13634.0348.29946.006.42788-.0827h.0005159l1.0852-.72348.26097.52192c.11682.23391.39274.34829.64079.26561l.79375-.26458-.00775.003c.15105-.0454.27732-.15615.33486-.2863.057538-.13015.055144-.26773.014986-.38809-.03156-.0946-.10972-.1687-.19275-.23617.069099-.0546.1445-.10364.18035-.19325.051761-.12941.045257-.29292-.02377-.43098l-.26459-.52946c-.089407-.17933-.27348-.29308-.47335-.29305h-.1111c.052029-.0817.1111-.16214.1111-.26458v-.79375c0-.28858-.24059-.52917-.52917-.52917z"/><path d="m1.5875.26458c-.14658 0-.26458.118-.26458.26459v.79375c0 .14658.118.26458.26458.26458h.26458v.262a.26461.26461 0 0 0 -.083716.0165l-.5426.18086-.18087-.5426a.26461.26461 0 0 0 -.262-.18448.26461.26461 0 0 0 -.2403.3514l.26458.79375a.26461.26461 0 0 0 .33486.16743l.44545-.14831v.16174c0 .0108.00495.02.0062.0305l-1.2113.80771a.26461.26461 0 1 0 .29352.44028l1.3379-.89194.39532.79014a.26461.26461 0 0 0 .32039.1328l.79375-.26458a.26461.26461 0 1 0 -.16743-.50175l-.57619.19172-.25787-.51625c.072998-.047.12402-.12495.12402-.21859v-.26458h.36587l.1912.38292a.26461.26461 0 1 0 .47336-.23668l-.26458-.52916a.26461.26461 0 0 0 -.23668-.14625h-.79375v-.26458h.26458c.14658 0 .26458-.118.26458-.26458v-.79375c0-.14659-.118-.26459-.26458-.26459zm0 .52917h.26458v.52917h-.26458z" fill="#fff" fill-opacity=".99608"/></svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g stroke-width="3.77953"><path d="m6.0285136 0c-1.0906961 0-2.0000127.90931655-2.0000127 2.0000126v2.3105008c-.3234859-.1927559-.6845858-.3367559-1.0781102-.3223937-1.3171276.048-2.24957487 1.4115024-1.8164032 2.6561764l.9960945 2.9883213c.183927.5526806.6039307.9375116 1.1054741 1.1581986l-2.30275287 1.537096c-.49591181.31937-.83535119.846198-.91211339 1.373102-.07676977.526904.06603212 1.019906.33007748 1.416.26404536.396095.66572598.719811 1.18163158.851603.5153008.131528 1.1318173.02268 1.6171842-.312566h.00195l4.1015433-2.734413.9863434 1.972611c.4415244.884069 1.4843716 1.316372 2.4218832 1.00388l3-.999987-.02929.01134c.570898-.17159 1.048139-.590173 1.265613-1.082078.217466-.491906.208418-1.011893.05664-1.466797-.119282-.357543-.41469-.637606-.728504-.892611.261162-.206362.546142-.39171.681638-.730394.195632-.489109.17105-1.1070991-.08984-1.6289007l-1.000027-2.0011107c-.337916-.6777827-1.033625-1.1077039-1.789039-1.1075905h-.419906c.196645-.3087874.419906-.6128126.419906-.9999874v-3.0000001c0-1.09069605-.909317-2.0000126-2.000012-2.0000126z"/><path d="m6.0285136.99998741c-.5540032 0-.9999874.44598429-.9999874 1.00002519v3.0000001c0 .5540031.4459842.9999874.9999874.9999874h.9999874v.9902362a1.0001008 1.0001008 0 0 0 -.316407.062362l-2.0507716.6835656-.6836032-2.0507717a1.0001008 1.0001008 0 0 0 -.9902362-.6972473 1.0001008 1.0001008 0 0 0 -.9082205 1.328126l.9999874 3.0000001a1.0001008 1.0001008 0 0 0 1.2656126.6328063l1.6835906-.5605418v.6113008c0 .040819.018709.075591.023433.1152757l-4.5781418 3.052762a1.0001008 1.0001008 0 1 0 1.1093669 1.664051l5.05663-3.371112 1.4941228 2.986356a1.0001008 1.0001008 0 0 0 1.210922.501921l3.000001-.999987a1.0001008 1.0001008 0 1 0 -.632807-1.896378l-2.177726.724611-.9746262-1.951182c.275898-.177637.4687372-.472252.4687372-.8261665v-.9999874h1.382815l.722646 1.4472569a1.0001246 1.0001246 0 1 0 1.789077-.8945388l-.999987-1.9999748a1.0001008 1.0001008 0 0 0 -.894539-.5527559h-2.9999995v-.9999874h.9999875c.554003 0 .999987-.4459843.999987-.9999874v-3.0000001c0-.5540409-.445984-1.00002519-.999987-1.00002519zm0 2.00001259h.9999874v2.0000127h-.9999874z" fill="#fff" fill-opacity=".99608"/></g></svg> diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index f0a2d7d553..2ecc483938 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -484,6 +484,14 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper if (font_preview->get_data_count() > 0) { font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); } + } else if (p_edited_property == "embolden") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_embolden(import_settings_data->get("embolden")); + } + } else if (p_edited_property == "transform") { + if (font_preview->get_data_count() > 0) { + font_preview->get_data(0)->set_transform(import_settings_data->get("transform")); + } } else if (p_edited_property == "oversampling") { if (font_preview->get_data_count() > 0) { font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); @@ -924,6 +932,8 @@ void DynamicFontImportSettings::_re_import() { main_settings["force_autohinter"] = import_settings_data->get("force_autohinter"); main_settings["hinting"] = import_settings_data->get("hinting"); main_settings["subpixel_positioning"] = import_settings_data->get("subpixel_positioning"); + main_settings["embolden"] = import_settings_data->get("embolden"); + main_settings["transform"] = import_settings_data->get("transform"); main_settings["oversampling"] = import_settings_data->get("oversampling"); main_settings["compress"] = import_settings_data->get("compress"); @@ -1275,6 +1285,8 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { font_preview->get_data(0)->set_force_autohinter(import_settings_data->get("force_autohinter")); font_preview->get_data(0)->set_hinting((TextServer::Hinting)import_settings_data->get("hinting").operator int()); font_preview->get_data(0)->set_subpixel_positioning((TextServer::SubpixelPositioning)import_settings_data->get("subpixel_positioning").operator int()); + font_preview->get_data(0)->set_embolden(import_settings_data->get("embolden")); + font_preview->get_data(0)->set_transform(import_settings_data->get("transform")); font_preview->get_data(0)->set_oversampling(import_settings_data->get("oversampling")); } font_preview_label->add_theme_font_override("font", font_preview); @@ -1334,6 +1346,8 @@ DynamicFontImportSettings::DynamicFontImportSettings() { options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "embolden", PROPERTY_HINT_RANGE, "-2,2,0.01"), 0.f)); + options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::TRANSFORM2D, "transform"), Transform2D())); options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "compress", PROPERTY_HINT_NONE, ""), false)); diff --git a/editor/import/resource_importer_dynamic_font.cpp b/editor/import/resource_importer_dynamic_font.cpp index 70fc87ea3f..077b94bb4e 100644 --- a/editor/import/resource_importer_dynamic_font.cpp +++ b/editor/import/resource_importer_dynamic_font.cpp @@ -109,6 +109,8 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List< r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force_autohinter"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "hinting", PROPERTY_HINT_ENUM, "None,Light,Normal"), 1)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "subpixel_positioning", PROPERTY_HINT_ENUM, "Disabled,Auto,One half of a pixel,One quarter of a pixel"), 1)); + r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "embolden", PROPERTY_HINT_RANGE, "-2,2,0.01"), 0.f)); + r_options->push_back(ImportOption(PropertyInfo(Variant::TRANSFORM2D, "transform"), Transform2D())); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "oversampling", PROPERTY_HINT_RANGE, "0,10,0.1"), 0.0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); @@ -186,6 +188,8 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str int hinting = p_options["hinting"]; int subpixel_positioning = p_options["subpixel_positioning"]; real_t oversampling = p_options["oversampling"]; + real_t embolden = p_options["embolden"]; + Transform2D transform = p_options["transform"]; // Load base font data. Vector<uint8_t> data = FileAccess::get_file_as_array(p_source_file); @@ -202,6 +206,8 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str font->set_fixed_size(0); font->set_force_autohinter(autohinter); font->set_subpixel_positioning((TextServer::SubpixelPositioning)subpixel_positioning); + font->set_embolden(embolden); + font->set_transform(transform); font->set_hinting((TextServer::Hinting)hinting); font->set_oversampling(oversampling); diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 197cc49a95..9ddee9c058 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -85,16 +85,16 @@ void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_e String ResourceImporterLayeredTexture::get_save_extension() const { switch (mode) { case MODE_CUBEMAP: { - return "scube"; + return "ccube"; } break; case MODE_2D_ARRAY: { - return "stexarray"; + return "ctexarray"; } break; case MODE_CUBEMAP_ARRAY: { - return "scubearray"; + return "ccubearray"; } break; case MODE_3D: { - return "stex3d"; + return "ctex3d"; } break; } @@ -274,11 +274,11 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons f->store_32(0); for (int i = 0; i < p_images.size(); i++) { - ResourceImporterTexture::save_to_stex_format(f, p_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy); + ResourceImporterTexture::save_to_ctex_format(f, p_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy); } for (int i = 0; i < mipmap_images.size(); i++) { - ResourceImporterTexture::save_to_stex_format(f, mipmap_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy); + ResourceImporterTexture::save_to_ctex_format(f, mipmap_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy); } f->close(); @@ -393,7 +393,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const texture_import->bptc_ldr = bptc_ldr; texture_import->mipmaps = mipmaps; texture_import->used_channels = used_channels; - _check_compress_stex(texture_import); + _check_compress_ctex(texture_import); if (r_metadata) { Dictionary metadata; metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED; @@ -474,7 +474,7 @@ ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() { ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() { } -void ResourceImporterLayeredTexture::_check_compress_stex(Ref<LayeredTextureImport> r_texture_import) { +void ResourceImporterLayeredTexture::_check_compress_ctex(Ref<LayeredTextureImport> r_texture_import) { String extension = get_save_extension(); ERR_FAIL_NULL(r_texture_import->csource); if (r_texture_import->compress_mode != COMPRESS_VRAM_COMPRESSED) { diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index 58e5c47d8d..5791914a9b 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -87,7 +87,7 @@ protected: static ResourceImporterLayeredTexture *singleton; public: - void _check_compress_stex(Ref<LayeredTextureImport> r_texture_import); + void _check_compress_ctex(Ref<LayeredTextureImport> r_texture_import); static ResourceImporterLayeredTexture *get_singleton() { return singleton; } virtual String get_importer_name() const override; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index e672fe2dee..1dec4b00bb 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -225,7 +225,7 @@ void ResourceImporterTexture::get_import_options(const String &p_path, List<Impo } } -void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) { +void ResourceImporterTexture::save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) { switch (p_compress_mode) { case COMPRESS_LOSSLESS: { bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/force_png") || @@ -317,7 +317,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } } -void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) { +void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); ERR_FAIL_NULL(f); f->store_8('G'); @@ -394,7 +394,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String Image::UsedChannels used_channels = image->detect_used_channels(csource); - save_to_stex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality); + save_to_ctex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality); memdelete(f); } @@ -540,19 +540,19 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (!bptc_ldr && can_s3tc && is_ldr) { image_compress_mode = Image::COMPRESS_S3TC; } - _save_stex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); + _save_ctex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("s3tc"); formats_imported.push_back("s3tc"); } if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2")) { - _save_stex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); + _save_ctex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc")) { - _save_stex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); + _save_ctex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } @@ -562,7 +562,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } } else { //import normally - _save_stex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); + _save_ctex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); } if (r_metadata) { diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index bd43eaef58..b3a68260fc 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -74,10 +74,10 @@ protected: static ResourceImporterTexture *singleton; static const char *compression_formats[]; - void _save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel); + void _save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel); public: - static void save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality); + static void save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality); static ResourceImporterTexture *get_singleton() { return singleton; } virtual String get_importer_name() const override; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 72cc33048c..9f1daac69f 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -128,7 +128,7 @@ void ImportDock::set_edit_path(const String &p_path) { for (const Pair<String, String> &E : importer_names) { import_as->add_item(E.first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + import_as->set_item_metadata(-1, E.second); if (E.second == importer_name) { import_as->select(import_as->get_item_count() - 1); } @@ -149,7 +149,7 @@ void ImportDock::set_edit_path(const String &p_path) { void ImportDock::_add_keep_import_option(const String &p_importer_name) { import_as->add_separator(); import_as->add_item(TTR("Keep File (No Import)")); - import_as->set_item_metadata(import_as->get_item_count() - 1, "keep"); + import_as->set_item_metadata(-1, "keep"); if (p_importer_name == "keep") { import_as->select(import_as->get_item_count() - 1); } @@ -286,7 +286,7 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { for (const Pair<String, String> &E : importer_names) { import_as->add_item(E.first); - import_as->set_item_metadata(import_as->get_item_count() - 1, E.second); + import_as->set_item_metadata(-1, E.second); if (E.second == params->importer->get_importer_name()) { import_as->select(import_as->get_item_count() - 1); } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index a766650cd9..77594dde78 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -473,7 +473,6 @@ void LocalizationEditor::_bind_methods() { LocalizationEditor::LocalizationEditor() { undo_redo = EditorNode::get_undo_redo(); - updating_translations = false; localization_changed = "localization_changed"; TabContainer *translations = memnew(TabContainer); diff --git a/editor/localization_editor.h b/editor/localization_editor.h index bde1b894e2..3424ba7c55 100644 --- a/editor/localization_editor.h +++ b/editor/localization_editor.h @@ -56,7 +56,7 @@ class LocalizationEditor : public VBoxContainer { EditorFileDialog *pot_generate_dialog; UndoRedo *undo_redo; - bool updating_translations; + bool updating_translations = false; String localization_changed; void _translation_file_open(); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index d5e7c312d9..02cc95e14a 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -50,7 +50,7 @@ void PluginConfigDialog::_on_confirmed() { String path = "res://addons/" + subfolder_edit->get_text(); if (!_edit_mode) { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (!d || d->make_dir_recursive(path) != OK) { return; } diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index 5a2696fff1..22e0a3dabb 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -292,15 +292,14 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) _commit_action(); return true; } else { - Vector<Vector2> vertices2 = _get_polygon(insert.polygon); - pre_move_edit = vertices2; + pre_move_edit = vertices; edited_point = PosVertex(insert.polygon, insert.vertex + 1, xform.affine_inverse().xform(insert.pos)); - vertices2.insert(edited_point.vertex, edited_point.pos); + vertices.insert(edited_point.vertex, edited_point.pos); selected_point = Vertex(edited_point.polygon, edited_point.vertex); edge_point = PosVertex(); undo_redo->create_action(TTR("Insert Point")); - _action_set_polygon(insert.polygon, vertices2); + _action_set_polygon(insert.polygon, vertices); _commit_action(); return true; } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index fba6d8e57f..ab8e2ca54a 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -897,11 +897,6 @@ void AnimationPlayerEditor::_update_player() { } void AnimationPlayerEditor::_update_animation_list_icons() { - List<StringName> animlist; - if (player) { - player->get_animation_list(&animlist); - } - for (int i = 0; i < animation->get_item_count(); i++) { String name = animation->get_item_text(i); @@ -1675,11 +1670,11 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug onion_skinning->set_tooltip(TTR("Onion Skinning Options")); onion_skinning->get_popup()->add_separator(TTR("Directions")); onion_skinning->get_popup()->add_check_item(TTR("Past"), ONION_SKINNING_PAST); - onion_skinning->get_popup()->set_item_checked(onion_skinning->get_popup()->get_item_count() - 1, true); + onion_skinning->get_popup()->set_item_checked(-1, true); onion_skinning->get_popup()->add_check_item(TTR("Future"), ONION_SKINNING_FUTURE); onion_skinning->get_popup()->add_separator(TTR("Depth")); onion_skinning->get_popup()->add_radio_check_item(TTR("1 step"), ONION_SKINNING_1_STEP); - onion_skinning->get_popup()->set_item_checked(onion_skinning->get_popup()->get_item_count() - 1, true); + onion_skinning->get_popup()->set_item_checked(-1, true); onion_skinning->get_popup()->add_radio_check_item(TTR("2 steps"), ONION_SKINNING_2_STEPS); onion_skinning->get_popup()->add_radio_check_item(TTR("3 steps"), ONION_SKINNING_3_STEPS); onion_skinning->get_popup()->add_separator(); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index 2f94176e2a..bd0c1afd19 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -346,29 +346,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv state_machine_draw->update(); } - //put ibeam (text cursor) over names to make it clearer that they are editable if (mm.is_valid()) { state_machine_draw->grab_focus(); - bool over_text_now = false; String new_over_node = StringName(); int new_over_node_what = -1; if (tool_select->is_pressed()) { - for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order - - if (node_rects[i].name.has_point(mm->get_position())) { - over_text_now = true; - break; - } - + for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order. if (node_rects[i].node.has_point(mm->get_position())) { new_over_node = node_rects[i].node_name; if (node_rects[i].play.has_point(mm->get_position())) { new_over_node_what = 0; - } - if (node_rects[i].edit.has_point(mm->get_position())) { + } else if (node_rects[i].edit.has_point(mm->get_position())) { new_over_node_what = 1; } + break; } } } @@ -378,16 +370,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv over_node_what = new_over_node_what; state_machine_draw->update(); } - - if (over_text != over_text_now) { - if (over_text_now) { - state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM); - } else { - state_machine_draw->set_default_cursor_shape(CURSOR_ARROW); - } - - over_text = over_text_now; - } } Ref<InputEventPanGesture> pan_gesture = p_event; @@ -397,6 +379,23 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv } } +Control::CursorShape AnimationNodeStateMachineEditor::get_cursor_shape(const Point2 &p_pos) const { + // Put ibeam (text cursor) over names to make it clearer that they are editable. + Transform2D xform = panel->get_transform() * state_machine_draw->get_transform(); + Point2 pos = xform.xform_inv(p_pos); + Control::CursorShape cursor_shape = get_default_cursor_shape(); + + for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order. + if (node_rects[i].node.has_point(pos)) { + if (node_rects[i].name.has_point(pos)) { + cursor_shape = Control::CURSOR_IBEAM; + } + break; + } + } + return cursor_shape; +} + void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) { file_loaded = ResourceLoader::load(p_file); if (file_loaded.is_valid()) { @@ -1287,6 +1286,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { panel = memnew(PanelContainer); panel->set_clip_contents(true); + panel->set_mouse_filter(Control::MOUSE_FILTER_PASS); add_child(panel); panel->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1295,6 +1295,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { state_machine_draw->connect("gui_input", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_gui_input)); state_machine_draw->connect("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_draw)); state_machine_draw->set_focus_mode(FOCUS_ALL); + state_machine_draw->set_mouse_filter(Control::MOUSE_FILTER_PASS); state_machine_play_pos = memnew(Control); state_machine_draw->add_child(state_machine_play_pos); @@ -1347,8 +1348,6 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() { open_file->connect("file_selected", callable_mp(this, &AnimationNodeStateMachineEditor::_file_opened)); undo_redo = EditorNode::get_undo_redo(); - over_text = false; - over_node_what = -1; dragging_selected_attempt = false; connecting = false; diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 208bd27f8e..03991d00f9 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -138,7 +138,6 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { StringName selected_transition_from; StringName selected_transition_to; - bool over_text; StringName over_node; int over_node_what; @@ -185,6 +184,7 @@ public: static AnimationNodeStateMachineEditor *get_singleton() { return singleton; } virtual bool can_edit(const Ref<AnimationNode> &p_node) override; virtual void edit(const Ref<AnimationNode> &p_node) override; + virtual CursorShape get_cursor_shape(const Point2 &p_pos) const override; AnimationNodeStateMachineEditor(); }; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 50f253b167..1468d63daf 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -577,6 +577,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { void EditorAssetLibrary::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { + add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("AssetLib"))); error_label->raise(); } break; @@ -1145,7 +1146,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const String name = cat["name"]; int id = cat["id"]; categories->add_item(name); - categories->set_item_metadata(categories->get_item_count() - 1, id); + categories->set_item_metadata(-1, id); category_map[cat["id"]] = name; } } @@ -1377,7 +1378,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { initial_loading = true; VBoxContainer *library_main = memnew(VBoxContainer); - add_child(library_main); HBoxContainer *search_hb = memnew(HBoxContainer); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 75f97efdbc..d713e70251 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -60,12 +60,12 @@ // Min and Max are power of two in order to play nicely with successive increment. // That way, we can naturally reach a 100% zoom from boundaries. -#define MIN_ZOOM 1. / 128 -#define MAX_ZOOM 128 +constexpr real_t MIN_ZOOM = 1. / 128; +constexpr real_t MAX_ZOOM = 128; #define RULER_WIDTH (15 * EDSCALE) -#define SCALE_HANDLE_DISTANCE 25 -#define MOVE_HANDLE_DISTANCE 25 +constexpr real_t SCALE_HANDLE_DISTANCE = 25; +constexpr real_t MOVE_HANDLE_DISTANCE = 25; class SnapDialog : public ConfirmationDialog { GDCLASS(SnapDialog, ConfirmationDialog); @@ -489,12 +489,12 @@ void CanvasItemEditor::unhandled_key_input(const Ref<InputEvent> &p_ev) { viewport->update(); } - if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo()) { - if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) { + if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo() && (grid_snap_active || _is_grid_visible())) { + if (multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) { // Multiply the grid size grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); viewport->update(); - } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) { + } else if (divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) { // Divide the grid size Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1); if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) { @@ -938,6 +938,60 @@ void CanvasItemEditor::_reset_create_position() { node_create_position = Point2(); } +bool CanvasItemEditor::_is_grid_visible() const { + switch (grid_visibility) { + case GRID_VISIBILITY_SHOW: + return true; + case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: + return grid_snap_active; + case GRID_VISIBILITY_HIDE: + return false; + } + ERR_FAIL_V_MSG(true, "Unexpected grid_visibility value"); +} + +void CanvasItemEditor::_prepare_grid_menu() { + for (int i = GRID_VISIBILITY_SHOW; i <= GRID_VISIBILITY_HIDE; i++) { + grid_menu->set_item_checked(i, i == grid_visibility); + } +} + +void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) { + switch (p_id) { + case GRID_VISIBILITY_SHOW: + case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: + case GRID_VISIBILITY_HIDE: + grid_visibility = (GridVisibility)p_id; + viewport->update(); + view_menu->get_popup()->hide(); + return; + } + + // Toggle grid: go to the least restrictive option possible. + if (grid_snap_active) { + switch (grid_visibility) { + case GRID_VISIBILITY_SHOW: + case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: + grid_visibility = GRID_VISIBILITY_HIDE; + break; + case GRID_VISIBILITY_HIDE: + grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING; + break; + } + } else { + switch (grid_visibility) { + case GRID_VISIBILITY_SHOW: + grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING; + break; + case GRID_VISIBILITY_SHOW_WHEN_SNAPPING: + case GRID_VISIBILITY_HIDE: + grid_visibility = GRID_VISIBILITY_SHOW; + break; + } + } + viewport->update(); +} + bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> b = p_event; Ref<InputEventMouseMotion> m = p_event; @@ -1139,6 +1193,8 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve } } } + snap_target[0] = SNAP_TARGET_NONE; + snap_target[1] = SNAP_TARGET_NONE; drag_type = DRAG_NONE; viewport->update(); return true; @@ -2160,7 +2216,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (drag_type == DRAG_NONE) { - if (b.is_valid() && + if (b.is_valid() && b->is_pressed() && ((b->get_button_index() == MouseButton::RIGHT && b->is_alt_pressed() && tool == TOOL_SELECT) || (b->get_button_index() == MouseButton::LEFT && tool == TOOL_LIST_SELECT))) { // Popup the selection menu list @@ -2726,7 +2782,7 @@ void CanvasItemEditor::_draw_rulers() { // The rule transform Transform2D ruler_transform = Transform2D(); - if (show_grid || grid_snap_active) { + if (grid_snap_active || _is_grid_visible()) { List<CanvasItem *> selection = _get_edited_canvas_items(); if (snap_relative && selection.size() > 0) { ruler_transform.translate(_get_encompassing_rect_from_list(selection).position); @@ -2806,7 +2862,7 @@ void CanvasItemEditor::_draw_rulers() { } void CanvasItemEditor::_draw_grid() { - if (show_grid || grid_snap_active) { + if (_is_grid_visible()) { // Draw the grid Vector2 real_grid_offset; const List<CanvasItem *> selection = _get_edited_canvas_items(); @@ -4137,12 +4193,6 @@ void CanvasItemEditor::_update_override_camera_button(bool p_game_running) { void CanvasItemEditor::_popup_callback(int p_op) { last_option = MenuOption(p_op); switch (p_op) { - case SHOW_GRID: { - show_grid = !show_grid; - int idx = view_menu->get_popup()->get_item_index(SHOW_GRID); - view_menu->get_popup()->set_item_checked(idx, show_grid); - viewport->update(); - } break; case SHOW_ORIGIN: { show_origin = !show_origin; int idx = view_menu->get_popup()->get_item_index(SHOW_ORIGIN); @@ -4615,7 +4665,7 @@ Dictionary CanvasItemEditor::get_state() const { state["snap_node_center"] = snap_node_center; state["snap_other_nodes"] = snap_other_nodes; state["snap_guides"] = snap_guides; - state["show_grid"] = show_grid; + state["grid_visibility"] = grid_visibility; state["show_origin"] = show_origin; state["show_viewport"] = show_viewport; state["show_rulers"] = show_rulers; @@ -4717,10 +4767,8 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { smartsnap_config_popup->set_item_checked(idx, snap_guides); } - if (state.has("show_grid")) { - show_grid = state["show_grid"]; - int idx = view_menu->get_popup()->get_item_index(SHOW_GRID); - view_menu->get_popup()->set_item_checked(idx, show_grid); + if (state.has("grid_visibility")) { + grid_visibility = (GridVisibility)(int)(state["grid_visibility"]); } if (state.has("show_origin")) { @@ -5130,7 +5178,19 @@ CanvasItemEditor::CanvasItemEditor() { p = view_menu->get_popup(); p->set_hide_on_checkable_item_selection(false); - p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), Key::NUMBERSIGN), SHOW_GRID); + + grid_menu = memnew(PopupMenu); + grid_menu->connect("about_to_popup", callable_mp(this, &CanvasItemEditor::_prepare_grid_menu)); + grid_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_on_grid_menu_id_pressed)); + grid_menu->set_name("GridMenu"); + grid_menu->add_radio_check_item(TTR("Show"), GRID_VISIBILITY_SHOW); + grid_menu->add_radio_check_item(TTR("Show When Snapping"), GRID_VISIBILITY_SHOW_WHEN_SNAPPING); + grid_menu->add_radio_check_item(TTR("Hide"), GRID_VISIBILITY_HIDE); + grid_menu->add_separator(); + grid_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/toggle_grid", TTR("Toggle Grid"), KeyModifierMask::CMD | Key::APOSTROPHE)); + p->add_child(grid_menu); + p->add_submenu_item(TTR("Grid"), "GridMenu"); + p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), Key::H), SHOW_HELPERS); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), Key::Y), SHOW_GUIDES); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index e7c265ee02..1a9d49a4a8 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -116,7 +116,6 @@ private: SNAP_RELATIVE, SNAP_CONFIGURE, SNAP_USE_PIXEL, - SHOW_GRID, SHOW_HELPERS, SHOW_RULERS, SHOW_GUIDES, @@ -175,6 +174,12 @@ private: DRAG_KEY_MOVE }; + enum GridVisibility { + GRID_VISIBILITY_SHOW, + GRID_VISIBILITY_SHOW_WHEN_SNAPPING, + GRID_VISIBILITY_HIDE, + }; + bool selection_menu_additive_selection; Tool tool = TOOL_SELECT; @@ -190,7 +195,7 @@ private: HBoxContainer *hbc_context_menu; Transform2D transform; - bool show_grid = false; + GridVisibility grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING; bool show_rulers = true; bool show_guides = true; bool show_origin = true; @@ -314,6 +319,7 @@ private: MenuButton *skeleton_menu; Button *override_camera_button; MenuButton *view_menu; + PopupMenu *grid_menu; HBoxContainer *animation_hb; MenuButton *animation_menu; @@ -390,6 +396,9 @@ private: void _node_created(Node *p_node); void _reset_create_position(); void _update_editor_settings(); + bool _is_grid_visible() const; + void _prepare_grid_menu(); + void _on_grid_menu_id_pressed(int p_id); UndoRedo *undo_redo; diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index 501becac57..c8d5aa3fdc 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -63,30 +63,24 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(MenuButton *p_debug_menu) { PopupMenu *p = debug_menu->get_popup(); p->set_hide_on_checkable_item_selection(false); p->add_check_shortcut(ED_SHORTCUT("editor/deploy_with_remote_debug", TTR("Deploy with Remote Debug")), RUN_DEPLOY_REMOTE_DEBUG); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, using one-click deploy will make the executable attempt to connect to this computer's IP so the running project can be debugged.\nThis option is intended to be used for remote debugging (typically with a mobile device).\nYou don't need to enable it to use the GDScript debugger locally.")); p->add_check_shortcut(ED_SHORTCUT("editor/small_deploy_with_network_fs", TTR("Small Deploy with Network Filesystem")), RUN_FILE_SERVER); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, using one-click deploy for Android will only export an executable without the project data.\nThe filesystem will be provided from the project by the editor over the network.\nOn Android, deploying will use the USB cable for faster performance. This option speeds up testing for projects with large assets.")); p->add_separator(); p->add_check_shortcut(ED_SHORTCUT("editor/visible_collision_shapes", TTR("Visible Collision Shapes")), RUN_DEBUG_COLLISONS); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, collision shapes and raycast nodes (for 2D and 3D) will be visible in the running project.")); p->add_check_shortcut(ED_SHORTCUT("editor/visible_navigation", TTR("Visible Navigation")), RUN_DEBUG_NAVIGATION); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, navigation meshes and polygons will be visible in the running project.")); p->add_separator(); p->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Synchronize Scene Changes")), RUN_LIVE_DEBUG); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, any changes made to the scene in the editor will be replicated in the running project.\nWhen used remotely on a device, this is more efficient when the network filesystem option is enabled.")); p->add_check_shortcut(ED_SHORTCUT("editor/sync_script_changes", TTR("Synchronize Script Changes")), RUN_RELOAD_SCRIPTS); - p->set_item_tooltip( - p->get_item_count() - 1, + p->set_item_tooltip(-1, TTR("When this option is enabled, any script that is saved will be reloaded in the running project.\nWhen used remotely on a device, this is more efficient when the network filesystem option is enabled.")); // Multi-instance, start/stop diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h new file mode 100644 index 0000000000..8ed72b1c42 --- /dev/null +++ b/editor/plugins/gdextension_export_plugin.h @@ -0,0 +1,138 @@ +/*************************************************************************/ +/* gdextension_export_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef GDEXTENSION_EXPORT_PLUGIN_H +#define GDEXTENSION_EXPORT_PLUGIN_H + +#include "editor/editor_export.h" + +class GDExtensionExportPlugin : public EditorExportPlugin { +protected: + virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); +}; + +void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { + if (p_type != "NativeExtension") { + return; + } + + Ref<ConfigFile> config; + config.instantiate(); + + Error err = config->load(p_path); + + if (err != OK) { + return; + } + + if (!config->has_section_key("configuration", "entry_symbol")) { + return; + } + + String entry_symbol = config->get_value("configuration", "entry_symbol"); + + List<String> libraries; + + config->get_section_keys("libraries", &libraries); + + for (const String &E : libraries) { + Vector<String> tags = E.split("."); + bool all_tags_met = true; + for (int i = 0; i < tags.size(); i++) { + String tag = tags[i].strip_edges(); + if (!p_features.has(tag)) { + all_tags_met = false; + break; + } + } + + if (all_tags_met) { + String library_path = config->get_value("libraries", E); + if (!library_path.begins_with("res://")) { + print_line("Skipping export of out-of-project library " + library_path); + continue; + } + add_shared_object(library_path, tags); + + if (p_features.has("iOS") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) { + String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n" + "extern void add_ios_init_callback(void (*cb)());\n" + "\n" + "extern \"C\" void $ENTRY();\n" + "void $ENTRY_init() {\n" + " if (&$ENTRY) register_dynamic_symbol((char *)\"$ENTRY\", (void *)$ENTRY);\n" + "}\n" + "struct $ENTRY_struct {\n" + " $ENTRY_struct() {\n" + " add_ios_init_callback($ENTRY_init);\n" + " }\n" + "};\n" + "$ENTRY_struct $ENTRY_struct_instance;\n\n"; + additional_code = additional_code.replace("$ENTRY", entry_symbol); + add_ios_cpp_code(additional_code); + + String linker_flags = "-Wl,-U,_" + entry_symbol; + add_ios_linker_flags(linker_flags); + } + break; + } + } + + List<String> dependencies; + + config->get_section_keys("dependencies", &dependencies); + for (const String &E : libraries) { + Vector<String> tags = E.split("."); + bool all_tags_met = true; + for (int i = 0; i < tags.size(); i++) { + String tag = tags[i].strip_edges(); + if (!p_features.has(tag)) { + all_tags_met = false; + break; + } + } + + if (all_tags_met) { + Dictionary dependency = config->get_value("dependencies", E); + for (const Variant *key = dependency.next(nullptr); key; key = dependency.next(key)) { + String library_path = *key; + String target_path = dependency[*key]; + if (!library_path.begins_with("res://")) { + print_line("Skipping export of out-of-project library " + library_path); + continue; + } + add_shared_object(library_path, tags, target_path); + } + break; + } + } +} + +#endif // GDEXTENSION_EXPORT_PLUGIN_H diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 64540ac157..8f285cb7f9 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -447,16 +447,16 @@ MeshInstance3DEditor::MeshInstance3DEditor() { options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("MeshInstance3D"), SNAME("EditorIcons"))); options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); + options->get_popup()->set_item_tooltip(-1, TTR("Creates a StaticBody3D and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Trimesh Collision Sibling"), MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); + options->get_popup()->set_item_tooltip(-1, TTR("Creates a polygon-based collision shape.\nThis is the most accurate (but slowest) option for collision detection.")); options->get_popup()->add_item(TTR("Create Single Convex Collision Sibling"), MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection.")); + options->get_popup()->set_item_tooltip(-1, TTR("Creates a single convex collision shape.\nThis is the fastest (but least accurate) option for collision detection.")); options->get_popup()->add_item(TTR("Create Simplified Convex Collision Sibling"), MENU_OPTION_CREATE_SIMPLIFIED_CONVEX_COLLISION_SHAPE); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a simplified convex collision shape.\nThis is similar to single collision shape, but can result in a simpler geometry in some cases, at the cost of accuracy.")); + options->get_popup()->set_item_tooltip(-1, TTR("Creates a simplified convex collision shape.\nThis is similar to single collision shape, but can result in a simpler geometry in some cases, at the cost of accuracy.")); options->get_popup()->add_item(TTR("Create Multiple Convex Collision Siblings"), MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between a single convex collision and a polygon-based collision.")); + options->get_popup()->set_item_tooltip(-1, TTR("Creates a polygon-based collision shape.\nThis is a performance middle-ground between a single convex collision and a polygon-based collision.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH); options->get_popup()->add_separator(); diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 8aa8ba1f00..51e2f6ff00 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -3177,13 +3177,8 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { continue; } - Vector2 dir; - dir[j] = 1.0; - Vector2 ta, tb; int j_n1 = (j + 1) % 3; int j_n2 = (j + 2) % 3; - ta[j_n1] = 1.0; - tb[j_n2] = 1.0; for (int k = 0; k < 4; k++) { Vector3 from = aabb.position, to = aabb.position; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 3927aaa438..39e2e0bc9b 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -56,31 +56,31 @@ #include "scene/resources/packed_scene.h" #include "scene/resources/surface_tool.h" -#define DISTANCE_DEFAULT 4 +constexpr real_t DISTANCE_DEFAULT = 4; -#define GIZMO_ARROW_SIZE 0.35 -#define GIZMO_RING_HALF_WIDTH 0.1 -#define GIZMO_PLANE_SIZE 0.2 -#define GIZMO_PLANE_DST 0.3 -#define GIZMO_CIRCLE_SIZE 1.1 -#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3) -#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3) +constexpr real_t GIZMO_ARROW_SIZE = 0.35; +constexpr real_t GIZMO_RING_HALF_WIDTH = 0.1; +constexpr real_t GIZMO_PLANE_SIZE = 0.2; +constexpr real_t GIZMO_PLANE_DST = 0.3; +constexpr real_t GIZMO_CIRCLE_SIZE = 1.1; +constexpr real_t GIZMO_SCALE_OFFSET = GIZMO_CIRCLE_SIZE + 0.3; +constexpr real_t GIZMO_ARROW_OFFSET = GIZMO_CIRCLE_SIZE + 0.3; -#define ZOOM_FREELOOK_MIN 0.01 -#define ZOOM_FREELOOK_MULTIPLIER 1.08 -#define ZOOM_FREELOOK_INDICATOR_DELAY_S 1.5 +constexpr real_t ZOOM_FREELOOK_MIN = 0.01; +constexpr real_t ZOOM_FREELOOK_MULTIPLIER = 1.08; +constexpr real_t ZOOM_FREELOOK_INDICATOR_DELAY_S = 1.5; #ifdef REAL_T_IS_DOUBLE -#define ZOOM_FREELOOK_MAX 1'000'000'000'000 +constexpr double ZOOM_FREELOOK_MAX = 1'000'000'000'000; #else -#define ZOOM_FREELOOK_MAX 10'000 +constexpr float ZOOM_FREELOOK_MAX = 10'000; #endif -#define MIN_Z 0.01 -#define MAX_Z 1000000.0 +constexpr real_t MIN_Z = 0.01; +constexpr real_t MAX_Z = 1000000.0; -#define MIN_FOV 0.01 -#define MAX_FOV 179 +constexpr real_t MIN_FOV = 0.01; +constexpr real_t MAX_FOV = 179; void ViewportRotationControl::_notification(int p_what) { switch (p_what) { @@ -145,7 +145,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) { // Draw the axis letter for the positive axes. const String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z"); - draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0, alpha)); + draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(Math::round(-4.0 * EDSCALE), Math::round(5.0 * EDSCALE)), axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0, alpha)); } else { // Draw an outline around the negative axes. draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c); @@ -2690,27 +2690,27 @@ void Node3DEditorViewport::_notification(int p_what) { } } -static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2D> icon, const Ref<Font> font, int font_size, const String &text) { +static void draw_indicator_bar(Control &p_surface, real_t p_fill, const Ref<Texture2D> p_icon, const Ref<Font> p_font, int p_font_size, const String &p_text, const Color &p_color) { // Adjust bar size from control height - const Vector2 surface_size = surface.get_size(); + const Vector2 surface_size = p_surface.get_size(); const real_t h = surface_size.y / 2.0; const real_t y = (surface_size.y - h) / 2.0; const Rect2 r(10 * EDSCALE, y, 6 * EDSCALE, h); - const real_t sy = r.size.y * fill; + const real_t sy = r.size.y * p_fill; // Note: because this bar appears over the viewport, it has to stay readable for any background color // Draw both neutral dark and bright colors to account this - surface.draw_rect(r, Color(1, 1, 1, 0.2)); - surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), Color(1, 1, 1, 0.6)); - surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE)); + p_surface.draw_rect(r, p_color * Color(1, 1, 1, 0.2)); + p_surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), p_color * Color(1, 1, 1, 0.6)); + p_surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE)); - const Vector2 icon_size = icon->get_size(); + const Vector2 icon_size = p_icon->get_size(); const Vector2 icon_pos = Vector2(r.position.x - (icon_size.x - r.size.x) / 2, r.position.y + r.size.y + 2 * EDSCALE); - surface.draw_texture(icon, icon_pos); + p_surface.draw_texture(p_icon, icon_pos, p_color); // Draw text below the bar (for speed/zoom information). - surface.draw_string(font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, font_size); + p_surface.draw_string(p_font, Vector2(icon_pos.x, icon_pos.y + icon_size.y + 16 * EDSCALE), p_text, HORIZONTAL_ALIGNMENT_LEFT, -1.f, p_font_size, p_color, Math::round(2 * EDSCALE), Color(0, 0, 0)); } void Node3DEditorViewport::_draw() { @@ -2828,7 +2828,8 @@ void Node3DEditorViewport::_draw() { get_theme_icon(SNAME("ViewportSpeed"), SNAME("EditorIcons")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), - vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision))); + vformat("%s u/s", String::num(freelook_speed).pad_decimals(precision)), + Color(1.0, 0.95, 0.7)); } } else { @@ -2850,7 +2851,8 @@ void Node3DEditorViewport::_draw() { get_theme_icon(SNAME("ViewportZoom"), SNAME("EditorIcons")), get_theme_font(SNAME("font"), SNAME("Label")), get_theme_font_size(SNAME("font_size"), SNAME("Label")), - vformat("%s u", String::num(cursor.distance).pad_decimals(precision))); + vformat("%s u", String::num(cursor.distance).pad_decimals(precision)), + Color(0.7, 0.95, 1.0)); } } } diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index b7aef7f1bb..eafc53c72b 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -39,7 +39,8 @@ void ResourcePreloaderEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } break; } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d506a1f3ab..2da5978fab 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1881,7 +1881,7 @@ void ScriptEditor::_update_members_overview() { String name = functions[i].get_slice(":", 0); if (filter.is_empty() || filter.is_subsequence_ofn(name)) { members_overview->add_item(name); - members_overview->set_item_metadata(members_overview->get_item_count() - 1, functions[i].get_slice(":", 1).to_int() - 1); + members_overview->set_item_metadata(-1, functions[i].get_slice(":", 1).to_int() - 1); } } @@ -2139,7 +2139,7 @@ void ScriptEditor::_update_script_names() { for (int i = 0; i < sedata_filtered.size(); i++) { script_list->add_item(sedata_filtered[i].name, sedata_filtered[i].icon); if (sedata_filtered[i].tool) { - script_list->set_item_icon_modulate(script_list->get_item_count() - 1, tool_color); + script_list->set_item_icon_modulate(-1, tool_color); } int index = script_list->get_item_count() - 1; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 10b6129864..30ca1c605f 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -579,7 +579,7 @@ void ScriptTextEditor::_update_bookmark_list() { } bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - `" + line + "`"); - bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]); + bookmarks_menu->set_item_metadata(-1, bookmark_list[i]); } } @@ -731,7 +731,7 @@ void ScriptTextEditor::_update_breakpoint_list() { } breakpoints_menu->add_item(String::num((int)breakpoint_list[i] + 1) + " - `" + line + "`"); - breakpoints_menu->set_item_metadata(breakpoints_menu->get_item_count() - 1, breakpoint_list[i]); + breakpoints_menu->set_item_metadata(-1, breakpoint_list[i]); } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 382138a995..dbe6ca192c 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -435,8 +435,16 @@ void ShaderEditor::_menu_option(int p_option) { } void ShaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) { - _check_for_external_edit(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + PopupMenu *popup = help_menu->get_popup(); + popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_theme_icon(SNAME("Instance"), SNAME("EditorIcons"))); + } break; + + case NOTIFICATION_WM_WINDOW_FOCUS_IN: { + _check_for_external_edit(); + } break; } } @@ -647,7 +655,7 @@ void ShaderEditor::_update_bookmark_list() { } bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\""); - bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]); + bookmarks_menu->set_item_metadata(-1, bookmark_list[i]); } } @@ -772,7 +780,7 @@ ShaderEditor::ShaderEditor() { help_menu = memnew(MenuButton); help_menu->set_text(TTR("Help")); help_menu->set_switch_on_hover(true); - help_menu->get_popup()->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Online Docs"), HELP_DOCS); + help_menu->get_popup()->add_item(TTR("Online Docs"), HELP_DOCS); help_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); add_child(main_container); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index c8db16d3be..87b5b829e0 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -204,15 +204,22 @@ void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) { // to allow performing this action anywhere, even if the cursor isn't // hovering the texture in the workspace. if (mb->get_button_index() == MouseButton::WHEEL_UP && mb->is_pressed() && mb->is_ctrl_pressed()) { - _sheet_zoom_in(); + _sheet_zoom_on_position(scale_ratio, mb->get_position()); // Don't scroll up after zooming in. - accept_event(); + split_sheet_scroll->accept_event(); } else if (mb->get_button_index() == MouseButton::WHEEL_DOWN && mb->is_pressed() && mb->is_ctrl_pressed()) { - _sheet_zoom_out(); + _sheet_zoom_on_position(1 / scale_ratio, mb->get_position()); // Don't scroll down after zooming out. - accept_event(); + split_sheet_scroll->accept_event(); } } + + const Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) { + const Vector2 dragged = Input::get_singleton()->warp_mouse_motion(mm, split_sheet_scroll->get_global_rect()); + split_sheet_scroll->set_h_scroll(split_sheet_scroll->get_h_scroll() - dragged.x); + split_sheet_scroll->set_v_scroll(split_sheet_scroll->get_v_scroll() - dragged.y); + } } void SpriteFramesEditor::_sheet_add_frames() { @@ -243,20 +250,25 @@ void SpriteFramesEditor::_sheet_add_frames() { undo_redo->commit_action(); } +void SpriteFramesEditor::_sheet_zoom_on_position(float p_zoom, const Vector2 &p_position) { + const float old_zoom = sheet_zoom; + sheet_zoom = CLAMP(sheet_zoom * p_zoom, min_sheet_zoom, max_sheet_zoom); + + const Size2 texture_size = split_sheet_preview->get_texture()->get_size(); + split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom); + + Vector2 offset = Vector2(split_sheet_scroll->get_h_scroll(), split_sheet_scroll->get_v_scroll()); + offset = (offset + p_position) / old_zoom * sheet_zoom - p_position; + split_sheet_scroll->set_h_scroll(offset.x); + split_sheet_scroll->set_v_scroll(offset.y); +} + void SpriteFramesEditor::_sheet_zoom_in() { - if (sheet_zoom < max_sheet_zoom) { - sheet_zoom *= scale_ratio; - Size2 texture_size = split_sheet_preview->get_texture()->get_size(); - split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom); - } + _sheet_zoom_on_position(scale_ratio, Vector2()); } void SpriteFramesEditor::_sheet_zoom_out() { - if (sheet_zoom > min_sheet_zoom) { - sheet_zoom /= scale_ratio; - Size2 texture_size = split_sheet_preview->get_texture()->get_size(); - split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom); - } + _sheet_zoom_on_position(1 / scale_ratio, Vector2()); } void SpriteFramesEditor::_sheet_zoom_reset() { @@ -310,7 +322,8 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) { void SpriteFramesEditor::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_TREE: { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons"))); load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons"))); copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons"))); @@ -328,11 +341,9 @@ void SpriteFramesEditor::_notification(int p_what) { split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons"))); split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons"))); split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons"))); - [[fallthrough]]; - } - case NOTIFICATION_THEME_CHANGED: { split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); } break; + case NOTIFICATION_READY: { add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up. } break; @@ -847,7 +858,7 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) { at = at->get_atlas(); } - tree->set_item_tooltip(tree->get_item_count() - 1, tooltip); + tree->set_item_tooltip(-1, tooltip); } if (sel == i) { tree->select(tree->get_item_count() - 1); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 461c8dd41a..872a88e262 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -143,6 +143,7 @@ class SpriteFramesEditor : public HSplitContainer { void _sheet_preview_input(const Ref<InputEvent> &p_event); void _sheet_scroll_input(const Ref<InputEvent> &p_event); void _sheet_add_frames(); + void _sheet_zoom_on_position(float p_zoom, const Vector2 &p_position); void _sheet_zoom_in(); void _sheet_zoom_out(); void _sheet_zoom_reset(); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 940f269803..34f3ec73c0 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -179,7 +179,7 @@ void TextEditor::_update_bookmark_list() { } bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\""); - bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]); + bookmarks_menu->set_item_metadata(-1, bookmark_list[i]); } } diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp index 0f8c8c616c..086588f5a5 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.cpp +++ b/editor/plugins/tiles/atlas_merging_dialog.cpp @@ -241,7 +241,7 @@ void AtlasMergingDialog::update_tile_set(Ref<TileSet> p_tile_set) { if (texture.is_valid()) { String item_text = vformat("%s (id:%d)", texture->get_path().get_file(), source_id); atlas_merging_atlases_list->add_item(item_text, texture); - atlas_merging_atlases_list->set_item_metadata(atlas_merging_atlases_list->get_item_count() - 1, source_id); + atlas_merging_atlases_list->set_item_metadata(-1, source_id); } } } diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 4a0fc0b29f..8d8c65f2c4 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -188,7 +188,7 @@ void TileMapEditorTilesPlugin::_update_tile_set_sources_list() { } sources_list->add_item(item_text, texture); - sources_list->set_item_metadata(sources_list->get_item_count() - 1, source_id); + sources_list->set_item_metadata(-1, source_id); } if (sources_list->get_item_count() > 0) { diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 49e589c9ef..8b0b184f54 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -182,7 +182,7 @@ void TileSetEditor::_update_sources_list(int force_selected_id) { } sources_list->add_item(item_text, texture); - sources_list->set_item_metadata(sources_list->get_item_count() - 1, source_id); + sources_list->set_item_metadata(-1, source_id); } // Set again the current selected item if needed. diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 17db955cc7..9963ac0232 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1128,9 +1128,6 @@ ProjectExportDialog::ProjectExportDialog() { // Script export parameters. - updating_script_key = false; - updating_enc_filters = false; - VBoxContainer *sec_vb = memnew(VBoxContainer); sec_vb->set_name(TTR("Encryption")); @@ -1153,7 +1150,7 @@ ProjectExportDialog::ProjectExportDialog() { enc_ex_filters = memnew(LineEdit); enc_ex_filters->connect("text_changed", callable_mp(this, &ProjectExportDialog::_enc_filters_changed)); sec_vb->add_margin_child( - TTR("Filters to exclude files/folders\n(comma-separated, e.g: *.stex, *.import, music/*)"), + TTR("Filters to exclude files/folders\n(comma-separated, e.g: *.ctex, *.import, music/*)"), enc_ex_filters); script_key = memnew(LineEdit); @@ -1195,8 +1192,6 @@ ProjectExportDialog::ProjectExportDialog() { // Export buttons, dialogs and errors. - updating = false; - 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"); diff --git a/editor/project_export.h b/editor/project_export.h index 569563ba55..057fd31168 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -71,7 +71,7 @@ private: CheckButton *runnable; Button *button_export; - bool updating; + bool updating = false; AcceptDialog *error_dialog; ConfirmationDialog *delete_confirm; @@ -152,8 +152,8 @@ private: void _update_feature_list(); void _custom_features_changed(const String &p_text); - bool updating_script_key; - bool updating_enc_filters; + bool updating_script_key = false; + bool updating_enc_filters = false; void _enc_pck_changed(bool p_pressed); void _enc_directory_changed(bool p_pressed); void _enc_filters_changed(const String &p_text); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 78f6fe58d0..d32f935b54 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -147,7 +147,7 @@ private: } String _test_path() { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String valid_path, valid_install_path; if (d->change_dir(project_path->get_text()) == OK) { valid_path = project_path->get_text(); @@ -165,7 +165,6 @@ private: if (valid_path.is_empty()) { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR); - memdelete(d); get_ok_button()->set_disabled(true); return ""; } @@ -179,7 +178,6 @@ private: if (valid_install_path.is_empty()) { set_message(TTR("The path specified doesn't exist."), MESSAGE_ERROR, INSTALL_PATH); - memdelete(d); get_ok_button()->set_disabled(true); return ""; } @@ -194,7 +192,6 @@ private: unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io); if (!pkg) { set_message(TTR("Error opening package file (it's not in ZIP format)."), MESSAGE_ERROR); - memdelete(d); get_ok_button()->set_disabled(true); unzClose(pkg); return ""; @@ -215,7 +212,6 @@ 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_button()->set_disabled(true); unzClose(pkg); return ""; @@ -242,14 +238,12 @@ private: if (!is_folder_empty) { set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH); - memdelete(d); get_ok_button()->set_disabled(true); return ""; } } else { set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR); - memdelete(d); install_path_container->hide(); get_ok_button()->set_disabled(true); return ""; @@ -257,7 +251,6 @@ private: } else if (valid_path.ends_with("zip")) { set_message(TTR("This directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH); - memdelete(d); get_ok_button()->set_disabled(true); return ""; } @@ -282,7 +275,6 @@ 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_button()->set_disabled(false); return valid_path; } @@ -290,7 +282,6 @@ private: set_message(""); set_message("", MESSAGE_SUCCESS, INSTALL_PATH); - memdelete(d); get_ok_button()->set_disabled(false); return valid_path; } @@ -389,7 +380,7 @@ private: return; } - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (d->change_dir(project_path->get_text()) == OK) { if (!d->dir_exists(project_name_no_edges)) { if (d->make_dir(project_name_no_edges) == OK) { @@ -408,8 +399,6 @@ private: dialog_error->popup_centered(); } } - - memdelete(d); } void _text_changed(const String &p_text) { @@ -551,14 +540,11 @@ private: if (path.is_empty() || path == zip_root || !zip_root.is_subsequence_of(path)) { // } else if (path.ends_with("/")) { // a dir - path = path.substr(0, path.length() - 1); String rel_path = path.substr(zip_root.length()); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); da->make_dir(dir.plus_file(rel_path)); - memdelete(da); - } else { Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -620,9 +606,8 @@ private: void _remove_created_folder() { if (!created_folder_path.is_empty()) { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); d->remove(created_folder_path); - memdelete(d); create_dir->set_disabled(false); created_folder_path = ""; @@ -725,10 +710,9 @@ public: project_path->set_text(fav_dir); fdialog->set_current_dir(fav_dir); } else { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); project_path->set_text(d->get_current_dir()); fdialog->set_current_dir(d->get_current_dir()); - memdelete(d); } String proj = TTR("New Game Project"); project_name->set_text(proj); @@ -1911,6 +1895,11 @@ void ProjectManager::_notification(int p_what) { // to search without having to reach for their mouse search_box->grab_focus(); } + + if (asset_library) { + // Removes extra border margins. + asset_library->add_theme_style_override("panel", memnew(StyleBoxEmpty)); + } } break; case NOTIFICATION_VISIBILITY_CHANGED: { @@ -2411,12 +2400,11 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { return; } Set<String> folders_set; - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); for (int i = 0; i < p_files.size(); i++) { String file = p_files[i]; folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir()); } - memdelete(da); if (folders_set.size() > 0) { PackedStringArray folders; for (Set<String>::Element *E = folders_set.front(); E; E = E->next()) { @@ -2425,7 +2413,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { bool confirm = true; if (folders.size() == 1) { - DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (dir->change_dir(folders[0]) == OK) { dir->list_dir_begin(); String file = dir->get_next(); @@ -2437,7 +2425,6 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) { } dir->list_dir_end(); } - memdelete(dir); } if (confirm) { multi_scan_ask->get_ok_button()->disconnect("pressed", callable_mp(this, &ProjectManager::_scan_multiple_folders)); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index dd4b963fc0..52fb0d4f4e 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -1771,9 +1771,6 @@ void CustomPropertyEditor::_bind_methods() { } CustomPropertyEditor::CustomPropertyEditor() { - read_only = false; - updating = false; - value_vbox = memnew(VBoxContainer); add_child(value_vbox); diff --git a/editor/property_editor.h b/editor/property_editor.h index c4287dc115..73306e0bc2 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -119,7 +119,7 @@ class CustomPropertyEditor : public PopupPanel { TextureRect *texture_preview; ColorPicker *color_picker; TextEdit *text_edit; - bool read_only; + bool read_only = false; bool picking_viewport; GridContainer *checks20gc; CheckBox *checks20[20]; @@ -132,7 +132,7 @@ class CustomPropertyEditor : public PopupPanel { Object *owner; - bool updating; + bool updating = false; PropertyValueEvaluator *evaluator; diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 453ecb6b24..1ac15a0a9d 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -589,7 +589,6 @@ PropertySelector::PropertySelector() { search_options->connect("cell_selected", callable_mp(this, &PropertySelector::_item_selected)); search_options->set_hide_root(true); search_options->set_hide_folding(true); - virtuals_only = false; help_bit = memnew(EditorHelpBit); vbc->add_margin_child(TTR("Description:"), help_bit); diff --git a/editor/property_selector.h b/editor/property_selector.h index 1e8c6300a0..7e629a847e 100644 --- a/editor/property_selector.h +++ b/editor/property_selector.h @@ -56,7 +56,7 @@ class PropertySelector : public ConfirmationDialog { String base_type; ObjectID script; Object *instance; - bool virtuals_only; + bool virtuals_only = false; Vector<Variant::Type> type_filter; diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 4e64aba1db..53da945868 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -245,8 +245,6 @@ void EditorQuickOpen::_bind_methods() { } EditorQuickOpen::EditorQuickOpen() { - allow_multi_select = false; - VBoxContainer *vbc = memnew(VBoxContainer); vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed)); add_child(vbc); diff --git a/editor/quick_open.h b/editor/quick_open.h index dc485a7c86..f50f09604c 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -42,7 +42,7 @@ class EditorQuickOpen : public ConfirmationDialog { LineEdit *search_box; Tree *search_options; StringName base_type; - bool allow_multi_select; + bool allow_multi_select = false; Vector<String> files; OAHashMap<String, Ref<Texture2D>> icons; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 571b87a0aa..8d7916685a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2551,7 +2551,7 @@ void SceneTreeDock::_files_dropped(Vector<String> p_files, NodePath p_to, int p_ menu_properties->clear(); for (const String &p : valid_properties) { menu_properties->add_item(capitalize ? p.capitalize() : p); - menu_properties->set_item_metadata(menu_properties->get_item_count() - 1, p); + menu_properties->set_item_metadata(-1, p); } menu_properties->reset_size(); @@ -3497,8 +3497,6 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec menu_subresources->set_name("Sub-Resources"); menu_subresources->connect("id_pressed", callable_mp(this, &SceneTreeDock::_tool_selected), make_binds(false)); menu->add_child(menu_subresources); - first_enter = true; - restore_script_editor_on_drag = false; menu_properties = memnew(PopupMenu); add_child(menu_properties); @@ -3512,9 +3510,6 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec set_process_input(true); set_process(true); - profile_allow_editing = true; - profile_allow_script_editing = true; - EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true); EDITOR_DEF("interface/editors/derive_script_globals_by_name", true); EDITOR_DEF("_use_favorites_root_selection", false); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 2a98c469dc..938f83725d 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -105,7 +105,7 @@ class SceneTreeDock : public VBoxContainer { Vector<ObjectID> subresources; - bool restore_script_editor_on_drag; + bool restore_script_editor_on_drag = false; bool reset_create_dialog = false; int current_option; @@ -166,7 +166,7 @@ class SceneTreeDock : public VBoxContainer { PopupMenu *menu_properties; ConfirmationDialog *clear_inherit_confirm; - bool first_enter; + bool first_enter = true; void _create(); void _do_create(Node *p_parent); @@ -261,8 +261,8 @@ class SceneTreeDock : public VBoxContainer { void _create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap); void _create_remap_for_resource(RES p_resource, Map<RES, RES> &r_remap); - bool profile_allow_editing; - bool profile_allow_script_editing; + bool profile_allow_editing = true; + bool profile_allow_script_editing = true; static void _update_configuration_warning(); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c6a8a928db..3b8c540592 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1197,17 +1197,11 @@ void SceneTreeEditor::_bind_methods() { } SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_open_instance) { - connect_to_script_mode = false; - connecting_signal = false; undo_redo = nullptr; - tree_dirty = true; selected = nullptr; - marked_selectable = false; - marked_children_selectable = false; can_rename = p_can_rename; can_open_instance = p_can_open_instance; - display_foreign = false; editor_selection = nullptr; if (p_label) { @@ -1249,11 +1243,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope add_child(warning); warning->set_title(TTR("Node Configuration Warning!")); - show_enabled_subscene = false; - last_hash = 0; - pending_test_update = false; - updating_tree = false; blocked = 0; update_timer = memnew(Timer); diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index f700182681..2466b8576a 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -65,8 +65,8 @@ class SceneTreeEditor : public Control { AcceptDialog *warning; bool auto_expand_selected = true; - bool connect_to_script_mode; - bool connecting_signal; + bool connect_to_script_mode = false; + bool connecting_signal = false; int blocked; @@ -92,18 +92,18 @@ class SceneTreeEditor : public Control { bool can_rename; bool can_open_instance; - bool updating_tree; - bool show_enabled_subscene; + bool updating_tree = false; + bool show_enabled_subscene = false; void _renamed(); UndoRedo *undo_redo; Set<Node *> marked; - bool marked_selectable; - bool marked_children_selectable; - bool display_foreign; - bool tree_dirty; - bool pending_test_update; + bool marked_selectable = false; + bool marked_children_selectable = false; + bool display_foreign = false; + bool tree_dirty = true; + bool pending_test_update = false; static void _bind_methods(); void _cell_button_pressed(Object *p_item, int p_column, int p_id); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index bf43e11cdb..baafef8639 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -247,23 +247,22 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must return TTR("Path is not local."); } - DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - if (d->change_dir(p.get_base_dir()) != OK) { - memdelete(d); - return TTR("Base path is invalid."); + { + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + if (da->change_dir(p.get_base_dir()) != OK) { + return TTR("Base path is invalid."); + } } - memdelete(d); - // Check if file exists. - DirAccess *f = DirAccess::create(DirAccess::ACCESS_RESOURCES); - if (f->dir_exists(p)) { - memdelete(f); - return TTR("A directory with the same name exists."); - } else if (p_file_must_exist && !f->file_exists(p)) { - memdelete(f); - return TTR("File does not exist."); + { + // Check if file exists. + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); + if (da->dir_exists(p)) { + return TTR("A directory with the same name exists."); + } else if (p_file_must_exist && !da->file_exists(p)) { + return TTR("File does not exist."); + } } - memdelete(f); // Check file extension. String extension = p.get_extension(); @@ -556,13 +555,12 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { } // Check if file exists. - DirAccess *f = DirAccess::create(DirAccess::ACCESS_RESOURCES); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); String p = ProjectSettings::get_singleton()->localize_path(p_path.strip_edges()); - if (f->file_exists(p)) { + if (da->file_exists(p)) { is_new_script_created = false; _msg_path_valid(true, TTR("File exists, it will be reused.")); } - memdelete(f); is_path_valid = true; _update_dialog(); @@ -643,7 +641,7 @@ void ScriptCreateDialog::_update_template_menu() { if (!templates_found.is_empty()) { if (!separator) { template_menu->add_separator(); - template_menu->set_item_text(template_menu->get_item_count() - 1, display_name); + template_menu->set_item_text(-1, display_name); separator = true; } for (ScriptLanguage::ScriptTemplate &t : templates_found) { @@ -838,7 +836,7 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c String dir_path = p_dir.plus_file(p_object); - DirAccess *d = DirAccess::open(dir_path); + DirAccessRef d = DirAccess::open(dir_path); if (d) { d->list_dir_begin(); String file = d->get_next(); @@ -849,7 +847,6 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c file = d->get_next(); } d->list_dir_end(); - memdelete(d); } return user_templates; } @@ -1029,7 +1026,6 @@ ScriptCreateDialog::ScriptCreateDialog() { hb->add_child(parent_browse_button); gc->add_child(memnew(Label(TTR("Inherits:")))); gc->add_child(hb); - is_browsing_parent = false; /* Class Name */ @@ -1040,8 +1036,6 @@ ScriptCreateDialog::ScriptCreateDialog() { gc->add_child(class_name); /* Templates */ - - is_using_templates = true; gc->add_child(memnew(Label(TTR("Template:")))); HBoxContainer *template_hb = memnew(HBoxContainer); template_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); @@ -1082,7 +1076,6 @@ ScriptCreateDialog::ScriptCreateDialog() { Label *label = memnew(Label(TTR("Path:"))); gc->add_child(label); gc->add_child(hb); - re_check_path = false; path_controls[0] = label; path_controls[1] = hb; @@ -1119,17 +1112,4 @@ ScriptCreateDialog::ScriptCreateDialog() { set_hide_on_ok(false); set_title(TTR("Attach Node Script")); - - is_parent_name_valid = false; - is_class_name_valid = false; - is_path_valid = false; - - has_named_classes = false; - supports_built_in = false; - can_inherit_from_file = false; - is_built_in = false; - built_in_enabled = true; - load_enabled = true; - - is_new_script_created = true; } diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index 5c0f51812f..d7c43f322c 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -66,25 +66,23 @@ class ScriptCreateDialog : public ConfirmationDialog { VBoxContainer *path_vb; AcceptDialog *alert; CreateDialog *select_class; - bool path_valid; - bool create_new; - bool is_browsing_parent; + bool is_browsing_parent = false; String template_inactive_message; String initial_bp; - bool is_new_script_created; - bool is_path_valid; - bool has_named_classes; - bool supports_built_in; - bool can_inherit_from_file; - bool is_parent_name_valid; - bool is_class_name_valid; - bool is_built_in; - bool is_using_templates; - bool built_in_enabled; - bool load_enabled; + bool is_new_script_created = true; + bool is_path_valid = false; + bool has_named_classes = false; + bool supports_built_in = false; + bool can_inherit_from_file = false; + bool is_parent_name_valid = false; + bool is_class_name_valid = false; + bool is_built_in = false; + bool is_using_templates = true; + bool built_in_enabled = true; + bool load_enabled = true; int current_language; int default_language; - bool re_check_path; + bool re_check_path = false; Control *path_controls[2]; Control *name_controls[2]; |