diff options
Diffstat (limited to 'editor')
187 files changed, 2929 insertions, 2786 deletions
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index 34c70c942e..e96139e070 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -63,24 +63,24 @@ private: Ref<InputEvent> event = Ref<InputEvent>(); - TabContainer *tab_container; + TabContainer *tab_container = nullptr; // Listening for input - Label *event_as_text; - ColorRect *mouse_detection_rect; + Label *event_as_text = nullptr; + ColorRect *mouse_detection_rect = nullptr; // List of All Key/Mouse/Joypad input options. int allowed_input_types; - Tree *input_list_tree; - LineEdit *input_list_search; + Tree *input_list_tree = nullptr; + LineEdit *input_list_search = nullptr; // Additional Options, shown depending on event selected - VBoxContainer *additional_options_container; + VBoxContainer *additional_options_container = nullptr; - HBoxContainer *device_container; - OptionButton *device_id_option; + HBoxContainer *device_container = nullptr; + OptionButton *device_id_option = nullptr; - HBoxContainer *mod_container; // Contains the subcontainer and the store command checkbox. + HBoxContainer *mod_container = nullptr; // Contains the subcontainer and the store command checkbox. enum ModCheckbox { MOD_ALT, @@ -93,9 +93,9 @@ private: String mods[MOD_MAX] = { "Alt", "Shift", "Command", "Ctrl", "Metakey" }; CheckBox *mod_checkboxes[MOD_MAX]; - CheckBox *store_command_checkbox; + CheckBox *store_command_checkbox = nullptr; - CheckBox *physical_key_checkbox; + CheckBox *physical_key_checkbox = nullptr; void _set_event(const Ref<InputEvent> &p_event); @@ -149,7 +149,7 @@ private: }; Vector<ActionInfo> actions_cache; - Tree *action_tree; + Tree *action_tree = nullptr; // Storing which action/event is currently being edited in the InputEventConfigurationDialog. @@ -159,17 +159,17 @@ private: // Popups - InputEventConfigurationDialog *event_config_dialog; - AcceptDialog *message; + InputEventConfigurationDialog *event_config_dialog = nullptr; + AcceptDialog *message = nullptr; // Filtering and Adding actions bool show_builtin_actions = false; - CheckButton *show_builtin_actions_checkbutton; - LineEdit *action_list_search; + CheckButton *show_builtin_actions_checkbutton = nullptr; + LineEdit *action_list_search = nullptr; - HBoxContainer *add_hbox; - LineEdit *add_edit; + HBoxContainer *add_hbox = nullptr; + LineEdit *add_edit = nullptr; void _event_config_confirmed(); diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 0dbe230699..8239745a3e 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -146,11 +146,10 @@ void AnimationBezierTrackEdit::_draw_track(int p_track, const Color &p_color) { int iterations = 10; float low = 0; float high = 1; - float middle; //narrow high and low as much as possible for (int k = 0; k < iterations; k++) { - middle = (low + high) / 2; + float middle = (low + high) / 2; Vector2 interp = _bezier_interp(middle, start, out_handle, in_handle, end); diff --git a/editor/animation_bezier_editor.h b/editor/animation_bezier_editor.h index fa6fc405f2..dcb6502440 100644 --- a/editor/animation_bezier_editor.h +++ b/editor/animation_bezier_editor.h @@ -49,7 +49,7 @@ class AnimationBezierTrackEdit : public Control { AnimationTimelineEdit *timeline = nullptr; UndoRedo *undo_redo = nullptr; Node *root = nullptr; - Control *play_position; //separate control used to draw so updates for only position changed are much faster + Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster float play_position_pos = 0; Ref<Animation> animation; @@ -130,7 +130,7 @@ class AnimationBezierTrackEdit : public Control { float transition = 0; }; - AnimationTrackEditor *editor; + AnimationTrackEditor *editor = nullptr; struct EditPoint { Rect2 point_rect; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index e61a1aae9c..dc69a8cb08 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3383,7 +3383,7 @@ Node *AnimationTrackEditor::get_root() const { void AnimationTrackEditor::update_keying() { bool keying_enabled = false; - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); if (is_visible_in_tree() && animation.is_valid() && editor_history->get_path_size() > 0) { Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0)); keying_enabled = Object::cast_to<Node>(obj) != nullptr; @@ -3776,7 +3776,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p return; } - EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history(); for (int i = 1; i < history->get_path_size(); i++) { String prop = history->get_path_property(i); ERR_FAIL_COND(prop.is_empty()); @@ -3856,7 +3856,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p } void AnimationTrackEditor::insert_value_key(const String &p_property, const Variant &p_value, bool p_advance) { - EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history(); ERR_FAIL_COND(!root); // Let's build a node path. diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 1baebc469e..d025dd3d26 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -54,27 +54,27 @@ class AnimationTimelineEdit : public Range { GDCLASS(AnimationTimelineEdit, Range); Ref<Animation> animation; - AnimationTrackEdit *track_edit; + AnimationTrackEdit *track_edit = nullptr; int name_limit; - Range *zoom; - Range *h_scroll; + Range *zoom = nullptr; + Range *h_scroll = nullptr; float play_position_pos; - HBoxContainer *len_hb; - EditorSpinSlider *length; - Button *loop; - TextureRect *time_icon; + HBoxContainer *len_hb = nullptr; + EditorSpinSlider *length = nullptr; + Button *loop = nullptr; + TextureRect *time_icon = nullptr; - MenuButton *add_track; - Control *play_position; //separate control used to draw so updates for only position changed are much faster - HScrollBar *hscroll; + MenuButton *add_track = nullptr; + Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster + HScrollBar *hscroll = nullptr; void _zoom_changed(double); void _anim_length_changed(double p_new_len); void _anim_loop_pressed(); void _play_position_draw(); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; Rect2 hsize_rect; bool editing = false; @@ -146,12 +146,12 @@ class AnimationTrackEdit : public Control { MENU_KEY_ADD_RESET, MENU_KEY_DELETE }; - AnimationTimelineEdit *timeline; - UndoRedo *undo_redo; - Popup *path_popup; - LineEdit *path; - Node *root; - Control *play_position; //separate control used to draw so updates for only position changed are much faster + AnimationTimelineEdit *timeline = nullptr; + UndoRedo *undo_redo = nullptr; + Popup *path_popup = nullptr; + LineEdit *path = nullptr; + Node *root = nullptr; + Control *play_position = nullptr; //separate control used to draw so updates for only position changed are much faster float play_position_pos; NodePath node_path; @@ -169,7 +169,7 @@ class AnimationTrackEdit : public Control { Ref<Texture2D> type_icon; Ref<Texture2D> selected_icon; - PopupMenu *menu; + PopupMenu *menu = nullptr; bool clicking_on_name = false; @@ -194,7 +194,7 @@ class AnimationTrackEdit : public Control { float moving_selection_from_ofs; bool in_group = false; - AnimationTrackEditor *editor; + AnimationTrackEditor *editor = nullptr; protected: static void _bind_methods(); @@ -285,27 +285,27 @@ class AnimationTrackEditor : public VBoxContainer { GDCLASS(AnimationTrackEditor, VBoxContainer); Ref<Animation> animation; - Node *root; - - MenuButton *edit; + Node *root = nullptr; - PanelContainer *main_panel; - HScrollBar *hscroll; - ScrollContainer *scroll; - VBoxContainer *track_vbox; - AnimationBezierTrackEdit *bezier_edit; + MenuButton *edit = nullptr; - Label *info_message; + PanelContainer *main_panel = nullptr; + HScrollBar *hscroll = nullptr; + ScrollContainer *scroll = nullptr; + VBoxContainer *track_vbox = nullptr; + AnimationBezierTrackEdit *bezier_edit = nullptr; - AnimationTimelineEdit *timeline; - HSlider *zoom; - EditorSpinSlider *step; - TextureRect *zoom_icon; - Button *snap; - Button *bezier_edit_icon; - OptionButton *snap_mode; + Label *info_message = nullptr; - Button *imported_anim_warning; + AnimationTimelineEdit *timeline = nullptr; + HSlider *zoom = nullptr; + EditorSpinSlider *step = nullptr; + TextureRect *zoom_icon = nullptr; + Button *snap = nullptr; + Button *bezier_edit_icon = nullptr; + OptionButton *snap_mode = nullptr; + + Button *imported_anim_warning = nullptr; void _show_imported_anim_warning(); void _snap_mode_changed(int p_mode); @@ -323,7 +323,7 @@ class AnimationTrackEditor : public VBoxContainer { void _track_remove_request(int p_track); void _track_grab_focus(int p_track); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void _update_scroll(double); void _update_step(double p_new_step); @@ -336,9 +336,9 @@ class AnimationTrackEditor : public VBoxContainer { void _update_step_spinbox(); - PropertySelector *prop_selector; - PropertySelector *method_selector; - SceneTreeDialog *pick_track; + PropertySelector *prop_selector = nullptr; + PropertySelector *method_selector = nullptr; + SceneTreeDialog *pick_track = nullptr; int adding_track_type; NodePath adding_track_path; @@ -353,10 +353,10 @@ class AnimationTrackEditor : public VBoxContainer { bool advance = false; }; /* insert_data;*/ - Label *insert_confirm_text; - CheckBox *insert_confirm_bezier; - CheckBox *insert_confirm_reset; - ConfirmationDialog *insert_confirm; + Label *insert_confirm_text = nullptr; + CheckBox *insert_confirm_bezier = nullptr; + CheckBox *insert_confirm_reset = nullptr; + ConfirmationDialog *insert_confirm = nullptr; bool insert_queue = false; List<InsertData> insert_data; @@ -419,13 +419,13 @@ class AnimationTrackEditor : public VBoxContainer { void _move_selection_commit(); void _move_selection_cancel(); - AnimationTrackKeyEdit *key_edit; - AnimationMultiTrackKeyEdit *multi_key_edit; + AnimationTrackKeyEdit *key_edit = nullptr; + AnimationMultiTrackKeyEdit *multi_key_edit = nullptr; void _update_key_edit(); void _clear_key_edit(); - Control *box_selection; + Control *box_selection = nullptr; void _box_selection_draw(); bool box_selecting = false; Vector2 box_selecting_from; @@ -440,18 +440,18 @@ class AnimationTrackEditor : public VBoxContainer { ////////////// edit menu stuff - ConfirmationDialog *optimize_dialog; - SpinBox *optimize_linear_error; - SpinBox *optimize_angular_error; - SpinBox *optimize_max_angle; + ConfirmationDialog *optimize_dialog = nullptr; + SpinBox *optimize_linear_error = nullptr; + SpinBox *optimize_angular_error = nullptr; + SpinBox *optimize_max_angle = nullptr; - ConfirmationDialog *cleanup_dialog; - CheckBox *cleanup_keys; - CheckBox *cleanup_tracks; - CheckBox *cleanup_all; + ConfirmationDialog *cleanup_dialog = nullptr; + CheckBox *cleanup_keys = nullptr; + CheckBox *cleanup_tracks = nullptr; + CheckBox *cleanup_all = nullptr; - ConfirmationDialog *scale_dialog; - SpinBox *scale; + ConfirmationDialog *scale_dialog = nullptr; + SpinBox *scale = nullptr; void _select_all_tracks_for_copy(); @@ -464,13 +464,13 @@ class AnimationTrackEditor : public VBoxContainer { void _anim_duplicate_keys(bool transpose); void _view_group_toggle(); - Button *view_group; - Button *selected_filter; + Button *view_group = nullptr; + Button *selected_filter = nullptr; void _selection_changed(); - ConfirmationDialog *track_copy_dialog; - Tree *track_copy_select; + ConfirmationDialog *track_copy_dialog = nullptr; + Tree *track_copy_select = nullptr; struct TrackClipboard { NodePath full_path; diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index 2ad8b2d2a4..d07881e28e 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -339,11 +339,11 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x, Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); - draw_rect(rect, color); + draw_rect_clipped(rect, color); if (p_selected) { Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - draw_rect(rect, accent, false); + draw_rect_clipped(rect, accent, false); } } } @@ -712,11 +712,11 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_ Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); - draw_rect(rect, color); + draw_rect_clipped(rect, color); if (p_selected) { Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - draw_rect(rect, accent, false); + draw_rect_clipped(rect, accent, false); } } } @@ -1287,11 +1287,11 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec, Rect2 rect(Vector2(p_x, int(get_size().height - fh) / 2), Size2(fh, fh)); Color color = get_theme_color(SNAME("font_color"), SNAME("Label")); - draw_rect(rect, color); + draw_rect_clipped(rect, color); if (p_selected) { Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - draw_rect(rect, accent, false); + draw_rect_clipped(rect, accent, false); } } } diff --git a/editor/code_editor.h b/editor/code_editor.h index bbc45d6ec0..d52f57860c 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -43,10 +43,10 @@ class GotoLineDialog : public ConfirmationDialog { GDCLASS(GotoLineDialog, ConfirmationDialog); - Label *line_label; - LineEdit *line; + Label *line_label = nullptr; + LineEdit *line = nullptr; - CodeEdit *text_editor; + CodeEdit *text_editor = nullptr; virtual void ok_pressed() override; @@ -62,25 +62,25 @@ class CodeTextEditor; class FindReplaceBar : public HBoxContainer { GDCLASS(FindReplaceBar, HBoxContainer); - LineEdit *search_text; - Label *matches_label; - Button *find_prev; - Button *find_next; - CheckBox *case_sensitive; - CheckBox *whole_words; - TextureButton *hide_button; + LineEdit *search_text = nullptr; + Label *matches_label = nullptr; + Button *find_prev = nullptr; + Button *find_next = nullptr; + CheckBox *case_sensitive = nullptr; + CheckBox *whole_words = nullptr; + TextureButton *hide_button = nullptr; - LineEdit *replace_text; - Button *replace; - Button *replace_all; - CheckBox *selection_only; + LineEdit *replace_text = nullptr; + Button *replace = nullptr; + Button *replace_all = nullptr; + CheckBox *selection_only = nullptr; - VBoxContainer *vbc_lineedit; - HBoxContainer *hbc_button_replace; - HBoxContainer *hbc_option_replace; + VBoxContainer *vbc_lineedit = nullptr; + HBoxContainer *hbc_button_replace = nullptr; + HBoxContainer *hbc_option_replace = nullptr; CodeTextEditor *base_text_editor = nullptr; - CodeEdit *text_editor; + CodeEdit *text_editor = nullptr; int result_line; int result_col; @@ -139,25 +139,25 @@ typedef void (*CodeTextEditorCodeCompleteFunc)(void *p_ud, const String &p_code, class CodeTextEditor : public VBoxContainer { GDCLASS(CodeTextEditor, VBoxContainer); - CodeEdit *text_editor; + CodeEdit *text_editor = nullptr; FindReplaceBar *find_replace_bar = nullptr; - HBoxContainer *status_bar; + HBoxContainer *status_bar = nullptr; - Button *toggle_scripts_button; - Button *error_button; - Button *warning_button; + Button *toggle_scripts_button = nullptr; + Button *error_button = nullptr; + Button *warning_button = nullptr; - Label *line_and_col_txt; + Label *line_and_col_txt = nullptr; - Label *info; - Timer *idle; - Timer *code_complete_timer; + Label *info = nullptr; + Timer *idle = nullptr; + Timer *code_complete_timer = nullptr; - Timer *font_resize_timer; + Timer *font_resize_timer = nullptr; int font_resize_val; real_t font_size; - Label *error; + Label *error = nullptr; int error_line; int error_column; @@ -181,7 +181,7 @@ class CodeTextEditor : public VBoxContainer { Color completion_string_color; Color completion_comment_color; CodeTextEditorCodeCompleteFunc code_complete_func; - void *code_complete_ud; + void *code_complete_ud = nullptr; void _error_button_pressed(); void _warning_button_pressed(); diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 58c584b8b2..4b1b8363dd 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -105,27 +105,27 @@ public: }; private: - Label *connect_to_label; - LineEdit *from_signal; - Node *source; + Label *connect_to_label = nullptr; + LineEdit *from_signal = nullptr; + Node *source = nullptr; StringName signal; - LineEdit *dst_method; - ConnectDialogBinds *cdbinds; + LineEdit *dst_method = nullptr; + ConnectDialogBinds *cdbinds = nullptr; bool edit_mode; NodePath dst_path; - VBoxContainer *vbc_right; - - SceneTreeEditor *tree; - AcceptDialog *error; - SpinBox *unbind_count; - EditorInspector *bind_editor; - OptionButton *type_list; - CheckBox *deferred; - CheckBox *oneshot; - CheckButton *advanced; + VBoxContainer *vbc_right = nullptr; + + SceneTreeEditor *tree = nullptr; + AcceptDialog *error = nullptr; + SpinBox *unbind_count = nullptr; + EditorInspector *bind_editor = nullptr; + OptionButton *type_list = nullptr; + CheckBox *deferred = nullptr; + CheckBox *oneshot = nullptr; + CheckButton *advanced = nullptr; Vector<Control *> bind_controls; - Label *error_label; + Label *error_label = nullptr; void ok_pressed() override; void _cancel_pressed(); @@ -186,16 +186,16 @@ class ConnectionsDock : public VBoxContainer { DISCONNECT }; - Node *selected_node; - ConnectionsDockTree *tree; + Node *selected_node = nullptr; + ConnectionsDockTree *tree = nullptr; - ConfirmationDialog *disconnect_all_dialog; - ConnectDialog *connect_dialog; - Button *connect_button; - PopupMenu *signal_menu; - PopupMenu *slot_menu; - UndoRedo *undo_redo; - LineEdit *search_box; + ConfirmationDialog *disconnect_all_dialog = nullptr; + ConnectDialog *connect_dialog = nullptr; + Button *connect_button = nullptr; + PopupMenu *signal_menu = nullptr; + PopupMenu *slot_menu = nullptr; + UndoRedo *undo_redo = nullptr; + LineEdit *search_box = nullptr; Map<StringName, Map<StringName, String>> descr_cache; diff --git a/editor/create_dialog.h b/editor/create_dialog.h index fe7c89c059..31761be6fe 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -47,18 +47,18 @@ class CreateDialog : public ConfirmationDialog { OTHER_TYPE }; - LineEdit *search_box; - Tree *search_options; + LineEdit *search_box = nullptr; + Tree *search_options = nullptr; String base_type; String icon_fallback; String preferred_search_result_type; - Button *favorite; + Button *favorite = nullptr; Vector<String> favorite_list; - Tree *favorites; - ItemList *recent; - EditorHelpBit *help_bit; + Tree *favorites = nullptr; + ItemList *recent = nullptr; + EditorHelpBit *help_bit = nullptr; HashMap<String, TreeItem *> search_options_types; HashMap<String, String> custom_type_parents; diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index b54a5f1f3f..e4760bea54 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -76,7 +76,7 @@ class DebugAdapterProtocol : public Object { private: static DebugAdapterProtocol *singleton; - DebugAdapterParser *parser; + DebugAdapterParser *parser = nullptr; List<Ref<DAPeer>> clients; Ref<TCPServer> server; diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index c111190ca3..936b8ca626 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -206,7 +206,7 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { void EditorDebuggerInspector::clear_cache() { for (const KeyValue<ObjectID, EditorDebuggerRemoteObject *> &E : remote_objects) { EditorNode *editor = EditorNode::get_singleton(); - if (editor->get_editor_history()->get_current() == E.value->get_instance_id()) { + if (editor->get_editor_selection_history()->get_current() == E.value->get_instance_id()) { editor->push_item(nullptr); } memdelete(E.value); diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index 5cdc4417d0..8f523bfbdc 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -70,7 +70,7 @@ private: ObjectID inspected_object_id; Map<ObjectID, EditorDebuggerRemoteObject *> remote_objects; Set<RES> remote_dependencies; - EditorDebuggerRemoteObject *variables; + EditorDebuggerRemoteObject *variables = nullptr; void _object_selected(ObjectID p_object); void _object_edited(ObjectID p_id, const String &p_prop, const Variant &p_value); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index d294858ff8..c0685af572 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -181,7 +181,7 @@ void EditorDebuggerNode::_bind_methods() { } EditorDebuggerRemoteObject *EditorDebuggerNode::get_inspected_remote_object() { - return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_current())); + return Object::cast_to<EditorDebuggerRemoteObject>(ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_current())); } ScriptEditorDebugger *EditorDebuggerNode::get_debugger(int p_id) const { diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index 3e95eb0de6..3a604f5564 100644 --- a/editor/debugger/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -42,13 +42,13 @@ class EditorNetworkProfiler : public VBoxContainer { GDCLASS(EditorNetworkProfiler, VBoxContainer) private: - Button *activate; - Button *clear_button; - Tree *counters_display; - LineEdit *incoming_bandwidth_text; - LineEdit *outgoing_bandwidth_text; + Button *activate = nullptr; + Button *clear_button = nullptr; + Tree *counters_display = nullptr; + LineEdit *incoming_bandwidth_text = nullptr; + LineEdit *outgoing_bandwidth_text = nullptr; - Timer *frame_delay; + Timer *frame_delay = nullptr; Map<ObjectID, SceneDebugger::RPCNodeInfo> nodes_data; diff --git a/editor/debugger/editor_performance_profiler.h b/editor/debugger/editor_performance_profiler.h index 998ecc5bb6..a917ddbe28 100644 --- a/editor/debugger/editor_performance_profiler.h +++ b/editor/debugger/editor_performance_profiler.h @@ -62,9 +62,9 @@ private: OrderedHashMap<StringName, Monitor> monitors; Map<StringName, TreeItem *> base_map; - Tree *monitor_tree; - Control *monitor_draw; - Label *info_message; + Tree *monitor_tree = nullptr; + Control *monitor_draw = nullptr; + Label *info_message = nullptr; StringName marker_key; int marker_frame; const int MARGIN = 4; diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index 45f7ac39c1..34f34be7c3 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -90,20 +90,20 @@ public: }; private: - Button *activate; - Button *clear_button; - TextureRect *graph; + Button *activate = nullptr; + Button *clear_button = nullptr; + TextureRect *graph = nullptr; Ref<ImageTexture> graph_texture; Vector<uint8_t> graph_image; - Tree *variables; - HSplitContainer *h_split; + Tree *variables = nullptr; + HSplitContainer *h_split = nullptr; Set<StringName> plot_sigs; - OptionButton *display_mode; - OptionButton *display_time; + OptionButton *display_mode = nullptr; + OptionButton *display_time = nullptr; - SpinBox *cursor_metric_edit; + SpinBox *cursor_metric_edit = nullptr; Vector<Metric> frame_metrics; int total_metrics; @@ -119,8 +119,8 @@ private: bool seeking; - Timer *frame_delay; - Timer *plot_delay; + Timer *frame_delay = nullptr; + Timer *plot_delay = nullptr; void _update_frame(); diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index 55ba725ae8..14eacca02d 100644 --- a/editor/debugger/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h @@ -67,20 +67,20 @@ public: }; private: - Button *activate; - Button *clear_button; + Button *activate = nullptr; + Button *clear_button = nullptr; - TextureRect *graph; + TextureRect *graph = nullptr; Ref<ImageTexture> graph_texture; Vector<uint8_t> graph_image; - Tree *variables; - HSplitContainer *h_split; - CheckBox *frame_relative; - CheckBox *linked; + Tree *variables = nullptr; + HSplitContainer *h_split = nullptr; + CheckBox *frame_relative = nullptr; + CheckBox *linked = nullptr; - OptionButton *display_mode; + OptionButton *display_mode = nullptr; - SpinBox *cursor_metric_edit; + SpinBox *cursor_metric_edit = nullptr; Vector<Metric> frame_metrics; int last_metric; @@ -99,8 +99,8 @@ private: bool seeking; - Timer *frame_delay; - Timer *plot_delay; + Timer *frame_delay = nullptr; + Timer *plot_delay = nullptr; void _update_frame(bool p_focus_selected = false); diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index 486ac26ef7..ad90e63c16 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -85,26 +85,26 @@ private: ACTION_DELETE_ALL_BREAKPOINTS, }; - AcceptDialog *msgdialog; - - LineEdit *clicked_ctrl; - LineEdit *clicked_ctrl_type; - LineEdit *live_edit_root; - Button *le_set; - Button *le_clear; - Button *export_csv; - - VBoxContainer *errors_tab; - Tree *error_tree; - Button *expand_all_button; - Button *collapse_all_button; - Button *clear_button; - PopupMenu *item_menu; - - Tree *breakpoints_tree; - PopupMenu *breakpoints_menu; - - EditorFileDialog *file_dialog; + AcceptDialog *msgdialog = nullptr; + + LineEdit *clicked_ctrl = nullptr; + LineEdit *clicked_ctrl_type = nullptr; + LineEdit *live_edit_root = nullptr; + Button *le_set = nullptr; + Button *le_clear = nullptr; + Button *export_csv = nullptr; + + VBoxContainer *errors_tab = nullptr; + Tree *error_tree = nullptr; + Button *expand_all_button = nullptr; + Button *collapse_all_button = nullptr; + Button *clear_button = nullptr; + PopupMenu *item_menu = nullptr; + + Tree *breakpoints_tree = nullptr; + PopupMenu *breakpoints_menu = nullptr; + + EditorFileDialog *file_dialog = nullptr; enum FileDialogPurpose { SAVE_MONITORS_CSV, SAVE_VRAM_CSV, @@ -117,31 +117,31 @@ private: bool skip_breakpoints_value = false; Ref<Script> stack_script; - TabContainer *tabs; + TabContainer *tabs = nullptr; - Label *reason; + Label *reason = nullptr; - Button *skip_breakpoints; - Button *copy; - Button *step; - Button *next; - Button *dobreak; - Button *docontinue; + Button *skip_breakpoints = nullptr; + Button *copy = nullptr; + Button *step = nullptr; + Button *next = nullptr; + Button *dobreak = nullptr; + Button *docontinue = nullptr; // Reference to "Remote" tab in scene tree. Needed by _live_edit_set and buttons state. // Each debugger should have it's tree in the future I guess. const Tree *editor_remote_tree = nullptr; Map<int, String> profiler_signature; - Tree *vmem_tree; - Button *vmem_refresh; - Button *vmem_export; - LineEdit *vmem_total; + Tree *vmem_tree = nullptr; + Button *vmem_refresh = nullptr; + Button *vmem_export = nullptr; + LineEdit *vmem_total = nullptr; - Tree *stack_dump; + Tree *stack_dump = nullptr; LineEdit *search = nullptr; - EditorDebuggerInspector *inspector; - SceneDebuggerTree *scene_tree; + EditorDebuggerInspector *inspector = nullptr; + SceneDebuggerTree *scene_tree = nullptr; Ref<RemoteDebuggerPeer> peer; @@ -149,10 +149,10 @@ private: int last_path_id; Map<String, int> res_path_cache; - EditorProfiler *profiler; - EditorVisualProfiler *visual_profiler; - EditorNetworkProfiler *network_profiler; - EditorPerformanceProfiler *performance_profiler; + EditorProfiler *profiler = nullptr; + EditorVisualProfiler *visual_profiler = nullptr; + EditorNetworkProfiler *network_profiler = nullptr; + EditorPerformanceProfiler *performance_profiler = nullptr; OS::ProcessID remote_pid = 0; bool breaked = false; diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index 84642edd79..d1dc470c79 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -42,10 +42,10 @@ class EditorFileSystemDirectory; class DependencyEditor : public AcceptDialog { GDCLASS(DependencyEditor, AcceptDialog); - Tree *tree; - Button *fixdeps; + Tree *tree = nullptr; + Button *fixdeps = nullptr; - EditorFileDialog *search; + EditorFileDialog *search = nullptr; String replacing; String editing; @@ -71,8 +71,8 @@ public: class DependencyEditorOwners : public AcceptDialog { GDCLASS(DependencyEditorOwners, AcceptDialog); - ItemList *owners; - PopupMenu *file_options; + ItemList *owners = nullptr; + PopupMenu *file_options = nullptr; String editing; void _fill_owners(EditorFileSystemDirectory *efsd); @@ -95,8 +95,8 @@ public: class DependencyRemoveDialog : public ConfirmationDialog { GDCLASS(DependencyRemoveDialog, ConfirmationDialog); - Label *text; - Tree *owners; + Label *text = nullptr; + Tree *owners = nullptr; Map<String, String> all_remove_files; Vector<String> dirs_to_delete; @@ -142,9 +142,9 @@ public: private: String for_file; Mode mode; - Button *fdep; - Label *text; - Tree *files; + Button *fdep = nullptr; + Label *text = nullptr; + Tree *files = nullptr; void ok_pressed() override; void custom_action(const String &) override; @@ -156,9 +156,9 @@ public: class OrphanResourcesDialog : public ConfirmationDialog { GDCLASS(OrphanResourcesDialog, ConfirmationDialog); - DependencyEditor *dep_edit; - Tree *files; - ConfirmationDialog *delete_confirm; + DependencyEditor *dep_edit = nullptr; + Tree *files = nullptr; + ConfirmationDialog *delete_confirm = nullptr; void ok_pressed() override; bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent); diff --git a/editor/editor_about.h b/editor/editor_about.h index 5a3b1e1987..6f05700582 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -56,11 +56,11 @@ private: void _version_button_pressed(); ScrollContainer *_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column = 0); - LinkButton *version_btn; - Tree *_tpl_tree; - RichTextLabel *_license_text; - RichTextLabel *_tpl_text; - TextureRect *_logo; + LinkButton *version_btn = nullptr; + Tree *_tpl_tree = nullptr; + RichTextLabel *_license_text = nullptr; + RichTextLabel *_tpl_text = nullptr; + TextureRect *_logo = nullptr; void _theme_changed(); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index f1674c47c5..2537c4d4a8 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -259,6 +259,9 @@ void EditorAssetInstaller::ok_pressed() { unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } String name = String::utf8(fname); diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index 58c232f351..deb320e7fa 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -36,11 +36,11 @@ class EditorAssetInstaller : public ConfirmationDialog { GDCLASS(EditorAssetInstaller, ConfirmationDialog); - Tree *tree; - Label *asset_contents; + Tree *tree = nullptr; + Label *asset_contents = nullptr; String package_path; String asset_name; - AcceptDialog *error; + AcceptDialog *error = nullptr; Map<String, TreeItem *> status_map; bool updating = false; void _item_edited(); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 0020b61370..81a6e5b86d 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -52,9 +52,9 @@ class EditorAudioBus : public PanelContainer { GDCLASS(EditorAudioBus, PanelContainer); Ref<Texture2D> disabled_vu; - LineEdit *track_name; - MenuButton *bus_options; - VSlider *slider; + LineEdit *track_name = nullptr; + MenuButton *bus_options = nullptr; + VSlider *slider = nullptr; int cc; static const int CHANNELS_MAX = 4; @@ -69,21 +69,21 @@ class EditorAudioBus : public PanelContainer { TextureProgressBar *vu_r = nullptr; } channel[CHANNELS_MAX]; - OptionButton *send; + OptionButton *send = nullptr; - PopupMenu *effect_options; - PopupMenu *bus_popup; - PopupMenu *delete_effect_popup; + PopupMenu *effect_options = nullptr; + PopupMenu *bus_popup = nullptr; + PopupMenu *delete_effect_popup = nullptr; - Panel *audio_value_preview_box; - Label *audio_value_preview_label; - Timer *preview_timer; + Panel *audio_value_preview_box = nullptr; + Label *audio_value_preview_label = nullptr; + Timer *preview_timer = nullptr; - Button *solo; - Button *mute; - Button *bypass; + Button *solo = nullptr; + Button *mute = nullptr; + Button *bypass = nullptr; - Tree *effects; + Tree *effects = nullptr; bool updating_bus = false; bool is_master; @@ -121,7 +121,7 @@ class EditorAudioBus : public PanelContainer { friend class EditorAudioBuses; - EditorAudioBuses *buses; + EditorAudioBuses *buses = nullptr; protected: static void _bind_methods(); @@ -153,22 +153,22 @@ public: class EditorAudioBuses : public VBoxContainer { GDCLASS(EditorAudioBuses, VBoxContainer); - HBoxContainer *top_hb; + HBoxContainer *top_hb = nullptr; - ScrollContainer *bus_scroll; - HBoxContainer *bus_hb; + ScrollContainer *bus_scroll = nullptr; + HBoxContainer *bus_hb = nullptr; - EditorAudioBusDrop *drop_end; + EditorAudioBusDrop *drop_end = nullptr; - Label *file; + Label *file = nullptr; - Button *add; - Button *load; - Button *save_as; - Button *_default; - Button *_new; + Button *add = nullptr; + Button *load = nullptr; + Button *save_as = nullptr; + Button *_default = nullptr; + Button *_new = nullptr; - Timer *save_timer; + Timer *save_timer = nullptr; String edited_path; void _add_bus(); @@ -191,7 +191,7 @@ class EditorAudioBuses : public VBoxContainer { void _load_default_layout(); void _new_layout(); - EditorFileDialog *file_dialog; + EditorFileDialog *file_dialog = nullptr; bool new_layout; void _file_dialog_callback(const String &p_string); @@ -262,7 +262,7 @@ public: class AudioBusesEditorPlugin : public EditorPlugin { GDCLASS(AudioBusesEditorPlugin, EditorPlugin); - EditorAudioBuses *audio_bus_editor; + EditorAudioBuses *audio_bus_editor = nullptr; public: virtual String get_name() const override { return "SampleLibrary"; } diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index b37b06748d..49bf24f864 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -406,7 +406,7 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { } else if (script.is_valid()) { StringName ibt = script->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); - ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + "."); + ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit from Node: " + p_path + "."); Object *obj = ClassDB::instantiate(ibt); diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index 41141af0c3..124703cca4 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -40,8 +40,8 @@ class EditorCommandPalette : public ConfirmationDialog { GDCLASS(EditorCommandPalette, ConfirmationDialog); static EditorCommandPalette *singleton; - LineEdit *command_search_box; - Tree *search_options; + LineEdit *command_search_box = nullptr; + Tree *search_options = nullptr; struct Command { Callable callable; diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index c16451f3c6..a58a279faa 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -38,12 +38,13 @@ #include "editor/plugins/script_editor_plugin.h" #include "scene/resources/packed_scene.h" -void EditorHistory::cleanup_history() { +void EditorSelectionHistory::cleanup_history() { for (int i = 0; i < history.size(); i++) { bool fail = false; for (int j = 0; j < history[i].path.size(); j++) { if (!history[i].path[j].ref.is_null()) { + // Reference is not null - object still alive. continue; } @@ -51,21 +52,16 @@ void EditorHistory::cleanup_history() { if (obj) { Node *n = Object::cast_to<Node>(obj); if (n && n->is_inside_tree()) { + // Node valid and inside tree - object still alive. continue; } - if (!n) { // Possibly still alive + if (!n) { + // Node possibly still alive. continue; } - } - - if (j <= history[i].level) { - //before or equal level, complete fail - fail = true; - } else { - //after level, clip - history.write[i].path.resize(j); - } + } // Else: object not valid - not alive. + fail = true; break; } @@ -75,16 +71,16 @@ void EditorHistory::cleanup_history() { } } - if (current >= history.size()) { - current = history.size() - 1; + if (current_elem_idx >= history.size()) { + current_elem_idx = history.size() - 1; } } -void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int p_level_change, bool p_inspector_only) { +void EditorSelectionHistory::add_object(ObjectID p_object, const String &p_property, bool p_inspector_only) { Object *obj = ObjectDB::get_instance(p_object); ERR_FAIL_COND(!obj); RefCounted *r = Object::cast_to<RefCounted>(obj); - Obj o; + _Object o; if (r) { o.ref = REF(r); } @@ -92,86 +88,64 @@ void EditorHistory::_add_object(ObjectID p_object, const String &p_property, int o.property = p_property; o.inspector_only = p_inspector_only; - History h; - - bool has_prev = current >= 0 && current < history.size(); + bool has_prev = current_elem_idx >= 0 && current_elem_idx < history.size(); if (has_prev) { - history.resize(current + 1); //clip history to next + history.resize(current_elem_idx + 1); // Clip history to next. } + HistoryElement h; if (!p_property.is_empty() && has_prev) { - //add a sub property - History &pr = history.write[current]; - h = pr; + // Add a sub property. + HistoryElement &prev_element = history.write[current_elem_idx]; + h = prev_element; h.path.resize(h.level + 1); h.path.push_back(o); h.level++; - } else if (p_level_change != -1 && has_prev) { - //add a sub property - History &pr = history.write[current]; - h = pr; - ERR_FAIL_INDEX(p_level_change, h.path.size()); - h.level = p_level_change; + } else { - //add a new node + // Create a new history item. h.path.push_back(o); h.level = 0; } history.push_back(h); - current++; -} - -void EditorHistory::add_object_inspector_only(ObjectID p_object) { - _add_object(p_object, "", -1, true); -} - -void EditorHistory::add_object(ObjectID p_object) { - _add_object(p_object, "", -1); + current_elem_idx++; } -void EditorHistory::add_object(ObjectID p_object, const String &p_subprop) { - _add_object(p_object, p_subprop, -1); -} - -void EditorHistory::add_object(ObjectID p_object, int p_relevel) { - _add_object(p_object, "", p_relevel); -} - -int EditorHistory::get_history_len() { +int EditorSelectionHistory::get_history_len() { return history.size(); } -int EditorHistory::get_history_pos() { - return current; +int EditorSelectionHistory::get_history_pos() { + return current_elem_idx; } -bool EditorHistory::is_history_obj_inspector_only(int p_obj) const { +bool EditorSelectionHistory::is_history_obj_inspector_only(int p_obj) const { ERR_FAIL_INDEX_V(p_obj, history.size(), false); ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), false); return history[p_obj].path[history[p_obj].level].inspector_only; } -ObjectID EditorHistory::get_history_obj(int p_obj) const { +ObjectID EditorSelectionHistory::get_history_obj(int p_obj) const { ERR_FAIL_INDEX_V(p_obj, history.size(), ObjectID()); ERR_FAIL_INDEX_V(history[p_obj].level, history[p_obj].path.size(), ObjectID()); return history[p_obj].path[history[p_obj].level].object; } -bool EditorHistory::is_at_beginning() const { - return current <= 0; +bool EditorSelectionHistory::is_at_beginning() const { + return current_elem_idx <= 0; } -bool EditorHistory::is_at_end() const { - return ((current + 1) >= history.size()); +bool EditorSelectionHistory::is_at_end() const { + return ((current_elem_idx + 1) >= history.size()); } -bool EditorHistory::next() { +bool EditorSelectionHistory::next() { cleanup_history(); - if ((current + 1) < history.size()) { - current++; + if ((current_elem_idx + 1) < history.size()) { + current_elem_idx++; } else { return false; } @@ -179,11 +153,11 @@ bool EditorHistory::next() { return true; } -bool EditorHistory::previous() { +bool EditorSelectionHistory::previous() { cleanup_history(); - if (current > 0) { - current--; + if (current_elem_idx > 0) { + current_elem_idx--; } else { return false; } @@ -191,76 +165,63 @@ bool EditorHistory::previous() { return true; } -bool EditorHistory::is_current_inspector_only() const { - if (current < 0 || current >= history.size()) { +bool EditorSelectionHistory::is_current_inspector_only() const { + if (current_elem_idx < 0 || current_elem_idx >= history.size()) { return false; } - const History &h = history[current]; + const HistoryElement &h = history[current_elem_idx]; return h.path[h.level].inspector_only; } -ObjectID EditorHistory::get_current() { - if (current < 0 || current >= history.size()) { +ObjectID EditorSelectionHistory::get_current() { + if (current_elem_idx < 0 || current_elem_idx >= history.size()) { return ObjectID(); } - History &h = history.write[current]; - Object *obj = ObjectDB::get_instance(h.path[h.level].object); - if (!obj) { - return ObjectID(); - } - - return obj->get_instance_id(); + Object *obj = ObjectDB::get_instance(get_history_obj(current_elem_idx)); + return obj ? obj->get_instance_id() : ObjectID(); } -int EditorHistory::get_path_size() const { - if (current < 0 || current >= history.size()) { +int EditorSelectionHistory::get_path_size() const { + if (current_elem_idx < 0 || current_elem_idx >= history.size()) { return 0; } - const History &h = history[current]; - return h.path.size(); + return history[current_elem_idx].path.size(); } -ObjectID EditorHistory::get_path_object(int p_index) const { - if (current < 0 || current >= history.size()) { +ObjectID EditorSelectionHistory::get_path_object(int p_index) const { + if (current_elem_idx < 0 || current_elem_idx >= history.size()) { return ObjectID(); } - const History &h = history[current]; + ERR_FAIL_INDEX_V(p_index, history[current_elem_idx].path.size(), ObjectID()); - ERR_FAIL_INDEX_V(p_index, h.path.size(), ObjectID()); - - Object *obj = ObjectDB::get_instance(h.path[p_index].object); - if (!obj) { - return ObjectID(); - } - - return obj->get_instance_id(); + Object *obj = ObjectDB::get_instance(history[current_elem_idx].path[p_index].object); + return obj ? obj->get_instance_id() : ObjectID(); } -String EditorHistory::get_path_property(int p_index) const { - if (current < 0 || current >= history.size()) { +String EditorSelectionHistory::get_path_property(int p_index) const { + if (current_elem_idx < 0 || current_elem_idx >= history.size()) { return ""; } - const History &h = history[current]; - - ERR_FAIL_INDEX_V(p_index, h.path.size(), ""); - - return h.path[p_index].property; + ERR_FAIL_INDEX_V(p_index, history[current_elem_idx].path.size(), ""); + return history[current_elem_idx].path[p_index].property; } -void EditorHistory::clear() { +void EditorSelectionHistory::clear() { history.clear(); - current = -1; + current_elem_idx = -1; } -EditorHistory::EditorHistory() { - current = -1; +EditorSelectionHistory::EditorSelectionHistory() { + current_elem_idx = -1; } +//////////////////////////////////////////////////////////// + EditorPlugin *EditorData::get_editor(Object *p_object) { // We need to iterate backwards so that we can check user-created plugins first. // Otherwise, it would not be possible for plugins to handle CanvasItem and Spatial nodes. @@ -636,14 +597,14 @@ bool EditorData::check_and_update_scene(int p_idx) { EditorProgress ep("update_scene", TTR("Updating Scene"), 2); ep.step(TTR("Storing local changes..."), 0); - //pack first, so it stores diffs to previous version of saved scene + // Pack first, so it stores diffs to previous version of saved scene. Error err = pscene->pack(edited_scene[p_idx].root); ERR_FAIL_COND_V(err != OK, false); ep.step(TTR("Updating scene..."), 1); Node *new_scene = pscene->instantiate(PackedScene::GEN_EDIT_STATE_MAIN); ERR_FAIL_COND_V(!new_scene, false); - //transfer selection + // Transfer selection. List<Node *> new_selection; for (const Node *E : edited_scene.write[p_idx].selection) { NodePath p = edited_scene[p_idx].root->get_path_to(E); @@ -675,7 +636,6 @@ int EditorData::get_edited_scene() const { void EditorData::set_edited_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); current_edited_scene = p_idx; - //swap } Node *EditorData::get_edited_scene_root(int p_idx) { @@ -850,23 +810,23 @@ NodePath EditorData::get_edited_scene_live_edit_root() { return edited_scene[current_edited_scene].live_edit_root; } -void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom) { +void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorSelectionHistory *p_history, const Dictionary &p_custom) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); EditedScene &es = edited_scene.write[current_edited_scene]; es.selection = p_selection->get_full_selected_node_list(); - es.history_current = p_history->current; + es.history_current = p_history->current_elem_idx; es.history_stored = p_history->history; es.editor_states = get_editor_states(); es.custom_state = p_custom; } -Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history) { +Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection, EditorSelectionHistory *p_history) { ERR_FAIL_INDEX_V(current_edited_scene, edited_scene.size(), Dictionary()); - EditedScene &es = edited_scene.write[current_edited_scene]; + const EditedScene &es = edited_scene.write[current_edited_scene]; - p_history->current = es.history_current; + p_history->current_elem_idx = es.history_current; p_history->history = es.history_stored; p_selection->clear(); @@ -1033,12 +993,11 @@ void EditorData::script_class_load_icon_paths() { EditorData::EditorData() { current_edited_scene = -1; - - //load_imported_scenes_from_globals(); script_class_load_icon_paths(); } -/////////// +/////////////////////////////////////////////////////////////////////////////// + void EditorSelection::_node_removed(Node *p_node) { if (!selection.has(p_node)) { return; @@ -1050,7 +1009,7 @@ void EditorSelection::_node_removed(Node *p_node) { } selection.erase(p_node); changed = true; - nl_changed = true; + node_list_changed = true; } void EditorSelection::add_node(Node *p_node) { @@ -1061,7 +1020,7 @@ void EditorSelection::add_node(Node *p_node) { } changed = true; - nl_changed = true; + node_list_changed = true; Object *meta = nullptr; for (Object *E : editor_plugins) { meta = E->call("_get_editor_data", p_node); @@ -1072,52 +1031,29 @@ void EditorSelection::add_node(Node *p_node) { selection[p_node] = meta; p_node->connect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed), varray(p_node), CONNECT_ONESHOT); - - //emit_signal(SNAME("selection_changed")); } void EditorSelection::remove_node(Node *p_node) { ERR_FAIL_NULL(p_node); - if (!selection.has(p_node)) { return; } changed = true; - nl_changed = true; + node_list_changed = true; Object *meta = selection[p_node]; if (meta) { memdelete(meta); } selection.erase(p_node); + p_node->disconnect("tree_exiting", callable_mp(this, &EditorSelection::_node_removed)); - //emit_signal(SNAME("selection_changed")); } bool EditorSelection::is_selected(Node *p_node) const { return selection.has(p_node); } -Array EditorSelection::_get_transformable_selected_nodes() { - Array ret; - - for (const Node *E : selected_node_list) { - ret.push_back(E); - } - - return ret; -} - -TypedArray<Node> EditorSelection::get_selected_nodes() { - TypedArray<Node> ret; - - for (const KeyValue<Node *, Object *> &E : selection) { - ret.push_back(E.key); - } - - return ret; -} - void EditorSelection::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &EditorSelection::clear); ClassDB::bind_method(D_METHOD("add_node", "node"), &EditorSelection::add_node); @@ -1132,13 +1068,16 @@ void EditorSelection::add_editor_plugin(Object *p_object) { editor_plugins.push_back(p_object); } -void EditorSelection::_update_nl() { - if (!nl_changed) { +void EditorSelection::_update_node_list() { + if (!node_list_changed) { return; } selected_node_list.clear(); + // If the selection does not have the parent of the selected node, then add the node to the node list. + // However, if the parent is already selected, then adding this node is redundant as + // it is included with the parent, so skip it. for (const KeyValue<Node *, Object *> &E : selection) { Node *parent = E.key; parent = parent->get_parent(); @@ -1157,11 +1096,11 @@ void EditorSelection::_update_nl() { selected_node_list.push_back(E.key); } - nl_changed = true; + node_list_changed = true; } void EditorSelection::update() { - _update_nl(); + _update_node_list(); if (!changed) { return; @@ -1178,11 +1117,31 @@ void EditorSelection::_emit_change() { emitted = false; } +Array EditorSelection::_get_transformable_selected_nodes() { + Array ret; + + for (const Node *E : selected_node_list) { + ret.push_back(E); + } + + return ret; +} + +TypedArray<Node> EditorSelection::get_selected_nodes() { + TypedArray<Node> ret; + + for (const KeyValue<Node *, Object *> &E : selection) { + ret.push_back(E.key); + } + + return ret; +} + List<Node *> &EditorSelection::get_selected_node_list() { if (changed) { update(); } else { - _update_nl(); + _update_node_list(); } return selected_node_list; } @@ -1202,7 +1161,7 @@ void EditorSelection::clear() { } changed = true; - nl_changed = true; + node_list_changed = true; } EditorSelection::EditorSelection() { diff --git a/editor/editor_data.h b/editor/editor_data.h index 79f8227e5c..0a9f40b714 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -38,33 +38,32 @@ class ConfigFile; class EditorPlugin; -class EditorHistory { - enum { - HISTORY_MAX = 64 - }; - - struct Obj { +/** + * Stores the history of objects which have been selected for editing in the Editor & the Inspector. + * + * Used in the editor to set & access the currently edited object, as well as the history of objects which have been edited. + */ +class EditorSelectionHistory { + // Stores the object & property (if relevant). + struct _Object { REF ref; ObjectID object; String property; bool inspector_only = false; }; - struct History { - Vector<Obj> path; + // Represents the selection of an object for editing. + struct HistoryElement { + // The sub-resources of the parent object (first in the path) that have been edited. + // For example, Node2D -> nested resource -> nested resource, if edited each individually in their own inspector. + Vector<_Object> path; + // The current point in the path. This is always equal to the last item in the path - it is never decremented. int level = 0; }; friend class EditorData; - Vector<History> history; - int current; - - struct PropertyData { - String name; - Variant value; - }; - - void _add_object(ObjectID p_object, const String &p_property, int p_level_change, bool p_inspector_only = false); + Vector<HistoryElement> history; + int current_elem_idx; // The current history element being edited. public: void cleanup_history(); @@ -72,13 +71,14 @@ public: bool is_at_beginning() const; bool is_at_end() const; - void add_object_inspector_only(ObjectID p_object); - void add_object(ObjectID p_object); - void add_object(ObjectID p_object, const String &p_subprop); - void add_object(ObjectID p_object, int p_relevel); + // Adds an object to the selection history. A property name can be passed if the target is a subresource of the given object. + // If the object should not change the main screen plugin, it can be set as inspector only. + void add_object(ObjectID p_object, const String &p_property = String(), bool p_inspector_only = false); int get_history_len(); int get_history_pos(); + + // Gets an object from the history. The most recent object would be the object with p_obj = get_history_len() - 1. ObjectID get_history_obj(int p_obj) const; bool is_history_obj_inspector_only(int p_obj) const; @@ -87,13 +87,16 @@ public: ObjectID get_current(); bool is_current_inspector_only() const; + // Gets the size of the path of the current history item. int get_path_size() const; + // Gets the object of the current history item, if valid. ObjectID get_path_object(int p_index) const; + // Gets the property of the current history item. String get_path_property(int p_index) const; void clear(); - EditorHistory(); + EditorSelectionHistory(); }; class EditorSelection; @@ -112,7 +115,7 @@ public: uint64_t file_modified_time = 0; Dictionary editor_states; List<Node *> selection; - Vector<EditorHistory::History> history_stored; + Vector<EditorSelectionHistory::HistoryElement> history_stored; int history_current = 0; Dictionary custom_state; uint64_t version = 0; @@ -210,8 +213,8 @@ public: void set_plugin_window_layout(Ref<ConfigFile> p_layout); void get_plugin_window_layout(Ref<ConfigFile> p_layout); - void save_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history, const Dictionary &p_custom); - Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); + void save_edited_scene_state(EditorSelection *p_selection, EditorSelectionHistory *p_history, const Dictionary &p_custom); + Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorSelectionHistory *p_history); void notify_edited_scene_changed(); void notify_resource_saved(const Ref<Resource> &p_resource); @@ -233,22 +236,33 @@ public: EditorData(); }; +/** + * Stores and provides access to the nodes currently selected in the editor. + * + * This provides a central location for storing "selected" nodes, as a selection can be triggered from multiple places, + * such as the SceneTreeDock or a main screen editor plugin (e.g. CanvasItemEditor). + */ class EditorSelection : public Object { GDCLASS(EditorSelection, Object); -private: + // Contains the selected nodes and corresponding metadata. + // Metadata objects come from calling _get_editor_data on the editor_plugins, passing the selected node. Map<Node *, Object *> selection; + // Tracks whether the selection change signal has been emitted. + // Prevents multiple signals being called in one frame. bool emitted = false; + bool changed = false; - bool nl_changed = false; + bool node_list_changed = false; void _node_removed(Node *p_node); + // Editor plugins which are related to selection. List<Object *> editor_plugins; List<Node *> selected_node_list; - void _update_nl(); + void _update_node_list(); Array _get_transformable_selected_nodes(); void _emit_change(); @@ -256,10 +270,9 @@ protected: static void _bind_methods(); public: - TypedArray<Node> get_selected_nodes(); void add_node(Node *p_node); void remove_node(Node *p_node); - bool is_selected(Node *) const; + bool is_selected(Node *p_node) const; template <class T> T *get_node_editor_data(Node *p_node) { @@ -269,13 +282,20 @@ public: return Object::cast_to<T>(selection[p_node]); } + // Adds an editor plugin which can provide metadata for selected nodes. void add_editor_plugin(Object *p_object); void update(); void clear(); + // Returns all the selected nodes. + TypedArray<Node> get_selected_nodes(); + // Returns only the top level selected nodes. + // That is, if the selection includes some node and a child of that node, only the parent is returned. List<Node *> &get_selected_node_list(); + // Returns all the selected nodes (list version of "get_selected_nodes"). List<Node *> get_full_selected_node_list(); + // Returns the map of selected objects and their metadata. Map<Node *, Object *> &get_selection() { return selection; } EditorSelection(); diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 866f28c03b..9fabde93ef 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -156,15 +156,18 @@ void EditorDirDialog::_make_dir_confirm() { String dir = ti->get_metadata(0); - if (EditorFileSystem::get_singleton()->get_filesystem_path(dir + makedirname->get_text())) { + DirAccessRef d = DirAccess::open(dir); + ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'."); + + const String stripped_dirname = makedirname->get_text().strip_edges(); + + if (d->dir_exists(stripped_dirname)) { mkdirerr->set_text(TTR("Could not create folder. File with that name already exists.")); mkdirerr->popup_centered(); return; } - DirAccessRef d = DirAccess::open(dir); - ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + dir + "'."); - Error err = d->make_dir(makedirname->get_text()); + Error err = d->make_dir(stripped_dirname); if (err != OK) { mkdirerr->popup_centered(Size2(250, 80) * EDSCALE); } else { diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index e97b5ce8af..9baa37793b 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -39,14 +39,14 @@ class EditorDirDialog : public ConfirmationDialog { GDCLASS(EditorDirDialog, ConfirmationDialog); - ConfirmationDialog *makedialog; - LineEdit *makedirname; - AcceptDialog *mkdirerr; + ConfirmationDialog *makedialog = nullptr; + LineEdit *makedirname = nullptr; + AcceptDialog *mkdirerr = nullptr; - Button *makedir; + Button *makedir = nullptr; Set<String> opened_paths; - Tree *tree; + Tree *tree = nullptr; bool updating = false; void _item_collapsed(Object *p_item); diff --git a/editor/editor_export.h b/editor/editor_export.h index 7c61e7cff6..4d5aebc770 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -380,7 +380,7 @@ class EditorExport : public Node { StringName _export_presets_updated; - Timer *save_timer; + Timer *save_timer = nullptr; bool block_save = false; static EditorExport *singleton; diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 881f14638f..19df8a9686 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -117,25 +117,25 @@ class EditorFeatureProfileManager : public AcceptDialog { CLASS_OPTION_DISABLE_EDITOR }; - ConfirmationDialog *erase_profile_dialog; - ConfirmationDialog *new_profile_dialog; - LineEdit *new_profile_name; + ConfirmationDialog *erase_profile_dialog = nullptr; + ConfirmationDialog *new_profile_dialog = nullptr; + LineEdit *new_profile_name = nullptr; - LineEdit *current_profile_name; - OptionButton *profile_list; + LineEdit *current_profile_name = nullptr; + OptionButton *profile_list = nullptr; Button *profile_actions[PROFILE_MAX]; - HSplitContainer *h_split; + HSplitContainer *h_split = nullptr; - VBoxContainer *class_list_vbc; - Tree *class_list; - VBoxContainer *property_list_vbc; - Tree *property_list; - EditorHelpBit *description_bit; - Label *no_profile_selected_help; + VBoxContainer *class_list_vbc = nullptr; + Tree *class_list = nullptr; + VBoxContainer *property_list_vbc = nullptr; + Tree *property_list = nullptr; + EditorHelpBit *description_bit = nullptr; + Label *no_profile_selected_help = nullptr; - EditorFileDialog *import_profiles; - EditorFileDialog *export_profile; + EditorFileDialog *import_profiles = nullptr; + EditorFileDialog *export_profile = nullptr; void _profile_action(int p_action); void _profile_selected(int p_what); @@ -163,7 +163,7 @@ class EditorFeatureProfileManager : public AcceptDialog { void _property_item_edited(); void _save_and_update(); - Timer *update_timer; + Timer *update_timer = nullptr; void _emit_current_profile_changed(); static EditorFeatureProfileManager *singleton; diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index ab403c4212..ca3e70830c 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -106,7 +106,7 @@ void EditorFileDialog::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { - set_process_unhandled_input(false); + set_process_shortcut_input(false); } } break; @@ -126,7 +126,7 @@ void EditorFileDialog::_notification(int p_what) { } } -void EditorFileDialog::unhandled_input(const Ref<InputEvent> &p_event) { +void EditorFileDialog::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventKey> k = p_event; @@ -327,7 +327,7 @@ void EditorFileDialog::_post_popup() { _update_favorites(); } - set_process_unhandled_input(true); + set_process_shortcut_input(true); } void EditorFileDialog::_thumbnail_result(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata) { @@ -789,7 +789,7 @@ void EditorFileDialog::update_file_list() { } } else if (!dir_access->current_is_hidden()) { String full_path = cdir == "res://" ? item : dir_access->get_current_dir() + "/" + item; - if (dir_access->current_is_dir() && !EditorFileSystem::_should_skip_directory(full_path)) { + if (dir_access->current_is_dir() && (!EditorFileSystem::_should_skip_directory(full_path) || Engine::get_singleton()->is_project_manager_hint())) { dirs.push_back(item); } else { files.push_back(item); @@ -1099,16 +1099,18 @@ EditorFileDialog::Access EditorFileDialog::get_access() const { } void EditorFileDialog::_make_dir_confirm() { - if (EditorFileSystem::get_singleton()->get_filesystem_path(makedirname->get_text().strip_edges())) { + const String stripped_dirname = makedirname->get_text().strip_edges(); + + if (dir_access->dir_exists(stripped_dirname)) { error_dialog->set_text(TTR("Could not create folder. File with that name already exists.")); error_dialog->popup_centered(Size2(250, 50) * EDSCALE); makedirname->set_text(""); // Reset label. return; } - Error err = dir_access->make_dir(makedirname->get_text().strip_edges()); + Error err = dir_access->make_dir(stripped_dirname); if (err == OK) { - dir_access->change_dir(makedirname->get_text().strip_edges()); + dir_access->change_dir(stripped_dirname); invalidate(); update_filters(); update_dir(); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index a747255ce8..fffe7ffcc5 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -84,50 +84,50 @@ private: ITEM_MENU_SHOW_IN_EXPLORER }; - ConfirmationDialog *makedialog; - LineEdit *makedirname; + ConfirmationDialog *makedialog = nullptr; + LineEdit *makedirname = nullptr; - Button *makedir; + Button *makedir = nullptr; Access access; - VBoxContainer *vbox; + VBoxContainer *vbox = nullptr; FileMode mode; bool can_create_dir; - LineEdit *dir; - - Button *dir_prev; - Button *dir_next; - Button *dir_up; - - HBoxContainer *drives_container; - HBoxContainer *shortcuts_container; - OptionButton *drives; - ItemList *item_list; - PopupMenu *item_menu; - TextureRect *preview; - VBoxContainer *preview_vb; - HSplitContainer *list_hb; - HBoxContainer *file_box; - LineEdit *file; - OptionButton *filter; - AcceptDialog *error_dialog; - DirAccess *dir_access; - ConfirmationDialog *confirm_save; - DependencyRemoveDialog *dep_remove_dialog; - ConfirmationDialog *global_remove_dialog; - - Button *mode_thumbnails; - Button *mode_list; - - Button *refresh; - Button *favorite; - Button *show_hidden; - - Button *fav_up; - Button *fav_down; - - ItemList *favorites; - ItemList *recent; + LineEdit *dir = nullptr; + + Button *dir_prev = nullptr; + Button *dir_next = nullptr; + Button *dir_up = nullptr; + + HBoxContainer *drives_container = nullptr; + HBoxContainer *shortcuts_container = nullptr; + OptionButton *drives = nullptr; + ItemList *item_list = nullptr; + PopupMenu *item_menu = nullptr; + TextureRect *preview = nullptr; + VBoxContainer *preview_vb = nullptr; + HSplitContainer *list_hb = nullptr; + HBoxContainer *file_box = nullptr; + LineEdit *file = nullptr; + OptionButton *filter = nullptr; + AcceptDialog *error_dialog = nullptr; + DirAccess *dir_access = nullptr; + ConfirmationDialog *confirm_save = nullptr; + DependencyRemoveDialog *dep_remove_dialog = nullptr; + ConfirmationDialog *global_remove_dialog = nullptr; + + Button *mode_thumbnails = nullptr; + Button *mode_list = nullptr; + + Button *refresh = nullptr; + Button *favorite = nullptr; + Button *show_hidden = nullptr; + + Button *fav_up = nullptr; + Button *fav_down = nullptr; + + ItemList *favorites = nullptr; + ItemList *recent = nullptr; Vector<String> local_history; int local_history_pos; @@ -201,7 +201,7 @@ private: void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata); void _request_single_thumbnail(const String &p_path); - virtual void unhandled_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; bool _is_open_should_be_disabled(); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index f3d9449c6c..2b98a4b02a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -520,6 +520,45 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo return false; //nothing changed } +bool EditorFileSystem::_scan_import_support(Vector<String> reimports) { + if (import_support_queries.size() == 0) { + return false; + } + Map<String, int> import_support_test; + Vector<bool> import_support_tested; + import_support_tested.resize(import_support_queries.size()); + for (int i = 0; i < import_support_queries.size(); i++) { + import_support_tested.write[i] = false; + if (import_support_queries[i]->is_active()) { + Vector<String> extensions = import_support_queries[i]->get_file_extensions(); + for (int j = 0; j < extensions.size(); j++) { + import_support_test.insert(extensions[j], i); + } + } + } + + if (import_support_test.size() == 0) { + return false; //well nothing to do + } + + for (int i = 0; i < reimports.size(); i++) { + Map<String, int>::Element *E = import_support_test.find(reimports[i].get_extension()); + if (E) { + import_support_tested.write[E->get()] = true; + } + } + + for (int i = 0; i < import_support_tested.size(); i++) { + if (import_support_tested[i]) { + if (import_support_queries.write[i]->query()) { + return true; + } + } + } + + return false; +} + bool EditorFileSystem::_update_scan_actions() { sources_changed.clear(); @@ -612,7 +651,7 @@ bool EditorFileSystem::_update_scan_actions() { if (_scan_extensions()) { //needs editor restart //extensions also may provide filetypes to be imported, so they must run before importing - if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save&Restart"), TTR("Continue"))) { + if (EditorNode::immediate_confirmation_dialog(TTR("Some extensions need the editor to restart to take effect."), first_scan ? TTR("Restart") : TTR("Save & Restart"), TTR("Continue"))) { if (!first_scan) { EditorNode::get_singleton()->save_all_scenes(); } @@ -621,7 +660,12 @@ bool EditorFileSystem::_update_scan_actions() { return true; } } + if (reimports.size()) { + if (_scan_import_support(reimports)) { + return true; + } + reimport_files(reimports); } else { //reimport files will update the uid cache file so if nothing was reimported, update it manually @@ -2274,6 +2318,7 @@ static void _scan_extensions_dir(EditorFileSystemDirectory *d, Set<String> &exte bool EditorFileSystem::_scan_extensions() { EditorFileSystemDirectory *d = get_filesystem(); Set<String> extensions; + _scan_extensions_dir(d, extensions); //verify against loaded extensions @@ -2374,6 +2419,14 @@ void EditorFileSystem::_update_extensions() { } } +void EditorFileSystem::add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) { + ERR_FAIL_COND(import_support_queries.find(p_query) != -1); + import_support_queries.push_back(p_query); +} +void EditorFileSystem::remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query) { + import_support_queries.erase(p_query); +} + EditorFileSystem::EditorFileSystem() { ResourceLoader::import = _resource_import; reimport_on_missing_imported_files = GLOBAL_DEF("editor/import/reimport_missing_imported_files", true); diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 0ec0094030..05b55d4e1b 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -49,7 +49,7 @@ class EditorFileSystemDirectory : public Object { uint64_t modified_time; bool verified = false; //used for checking changes - EditorFileSystemDirectory *parent; + EditorFileSystemDirectory *parent = nullptr; Vector<EditorFileSystemDirectory *> subdirs; struct FileInfo { @@ -109,6 +109,37 @@ public: ~EditorFileSystemDirectory(); }; +class EditorFileSystemImportFormatSupportQuery : public RefCounted { + GDCLASS(EditorFileSystemImportFormatSupportQuery, RefCounted); + +protected: + GDVIRTUAL0RC(bool, _is_active) + GDVIRTUAL0RC(Vector<String>, _get_file_extensions) + GDVIRTUAL0RC(bool, _query) + static void _bind_methods() { + GDVIRTUAL_BIND(_is_active); + GDVIRTUAL_BIND(_get_file_extensions); + GDVIRTUAL_BIND(_query); + } + +public: + virtual bool is_active() const { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_is_active, ret); + return ret; + } + virtual Vector<String> get_file_extensions() const { + Vector<String> ret; + GDVIRTUAL_REQUIRED_CALL(_get_file_extensions, ret); + return ret; + } + virtual bool query() { + bool ret = false; + GDVIRTUAL_REQUIRED_CALL(_query, ret); + return ret; + } +}; + class EditorFileSystem : public Node { GDCLASS(EditorFileSystem, Node); @@ -136,7 +167,7 @@ class EditorFileSystem : public Node { Thread thread; static void _thread_func(void *_userdata); - EditorFileSystemDirectory *new_filesystem; + EditorFileSystemDirectory *new_filesystem = nullptr; bool abort_scan = false; bool scanning = false; @@ -153,7 +184,7 @@ class EditorFileSystem : public Node { void _save_late_updated_files(); - EditorFileSystemDirectory *filesystem; + EditorFileSystemDirectory *filesystem = nullptr; static EditorFileSystem *singleton; @@ -257,6 +288,9 @@ class EditorFileSystem : public Node { static ResourceUID::ID _resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate); bool _scan_extensions(); + bool _scan_import_support(Vector<String> reimports); + + Vector<Ref<EditorFileSystemImportFormatSupportQuery>> import_support_queries; protected: void _notification(int p_what); @@ -289,6 +323,8 @@ public: static bool _should_skip_directory(const String &p_path); + void add_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query); + void remove_import_format_support_query(Ref<EditorFileSystemImportFormatSupportQuery> p_query); EditorFileSystem(); ~EditorFileSystem(); }; diff --git a/editor/editor_help.h b/editor/editor_help.h index b40d1709b6..054fd84af6 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -47,14 +47,14 @@ class FindBar : public HBoxContainer { GDCLASS(FindBar, HBoxContainer); - LineEdit *search_text; - Button *find_prev; - Button *find_next; - Label *matches_label; - TextureButton *hide_button; + LineEdit *search_text = nullptr; + Button *find_prev = nullptr; + Button *find_next = nullptr; + Label *matches_label = nullptr; + TextureButton *hide_button = nullptr; String prev_search; - RichTextLabel *rich_text_label; + RichTextLabel *rich_text_label = nullptr; int results_count; @@ -114,15 +114,15 @@ class EditorHelp : public VBoxContainer { Map<String, Map<String, int>> enum_values_line; int description_line; - RichTextLabel *class_desc; - HSplitContainer *h_split; + RichTextLabel *class_desc = nullptr; + HSplitContainer *h_split = nullptr; static DocTools *doc; - ConfirmationDialog *search_dialog; - LineEdit *search; - FindBar *find_bar; - HBoxContainer *status_bar; - Button *toggle_scripts_button; + ConfirmationDialog *search_dialog = nullptr; + LineEdit *search = nullptr; + FindBar *find_bar = nullptr; + HBoxContainer *status_bar = nullptr; + Button *toggle_scripts_button = nullptr; String base_path; @@ -210,7 +210,7 @@ public: class EditorHelpBit : public MarginContainer { GDCLASS(EditorHelpBit, MarginContainer); - RichTextLabel *rich_text; + RichTextLabel *rich_text = nullptr; void _go_to_help(String p_what); void _meta_clicked(String p_select); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 8e03c55712..c747ae326f 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -331,7 +331,10 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { // Match class name. if (search_flags & SEARCH_CLASSES) { - match.name = term.is_empty() || _match_string(term, class_doc.name); + // If the search term is empty, add any classes which are not script docs or which don't start with + // a double-quotation. This will ensure that only C++ classes and explictly named classes will + // be added. + match.name = (term.is_empty() && (!class_doc.is_script_doc || class_doc.name[0] != '\"')) || _match_string(term, class_doc.name); } // Match members if the term is long enough. @@ -398,6 +401,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { } } } + matches[class_doc.name] = match; } iterator_doc = iterator_doc->next(); diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h index bf69fe1693..d89bb0959c 100644 --- a/editor/editor_help_search.h +++ b/editor/editor_help_search.h @@ -55,11 +55,11 @@ class EditorHelpSearch : public ConfirmationDialog { SEARCH_SHOW_HIERARCHY = 1 << 30 }; - LineEdit *search_box; - Button *case_sensitive_button; - Button *hierarchy_button; - OptionButton *filter_combo; - Tree *results_tree; + LineEdit *search_box = nullptr; + Button *case_sensitive_button = nullptr; + Button *hierarchy_button = nullptr; + OptionButton *filter_combo = nullptr; + Tree *results_tree = nullptr; bool old_search = false; String old_term; @@ -114,8 +114,8 @@ class EditorHelpSearch::Runner : public RefCounted { } }; - Control *ui_service; - Tree *results_tree; + Control *ui_service = nullptr; + Tree *results_tree = nullptr; String term; int search_flags; diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 1449edb58f..d5085942c3 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -685,7 +685,7 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) { } } -void EditorProperty::unhandled_key_input(const Ref<InputEvent> &p_event) { +void EditorProperty::shortcut_input(const Ref<InputEvent> &p_event) { if (!selected || !p_event->is_pressed()) { return; } @@ -971,7 +971,7 @@ EditorProperty::EditorProperty() { label_reference = nullptr; bottom_editor = nullptr; menu = nullptr; - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); } void EditorProperty::_update_popup() { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 87703564b9..c5bcbe0725 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -68,7 +68,7 @@ private: String label; int text_size; friend class EditorInspector; - Object *object; + Object *object = nullptr; StringName property; String property_path; @@ -111,9 +111,9 @@ private: float split_ratio; Vector<Control *> focusables; - Control *label_reference; - Control *bottom_editor; - PopupMenu *menu; + Control *label_reference = nullptr; + Control *bottom_editor = nullptr; + PopupMenu *menu = nullptr; mutable String tooltip_text; @@ -128,7 +128,7 @@ protected: virtual void _set_read_only(bool p_read_only); virtual void gui_input(const Ref<InputEvent> &p_event) override; - virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; const Color *_get_property_colors(); public: @@ -269,14 +269,14 @@ class EditorInspectorSection : public Container { bool foldable = false; int indent_depth = 0; - Timer *dropping_unfold_timer; + Timer *dropping_unfold_timer = nullptr; bool dropping = false; void _test_unfold(); protected: Object *object = nullptr; - VBoxContainer *vbox; + VBoxContainer *vbox = nullptr; void _notification(int p_what); static void _bind_methods(); @@ -297,7 +297,7 @@ public: class EditorInspectorArray : public EditorInspectorSection { GDCLASS(EditorInspectorArray, EditorInspectorSection); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; enum Mode { MODE_NONE, @@ -309,16 +309,16 @@ class EditorInspectorArray : public EditorInspectorSection { int count = 0; - VBoxContainer *elements_vbox; + VBoxContainer *elements_vbox = nullptr; - Control *control_dropping; + Control *control_dropping = nullptr; bool dropping = false; - Button *add_button; + Button *add_button = nullptr; - AcceptDialog *resize_dialog; + AcceptDialog *resize_dialog = nullptr; int new_size = 0; - LineEdit *new_size_line_edit; + LineEdit *new_size_line_edit = nullptr; // Pagination int page_length = 5; @@ -337,14 +337,14 @@ class EditorInspectorArray : public EditorInspectorSection { OPTION_RESIZE_ARRAY, }; int popup_array_index_pressed = -1; - PopupMenu *rmb_popup; + PopupMenu *rmb_popup = nullptr; struct ArrayElement { - PanelContainer *panel; - MarginContainer *margin; - HBoxContainer *hbox; - TextureRect *move_texture_rect; - VBoxContainer *vbox; + PanelContainer *panel = nullptr; + MarginContainer *margin = nullptr; + HBoxContainer *hbox = nullptr; + TextureRect *move_texture_rect = nullptr; + VBoxContainer *vbox = nullptr; }; LocalVector<ArrayElement> array_elements; @@ -399,12 +399,12 @@ class EditorPaginator : public HBoxContainer { int page = 0; int max_page = 0; - Button *first_page_button; - Button *prev_page_button; - LineEdit *page_line_edit; - Label *page_count_label; - Button *next_page_button; - Button *last_page_button; + Button *first_page_button = nullptr; + Button *prev_page_button = nullptr; + LineEdit *page_line_edit = nullptr; + Label *page_count_label = nullptr; + Button *next_page_button = nullptr; + Button *last_page_button = nullptr; void _first_page_button_pressed(); void _prev_page_button_pressed(); @@ -425,14 +425,14 @@ public: class EditorInspector : public ScrollContainer { GDCLASS(EditorInspector, ScrollContainer); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; enum { MAX_PLUGINS = 1024 }; static Ref<EditorInspectorPlugin> inspector_plugins[MAX_PLUGINS]; static int inspector_plugin_count; - VBoxContainer *main_vbox; + VBoxContainer *main_vbox = nullptr; //map use to cache the instantiated editors Map<StringName, List<EditorProperty *>> editor_property_map; @@ -440,11 +440,11 @@ class EditorInspector : public ScrollContainer { Set<StringName> pending; void _clear(); - Object *object; + Object *object = nullptr; // - LineEdit *search_box; + LineEdit *search_box = nullptr; bool show_categories = false; bool hide_script = true; bool hide_metadata = true; diff --git a/editor/editor_layouts_dialog.h b/editor/editor_layouts_dialog.h index bbdffd6722..a597ac38cc 100644 --- a/editor/editor_layouts_dialog.h +++ b/editor/editor_layouts_dialog.h @@ -39,9 +39,9 @@ class ItemList; class EditorLayoutsDialog : public ConfirmationDialog { GDCLASS(EditorLayoutsDialog, ConfirmationDialog); - LineEdit *name; - ItemList *layout_names; - VBoxContainer *makevb; + LineEdit *name = nullptr; + ItemList *layout_names = nullptr; + VBoxContainer *makevb = nullptr; void _line_gui_input(const Ref<InputEvent> &p_event); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 54a55286e9..ee2d72c5b0 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -38,7 +38,7 @@ #include "scene/resources/font.h" void EditorLog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type) { - EditorLog *self = (EditorLog *)p_self; + EditorLog *self = static_cast<EditorLog *>(p_self); if (self->current != Thread::get_caller_id()) { return; } @@ -216,7 +216,7 @@ void EditorLog::set_tool_button(Button *p_tool_button) { } void EditorLog::_undo_redo_cbk(void *p_self, const String &p_name) { - EditorLog *self = (EditorLog *)p_self; + EditorLog *self = static_cast<EditorLog *>(p_self); self->add_message(p_name, EditorLog::MSG_TYPE_EDITOR); } @@ -347,6 +347,7 @@ EditorLog::EditorLog() { log->set_focus_mode(FOCUS_CLICK); log->set_v_size_flags(SIZE_EXPAND_FILL); log->set_h_size_flags(SIZE_EXPAND_FILL); + log->set_deselect_on_focus_loss_enabled(false); vb_left->add_child(log); // Search box diff --git a/editor/editor_log.h b/editor/editor_log.h index e66b732ffe..267ad406d4 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -117,23 +117,23 @@ private: // Maps MessageTypes to LogFilters for convenient access and storage (don't need 1 member per filter). Map<MessageType, LogFilter *> type_filter_map; - RichTextLabel *log; + RichTextLabel *log = nullptr; - Button *clear_button; - Button *copy_button; + Button *clear_button = nullptr; + Button *copy_button = nullptr; - Button *collapse_button; + Button *collapse_button = nullptr; bool collapse = false; - Button *show_search_button; - LineEdit *search_box; + Button *show_search_button = nullptr; + LineEdit *search_box = nullptr; // Reference to the "Output" button on the toolbar so we can update it's icon when // Warnings or Errors are encounetered. - Button *tool_button; + Button *tool_button = nullptr; bool is_loading_state = false; // Used to disable saving requests while loading (some signals from buttons will try trigger a save, which happens during loading). - Timer *save_state_timer; + Timer *save_state_timer = nullptr; static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index bcdd54edd4..a80c7853f5 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -225,17 +225,17 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto index_sets.write[scene_name_to_set_index[scene_name]].insert(i); } - // For each index set with a size > 1, we need to disambiguate + // For each index set with a size > 1, we need to disambiguate. for (int i = 0; i < index_sets.size(); i++) { Set<int> iset = index_sets[i]; while (iset.size() > 1) { - // Append the parent folder to each scene name + // Append the parent folder to each scene name. for (Set<int>::Element *E = iset.front(); E; E = E->next()) { int set_idx = E->get(); String scene_name = r_filenames[set_idx]; String full_path = p_full_paths[set_idx]; - // Get rid of file extensions and res:// prefixes + // Get rid of file extensions and res:// prefixes. if (scene_name.rfind(".") >= 0) { scene_name = scene_name.substr(0, scene_name.rfind(".")); } @@ -263,7 +263,7 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto } } - // Loop back through scene names and remove non-ambiguous names + // Loop back through scene names and remove non-ambiguous names. bool can_proceed = false; Set<int>::Element *E = iset.front(); while (E) { @@ -430,7 +430,7 @@ void EditorNode::_update_title() { DisplayServer::get_singleton()->window_set_title(title); } -void EditorNode::unhandled_input(const Ref<InputEvent> &p_event) { +void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); Ref<InputEventKey> k = p_event; @@ -648,7 +648,7 @@ void EditorNode::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { editor_data.save_editor_external_data(); FileAccess::set_file_close_fail_notify_callback(nullptr); - log->deinit(); // do not get messages anymore + log->deinit(); // Do not get messages anymore. editor_data.clear_edited_scenes(); } break; @@ -658,7 +658,7 @@ void EditorNode::_notification(int p_what) { case NOTIFICATION_READY: { { - _initializing_addons = true; + _initializing_plugins = true; Vector<String> addons; if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) { addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled"); @@ -667,7 +667,7 @@ void EditorNode::_notification(int p_what) { for (int i = 0; i < addons.size(); i++) { set_addon_plugin_enabled(addons[i], true); } - _initializing_addons = false; + _initializing_plugins = false; } RenderingServer::get_singleton()->viewport_set_disable_2d(get_scene_root()->get_viewport_rid(), true); @@ -745,12 +745,12 @@ void EditorNode::_notification(int p_what) { recent_scenes->reset_size(); - // debugger area + // Update debugger area. if (EditorDebuggerNode::get_singleton()->is_visible()) { bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } - // update_icons + // Update icons. for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { Button *tb = singleton->main_editor_buttons[i]; EditorPlugin *p_editor = singleton->editor_table[i]; @@ -893,7 +893,7 @@ void EditorNode::_resources_changed(const Vector<String> &p_resources) { } if (!res->get_import_path().is_empty()) { - // this is an imported resource, will be reloaded if reimported via the _resources_reimported() callback + // This is an imported resource, will be reloaded if reimported via the _resources_reimported() callback. continue; } @@ -918,23 +918,23 @@ void EditorNode::_fs_changed() { _mark_unsaved_scenes(); - // FIXME: Move this to a cleaner location, it's hacky to do this is _fs_changed. + // FIXME: Move this to a cleaner location, it's hacky to do this in _fs_changed. String export_error; if (!export_defer.preset.is_empty() && !EditorFileSystem::get_singleton()->is_scanning()) { String preset_name = export_defer.preset; // Ensures export_project does not loop infinitely, because notifications may // come during the export. export_defer.preset = ""; - Ref<EditorExportPreset> preset; + Ref<EditorExportPreset> export_preset; for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); ++i) { - preset = EditorExport::get_singleton()->get_export_preset(i); - if (preset->get_name() == preset_name) { + export_preset = EditorExport::get_singleton()->get_export_preset(i); + if (export_preset->get_name() == preset_name) { break; } - preset.unref(); + export_preset.unref(); } - if (preset.is_null()) { + if (export_preset.is_null()) { DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists("res://export_presets.cfg")) { export_error = vformat( @@ -948,8 +948,8 @@ void EditorNode::_fs_changed() { export_error = "This project doesn't have an `export_presets.cfg` file at its root.\nCreate an export preset from the \"Project > Export\" dialog and try again."; } } else { - Ref<EditorExportPlatform> platform = preset->get_platform(); - const String export_path = export_defer.path.is_empty() ? preset->get_export_path() : export_defer.path; + Ref<EditorExportPlatform> platform = export_preset->get_platform(); + const String export_path = export_defer.path.is_empty() ? export_preset->get_export_path() : export_defer.path; if (export_path.is_empty()) { export_error = vformat("Export preset \"%s\" doesn't have a default export path, and none was specified.", preset_name); } else if (platform.is_null()) { @@ -958,18 +958,18 @@ void EditorNode::_fs_changed() { Error err = OK; if (export_defer.pack_only) { // Only export .pck or .zip data pack. if (export_path.ends_with(".zip")) { - err = platform->export_zip(preset, export_defer.debug, export_path); + err = platform->export_zip(export_preset, export_defer.debug, export_path); } else if (export_path.ends_with(".pck")) { - err = platform->export_pack(preset, export_defer.debug, export_path); + err = platform->export_pack(export_preset, export_defer.debug, export_path); } } else { // Normal project export. String config_error; bool missing_templates; - if (!platform->can_export(preset, config_error, missing_templates)) { + if (!platform->can_export(export_preset, config_error, missing_templates)) { ERR_PRINT(vformat("Cannot export project with preset \"%s\" due to configuration errors:\n%s", preset_name, config_error)); err = missing_templates ? ERR_FILE_NOT_FOUND : ERR_UNCONFIGURED; } else { - err = platform->export_project(preset, export_defer.debug, export_path); + err = platform->export_project(export_preset, export_defer.debug, export_path); } } switch (err) { @@ -998,21 +998,22 @@ void EditorNode::_fs_changed() { } void EditorNode::_resources_reimported(const Vector<String> &p_resources) { - List<String> scenes; // will load later + List<String> scenes; int current_tab = scene_tabs->get_current_tab(); for (int i = 0; i < p_resources.size(); i++) { String file_type = ResourceLoader::get_resource_type(p_resources[i]); if (file_type == "PackedScene") { scenes.push_back(p_resources[i]); - // reload later if needed, first go with normal resources + // Reload later if needed, first go with normal resources. continue; } if (!ResourceCache::has(p_resources[i])) { - continue; // not loaded, no need to reload + // Not loaded, no need to reload. + continue; } - // reload normally + // Reload normally. Resource *resource = ResourceCache::get(p_resources[i]); if (resource) { resource->reload_from_file(); @@ -1184,7 +1185,6 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN); if (!p_ignore_broken_deps && dependency_errors.has(p_resource)) { - // current_option = -1; Vector<String> errors; for (Set<String>::Element *E = dependency_errors[p_resource].front(); E; E = E->next()) { errors.push_back(E->get()); @@ -1251,7 +1251,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); saving_resource = p_resource; - current_option = RESOURCE_SAVE_AS; + current_menu_option = RESOURCE_SAVE_AS; List<String> extensions; Ref<PackedScene> sd = memnew(PackedScene); ResourceSaver::get_recognized_extensions(p_resource, &extensions); @@ -1260,18 +1260,18 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String List<String> preferred; for (const String &E : extensions) { if (p_resource->is_class("Script") && (E == "tres" || E == "res")) { - // this serves no purpose and confused people + // This serves no purpose and confused people. continue; } file->add_filter("*." + E + " ; " + E.to_upper()); preferred.push_back(E); } - // Lowest priority extension + // Lowest priority extension. List<String>::Element *res_element = preferred.find("res"); if (res_element) { preferred.move_to_back(res_element); } - // Highest priority extension + // Highest priority extension. List<String>::Element *tres_element = preferred.find("tres"); if (tres_element) { preferred.move_to_front(tres_element); @@ -1314,7 +1314,7 @@ void EditorNode::_menu_option(int p_option) { } void EditorNode::_menu_confirm_current() { - _menu_option_confirm(current_option, true); + _menu_option_confirm(current_menu_option, true); } void EditorNode::_dialog_display_save_error(String p_file, Error p_error) { @@ -1369,7 +1369,8 @@ void EditorNode::_get_scene_metadata(const String &p_file) { Error err = cf->load(path); if (err != OK || !cf->has_section("editor_states")) { - return; // must not exist + // Must not exist. + return; } List<String> esl; @@ -1393,9 +1394,6 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { return; } - scene->set_meta("__editor_run_settings__", Variant()); // clear it (no point in keeping it) - scene->set_meta("__editor_plugin_states__", Variant()); - String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; @@ -1436,10 +1434,9 @@ bool EditorNode::_find_and_save_resource(RES p_res, Map<RES, bool> &processed, i if (p_res->get_path().is_resource_file()) { if (changed || subchanged) { - // save ResourceSaver::save(p_res->get_path(), p_res, flags); } - processed[p_res] = false; // because it's a file + processed[p_res] = false; // Because it's a file. return false; } else { processed[p_res] = changed; @@ -1537,7 +1534,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { _find_node_types(editor_data.get_edited_scene_root(), c2d, c3d); save.step(TTR("Creating Thumbnail"), 1); - // current view? + // Current view? Ref<Image> img; // If neither 3D or 2D nodes are present, make a 1x1 black texture. @@ -1570,13 +1567,13 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); preview_size *= EDSCALE; - // consider a square region + // Consider a square region. int vp_size = MIN(img->get_width(), img->get_height()); int x = (img->get_width() - vp_size) / 2; int y = (img->get_height() - vp_size) / 2; if (vp_size < preview_size) { - // just square it. + // Just square it. img->crop_from_point(x, y, vp_size, vp_size); } else { int ratio = vp_size / preview_size; @@ -1590,13 +1587,12 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } img->convert(Image::FORMAT_RGB8); - // save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5 + // Save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5. String temp_path = EditorPaths::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); - // does not have it, try to load a cached thumbnail - + // Does not have it, try to load a cached thumbnail. String file = cache_base + ".png"; post_process_preview(img); @@ -1643,7 +1639,7 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso if (res.is_null()) { continue; } - if (res->get_path().is_resource_file()) { // not a subresource, continue + if (res->get_path().is_resource_file()) { // Not a subresource, continue. continue; } if (_find_edited_resources(res, edited_resources)) { @@ -1656,7 +1652,7 @@ static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Reso } int EditorNode::_save_external_resources() { - // save external resources and its subresources if any was modified + // Save external resources and its subresources if any was modified. int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) { @@ -1679,8 +1675,8 @@ int EditorNode::_save_external_resources() { } } - // clear later, because user may have put the same subresource in two different resources, - // which will be shared until the next reload + // Clear later, because user may have put the same subresource in two different resources, + // which will be shared until the next reload. for (Set<Ref<Resource>>::Element *E = edited_subresources.front(); E; E = E->next()) { Ref<Resource> res = E->get(); @@ -1728,9 +1724,9 @@ void EditorNode::_save_scene(String p_file, int idx) { Ref<PackedScene> sdata; if (ResourceCache::has(p_file)) { - // something may be referencing this resource and we are good with that. - // we must update it, but also let the previous scene state go, as - // old version still work for referencing changes in instantiated or inherited scenes + // Something may be referencing this resource and we are good with that. + // We must update it, but also let the previous scene state go, as + // old version still work for referencing changes in instantiated or inherited scenes. sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(p_file))); if (sdata.is_valid()) { @@ -1867,7 +1863,7 @@ void EditorNode::_mark_unsaved_scenes() { } void EditorNode::_dialog_action(String p_file) { - switch (current_option) { + switch (current_menu_option) { case FILE_NEW_INHERITED_SCENE: { Node *scene = editor_data.get_edited_scene_root(); // If the previous scene is rootless, just close it in favor of the new one. @@ -1883,12 +1879,12 @@ void EditorNode::_dialog_action(String p_file) { case SETTINGS_PICK_MAIN_SCENE: { ProjectSettings::get_singleton()->set("application/run/main_scene", p_file); ProjectSettings::get_singleton()->save(); - // would be nice to show the project manager opened with the highlighted field.. + // TODO: Would be nice to show the project manager opened with the highlighted field. if (pick_main_scene->has_meta("from_native") && (bool)pick_main_scene->get_meta("from_native")) { run_native->resume_run_native(); } else { - _run(false, ""); // automatically run the project + _run(false, ""); // Automatically run the project. } } break; case FILE_CLOSE: @@ -1898,7 +1894,7 @@ void EditorNode::_dialog_action(String p_file) { case SCENE_TAB_CLOSE: case FILE_SAVE_SCENE: case FILE_SAVE_AS_SCENE: { - int scene_idx = (current_option == FILE_SAVE_SCENE || current_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing; + int scene_idx = (current_menu_option == FILE_SAVE_SCENE || current_menu_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing_idx; if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { bool same_open_scene = false; @@ -1978,7 +1974,7 @@ void EditorNode::_dialog_action(String p_file) { Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err == ERR_FILE_CANT_OPEN || err == ERR_FILE_NOT_FOUND) { - config.instantiate(); // new config + config.instantiate(); } else if (err != OK) { show_warning(TTR("An error occurred while trying to save the editor layout.\nMake sure the editor's user data path is writable.")); return; @@ -2010,11 +2006,11 @@ void EditorNode::_dialog_action(String p_file) { return; } - // erase + // Erase key values. List<String> keys; config->get_section_keys(p_file, &keys); - for (const String &E : keys) { - config->set_value(p_file, E, Variant()); + for (const String &key : keys) { + config->set_value(p_file, key, Variant()); } config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); @@ -2027,8 +2023,8 @@ void EditorNode::_dialog_action(String p_file) { } } break; - default: { // save scene? - + default: { + // Save scene? if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) { _save_scene_with_preview(p_file); } @@ -2115,7 +2111,7 @@ void EditorNode::push_item(Object *p_object, const String &p_property, bool p_in ObjectID id = p_object->get_instance_id(); if (id != editor_history.get_current()) { if (p_inspector_only) { - editor_history.add_object_inspector_only(id); + editor_history.add_object(id, String(), true); } else if (p_property.is_empty()) { editor_history.add_object(id); } else { @@ -2196,7 +2192,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { bool is_resource = current_obj->is_class("Resource"); bool is_node = current_obj->is_class("Node"); - String editable_warning; // none by default + String editable_warning; // None by default. if (is_resource) { Resource *current_res = Object::cast_to<Resource>(current_obj); @@ -2264,7 +2260,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { } } if (!multi_nodes.is_empty()) { - // Pick the top-most node + // Pick the top-most node. multi_nodes.sort_custom<Node::Comparator>(); selected_node = multi_nodes.front()->get(); } @@ -2289,7 +2285,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { InspectorDock::get_inspector_singleton()->set_use_folding(!disable_folding); } - /* Take care of PLUGIN EDITOR */ + // Take care of the main editor plugin. if (!inspector_only) { EditorPlugin *main_plugin = editor_data.get_editor(current_obj); @@ -2298,7 +2294,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { for (; plugin_index < editor_table.size(); plugin_index++) { if (editor_table[plugin_index] == main_plugin) { if (!main_editor_buttons[plugin_index]->is_visible()) { - main_plugin = nullptr; // if button is not visible, then no plugin active + main_plugin = nullptr; // If button is not visible, then no plugin is active. } break; @@ -2306,7 +2302,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { } if (main_plugin) { - // special case if use of external editor is true + // Special case if use of external editor is true. Resource *current_res = Object::cast_to<Resource>(current_obj); if (main_plugin->get_name() == "Script" && current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { @@ -2315,7 +2311,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { } else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) { - // update screen main_plugin + // Update screen main_plugin. _editor_select(plugin_index); main_plugin->edit(current_obj); } else { @@ -2368,10 +2364,10 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } if (scene->get_scene_file_path().is_empty()) { - current_option = -1; + current_menu_option = -1; _menu_option(FILE_SAVE_AS_SCENE); // Set the option to save and run so when the dialog is accepted, the scene runs. - current_option = FILE_SAVE_AND_RUN; + current_menu_option = FILE_SAVE_AND_RUN; file->set_title(TTR("Save scene before running...")); return; } @@ -2382,7 +2378,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } if (run_filename.is_empty()) { - // evidently, run the scene + // Evidently, run the scene. if (!ensure_main_scene(false)) { return; } @@ -2446,7 +2442,7 @@ void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) { _menu_option_confirm(RUN_STOP, true); if (!call_build()) { - return; // build failed + return; // Build failed. } EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol()); @@ -2459,8 +2455,8 @@ void EditorNode::_android_build_source_selected(const String &p_file) { export_template_manager->install_android_template_from_file(p_file); } void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { - if (!p_confirmed) { // this may be a hack.. - current_option = (MenuOptions)p_option; + if (!p_confirmed) { // FIXME: this may be a hack. + current_menu_option = (MenuOptions)p_option; } switch (p_option) { @@ -2513,13 +2509,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_CLOSE_OTHERS: case FILE_CLOSE_RIGHT: case FILE_CLOSE_ALL: { - if (editor_data.get_edited_scene_count() > 1 && (current_option != FILE_CLOSE_RIGHT || editor_data.get_edited_scene() < editor_data.get_edited_scene_count() - 1)) { + if (editor_data.get_edited_scene_count() > 1 && (current_menu_option != FILE_CLOSE_RIGHT || editor_data.get_edited_scene() < editor_data.get_edited_scene_count() - 1)) { int next_tab = editor_data.get_edited_scene() + 1; next_tab %= editor_data.get_edited_scene_count(); - _scene_tab_closed(next_tab, current_option); + _scene_tab_closed(next_tab, current_menu_option); } else { - if (current_option != FILE_CLOSE_ALL) { - current_option = -1; + if (current_menu_option != FILE_CLOSE_ALL) { + current_menu_option = -1; } else { _scene_tab_closed(editor_data.get_edited_scene()); } @@ -2537,11 +2533,11 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT: { if (!p_confirmed) { - tab_closing = _next_unsaved_scene(false); - _scene_tab_changed(tab_closing); + tab_closing_idx = _next_unsaved_scene(false); + _scene_tab_changed(tab_closing_idx); if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { - Node *scene_root = editor_data.get_edited_scene_root(tab_closing); + Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx); if (scene_root) { String scene_filename = scene_root->get_scene_file_path(); if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { @@ -2556,9 +2552,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } } - if (!editor_data.get_edited_scene_root(tab_closing)) { - // empty tab - _scene_tab_closed(tab_closing); + if (!editor_data.get_edited_scene_root(tab_closing_idx)) { + // Empty tab. + _scene_tab_closed(tab_closing_idx); break; } @@ -2566,7 +2562,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } case SCENE_TAB_CLOSE: case FILE_SAVE_SCENE: { - int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing; + int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing_idx; Node *scene = editor_data.get_edited_scene_root(scene_idx); if (scene && !scene->get_scene_file_path().is_empty()) { if (DirAccess::exists(scene->get_scene_file_path().get_base_dir())) { @@ -2588,7 +2584,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { [[fallthrough]]; } case FILE_SAVE_AS_SCENE: { - int scene_idx = (p_option == FILE_SAVE_SCENE || p_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing; + int scene_idx = (p_option == FILE_SAVE_SCENE || p_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing_idx; Node *scene = editor_data.get_edited_scene_root(scene_idx); @@ -2829,7 +2825,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } break; case RUN_USER_DATA_FOLDER: { - // ensure_user_data_dir() to prevent the edge case: "Open User Data Folder" won't work after the project was renamed in ProjectSettingsEditor unless the project is saved + // Ensure_user_data_dir() to prevent the edge case: "Open User Data Folder" won't work after the project was renamed in ProjectSettingsEditor unless the project is saved. OS::get_singleton()->ensure_user_data_dir(); OS::get_singleton()->shell_open(String("file://") + OS::get_singleton()->get_user_data_dir()); } break; @@ -2967,12 +2963,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case HELP_SUPPORT_GODOT_DEVELOPMENT: { OS::get_singleton()->shell_open("https://godotengine.org/donate"); } break; - - // case SET_VIDEO_DRIVER_SAVE_AND_RESTART: { - // ProjectSettings::get_singleton()->set("rendering/driver/driver_name", video_driver_request); - // save_all_scenes(); - // restart_editor(); - // } break; case SET_RENDERING_DRIVER_SAVE_AND_RESTART: { ProjectSettings::get_singleton()->set("rendering/driver/driver_name", rendering_driver_request); ProjectSettings::get_singleton()->save(); @@ -3025,7 +3015,7 @@ void EditorNode::_tool_menu_option(int p_idx) { String err = Variant::get_callable_error_text(callback, nullptr, 0, ce); ERR_PRINT("Error calling function from tool menu: " + err); } - } // else it's a submenu so don't do anything. + } // Else it's a submenu so don't do anything. } break; } } @@ -3050,17 +3040,17 @@ int EditorNode::_next_unsaved_scene(bool p_valid_filename, int p_start) { void EditorNode::_exit_editor(int p_exit_code) { exiting = true; - resource_preview->stop(); // stop early to avoid crashes + resource_preview->stop(); // Stop early to avoid crashes. _save_docks(); - // Dim the editor window while it's quitting to make it clearer that it's busy + // Dim the editor window while it's quitting to make it clearer that it's busy. dim_editor(true); get_tree()->quit(p_exit_code); } void EditorNode::_discard_changes(const String &p_str) { - switch (current_option) { + switch (current_menu_option) { case FILE_CLOSE_ALL_AND_QUIT: case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT: @@ -3069,7 +3059,7 @@ void EditorNode::_discard_changes(const String &p_str) { case FILE_CLOSE_RIGHT: case FILE_CLOSE_ALL: case SCENE_TAB_CLOSE: { - Node *scene = editor_data.get_edited_scene_root(tab_closing); + Node *scene = editor_data.get_edited_scene_root(tab_closing_idx); if (scene != nullptr) { String scene_filename = scene->get_scene_file_path(); if (!scene_filename.is_empty()) { @@ -3077,37 +3067,37 @@ void EditorNode::_discard_changes(const String &p_str) { } } - _remove_scene(tab_closing); + _remove_scene(tab_closing_idx); _update_scene_tabs(); - if (current_option == FILE_CLOSE_ALL_AND_QUIT || current_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || current_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { + if (current_menu_option == FILE_CLOSE_ALL_AND_QUIT || current_menu_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || current_menu_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { // If restore tabs is enabled, reopen the scene that has just been closed, so it's remembered properly. if (bool(EDITOR_GET("interface/scene_tabs/restore_scenes_on_load"))) { _menu_option_confirm(FILE_OPEN_PREV, true); } if (_next_unsaved_scene(false) == -1) { - if (current_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { - current_option = RELOAD_CURRENT_PROJECT; - } else if (current_option == FILE_CLOSE_ALL_AND_QUIT) { - current_option = FILE_QUIT; + if (current_menu_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) { + current_menu_option = RELOAD_CURRENT_PROJECT; + } else if (current_menu_option == FILE_CLOSE_ALL_AND_QUIT) { + current_menu_option = FILE_QUIT; } else { - current_option = RUN_PROJECT_MANAGER; + current_menu_option = RUN_PROJECT_MANAGER; } _discard_changes(); } else { - _menu_option_confirm(current_option, false); + _menu_option_confirm(current_menu_option, false); } - } else if (current_option == FILE_CLOSE_OTHERS || current_option == FILE_CLOSE_RIGHT) { - if (editor_data.get_edited_scene_count() == 1 || (current_option == FILE_CLOSE_RIGHT && editor_data.get_edited_scene_count() <= editor_data.get_edited_scene() + 1)) { - current_option = -1; + } else if (current_menu_option == FILE_CLOSE_OTHERS || current_menu_option == FILE_CLOSE_RIGHT) { + if (editor_data.get_edited_scene_count() == 1 || (current_menu_option == FILE_CLOSE_RIGHT && editor_data.get_edited_scene_count() <= editor_data.get_edited_scene() + 1)) { + current_menu_option = -1; save_confirmation->hide(); } else { - _menu_option_confirm(current_option, false); + _menu_option_confirm(current_menu_option, false); } - } else if (current_option == FILE_CLOSE_ALL && editor_data.get_edited_scene_count() > 0) { - _menu_option_confirm(current_option, false); + } else if (current_menu_option == FILE_CLOSE_ALL && editor_data.get_edited_scene_count() > 0) { + _menu_option_confirm(current_menu_option, false); } else { - current_option = -1; + current_menu_option = -1; save_confirmation->hide(); } } break; @@ -3166,7 +3156,7 @@ void EditorNode::_editor_select(int p_which) { ERR_FAIL_INDEX(p_which, editor_table.size()); - if (!main_editor_buttons[p_which]->is_visible()) { // button hidden, no editor + if (!main_editor_buttons[p_which]->is_visible()) { // Button hidden, no editor. return; } @@ -3200,9 +3190,9 @@ void EditorNode::_editor_select(int p_which) { if (EditorSettings::get_singleton()->get("interface/editor/separate_distraction_mode")) { if (p_which == EDITOR_SCRIPT) { - set_distraction_free_mode(script_distraction); + set_distraction_free_mode(script_distraction_free); } else { - set_distraction_free_mode(scene_distraction); + set_distraction_free_mode(scene_distraction_free); } } } @@ -3282,13 +3272,13 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan } void EditorNode::_update_addon_config() { - if (_initializing_addons) { + if (_initializing_plugins) { return; } Vector<String> enabled_addons; - for (const KeyValue<String, EditorPlugin *> &E : plugin_addons) { + for (const KeyValue<String, EditorPlugin *> &E : addon_name_to_plugin) { enabled_addons.push_back(E.key); } @@ -3302,14 +3292,14 @@ void EditorNode::_update_addon_config() { } void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) { - ERR_FAIL_COND(p_enabled && plugin_addons.has(p_addon)); - ERR_FAIL_COND(!p_enabled && !plugin_addons.has(p_addon)); + ERR_FAIL_COND(p_enabled && addon_name_to_plugin.has(p_addon)); + ERR_FAIL_COND(!p_enabled && !addon_name_to_plugin.has(p_addon)); if (!p_enabled) { - EditorPlugin *addon = plugin_addons[p_addon]; + EditorPlugin *addon = addon_name_to_plugin[p_addon]; remove_editor_plugin(addon, p_config_changed); - memdelete(addon); // bye - plugin_addons.erase(p_addon); + memdelete(addon); + addon_name_to_plugin.erase(p_addon); _update_addon_config(); return; } @@ -3366,14 +3356,14 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, EditorPlugin *ep = memnew(EditorPlugin); ep->set_script(script); - plugin_addons[p_addon] = ep; + addon_name_to_plugin[p_addon] = ep; add_editor_plugin(ep, p_config_changed); _update_addon_config(); } bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const { - return plugin_addons.has(p_addon); + return addon_name_to_plugin.has(p_addon); } void EditorNode::_remove_edited_scene(bool p_change_tab) { @@ -3400,10 +3390,10 @@ void EditorNode::_remove_edited_scene(bool p_change_tab) { void EditorNode::_remove_scene(int index, bool p_change_tab) { if (editor_data.get_edited_scene() == index) { - // Scene to remove is current scene + // Scene to remove is current scene. _remove_edited_scene(p_change_tab); } else { - // Scene to remove is not active scene + // Scene to remove is not active scene. editor_data.remove_scene(index); } } @@ -3417,7 +3407,7 @@ void EditorNode::set_edited_scene(Node *p_scene) { get_editor_data().set_edited_scene_root(p_scene); if (Object::cast_to<Popup>(p_scene)) { - Object::cast_to<Popup>(p_scene)->show(); // show popups + Object::cast_to<Popup>(p_scene)->show(); } SceneTreeDock::get_singleton()->set_edited_scene(p_scene); if (get_tree()) { @@ -3453,7 +3443,7 @@ Dictionary EditorNode::_get_main_scene_state() { void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { if (get_edited_scene() != p_for_scene && p_for_scene != nullptr) { - return; // not for this scene + return; // Not for this scene. } changing_scene = false; @@ -3468,7 +3458,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { if (p_state.has("editor_index")) { int index = p_state["editor_index"]; - if (current < 2) { // if currently in spatial/2d, only switch to spatial/2d. if currently in script, stay there + if (current < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there. if (index < 2 || !get_edited_scene()) { _editor_select(index); } @@ -3477,7 +3467,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { if (get_edited_scene()) { if (current < 2) { - // use heuristic instead + // Use heuristic instead. int n2d = 0, n3d = 0; _find_node_types(get_edited_scene(), n2d, n3d); if (n2d > n3d) { @@ -3499,7 +3489,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { SceneTreeDock::get_singleton()->set_filter(p_state["node_filter"]); } - // this should only happen at the very end + // This should only happen at the very end. EditorDebuggerNode::get_singleton()->update_live_edit_root(); ScriptEditor::get_singleton()->set_scene_root_script(editor_data.get_scene_root_script(editor_data.get_edited_scene())); @@ -3548,7 +3538,7 @@ void EditorNode::set_current_scene(int p_idx) { Node *new_scene = editor_data.get_edited_scene_root(); if (Object::cast_to<Popup>(new_scene)) { - Object::cast_to<Popup>(new_scene)->show(); // show popups + Object::cast_to<Popup>(new_scene)->show(); } SceneTreeDock::get_singleton()->set_edited_scene(new_scene); @@ -3567,7 +3557,7 @@ void EditorNode::set_current_scene(int p_idx) { _update_title(); - call_deferred(SNAME("_set_main_scene_state"), state, get_edited_scene()); // do after everything else is done setting up + call_deferred(SNAME("_set_main_scene_state"), state, get_edited_scene()); // Do after everything else is done setting up. } bool EditorNode::is_scene_open(const String &p_path) { @@ -3654,7 +3644,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b } if (!p_ignore_broken_deps && dependency_errors.has(lpath)) { - current_option = -1; + current_menu_option = -1; Vector<String> errors; for (Set<String>::Element *E = dependency_errors[lpath].front(); E; E = E->next()) { errors.push_back(E->get()); @@ -3669,7 +3659,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b return ERR_FILE_MISSING_DEPENDENCIES; } - dependency_errors.erase(lpath); // at least not self path + dependency_errors.erase(lpath); // At least not self path. for (KeyValue<String, Set<String>> &E : dependency_errors) { String txt = vformat(TTR("Scene '%s' has broken dependencies:"), E.key) + "\n"; @@ -3680,7 +3670,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b } if (ResourceCache::has(lpath)) { - // used from somewhere else? no problem! update state and replace sdata + // Used from somewhere else? No problem! Update state and replace sdata. Ref<PackedScene> ps = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(lpath))); if (ps.is_valid()) { ps->replace_state(sdata->get_state()); @@ -3689,7 +3679,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b } } else { - sdata->set_path(lpath, true); // take over path + sdata->set_path(lpath, true); // Take over path. } Node *new_scene = sdata->instantiate(p_set_inherited ? PackedScene::GEN_EDIT_STATE_MAIN_INHERITED : PackedScene::GEN_EDIT_STATE_MAIN); @@ -3752,7 +3742,7 @@ void EditorNode::open_request(const String &p_path) { } } - load_scene(p_path); // as it will be opened in separate tab + load_scene(p_path); // As it will be opened in separate tab. } void EditorNode::edit_foreign_resource(RES p_resource) { @@ -3769,7 +3759,7 @@ void EditorNode::request_instantiate_scenes(const Vector<String> &p_files) { } void EditorNode::_inherit_request(String p_file) { - current_option = FILE_NEW_INHERITED_SCENE; + current_menu_option = FILE_NEW_INHERITED_SCENE; _dialog_action(p_file); } @@ -3864,7 +3854,7 @@ void EditorNode::add_io_error(const String &p_error) { } void EditorNode::_load_error_notify(void *p_ud, const String &p_text) { - EditorNode *en = (EditorNode *)p_ud; + EditorNode *en = static_cast<EditorNode *>(p_ud); en->load_errors->add_image(en->gui_base->get_theme_icon(SNAME("Error"), SNAME("EditorIcons"))); en->load_errors->add_text(p_text + "\n"); en->load_error_dialog->popup_centered_ratio(0.5); @@ -3930,10 +3920,9 @@ void EditorNode::register_editor_types() { GDREGISTER_CLASS(EditorScriptPicker); GDREGISTER_ABSTRACT_CLASS(FileSystemDock); + GDREGISTER_VIRTUAL_CLASS(EditorFileSystemImportFormatSupportQuery); - // FIXME: Is this stuff obsolete, or should it be ported to new APIs? GDREGISTER_CLASS(EditorScenePostImport); - //ClassDB::register_type<EditorImportExport>(); GDREGISTER_CLASS(EditorCommandPalette); GDREGISTER_CLASS(EditorDebuggerPlugin); @@ -3971,7 +3960,7 @@ Ref<Script> EditorNode::get_object_custom_type_base(const Object *p_object) cons // return name; // } - // should probably be deprecated in 4.x + // TODO: Should probably be deprecated in 4.x StringName base = script->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; @@ -4007,7 +3996,7 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const return name; } - // should probably be deprecated in 4.x + // TODO: Should probably be deprecated in 4.x. StringName base = base_script->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; @@ -4048,7 +4037,7 @@ void EditorNode::_pick_main_scene_custom_action(const String &p_custom_action_na } pick_main_scene->hide(); - current_option = SETTINGS_PICK_MAIN_SCENE; + current_menu_option = SETTINGS_PICK_MAIN_SCENE; _dialog_action(scene->get_scene_file_path()); } } @@ -4071,7 +4060,7 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String return icon; } - // should probably be deprecated in 4.x + // TODO: should probably be deprecated in 4.x StringName base = base_script->get_instance_base_type(); if (base != StringName() && EditorNode::get_editor_data().get_custom_types().has(base)) { const Vector<EditorData::CustomType> &types = EditorNode::get_editor_data().get_custom_types()[base]; @@ -4085,7 +4074,7 @@ Ref<Texture2D> EditorNode::get_object_icon(const Object *p_object, const String } } - // should probably be deprecated in 4.x + // TODO: Should probably be deprecated in 4.x. if (p_object->has_meta("_editor_icon")) { return p_object->get_meta("_editor_icon"); } @@ -4243,14 +4232,14 @@ Error EditorNode::export_preset(const String &p_preset, const String &p_path, bo } void EditorNode::show_accept(const String &p_text, const String &p_title) { - current_option = -1; + current_menu_option = -1; accept->get_ok_button()->set_text(p_title); accept->set_text(p_text); accept->popup_centered(); } void EditorNode::show_save_accept(const String &p_text, const String &p_title) { - current_option = -1; + current_menu_option = -1; save_accept->get_ok_button()->set_text(p_title); save_accept->set_text(p_text); save_accept->popup_centered(); @@ -4272,7 +4261,7 @@ void EditorNode::_copy_warning(const String &p_str) { void EditorNode::_dock_floating_close_request(Control *p_control) { // Through the MarginContainer to the Window. - Window *window = (Window *)p_control->get_parent()->get_parent(); + Window *window = static_cast<Window *>(p_control->get_parent()->get_parent()); int window_slot = window->get_meta("dock_slot"); p_control->get_parent()->remove_child(p_control); @@ -4290,7 +4279,7 @@ void EditorNode::_dock_floating_close_request(Control *p_control) { } void EditorNode::_dock_make_float() { - Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control(); + Control *dock = dock_slot[dock_popup_selected_idx]->get_current_tab_control(); ERR_FAIL_COND(!dock); Size2 borders = Size2(4, 4) * EDSCALE; @@ -4299,7 +4288,7 @@ void EditorNode::_dock_make_float() { Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders; int dock_index = dock->get_index(); - dock_slot[dock_popup_selected]->remove_child(dock); + dock_slot[dock_popup_selected_idx]->remove_child(dock); Window *window = memnew(Window); window->set_title(dock->get_name()); @@ -4321,7 +4310,7 @@ void EditorNode::_dock_make_float() { window->set_position(dock_screen_pos); window->set_transient(true); window->connect("close_requested", callable_mp(this, &EditorNode::_dock_floating_close_request), varray(dock)); - window->set_meta("dock_slot", dock_popup_selected); + window->set_meta("dock_slot", dock_popup_selected_idx); window->set_meta("dock_index", dock_index); gui_base->add_child(window); @@ -4373,9 +4362,9 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { } } - if (nrect != dock_select_rect_over) { + if (nrect != dock_select_rect_over_idx) { dock_select->update(); - dock_select_rect_over = nrect; + dock_select_rect_over_idx = nrect; } if (nrect == -1) { @@ -4384,20 +4373,20 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouseButton> mb = me; - if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed() && dock_popup_selected != nrect) { - Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control(); + if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed() && dock_popup_selected_idx != nrect) { + Control *dock = dock_slot[dock_popup_selected_idx]->get_current_tab_control(); if (dock) { - dock_slot[dock_popup_selected]->remove_child(dock); + dock_slot[dock_popup_selected_idx]->remove_child(dock); } - if (dock_slot[dock_popup_selected]->get_tab_count() == 0) { - dock_slot[dock_popup_selected]->hide(); + if (dock_slot[dock_popup_selected_idx]->get_tab_count() == 0) { + dock_slot[dock_popup_selected_idx]->hide(); } else { - dock_slot[dock_popup_selected]->set_current_tab(0); + dock_slot[dock_popup_selected_idx]->set_current_tab(0); } dock_slot[nrect]->add_child(dock); - dock_popup_selected = nrect; + dock_popup_selected_idx = nrect; dock_slot[nrect]->set_current_tab(dock_slot[nrect]->get_tab_count() - 1); dock_slot[nrect]->show(); dock_select->update(); @@ -4411,38 +4400,38 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { } void EditorNode::_dock_popup_exit() { - dock_select_rect_over = -1; + dock_select_rect_over_idx = -1; dock_select->update(); } void EditorNode::_dock_pre_popup(int p_which) { - dock_popup_selected = p_which; + dock_popup_selected_idx = p_which; } void EditorNode::_dock_move_left() { - if (dock_popup_selected < 0 || dock_popup_selected >= DOCK_SLOT_MAX) { + if (dock_popup_selected_idx < 0 || dock_popup_selected_idx >= DOCK_SLOT_MAX) { return; } - Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab()); - Control *prev = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() - 1); + Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); + Control *prev = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); if (!current || !prev) { return; } - dock_slot[dock_popup_selected]->move_child(current, prev->get_index()); - dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() - 1); + dock_slot[dock_popup_selected_idx]->move_child(current, prev->get_index()); + dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() - 1); dock_select->update(); _edit_current(); _save_docks(); } void EditorNode::_dock_move_right() { - Control *current = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab()); - Control *next = dock_slot[dock_popup_selected]->get_tab_control(dock_slot[dock_popup_selected]->get_current_tab() + 1); + Control *current = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab()); + Control *next = dock_slot[dock_popup_selected_idx]->get_tab_control(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); if (!current || !next) { return; } - dock_slot[dock_popup_selected]->move_child(next, current->get_index()); - dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() + 1); + dock_slot[dock_popup_selected_idx]->move_child(next, current->get_index()); + dock_slot[dock_popup_selected_idx]->set_current_tab(dock_slot[dock_popup_selected_idx]->get_current_tab() + 1); dock_select->update(); _edit_current(); _save_docks(); @@ -4470,9 +4459,9 @@ void EditorNode::_dock_select_draw() { dock_tab_move_left->set_disabled(true); dock_tab_move_right->set_disabled(true); - if (dock_popup_selected != -1 && dock_slot[dock_popup_selected]->get_tab_count()) { - dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() == 0); - dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected]->get_current_tab() >= dock_slot[dock_popup_selected]->get_tab_count() - 1); + if (dock_popup_selected_idx != -1 && dock_slot[dock_popup_selected_idx]->get_tab_count()) { + dock_tab_move_left->set_disabled(dock_slot[dock_popup_selected_idx]->get_current_tab() == 0); + dock_tab_move_right->set_disabled(dock_slot[dock_popup_selected_idx]->get_current_tab() >= dock_slot[dock_popup_selected_idx]->get_tab_count() - 1); } for (int i = 0; i < DOCK_SLOT_MAX; i++) { @@ -4515,7 +4504,7 @@ void EditorNode::_dock_select_draw() { r.position += Vector2(2, 5); r.size -= Vector2(4, 7); - if (i == dock_select_rect_over) { + if (i == dock_select_rect_over_idx) { dock_select->draw_rect(r, used_selected); } else if (dock_slot[i]->get_tab_count() == 0) { dock_select->draw_rect(r, unused); @@ -4526,7 +4515,7 @@ void EditorNode::_dock_select_draw() { for (int j = 0; j < MIN(3, dock_slot[i]->get_tab_count()); j++) { int xofs = (r.size.width / 3) * j; Color c = used; - if (i == dock_popup_selected && (dock_slot[i]->get_current_tab() > 3 || dock_slot[i]->get_current_tab() == j)) { + if (i == dock_popup_selected_idx && (dock_slot[i]->get_current_tab() > 3 || dock_slot[i]->get_current_tab() == j)) { c = tab_selected; } dock_select->draw_rect(Rect2(2 + ofs.x + xofs, ofs.y, r.size.width / 3 - 1, 3), c); @@ -4536,7 +4525,7 @@ void EditorNode::_dock_select_draw() { void EditorNode::_save_docks() { if (waiting_for_first_scan) { - return; // scanning, do not touch docks + return; // Scanning, do not touch docks. } Ref<ConfigFile> config; config.instantiate(); @@ -4607,7 +4596,7 @@ void EditorNode::_load_docks() { config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); if (err != OK) { - // no config + // No config. if (overridden_default_layout >= 0) { _layout_menu_option(overridden_default_layout); } @@ -4670,7 +4659,7 @@ void EditorNode::_update_dock_slots_visibility() { } void EditorNode::_dock_tab_changed(int p_tab) { - // update visibility but don't set current tab + // Update visibility but don't set current tab. if (!docks_visible) { for (int i = 0; i < DOCK_SLOT_MAX; i++) { @@ -4720,7 +4709,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String for (int j = 0; j < names.size(); j++) { String name = names[j]; - // find it, in a horribly inefficient way + // FIXME: Find it, in a horribly inefficient way. int atidx = -1; Control *node = nullptr; for (int k = 0; k < DOCK_SLOT_MAX; k++) { @@ -4734,7 +4723,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String atidx = k; break; } - if (atidx == -1) { // well, it's not anywhere + if (atidx == -1) { // Well, it's not anywhere. continue; } @@ -4850,11 +4839,11 @@ bool EditorNode::has_scenes_in_session() { } bool EditorNode::ensure_main_scene(bool p_from_native) { - pick_main_scene->set_meta("from_native", p_from_native); // whether from play button or native run + pick_main_scene->set_meta("from_native", p_from_native); // Whether from play button or native run. String main_scene = GLOBAL_DEF("application/run/main_scene", ""); if (main_scene.is_empty()) { - current_option = -1; + current_menu_option = -1; pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in \"Project Settings\" under the 'application' category.")); pick_main_scene->popup_centered(); @@ -4869,14 +4858,14 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { } if (!FileAccess::exists(main_scene)) { - current_option = -1; + current_menu_option = -1; pick_main_scene->set_text(vformat(TTR("Selected scene '%s' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); pick_main_scene->popup_centered(); return false; } if (ResourceLoader::get_resource_type(main_scene) != "PackedScene") { - current_option = -1; + current_menu_option = -1; pick_main_scene->set_text(vformat(TTR("Selected scene '%s' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."), main_scene)); pick_main_scene->popup_centered(); return false; @@ -4971,7 +4960,7 @@ void EditorNode::_update_layouts_menu() { config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { - return; // no config + return; // No config. } List<String> layouts; @@ -4990,14 +4979,14 @@ void EditorNode::_update_layouts_menu() { void EditorNode::_layout_menu_option(int p_id) { switch (p_id) { case SETTINGS_LAYOUT_SAVE: { - current_option = p_id; + current_menu_option = p_id; layout_dialog->set_title(TTR("Save Layout")); layout_dialog->get_ok_button()->set_text(TTR("Save")); layout_dialog->popup_centered(); layout_dialog->set_name_line_enabled(true); } break; case SETTINGS_LAYOUT_DELETE: { - current_option = p_id; + current_menu_option = p_id; layout_dialog->set_title(TTR("Delete Layout")); layout_dialog->get_ok_button()->set_text(TTR("Delete")); layout_dialog->popup_centered(); @@ -5012,7 +5001,7 @@ void EditorNode::_layout_menu_option(int p_id) { config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { - return; // no config + return; // No config. } _load_docks_from_config(config, editor_layouts->get_item_text(p_id)); @@ -5029,8 +5018,8 @@ void EditorNode::_scene_tab_script_edited(int p_tab) { } void EditorNode::_scene_tab_closed(int p_tab, int option) { - current_option = option; - tab_closing = p_tab; + current_menu_option = option; + tab_closing_idx = p_tab; Node *scene = editor_data.get_edited_scene_root(p_tab); if (!scene) { _discard_changes(); @@ -5086,7 +5075,7 @@ void EditorNode::_scene_tab_input(const Ref<InputEvent> &p_input) { } } if (mb->get_button_index() == MouseButton::RIGHT && mb->is_pressed()) { - // context menu + // Context menu. scene_tabs_context_menu->clear(); scene_tabs_context_menu->reset_size(); @@ -5154,7 +5143,7 @@ void EditorNode::_scene_tab_changed(int p_tab) { bool unsaved = (saved_version != editor_data.get_undo_redo().get_version()); if (p_tab == editor_data.get_edited_scene()) { - return; // pointless + return; // Pointless. } uint64_t next_scene_version = editor_data.get_scene_version(p_tab); @@ -5256,7 +5245,8 @@ void EditorNode::_bottom_panel_switch(bool p_enable, int p_idx) { bottom_panel_items[i].button->set_pressed(i == p_idx); bottom_panel_items[i].control->set_visible(i == p_idx); } - if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { // this is the debug panel which uses tabs, so the top section should be smaller + if (EditorDebuggerNode::get_singleton() == bottom_panel_items[p_idx].control) { + // This is the debug panel which uses tabs, so the top section should be smaller. bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanelDebuggerOverride"), SNAME("EditorStyles"))); } else { bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); @@ -5301,11 +5291,11 @@ void EditorNode::_toggle_distraction_free_mode() { } if (screen == EDITOR_SCRIPT) { - script_distraction = !script_distraction; - set_distraction_free_mode(script_distraction); + script_distraction_free = !script_distraction_free; + set_distraction_free_mode(script_distraction_free); } else { - scene_distraction = !scene_distraction; - set_distraction_free_mode(scene_distraction); + scene_distraction_free = !scene_distraction_free; + set_distraction_free_mode(scene_distraction_free); } } else { set_distraction_free_mode(distraction_free->is_pressed()); @@ -5357,7 +5347,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { Ref<Texture2D> preview; { - // todo make proper previews + // TODO: make proper previews Ref<ImageTexture> texture = gui_base->get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); Ref<Image> img = texture->get_image(); img = img->duplicate(); @@ -5379,7 +5369,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { drag_control->add_child(label); - p_from->set_drag_preview(drag_control); // wait until it enters scene + p_from->set_drag_preview(drag_control); // Wait until it enters scene. label->set_position(Point2((preview->get_width() - label->get_minimum_size().width) / 2, preview->get_height())); @@ -5433,7 +5423,7 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control * } vbox->add_child(label); } - p_from->set_drag_preview(vbox); // wait until it enters scene + p_from->set_drag_preview(vbox); // Wait until it enters scene. Dictionary drag_data; drag_data["type"] = has_folder ? "files_and_dirs" : "files"; @@ -5549,7 +5539,7 @@ void EditorNode::reload_scene(const String &p_path) { if (scene_idx == -1) { if (get_edited_scene()) { - // scene is not open, so at it might be instantiated. We'll refresh the whole scene later. + // Scene is not open, so at it might be instantiated. We'll refresh the whole scene later. editor_data.get_undo_redo().clear_history(); } return; @@ -5560,17 +5550,15 @@ void EditorNode::reload_scene(const String &p_path) { _set_scene_metadata(p_path); } - // remove scene + // Reload scene. _remove_scene(scene_idx, false); - - // reload scene load_scene(p_path, true, false, true, true); - // adjust index so tab is back a the previous position + // Adjust index so tab is back a the previous position. editor_data.move_edited_scene_to_index(scene_idx); get_undo_redo()->clear_history(); - // recover the tab + // Recover the tab. scene_tabs->set_current_tab(current_tab); } @@ -5669,9 +5657,9 @@ void EditorNode::_update_rendering_driver_color() { void EditorNode::_rendering_driver_selected(int p_which) { String driver = rendering_driver->get_item_metadata(p_which); - String current = ""; // OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); + String current_driver = OS::get_singleton()->get_current_rendering_driver_name(); - if (driver == current) { + if (driver == current_driver) { return; } @@ -5785,7 +5773,7 @@ static Node *_resource_get_edited_scene() { } void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) { - EditorNode *en = (EditorNode *)p_this; + EditorNode *en = static_cast<EditorNode *>(p_this); en->log->add_message(p_string, p_error ? EditorLog::MSG_TYPE_ERROR : EditorLog::MSG_TYPE_STD); } @@ -5852,20 +5840,25 @@ EditorNode::EditorNode() { EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor); add_child(epnp); + PortableCompressedTexture2D::set_keep_all_compressed_buffers(true); Input::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; RenderingServer::get_singleton()->set_debug_generate_wireframes(true); - NavigationServer3D::get_singleton()->set_active(false); // no nav by default if editor + // No navigation server by default if in editor. + NavigationServer3D::get_singleton()->set_active(false); + + // No physics by default if in editor. + PhysicsServer3D::get_singleton()->set_active(false); + PhysicsServer2D::get_singleton()->set_active(false); - PhysicsServer3D::get_singleton()->set_active(false); // no physics by default if editor - PhysicsServer2D::get_singleton()->set_active(false); // no physics by default if editor - ScriptServer::set_scripting_enabled(false); // no scripting by default if editor + // No scripting by default if in editor. + ScriptServer::set_scripting_enabled(false); - EditorHelp::generate_doc(); // before any editor classes are created + EditorHelp::generate_doc(); // Before any editor classes are created. SceneState::set_disable_placeholders(true); - ResourceLoader::clear_translation_remaps(); // no remaps using during editor + ResourceLoader::clear_translation_remaps(); // Using no remaps if in editor. ResourceLoader::clear_path_remaps(); Input *id = Input::get_singleton(); @@ -5879,8 +5872,8 @@ EditorNode::EditorNode() { } if (!found_touchscreen && Input::get_singleton()) { - // only if no touchscreen ui hint, set emulation - id->set_emulate_touch_from_mouse(false); // just disable just in case + // Only if no touchscreen ui hint, disable emulation just in case. + id->set_emulate_touch_from_mouse(false); } DisplayServer::get_singleton()->cursor_set_custom_image(RES()); } @@ -5889,7 +5882,7 @@ EditorNode::EditorNode() { last_checked_version = 0; TranslationServer::get_singleton()->set_enabled(false); - // load settings + // Load settings. if (!EditorSettings::get_singleton()) { EditorSettings::create(); } @@ -5928,7 +5921,7 @@ EditorNode::EditorNode() { } } - // Define a minimum window size to prevent UI elements from overlapping or being cut off + // Define a minimum window size to prevent UI elements from overlapping or being cut off. DisplayServer::get_singleton()->window_set_min_size(Size2(1024, 600) * EDSCALE); ResourceLoader::set_abort_on_missing_resources(false); @@ -5938,7 +5931,8 @@ EditorNode::EditorNode() { ResourceLoader::set_error_notify_func(this, _load_error_notify); ResourceLoader::set_dependency_error_notify_func(this, _dependency_error_report); - { // register importers at the beginning, so dialogs are created with the right extensions + { + // Register importers at the beginning, so dialogs are created with the right extensions. Ref<ResourceImporterTexture> import_texture; import_texture.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_texture); @@ -6041,7 +6035,7 @@ EditorNode::EditorNode() { EditorFileSystem *efs = memnew(EditorFileSystem); add_child(efs); - // used for previews + // Used for previews. FileDialog::get_icon_func = _file_dialog_get_icon; FileDialog::register_func = _file_dialog_register; FileDialog::unregister_func = _file_dialog_unregister; @@ -6053,14 +6047,13 @@ EditorNode::EditorNode() { editor_export = memnew(EditorExport); add_child(editor_export); - // Exporters might need the theme + // Exporters might need the theme. theme = create_custom_theme(); register_exporters(); ClassDB::set_class_enabled("RootMotionView", true); - // defs here, use EDITOR_GET in logic EDITOR_DEF("interface/editor/save_on_focus_loss", false); EDITOR_DEF("interface/editor/show_update_spinner", false); EDITOR_DEF("interface/editor/update_continuously", false); @@ -6105,7 +6098,7 @@ EditorNode::EditorNode() { progress_dialog = memnew(ProgressDialog); gui_base->add_child(progress_dialog); - // take up all screen + // Take up all screen. gui_base->set_anchor(SIDE_RIGHT, Control::ANCHOR_END); gui_base->set_anchor(SIDE_BOTTOM, Control::ANCHOR_END); gui_base->set_end(Point2(0, 0)); @@ -6167,7 +6160,7 @@ EditorNode::EditorNode() { dock_slot[DOCK_SLOT_RIGHT_BR] = memnew(TabContainer); right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_BR]); - // Store them for easier access + // Store them for easier access. vsplits.push_back(left_l_vsplit); vsplits.push_back(left_r_vsplit); vsplits.push_back(right_l_vsplit); @@ -6236,8 +6229,9 @@ EditorNode::EditorNode() { dock_vb->add_child(dock_float); dock_select_popup->reset_size(); - dock_select_rect_over = -1; - dock_popup_selected = -1; + dock_select_rect_over_idx = -1; + dock_popup_selected_idx = -1; + for (int i = 0; i < DOCK_SLOT_MAX; i++) { dock_slot[i]->set_custom_minimum_size(Size2(170, 0) * EDSCALE); dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -6514,7 +6508,7 @@ EditorNode::EditorNode() { main_editor_button_vb = memnew(HBoxContainer); menu_hb->add_child(main_editor_button_vb); - // Options are added and handled by DebuggerEditorPlugin + // Options are added and handled by DebuggerEditorPlugin. debug_menu = memnew(MenuButton); debug_menu->set_flat(false); debug_menu->set_switch_on_hover(true); @@ -6559,10 +6553,10 @@ EditorNode::EditorNode() { p->add_separator(); if (OS::get_singleton()->get_data_path() == OS::get_singleton()->get_config_path()) { - // Configuration and data folders are located in the same place (Windows/macos) + // Configuration and data folders are located in the same place (Windows/MacOS). p->add_item(TTR("Open Editor Data/Settings Folder"), SETTINGS_EDITOR_DATA_FOLDER); } else { - // Separate configuration and data folders (Linux) + // Separate configuration and data folders (Linux). p->add_item(TTR("Open Editor Data Folder"), SETTINGS_EDITOR_DATA_FOLDER); p->add_item(TTR("Open Editor Settings Folder"), SETTINGS_EDITOR_CONFIG_FOLDER); } @@ -6571,7 +6565,6 @@ EditorNode::EditorNode() { p->add_item(TTR("Manage Editor Features..."), SETTINGS_MANAGE_FEATURE_PROFILES); p->add_item(TTR("Manage Export Templates..."), SETTINGS_MANAGE_EXPORT_TEMPLATES); - // Help Menu help_menu = memnew(MenuButton); help_menu->set_flat(false); help_menu->set_switch_on_hover(true); @@ -6736,7 +6729,7 @@ EditorNode::EditorNode() { p->add_item(TTR("Hide Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE); _update_update_spinner(); - // Instantiate and place editor docks + // Instantiate and place editor docks. memnew(SceneTreeDock(scene_root, editor_selection, editor_data)); memnew(InspectorDock(editor_data)); @@ -6748,27 +6741,27 @@ EditorNode::EditorNode() { filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request)); filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks)); - // Scene: Top left + // Scene: Top left. dock_slot[DOCK_SLOT_LEFT_UR]->add_child(SceneTreeDock::get_singleton()); dock_slot[DOCK_SLOT_LEFT_UR]->set_tab_title(dock_slot[DOCK_SLOT_LEFT_UR]->get_tab_idx_from_control(SceneTreeDock::get_singleton()), TTR("Scene")); - // Import: Top left, behind Scene + // Import: Top left, behind Scene. dock_slot[DOCK_SLOT_LEFT_UR]->add_child(ImportDock::get_singleton()); dock_slot[DOCK_SLOT_LEFT_UR]->set_tab_title(dock_slot[DOCK_SLOT_LEFT_UR]->get_tab_idx_from_control(ImportDock::get_singleton()), TTR("Import")); - // FileSystem: Bottom left + // FileSystem: Bottom left. dock_slot[DOCK_SLOT_LEFT_BR]->add_child(FileSystemDock::get_singleton()); dock_slot[DOCK_SLOT_LEFT_BR]->set_tab_title(dock_slot[DOCK_SLOT_LEFT_BR]->get_tab_idx_from_control(FileSystemDock::get_singleton()), TTR("FileSystem")); - // Inspector: Full height right + // Inspector: Full height right. dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(InspectorDock::get_singleton()); dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(dock_slot[DOCK_SLOT_RIGHT_UL]->get_tab_idx_from_control(InspectorDock::get_singleton()), TTR("Inspector")); - // Node: Full height right, behind Inspector + // Node: Full height right, behind Inspector. dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(NodeDock::get_singleton()); dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(dock_slot[DOCK_SLOT_RIGHT_UL]->get_tab_idx_from_control(NodeDock::get_singleton()), TTR("Node")); - // Hide unused dock slots and vsplits + // Hide unused dock slots and vsplits. dock_slot[DOCK_SLOT_LEFT_UL]->hide(); dock_slot[DOCK_SLOT_LEFT_BL]->hide(); dock_slot[DOCK_SLOT_RIGHT_BL]->hide(); @@ -6777,16 +6770,16 @@ EditorNode::EditorNode() { left_l_vsplit->hide(); right_r_vsplit->hide(); - // Add some offsets to left_r and main hsplits to make LEFT_R and RIGHT_L docks wider than minsize + // Add some offsets to left_r and main hsplits to make LEFT_R and RIGHT_L docks wider than minsize. left_r_hsplit->set_split_offset(70 * EDSCALE); main_hsplit->set_split_offset(-70 * EDSCALE); - // Define corresponding default layout + // Define corresponding default layout. const String docks_section = "docks"; overridden_default_layout = -1; default_layout.instantiate(); - // Dock numbers are based on DockSlot enum value + 1 + // Dock numbers are based on DockSlot enum value + 1. default_layout->set_value(docks_section, "dock_3", "Scene,Import"); default_layout->set_value(docks_section, "dock_4", "FileSystem"); default_layout->set_value(docks_section, "dock_5", "Inspector,Node"); @@ -6801,7 +6794,7 @@ EditorNode::EditorNode() { _update_layouts_menu(); - // Bottom panels + // Bottom panels. bottom_panel = memnew(PanelContainer); bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); @@ -6837,7 +6830,7 @@ EditorNode::EditorNode() { } // Set the text to copy in metadata as it slightly differs from the button's text. version_btn->set_meta(META_TEXT_TO_COPY, "v" VERSION_FULL_BUILD + hash); - // Fade out the version label to be less prominent, but still readable + // Fade out the version label to be less prominent, but still readable. version_btn->set_self_modulate(Color(1, 1, 1, 0.65)); version_btn->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER); version_btn->set_tooltip(TTR("Click to copy.")); @@ -6960,8 +6953,8 @@ EditorNode::EditorNode() { file->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); file_templates->connect("file_selected", callable_mp(this, &EditorNode::_dialog_action)); - preview_gen = memnew(AudioStreamPreviewGenerator); - add_child(preview_gen); + audio_preview_gen = memnew(AudioStreamPreviewGenerator); + add_child(audio_preview_gen); add_editor_plugin(memnew(DebuggerEditorPlugin(debug_menu))); add_editor_plugin(memnew(DebugAdapterServer())); @@ -6996,7 +6989,7 @@ EditorNode::EditorNode() { EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor(); - ScriptTextEditor::register_editor(); // register one for text scripts + ScriptTextEditor::register_editor(); // Register one for text scripts. TextEditor::register_editor(); if (StreamPeerSSL::is_available()) { @@ -7005,12 +6998,12 @@ EditorNode::EditorNode() { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } - // add interface before adding plugins + // Add interface before adding plugins. editor_interface = memnew(EditorInterface); add_child(editor_interface); - // more visually meaningful to have this later + // More visually meaningful to have this later. raise_bottom_panel_item(AnimationPlayerEditor::get_singleton()); add_editor_plugin(memnew(ReplicationEditorPlugin)); @@ -7175,7 +7168,7 @@ EditorNode::EditorNode() { _update_recent_scenes(); editor_data.restore_editor_global_states(); - set_process_unhandled_input(true); + set_process_shortcut_input(true); load_errors = memnew(RichTextLabel); load_error_dialog = memnew(AcceptDialog); @@ -7245,7 +7238,8 @@ EditorNode::EditorNode() { screenshot_timer->set_owner(get_owner()); String exec = OS::get_singleton()->get_executable_path(); - EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "executable_path", exec); // Save editor executable path for third-party tools + // Save editor executable path for third-party tools. + EditorSettings::get_singleton()->set_project_metadata("editor_metadata", "executable_path", exec); } EditorNode::~EditorNode() { diff --git a/editor/editor_node.h b/editor/editor_node.h index 785baee6c1..685714cb47 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -112,6 +112,13 @@ public: DOCK_SLOT_MAX }; + enum EditorTable { + EDITOR_2D = 0, + EDITOR_3D, + EDITOR_SCRIPT, + EDITOR_ASSETLIB + }; + struct ExecuteThreadArgs { String path; List<String> args; @@ -123,10 +130,6 @@ public: }; private: - enum { - HISTORY_SIZE = 64 - }; - enum MenuOptions { FILE_NEW_SCENE, FILE_NEW_INHERITED_SCENE, @@ -218,244 +221,291 @@ private: TOOL_MENU_BASE = 1000 }; + enum { + MAX_INIT_CALLBACKS = 128, + MAX_BUILD_CALLBACKS = 128 + }; + enum ScriptNameCasing { SCENE_NAME_CASING_AUTO, SCENE_NAME_CASING_PASCAL_CASE, SCENE_NAME_CASING_SNAKE_CASE }; - SubViewport *scene_root; // root of the scene being edited + struct BottomPanelItem { + String name; + Control *control = nullptr; + Button *button = nullptr; + }; + + struct ExportDefer { + String preset; + String path; + bool debug = false; + bool pack_only = false; + } export_defer; - PanelContainer *scene_root_parent; - Control *theme_base; - Control *gui_base; - VBoxContainer *main_vbox; - OptionButton *rendering_driver; + static EditorNode *singleton; - ConfirmationDialog *video_restart_dialog; + EditorData editor_data; + EditorFolding editor_folding; + EditorRun editor_run; + EditorSelectionHistory editor_history; + + EditorCommandPalette *command_palette = nullptr; + EditorExport *editor_export = nullptr; + EditorInterface *editor_interface = nullptr; + EditorLog *log = nullptr; + EditorNativeShaderSourceVisualizer *native_shader_source_visualizer = nullptr; + EditorPlugin *editor_plugin_screen = nullptr; + EditorPluginList *editor_plugins_force_input_forwarding = nullptr; + EditorPluginList *editor_plugins_force_over = nullptr; + EditorPluginList *editor_plugins_over = nullptr; + EditorQuickOpen *quick_open = nullptr; + EditorQuickOpen *quick_run = nullptr; + EditorResourcePreview *resource_preview = nullptr; + EditorRunNative *run_native = nullptr; + EditorSelection *editor_selection = nullptr; + EditorSettingsDialog *editor_settings_dialog = nullptr; + + ProjectExportDialog *project_export = nullptr; + ProjectSettingsEditor *project_settings_editor = nullptr; - int rendering_driver_current; - String rendering_driver_request; - void _rendering_driver_selected(int); - void _update_rendering_driver_color(); + Vector<EditorPlugin *> editor_plugins; + bool _initializing_plugins = false; + Map<String, EditorPlugin *> addon_name_to_plugin; - // Split containers + PanelContainer *scene_root_parent = nullptr; + Control *theme_base = nullptr; + Control *gui_base = nullptr; + VBoxContainer *main_vbox = nullptr; + OptionButton *rendering_driver = nullptr; - HSplitContainer *left_l_hsplit; - VSplitContainer *left_l_vsplit; - HSplitContainer *left_r_hsplit; - VSplitContainer *left_r_vsplit; - HSplitContainer *main_hsplit; - HSplitContainer *right_hsplit; - VSplitContainer *right_l_vsplit; - VSplitContainer *right_r_vsplit; + ConfirmationDialog *video_restart_dialog = nullptr; - VSplitContainer *center_split; + int rendering_driver_current; + String rendering_driver_request; - // To access those easily by index + // Split containers. + HSplitContainer *left_l_hsplit = nullptr; + VSplitContainer *left_l_vsplit = nullptr; + HSplitContainer *left_r_hsplit = nullptr; + VSplitContainer *left_r_vsplit = nullptr; + HSplitContainer *main_hsplit = nullptr; + HSplitContainer *right_hsplit = nullptr; + VSplitContainer *right_l_vsplit = nullptr; + VSplitContainer *right_r_vsplit = nullptr; + VSplitContainer *center_split = nullptr; + // To access those easily by index. Vector<VSplitContainer *> vsplits; Vector<HSplitContainer *> hsplits; - // Main tabs - - TabBar *scene_tabs; - PopupMenu *scene_tabs_context_menu; - Panel *tab_preview_panel; - TextureRect *tab_preview; - int tab_closing; + // Main tabs. + TabBar *scene_tabs = nullptr; + PopupMenu *scene_tabs_context_menu = nullptr; + Panel *tab_preview_panel = nullptr; + TextureRect *tab_preview = nullptr; + int tab_closing_idx; bool exiting = false; bool dimmed = false; int old_split_ofs; - VSplitContainer *top_split; - HBoxContainer *bottom_hb; - Control *vp_base; - - HBoxContainer *menu_hb; - Control *main_control; - MenuButton *file_menu; - MenuButton *project_menu; - MenuButton *debug_menu; - MenuButton *settings_menu; - MenuButton *help_menu; - PopupMenu *tool_menu; - Button *export_button; - Button *prev_scene; - Button *play_button; - Button *pause_button; - Button *stop_button; - Button *run_settings_button; - Button *play_scene_button; - Button *play_custom_scene_button; - Button *search_button; - TextureProgressBar *audio_vu; - - Timer *screenshot_timer; - - PluginConfigDialog *plugin_config_dialog; - - RichTextLabel *load_errors; - AcceptDialog *load_error_dialog; - - RichTextLabel *execute_outputs; - AcceptDialog *execute_output_dialog; + VSplitContainer *top_split = nullptr; + HBoxContainer *bottom_hb = nullptr; + Control *vp_base = nullptr; + + HBoxContainer *menu_hb = nullptr; + Control *main_control = nullptr; + MenuButton *file_menu = nullptr; + MenuButton *project_menu = nullptr; + MenuButton *debug_menu = nullptr; + MenuButton *settings_menu = nullptr; + MenuButton *help_menu = nullptr; + PopupMenu *tool_menu = nullptr; + Button *export_button = nullptr; + Button *prev_scene = nullptr; + Button *play_button = nullptr; + Button *pause_button = nullptr; + Button *stop_button = nullptr; + Button *run_settings_button = nullptr; + Button *play_scene_button = nullptr; + Button *play_custom_scene_button = nullptr; + Button *search_button = nullptr; + TextureProgressBar *audio_vu = nullptr; + + Timer *screenshot_timer = nullptr; + + PluginConfigDialog *plugin_config_dialog = nullptr; + + RichTextLabel *load_errors = nullptr; + AcceptDialog *load_error_dialog = nullptr; + + RichTextLabel *execute_outputs = nullptr; + AcceptDialog *execute_output_dialog = nullptr; Ref<Theme> theme; - PopupMenu *recent_scenes; - EditorRunNative *run_native; - - ConfirmationDialog *confirmation; - ConfirmationDialog *save_confirmation; - ConfirmationDialog *import_confirmation; - ConfirmationDialog *pick_main_scene; - Button *select_current_scene_button; - AcceptDialog *accept; - AcceptDialog *save_accept; - EditorAbout *about; - AcceptDialog *warning; + PopupMenu *recent_scenes = nullptr; + String _recent_scene; + List<String> previous_scenes; + String defer_load_scene; + Node *_last_instantiated_scene = nullptr; + + ConfirmationDialog *confirmation = nullptr; + ConfirmationDialog *save_confirmation = nullptr; + ConfirmationDialog *import_confirmation = nullptr; + ConfirmationDialog *pick_main_scene = nullptr; + Button *select_current_scene_button = nullptr; + AcceptDialog *accept = nullptr; + AcceptDialog *save_accept = nullptr; + EditorAbout *about = nullptr; + AcceptDialog *warning = nullptr; int overridden_default_layout; Ref<ConfigFile> default_layout; - PopupMenu *editor_layouts; - EditorLayoutsDialog *layout_dialog; - - ConfirmationDialog *custom_build_manage_templates; - ConfirmationDialog *install_android_build_template; - ConfirmationDialog *remove_android_build_template; - - EditorSettingsDialog *editor_settings_dialog; - ProjectSettingsEditor *project_settings_editor; - bool settings_changed = true; // make it update settings on first frame - void _update_from_settings(); - - PopupMenu *vcs_actions_menu; - EditorFileDialog *file; - ExportTemplateManager *export_template_manager; - EditorFeatureProfileManager *feature_profile_manager; - EditorFileDialog *file_templates; - EditorFileDialog *file_export_lib; - EditorFileDialog *file_script; - EditorFileDialog *file_android_build_source; - CheckBox *file_export_lib_merge; - CheckBox *file_export_lib_apply_xforms; + PopupMenu *editor_layouts = nullptr; + EditorLayoutsDialog *layout_dialog = nullptr; + + ConfirmationDialog *custom_build_manage_templates = nullptr; + ConfirmationDialog *install_android_build_template = nullptr; + ConfirmationDialog *remove_android_build_template = nullptr; + + PopupMenu *vcs_actions_menu = nullptr; + EditorFileDialog *file = nullptr; + ExportTemplateManager *export_template_manager = nullptr; + EditorFeatureProfileManager *feature_profile_manager = nullptr; + EditorFileDialog *file_templates = nullptr; + EditorFileDialog *file_export_lib = nullptr; + EditorFileDialog *file_script = nullptr; + EditorFileDialog *file_android_build_source = nullptr; + CheckBox *file_export_lib_merge = nullptr; + CheckBox *file_export_lib_apply_xforms = nullptr; String current_path; - MenuButton *update_spinner; - - EditorNativeShaderSourceVisualizer *native_shader_source_visualizer; - - String defer_load_scene; - Node *_last_instantiated_scene; + MenuButton *update_spinner = nullptr; - EditorLog *log; - CenterContainer *tabs_center; - EditorQuickOpen *quick_open; - EditorQuickOpen *quick_run; - EditorCommandPalette *command_palette; - - HBoxContainer *main_editor_button_vb; + HBoxContainer *main_editor_button_vb = nullptr; Vector<Button *> main_editor_buttons; Vector<EditorPlugin *> editor_table; - AudioStreamPreviewGenerator *preview_gen; - ProgressDialog *progress_dialog; - BackgroundProgress *progress_hb; + AudioStreamPreviewGenerator *audio_preview_gen = nullptr; + ProgressDialog *progress_dialog = nullptr; + BackgroundProgress *progress_hb = nullptr; - DependencyErrorDialog *dependency_error; - DependencyEditor *dependency_fixer; - OrphanResourcesDialog *orphan_resources; - ConfirmationDialog *open_imported; - Button *new_inherited_button; + DependencyErrorDialog *dependency_error = nullptr; + Map<String, Set<String>> dependency_errors; + DependencyEditor *dependency_fixer = nullptr; + OrphanResourcesDialog *orphan_resources = nullptr; + ConfirmationDialog *open_imported = nullptr; + Button *new_inherited_button = nullptr; String open_import_request; Vector<Control *> floating_docks; - TabContainer *dock_slot[DOCK_SLOT_MAX]; + Button *dock_float = nullptr; + Button *dock_tab_move_left = nullptr; + Button *dock_tab_move_right = nullptr; + Control *dock_select = nullptr; + PopupPanel *dock_select_popup = nullptr; Rect2 dock_select_rect[DOCK_SLOT_MAX]; - int dock_select_rect_over; - PopupPanel *dock_select_popup; - Control *dock_select; - Button *dock_float; - Button *dock_tab_move_left; - Button *dock_tab_move_right; - int dock_popup_selected; - Timer *dock_drag_timer; + TabContainer *dock_slot[DOCK_SLOT_MAX]; + Timer *dock_drag_timer = nullptr; bool docks_visible = true; + int dock_popup_selected_idx; + int dock_select_rect_over_idx; - HBoxContainer *tabbar_container; - Button *distraction_free; - Button *scene_tab_add; - Control *scene_tab_add_ph; + HBoxContainer *tabbar_container = nullptr; + Button *distraction_free = nullptr; + Button *scene_tab_add = nullptr; + Control *scene_tab_add_ph = nullptr; - bool scene_distraction = false; - bool script_distraction = false; + Vector<BottomPanelItem> bottom_panel_items; + PanelContainer *bottom_panel = nullptr; + HBoxContainer *bottom_panel_hb = nullptr; + HBoxContainer *bottom_panel_hb_editors = nullptr; + VBoxContainer *bottom_panel_vb = nullptr; + EditorToaster *editor_toaster = nullptr; + LinkButton *version_btn = nullptr; + Button *bottom_panel_raise = nullptr; - String _tmp_import_path; + Tree *disk_changed_list = nullptr; + ConfirmationDialog *disk_changed = nullptr; - EditorExport *editor_export; - - Object *current; - Ref<Resource> saving_resource; + bool scene_distraction_free = false; + bool script_distraction_free = false; bool _playing_edited = false; - String run_custom_filename; - bool reference_resource_mem = true; - uint64_t saved_version; - uint64_t last_checked_version; - bool unsaved_cache = true; - String open_navigate; bool changing_scene = false; + bool cmdline_export_mode = false; + bool convert_old = false; + bool immediate_dialog_confirmed = false; + bool opening_prev = false; + bool restoring_scenes = false; + bool settings_changed = true; // Make it update settings on first frame. + bool unsaved_cache = true; bool waiting_for_first_scan = true; + int current_menu_option; + + SubViewport *scene_root = nullptr; // Root of the scene being edited. + Object *current = nullptr; + + Ref<Resource> saving_resource; + uint64_t update_spinner_step_msec; uint64_t update_spinner_step_frame; int update_spinner_step; - Vector<EditorPlugin *> editor_plugins; - EditorPlugin *editor_plugin_screen; - EditorPluginList *editor_plugins_over; - EditorPluginList *editor_plugins_force_over; - EditorPluginList *editor_plugins_force_input_forwarding; + String _tmp_import_path; + String external_file; + String open_navigate; + String run_custom_filename; - EditorHistory editor_history; - EditorData editor_data; - EditorRun editor_run; - EditorSelection *editor_selection; - ProjectExportDialog *project_export; - EditorResourcePreview *resource_preview; - EditorFolding editor_folding; + uint64_t saved_version; + uint64_t last_checked_version; - DynamicFontImportSettings *fontdata_import_settings; - SceneImportSettings *scene_import_settings; - struct BottomPanelItem { - String name; - Control *control = nullptr; - Button *button = nullptr; - }; + DynamicFontImportSettings *fontdata_import_settings = nullptr; + SceneImportSettings *scene_import_settings = nullptr; - Vector<BottomPanelItem> bottom_panel_items; + String import_reload_fn; - PanelContainer *bottom_panel; - HBoxContainer *bottom_panel_hb; - HBoxContainer *bottom_panel_hb_editors; - VBoxContainer *bottom_panel_vb; - EditorToaster *editor_toaster; - LinkButton *version_btn; - Button *bottom_panel_raise; + Set<String> textfile_extensions; + Set<FileDialog *> file_dialogs; + Set<EditorFileDialog *> editor_file_dialogs; - Tree *disk_changed_list; - ConfirmationDialog *disk_changed; + Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins; + PrintHandlerList print_handler; - void _bottom_panel_raise_toggled(bool); + Map<String, Ref<Texture2D>> icon_type_cache; - EditorInterface *editor_interface; + static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS]; + static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS]; + static int build_callback_count; + static int plugin_init_callback_count; + static Vector<EditorNodeInitCallback> _init_callbacks; - void _bottom_panel_switch(bool p_enable, int p_idx); + static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) { + EditorNode *en = static_cast<EditorNode *>(ud); + if (!en->dependency_errors.has(p_path)) { + en->dependency_errors[p_path] = Set<String>(); + } + en->dependency_errors[p_path].insert(p_dep + "::" + p_type); + } - String external_file; - List<String> previous_scenes; - bool opening_prev = false; + static Ref<Texture2D> _file_dialog_get_icon(const String &p_path); + static void _file_dialog_register(FileDialog *p_dialog); + static void _file_dialog_unregister(FileDialog *p_dialog); + static void _editor_file_dialog_register(EditorFileDialog *p_dialog); + static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog); + + static void _load_error_notify(void *p_ud, const String &p_text); + static void _file_access_close_error_notify(const String &p_str); + + static void _print_handler(void *p_this, const String &p_string, bool p_error); + static void _resource_saved(RES p_resource, const String &p_path); + static void _resource_loaded(RES p_resource, const String &p_path); + + void _build_icon_type_cache(); void _dialog_action(String p_file); @@ -463,7 +513,6 @@ private: void _dialog_display_save_error(String p_file, Error p_error); void _dialog_display_load_error(String p_file, Error p_error); - int current_option; void _menu_option(int p_option); void _menu_confirm_current(); void _menu_option_confirm(int p_option, bool p_confirmed); @@ -528,36 +577,18 @@ private: void _global_menu_new_window(const Variant &p_tag); void _dropped_files(const Vector<String> &p_files, int p_screen); void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path); - String _recent_scene; - void _exit_editor(int p_exit_code); + void _update_from_settings(); - bool convert_old = false; + void _rendering_driver_selected(int); + void _update_rendering_driver_color(); - virtual void unhandled_input(const Ref<InputEvent> &p_event) override; + void _exit_editor(int p_exit_code); - static void _load_error_notify(void *p_ud, const String &p_text); + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; bool has_main_screen() const { return true; } - String import_reload_fn; - - Set<String> textfile_extensions; - Set<FileDialog *> file_dialogs; - Set<EditorFileDialog *> editor_file_dialogs; - - Map<String, Ref<Texture2D>> icon_type_cache; - void _build_icon_type_cache(); - - bool _initializing_addons = false; - Map<String, EditorPlugin *> plugin_addons; - - static Ref<Texture2D> _file_dialog_get_icon(const String &p_path); - static void _file_dialog_register(FileDialog *p_dialog); - static void _file_dialog_unregister(FileDialog *p_dialog); - static void _editor_file_dialog_register(EditorFileDialog *p_dialog); - static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog); - void _remove_edited_scene(bool p_change_tab = true); void _remove_scene(int index, bool p_change_tab = true); bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags); @@ -568,29 +599,6 @@ private: void _find_node_types(Node *p_node, int &count_2d, int &count_3d); void _save_scene_with_preview(String p_file, int p_idx = -1); - Map<String, Set<String>> dependency_errors; - - static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) { - EditorNode *en = (EditorNode *)ud; - if (!en->dependency_errors.has(p_path)) { - en->dependency_errors[p_path] = Set<String>(); - } - en->dependency_errors[p_path].insert(p_dep + "::" + p_type); - } - - struct ExportDefer { - String preset; - String path; - bool debug = false; - bool pack_only = false; - } export_defer; - - bool cmdline_export_mode = false; - - static EditorNode *singleton; - - static Vector<EditorNodeInitCallback> _init_callbacks; - bool _find_scene_in_use(Node *p_node, const String &p_path) const; void _update_dock_containers(); @@ -625,7 +633,6 @@ private: void _update_dock_slots_visibility(); void _dock_tab_changed(int p_tab); - 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); @@ -636,35 +643,14 @@ private: void _update_addon_config(); - static void _file_access_close_error_notify(const String &p_str); - void _toggle_distraction_free_mode(); - enum { - MAX_INIT_CALLBACKS = 128, - MAX_BUILD_CALLBACKS = 128 - }; - void _inherit_imported(const String &p_action); void _open_imported(); - static int plugin_init_callback_count; - static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS]; void _save_default_environment(); - - static int build_callback_count; - static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS]; - void _update_update_spinner(); - Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins; - - PrintHandlerList print_handler; - static void _print_handler(void *p_this, const String &p_string, bool p_error); - - static void _resource_saved(RES p_resource, const String &p_path); - static void _resource_loaded(RES p_resource, const String &p_path); - void _resources_changed(const Vector<String> &p_resources); void _scan_external_changes(); void _reload_modified_scenes(); @@ -677,48 +663,70 @@ private: void _pick_main_scene_custom_action(const String &p_custom_action_name); - bool immediate_dialog_confirmed = false; void _immediate_dialog_confirmed(); void _select_default_main_screen_plugin(); + void _bottom_panel_switch(bool p_enable, int p_idx); + void _bottom_panel_raise_toggled(bool); + protected: - void _notification(int p_what); + friend class FileSystemDock; static void _bind_methods(); -protected: - friend class FileSystemDock; + void _notification(int p_what); int get_current_tab(); void set_current_tab(int p_tab); public: - bool call_build(); + void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } - static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback); + bool call_build(); - enum EditorTable { - EDITOR_2D = 0, - EDITOR_3D, - EDITOR_SCRIPT, - EDITOR_ASSETLIB - }; + static void register_editor_types(); + static void unregister_editor_types(); - void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } static EditorNode *get_singleton() { return singleton; } - EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; } - EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; } - EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } - EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } + static EditorLog *get_log() { return singleton->log; } + static EditorData &get_editor_data() { return singleton->editor_data; } + static EditorFolding &get_editor_folding() { return singleton->editor_folding; } + static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); } - ProjectSettingsEditor *get_project_settings() { return project_settings_editor; } + static HBoxContainer *get_menu_hb() { return singleton->menu_hb; } + static VSplitContainer *get_top_split() { return singleton->top_split; } + + static bool has_unsaved_changes() { return singleton->unsaved_cache; } + static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames); + static void add_io_error(const String &p_error); + + static void progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel = false); + static bool progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true); + static void progress_end_task(const String &p_task); + + static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps); + static void progress_task_step_bg(const String &p_task, int p_step = -1); + static void progress_end_task_bg(const String &p_task); static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false); static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false); - static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames); + static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback); + static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); } + static void add_build_callback(EditorBuildCallback p_callback); + + static bool immediate_confirmation_dialog(const String &p_text, const String &p_ok_text = TTR("Ok"), const String &p_cancel_text = TTR("Cancel")); + + EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; } + EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } + EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } + EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; } + EditorSelection *get_editor_selection() { return editor_selection; } + EditorSelectionHistory *get_editor_selection_history() { return &editor_history; } + + ProjectSettingsEditor *get_project_settings() { return project_settings_editor; } void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); } @@ -743,10 +751,6 @@ public: void show_about() { _menu_option_confirm(HELP_ABOUT, false); } - static bool has_unsaved_changes() { return singleton->unsaved_cache; } - - static HBoxContainer *get_menu_hb() { return singleton->menu_hb; } - void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false); void edit_item(Object *p_object); void edit_item_resource(RES p_resource); @@ -760,15 +764,12 @@ public: bool is_changing_scene() const; - static EditorLog *get_log() { return singleton->log; } Control *get_main_control(); + SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited. void set_edited_scene(Node *p_scene); - Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } - SubViewport *get_scene_root() { return scene_root; } // root of the scene being edited - void fix_dependencies(const String &p_for_file); int new_scene(); Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false, bool p_silent_change_tab = false); @@ -779,17 +780,8 @@ public: void set_current_version(uint64_t p_version); void set_current_scene(int p_idx); - static EditorData &get_editor_data() { return singleton->editor_data; } - static EditorFolding &get_editor_folding() { return singleton->editor_folding; } - EditorHistory *get_editor_history() { return &editor_history; } - - static VSplitContainer *get_top_split() { return singleton->top_split; } - void request_instance_scene(const String &p_path); void request_instantiate_scenes(const Vector<String> &p_files); - static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); } - - EditorSelection *get_editor_selection() { return editor_selection; } void set_convert_old_scene(bool p_old) { convert_old = p_old; } @@ -812,22 +804,9 @@ public: Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only); - static void register_editor_types(); - static void unregister_editor_types(); - Control *get_gui_base() { return gui_base; } Control *get_theme_base() { return gui_base->get_parent_control(); } - static void add_io_error(const String &p_error); - - static void progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel = false); - static bool progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true); - static void progress_end_task(const String &p_task); - - static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps); - static void progress_task_step_bg(const String &p_task, int p_step = -1); - static void progress_end_task_bg(const String &p_task); - void save_scene_to_path(String p_file, bool p_with_preview = true) { if (p_with_preview) { _save_scene_with_preview(p_file); @@ -883,9 +862,6 @@ public: void remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin); Vector<Ref<EditorResourceConversionPlugin>> find_resource_conversion_plugin(const Ref<Resource> &p_for_resource); - static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); } - static void add_build_callback(EditorBuildCallback p_callback); - bool ensure_main_scene(bool p_from_native); Error run_play_native(int p_idx, int p_platform); @@ -895,8 +871,6 @@ public: void run_stop(); bool is_run_playing() const; String get_run_playing_scene() const; - - static bool immediate_confirmation_dialog(const String &p_text, const String &p_ok_text = TTR("Ok"), const String &p_cancel_text = TTR("Cancel")); }; struct EditorProgress { diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 5cb3d0cd75..8747128962 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -194,7 +194,7 @@ void EditorPath::_notification(int p_what) { void EditorPath::_bind_methods() { } -EditorPath::EditorPath(EditorHistory *p_history) { +EditorPath::EditorPath(EditorSelectionHistory *p_history) { history = p_history; MarginContainer *main_mc = memnew(MarginContainer); diff --git a/editor/editor_path.h b/editor/editor_path.h index 539ae7a11d..afc7a20bad 100644 --- a/editor/editor_path.h +++ b/editor/editor_path.h @@ -37,17 +37,17 @@ #include "scene/gui/popup_menu.h" #include "scene/gui/texture_rect.h" -class EditorHistory; +class EditorSelectionHistory; class EditorPath : public Button { GDCLASS(EditorPath, Button); - EditorHistory *history; + EditorSelectionHistory *history = nullptr; - TextureRect *current_object_icon; - Label *current_object_label; - TextureRect *sub_objects_icon; - PopupMenu *sub_objects_menu; + TextureRect *current_object_icon = nullptr; + Label *current_object_label = nullptr; + TextureRect *sub_objects_icon = nullptr; + PopupMenu *sub_objects_menu = nullptr; Vector<ObjectID> objects; @@ -65,7 +65,7 @@ public: void clear_path(); void enable_path(); - EditorPath(EditorHistory *p_history); + EditorPath(EditorSelectionHistory *p_history); }; #endif // EDITOR_PATH_H diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index c239b735de..826bb8c00f 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -44,10 +44,10 @@ class EditorPluginSettings : public VBoxContainer { BUTTON_PLUGIN_EDIT }; - PluginConfigDialog *plugin_config_dialog; - Button *create_plugin; - Button *update_list; - Tree *plugin_list; + PluginConfigDialog *plugin_config_dialog = nullptr; + Button *create_plugin = nullptr; + Button *update_list = nullptr; + Tree *plugin_list = nullptr; bool updating = false; void _plugin_activity_changed(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c6b369f201..d2b8883b8a 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2806,8 +2806,8 @@ void EditorPropertyNodePath::_node_selected(const NodePath &p_path) { if (!base_node) { //try a base node within history - if (EditorNode::get_singleton()->get_editor_history()->get_path_size() > 0) { - Object *base = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(0)); + if (EditorNode::get_singleton()->get_editor_selection_history()->get_path_size() > 0) { + Object *base = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_path_object(0)); if (base) { base_node = Object::cast_to<Node>(base); } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index c21e0e0b4d..1f40a7fe7b 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -52,7 +52,7 @@ public: class EditorPropertyText : public EditorProperty { GDCLASS(EditorPropertyText, EditorProperty); - LineEdit *text; + LineEdit *text = nullptr; bool updating = false; bool string_name = false; @@ -72,11 +72,11 @@ public: class EditorPropertyMultilineText : public EditorProperty { GDCLASS(EditorPropertyMultilineText, EditorProperty); - TextEdit *text; + TextEdit *text = nullptr; - AcceptDialog *big_text_dialog; - TextEdit *big_text; - Button *open_big_text; + AcceptDialog *big_text_dialog = nullptr; + TextEdit *big_text = nullptr; + Button *open_big_text = nullptr; void _big_text_changed(); void _text_changed(); @@ -95,15 +95,15 @@ public: class EditorPropertyTextEnum : public EditorProperty { GDCLASS(EditorPropertyTextEnum, EditorProperty); - HBoxContainer *default_layout; - HBoxContainer *edit_custom_layout; + HBoxContainer *default_layout = nullptr; + HBoxContainer *edit_custom_layout = nullptr; - OptionButton *option_button; - Button *edit_button; + OptionButton *option_button = nullptr; + Button *edit_button = nullptr; - LineEdit *custom_value_edit; - Button *accept_button; - Button *cancel_button; + LineEdit *custom_value_edit = nullptr; + Button *accept_button = nullptr; + Button *cancel_button = nullptr; Vector<String> options; bool string_name = false; @@ -134,9 +134,9 @@ class EditorPropertyPath : public EditorProperty { bool folder = false; bool global = false; bool save_mode = false; - EditorFileDialog *dialog; - LineEdit *path; - Button *path_edit; + EditorFileDialog *dialog = nullptr; + LineEdit *path = nullptr; + Button *path_edit = nullptr; void _path_selected(const String &p_path); void _path_pressed(); @@ -156,9 +156,9 @@ public: class EditorPropertyLocale : public EditorProperty { GDCLASS(EditorPropertyLocale, EditorProperty); - EditorLocaleDialog *dialog; - LineEdit *locale; - Button *locale_edit; + EditorLocaleDialog *dialog = nullptr; + LineEdit *locale = nullptr; + Button *locale_edit = nullptr; void _locale_selected(const String &p_locale); void _locale_pressed(); @@ -178,8 +178,8 @@ class EditorPropertyClassName : public EditorProperty { GDCLASS(EditorPropertyClassName, EditorProperty); private: - CreateDialog *dialog; - Button *property; + CreateDialog *dialog = nullptr; + Button *property = nullptr; String selected_type; String base_type; void _property_selected(); @@ -212,8 +212,8 @@ public: private: Type hint; - PropertySelector *selector; - Button *property; + PropertySelector *selector = nullptr; + Button *property = nullptr; String hint_text; void _property_selected(const String &p_selected); @@ -231,7 +231,7 @@ public: class EditorPropertyCheck : public EditorProperty { GDCLASS(EditorPropertyCheck, EditorProperty); - CheckBox *checkbox; + CheckBox *checkbox = nullptr; void _checkbox_pressed(); @@ -246,7 +246,7 @@ public: class EditorPropertyEnum : public EditorProperty { GDCLASS(EditorPropertyEnum, EditorProperty); - OptionButton *options; + OptionButton *options = nullptr; void _option_selected(int p_which); @@ -263,7 +263,7 @@ public: class EditorPropertyFlags : public EditorProperty { GDCLASS(EditorPropertyFlags, EditorProperty); - VBoxContainer *vbox; + VBoxContainer *vbox = nullptr; Vector<CheckBox *> flags; Vector<int> flag_indices; @@ -293,9 +293,9 @@ private: int hovered_index = -1; bool read_only = false; int renamed_layer_index = -1; - PopupMenu *layer_rename; - ConfirmationDialog *rename_dialog; - LineEdit *rename_dialog_text; + PopupMenu *layer_rename = nullptr; + ConfirmationDialog *rename_dialog = nullptr; + LineEdit *rename_dialog_text = nullptr; void _rename_pressed(int p_menu); void _rename_operation_confirm(); @@ -334,12 +334,12 @@ public: }; private: - EditorPropertyLayersGrid *grid; + EditorPropertyLayersGrid *grid = nullptr; void _grid_changed(uint32_t p_grid); String basename; LayerType layer_type; - PopupMenu *layers; - Button *button; + PopupMenu *layers = nullptr; + Button *button = nullptr; void _button_pressed(); void _menu_pressed(int p_menu); @@ -358,7 +358,7 @@ public: class EditorPropertyInteger : public EditorProperty { GDCLASS(EditorPropertyInteger, EditorProperty); - EditorSpinSlider *spin; + EditorSpinSlider *spin = nullptr; bool setting = false; void _value_changed(int64_t p_val); @@ -374,7 +374,7 @@ public: class EditorPropertyObjectID : public EditorProperty { GDCLASS(EditorPropertyObjectID, EditorProperty); - Button *edit; + Button *edit = nullptr; String base_type; void _edit_pressed(); @@ -390,7 +390,7 @@ public: class EditorPropertyFloat : public EditorProperty { GDCLASS(EditorPropertyFloat, EditorProperty); - EditorSpinSlider *spin; + EditorSpinSlider *spin = nullptr; bool setting = false; bool angle_in_radians = false; void _value_changed(double p_val); @@ -407,9 +407,9 @@ public: class EditorPropertyEasing : public EditorProperty { GDCLASS(EditorPropertyEasing, EditorProperty); - Control *easing_draw; - PopupMenu *preset; - EditorSpinSlider *spin; + Control *easing_draw = nullptr; + PopupMenu *preset = nullptr; + EditorSpinSlider *spin = nullptr; bool setting = false; bool dragging = false; @@ -657,7 +657,7 @@ public: class EditorPropertyColor : public EditorProperty { GDCLASS(EditorPropertyColor, EditorProperty); - ColorPickerButton *picker; + ColorPickerButton *picker = nullptr; void _color_changed(const Color &p_color); void _popup_closed(); void _picker_created(); @@ -677,9 +677,9 @@ public: class EditorPropertyNodePath : public EditorProperty { GDCLASS(EditorPropertyNodePath, EditorProperty); - Button *assign; - Button *clear; - SceneTreeDialog *scene_tree; + Button *assign = nullptr; + Button *clear = nullptr; + SceneTreeDialog *scene_tree = nullptr; NodePath base_hint; bool use_path_from_scene_root = false; @@ -705,7 +705,7 @@ public: class EditorPropertyRID : public EditorProperty { GDCLASS(EditorPropertyRID, EditorProperty); - Label *label; + Label *label = nullptr; public: virtual void update_property() override; diff --git a/editor/editor_properties_array_dict.h b/editor/editor_properties_array_dict.h index 3d9fe90b20..070353c538 100644 --- a/editor/editor_properties_array_dict.h +++ b/editor/editor_properties_array_dict.h @@ -80,7 +80,7 @@ public: class EditorPropertyArray : public EditorProperty { GDCLASS(EditorPropertyArray, EditorProperty); - PopupMenu *change_type; + PopupMenu *change_type = nullptr; bool updating = false; bool dropping = false; @@ -88,12 +88,12 @@ class EditorPropertyArray : public EditorProperty { int page_length = 20; int page_index = 0; int changing_type_index; - Button *edit; - VBoxContainer *vbox; - VBoxContainer *property_vbox; - EditorSpinSlider *size_slider; - Button *button_add_item; - EditorPaginator *paginator; + Button *edit = nullptr; + VBoxContainer *vbox = nullptr; + VBoxContainer *property_vbox = nullptr; + EditorSpinSlider *size_slider = nullptr; + Button *button_add_item = nullptr; + EditorPaginator *paginator = nullptr; Variant::Type array_type; Variant::Type subtype; PropertyHint subtype_hint; @@ -138,19 +138,19 @@ public: class EditorPropertyDictionary : public EditorProperty { GDCLASS(EditorPropertyDictionary, EditorProperty); - PopupMenu *change_type; + PopupMenu *change_type = nullptr; bool updating = false; Ref<EditorPropertyDictionaryObject> object; int page_length = 20; int page_index = 0; int changing_type_index; - Button *edit; - VBoxContainer *vbox; - VBoxContainer *property_vbox; - EditorSpinSlider *size_slider; - Button *button_add_item; - EditorPaginator *paginator; + Button *edit = nullptr; + VBoxContainer *vbox = nullptr; + VBoxContainer *property_vbox = nullptr; + EditorSpinSlider *size_slider = nullptr; + Button *button_add_item = nullptr; + EditorPaginator *paginator = nullptr; void _page_changed(int p_page); void _edit_pressed(); @@ -173,19 +173,19 @@ public: class EditorPropertyLocalizableString : public EditorProperty { GDCLASS(EditorPropertyLocalizableString, EditorProperty); - EditorLocaleDialog *locale_select; + EditorLocaleDialog *locale_select = nullptr; 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; + Button *edit = nullptr; + VBoxContainer *vbox = nullptr; + VBoxContainer *property_vbox = nullptr; + EditorSpinSlider *size_slider = nullptr; + Button *button_add_item = nullptr; + EditorPaginator *paginator = nullptr; void _page_changed(int p_page); void _edit_pressed(); diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index af4ae3e576..5b5d451df9 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -117,16 +117,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["bvh"] = "BVH"; capitalize_string_remaps["ca"] = "CA"; capitalize_string_remaps["cd"] = "CD"; + capitalize_string_remaps["commentfocus"] = "Comment Focus"; capitalize_string_remaps["cpu"] = "CPU"; capitalize_string_remaps["csg"] = "CSG"; capitalize_string_remaps["db"] = "dB"; + capitalize_string_remaps["defaultfocus"] = "Default Focus"; + capitalize_string_remaps["defaultframe"] = "Default Frame"; capitalize_string_remaps["dof"] = "DoF"; capitalize_string_remaps["dpi"] = "DPI"; capitalize_string_remaps["dtls"] = "DTLS"; + capitalize_string_remaps["eol"] = "EOL"; + capitalize_string_remaps["erp"] = "ERP"; capitalize_string_remaps["etc"] = "ETC"; capitalize_string_remaps["etc2"] = "ETC2"; capitalize_string_remaps["fbx"] = "FBX"; + capitalize_string_remaps["fbx2gltf"] = "FBX2glTF"; capitalize_string_remaps["fft"] = "FFT"; + capitalize_string_remaps["fg"] = "FG"; capitalize_string_remaps["fov"] = "FOV"; capitalize_string_remaps["fps"] = "FPS"; capitalize_string_remaps["fs"] = "FS"; @@ -140,10 +147,14 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["gles3"] = "GLES3"; capitalize_string_remaps["gpu"] = "GPU"; capitalize_string_remaps["gui"] = "GUI"; + capitalize_string_remaps["guid"] = "GUID"; capitalize_string_remaps["hdr"] = "HDR"; capitalize_string_remaps["hidpi"] = "hiDPI"; capitalize_string_remaps["hipass"] = "High-pass"; + capitalize_string_remaps["hl"] = "HL"; + capitalize_string_remaps["hseparation"] = "H Separation"; capitalize_string_remaps["hsv"] = "HSV"; + capitalize_string_remaps["html"] = "HTML"; capitalize_string_remaps["http"] = "HTTP"; capitalize_string_remaps["id"] = "ID"; capitalize_string_remaps["igd"] = "IGD"; @@ -157,6 +168,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["iphone"] = "iPhone"; capitalize_string_remaps["ipv6"] = "IPv6"; capitalize_string_remaps["ir"] = "IR"; + capitalize_string_remaps["itunes"] = "iTunes"; capitalize_string_remaps["jit"] = "JIT"; capitalize_string_remaps["k1"] = "K1"; capitalize_string_remaps["k2"] = "K2"; @@ -173,6 +185,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["msaa"] = "MSAA"; capitalize_string_remaps["nfc"] = "NFC"; capitalize_string_remaps["normalmap"] = "Normal Map"; + capitalize_string_remaps["ofs"] = "Offset"; capitalize_string_remaps["ok"] = "OK"; capitalize_string_remaps["opengl"] = "OpenGL"; capitalize_string_remaps["opentype"] = "OpenType"; @@ -191,6 +204,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["sdfgi"] = "SDFGI"; capitalize_string_remaps["sdk"] = "SDK"; capitalize_string_remaps["sec"] = "(sec)"; // Unit. + capitalize_string_remaps["selectedframe"] = "Selected Frame"; capitalize_string_remaps["sms"] = "SMS"; capitalize_string_remaps["srgb"] = "sRGB"; capitalize_string_remaps["ssao"] = "SSAO"; @@ -199,21 +213,25 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["ssl"] = "SSL"; capitalize_string_remaps["stderr"] = "stderr"; capitalize_string_remaps["stdout"] = "stdout"; + capitalize_string_remaps["sv"] = "SV"; capitalize_string_remaps["svg"] = "SVG"; capitalize_string_remaps["tcp"] = "TCP"; capitalize_string_remaps["ui"] = "UI"; capitalize_string_remaps["url"] = "URL"; capitalize_string_remaps["urls"] = "URLs"; capitalize_string_remaps["us"] = String::utf8("(µs)"); // Unit. + capitalize_string_remaps["usb"] = "USB"; capitalize_string_remaps["usec"] = String::utf8("(µsec)"); // Unit. capitalize_string_remaps["uuid"] = "UUID"; capitalize_string_remaps["uv"] = "UV"; capitalize_string_remaps["uv1"] = "UV1"; capitalize_string_remaps["uv2"] = "UV2"; capitalize_string_remaps["uwp"] = "UWP"; + capitalize_string_remaps["vadjust"] = "V Adjust"; capitalize_string_remaps["vector2"] = "Vector2"; capitalize_string_remaps["vpn"] = "VPN"; capitalize_string_remaps["vram"] = "VRAM"; + capitalize_string_remaps["vseparation"] = "V Separation"; capitalize_string_remaps["vsync"] = "V-Sync"; capitalize_string_remaps["wap"] = "WAP"; capitalize_string_remaps["webp"] = "WebP"; diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h index a6eff760e7..cd7e507984 100644 --- a/editor/editor_resource_picker.h +++ b/editor/editor_resource_picker.h @@ -52,9 +52,9 @@ class EditorResourcePicker : public HBoxContainer { Vector<String> inheritors_array; - Button *assign_button; - TextureRect *preview_rect; - Button *edit_button; + Button *assign_button = nullptr; + TextureRect *preview_rect = nullptr; + Button *edit_button = nullptr; EditorFileDialog *file_dialog = nullptr; EditorQuickOpen *quick_open = nullptr; diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 4743294967..574acdff1c 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -110,9 +110,10 @@ Error EditorRun::run(const String &p_scene) { } int window_placement = EditorSettings::get_singleton()->get("run/window_placement/rect"); - bool hidpi_proj = ProjectSettings::get_singleton()->get("display/window/dpi/allow_hidpi"); - int display_scale = 1; if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_HIDPI)) { + bool hidpi_proj = ProjectSettings::get_singleton()->get("display/window/dpi/allow_hidpi"); + int display_scale = 1; + if (OS::get_singleton()->is_hidpi_allowed()) { if (hidpi_proj) { display_scale = 1; // Both editor and project runs in hiDPI mode, do not scale. diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h index 28a854aaeb..a2399bd780 100644 --- a/editor/editor_run_script.h +++ b/editor/editor_run_script.h @@ -39,7 +39,7 @@ class EditorNode; class EditorScript : public RefCounted { GDCLASS(EditorScript, RefCounted); - EditorNode *editor; + EditorNode *editor = nullptr; protected: static void _bind_methods(); diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index 7c21e00c03..0ccffa0048 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -42,11 +42,11 @@ class SectionedInspector : public HSplitContainer { ObjectID obj; - Tree *sections; - SectionedInspectorFilter *filter; + Tree *sections = nullptr; + SectionedInspectorFilter *filter = nullptr; Map<String, TreeItem *> section_map; - EditorInspector *inspector; + EditorInspector *inspector = nullptr; LineEdit *search_box = nullptr; String selected_category; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1364f7891e..4ddc66ed98 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -542,7 +542,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/behavior/navigation/move_caret_on_right_click", true); _initial_set("text_editor/behavior/navigation/scroll_past_end_of_file", false); _initial_set("text_editor/behavior/navigation/smooth_scrolling", true); - _initial_set("text_editor/behavior/navigation/v_scroll_speed", 80); + EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/behavior/navigation/v_scroll_speed", 80, "1,10000,1") // Behavior: Indent EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/behavior/indent/type", 0, "Tabs,Spaces") @@ -1365,7 +1365,7 @@ String EditorSettings::get_editor_layouts_config() const { } float EditorSettings::get_auto_display_scale() const { -#ifdef OSX_ENABLED +#if defined(OSX_ENABLED) || defined(ANDROID_ENABLED) return DisplayServer::get_singleton()->screen_get_max_scale(); #else const int screen = DisplayServer::get_singleton()->window_get_current_screen(); @@ -1389,7 +1389,7 @@ float EditorSettings::get_auto_display_scale() const { // Shortcuts -void EditorSettings::add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut) { +void EditorSettings::add_shortcut(const String &p_name, const Ref<Shortcut> &p_shortcut) { shortcuts[p_name] = p_shortcut; } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 4f25259a01..d1b9cabfb7 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -179,7 +179,7 @@ public: String get_editor_layouts_config() const; float get_auto_display_scale() const; - void add_shortcut(const String &p_name, Ref<Shortcut> &p_shortcut); + void add_shortcut(const String &p_name, const Ref<Shortcut> &p_shortcut); bool is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const; Ref<Shortcut> get_shortcut(const String &p_name) const; void get_shortcut_list(List<String> *r_shortcuts); diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 285b909b66..dcbe91bd7f 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -92,7 +92,7 @@ void EditorSettingsDialog::popup_edit_settings() { search_box->grab_focus(); _update_shortcuts(); - set_process_unhandled_input(true); + set_process_shortcut_input(true); // Restore valid window bounds or pop up at default size. Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "editor_settings", Rect2()); @@ -119,7 +119,7 @@ void EditorSettingsDialog::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size())); - set_process_unhandled_input(false); + set_process_shortcut_input(false); } } break; @@ -148,7 +148,7 @@ void EditorSettingsDialog::_notification(int p_what) { } } -void EditorSettingsDialog::unhandled_input(const Ref<InputEvent> &p_event) { +void EditorSettingsDialog::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); const Ref<InputEventKey> k = p_event; diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h index e3139bb07a..9a34eac7ef 100644 --- a/editor/editor_settings_dialog.h +++ b/editor/editor_settings_dialog.h @@ -45,13 +45,13 @@ class EditorSettingsDialog : public AcceptDialog { bool updating = false; - TabContainer *tabs; - Control *tab_general; - Control *tab_shortcuts; + TabContainer *tabs = nullptr; + Control *tab_general = nullptr; + Control *tab_shortcuts = nullptr; - LineEdit *search_box; - LineEdit *shortcut_search_box; - SectionedInspector *inspector; + LineEdit *search_box = nullptr; + LineEdit *shortcut_search_box = nullptr; + SectionedInspector *inspector = nullptr; // Shortcuts enum ShortcutButton { @@ -61,19 +61,19 @@ class EditorSettingsDialog : public AcceptDialog { SHORTCUT_REVERT }; - Tree *shortcuts; + Tree *shortcuts = nullptr; String shortcut_filter; - InputEventConfigurationDialog *shortcut_editor; + InputEventConfigurationDialog *shortcut_editor = nullptr; bool is_editing_action = false; String current_edited_identifier; Array current_events; int current_event_index = -1; - Timer *timer; + Timer *timer = nullptr; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; virtual void cancel_pressed() override; virtual void ok_pressed() override; @@ -82,7 +82,7 @@ class EditorSettingsDialog : public AcceptDialog { void _settings_property_edited(const String &p_name); void _settings_save(); - virtual void unhandled_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; void _notification(int p_what); void _update_icons(); @@ -110,10 +110,10 @@ class EditorSettingsDialog : public AcceptDialog { static void _undo_redo_callback(void *p_self, const String &p_name); - Label *restart_label; - TextureRect *restart_icon; - PanelContainer *restart_container; - Button *restart_close_button; + Label *restart_label = nullptr; + TextureRect *restart_icon = nullptr; + PanelContainer *restart_container = nullptr; + Button *restart_close_button = nullptr; void _editor_restart_request(); void _editor_restart(); diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 405c3bfc22..fc9f6b8722 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -44,7 +44,7 @@ class EditorSpinSlider : public Range { bool hover_updown = false; bool mouse_hover = false; - TextureRect *grabber; + TextureRect *grabber = nullptr; int grabber_range; bool mouse_over_spin = false; diff --git a/editor/editor_toaster.h b/editor/editor_toaster.h index 059245ce66..791a146a8d 100644 --- a/editor/editor_toaster.h +++ b/editor/editor_toaster.h @@ -61,11 +61,11 @@ private: Ref<StyleBoxFlat> warning_panel_style_progress; Ref<StyleBoxFlat> error_panel_style_progress; - Button *main_button; - PanelContainer *disable_notifications_panel; - Button *disable_notifications_button; + Button *main_button = nullptr; + PanelContainer *disable_notifications_panel = nullptr; + Button *disable_notifications_button = nullptr; - VBoxContainer *vbox_container; + VBoxContainer *vbox_container = nullptr; const int max_temporary_count = 5; struct Toast { Severity severity = SEVERITY_INFO; diff --git a/editor/editor_zoom_widget.h b/editor/editor_zoom_widget.h index bf8358ff1a..4690a57a2b 100644 --- a/editor/editor_zoom_widget.h +++ b/editor/editor_zoom_widget.h @@ -37,9 +37,9 @@ class EditorZoomWidget : public HBoxContainer { GDCLASS(EditorZoomWidget, HBoxContainer); - Button *zoom_minus; - Button *zoom_reset; - Button *zoom_plus; + Button *zoom_minus = nullptr; + Button *zoom_reset = nullptr; + Button *zoom_plus = nullptr; float zoom = 1.0; void _update_zoom_label(); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 7320f957c9..f93c2df13d 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -395,6 +395,9 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } String file = String::utf8(fname); if (file.ends_with("version.txt")) { @@ -404,6 +407,9 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ // Read. unzOpenCurrentFile(pkg); ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + if (ret != UNZ_OK) { + break; + } unzCloseCurrentFile(pkg); String data_str; @@ -455,7 +461,10 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ // Get filename. unz_file_info info; char fname[16384]; - unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } String file_path(String::utf8(fname).simplify_path()); @@ -471,7 +480,10 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_ // Read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptrw(), data.size()); + ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + if (ret != UNZ_OK) { + break; + } unzCloseCurrentFile(pkg); String base_dir = file_path.get_base_dir().trim_suffix("/"); @@ -697,6 +709,9 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ unz_file_info info; char fpath[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } String path = String::utf8(fpath); String base_dir = path.get_base_dir(); diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h index cf7585635d..61df212f1f 100644 --- a/editor/export_template_manager.h +++ b/editor/export_template_manager.h @@ -51,42 +51,42 @@ class ExportTemplateManager : public AcceptDialog { bool is_downloading_templates = false; float update_countdown = 0; - Label *current_value; - Label *current_missing_label; - Label *current_installed_label; + Label *current_value = nullptr; + Label *current_missing_label = nullptr; + Label *current_installed_label = nullptr; - HBoxContainer *current_installed_hb; - LineEdit *current_installed_path; - Button *current_open_button; - Button *current_uninstall_button; + HBoxContainer *current_installed_hb = nullptr; + LineEdit *current_installed_path = nullptr; + Button *current_open_button = nullptr; + Button *current_uninstall_button = nullptr; - VBoxContainer *install_options_vb; - OptionButton *mirrors_list; + VBoxContainer *install_options_vb = nullptr; + OptionButton *mirrors_list = nullptr; enum MirrorAction { VISIT_WEB_MIRROR, COPY_MIRROR_URL, }; - MenuButton *mirror_options_button; - HBoxContainer *download_progress_hb; - ProgressBar *download_progress_bar; - Label *download_progress_label; - HTTPRequest *download_templates; - Button *install_file_button; - HTTPRequest *request_mirrors; + MenuButton *mirror_options_button = nullptr; + HBoxContainer *download_progress_hb = nullptr; + ProgressBar *download_progress_bar = nullptr; + Label *download_progress_label = nullptr; + HTTPRequest *download_templates = nullptr; + Button *install_file_button = nullptr; + HTTPRequest *request_mirrors = nullptr; enum TemplatesAction { OPEN_TEMPLATE_FOLDER, UNINSTALL_TEMPLATE, }; - Tree *installed_table; + Tree *installed_table = nullptr; - ConfirmationDialog *uninstall_confirm; + ConfirmationDialog *uninstall_confirm = nullptr; String uninstall_version; - FileDialog *install_file_dialog; - AcceptDialog *hide_dialog_accept; + FileDialog *install_file_dialog = nullptr; + AcceptDialog *hide_dialog_accept = nullptr; void _update_template_status(); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index df0af69359..30dc9180e3 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -53,7 +53,7 @@ void EditorFileServer::_close_client(ClientData *cd) { } void EditorFileServer::_subthread_start(void *s) { - ClientData *cd = (ClientData *)s; + ClientData *cd = static_cast<ClientData *>(s); cd->connection->set_no_delay(true); uint8_t buf4[8]; @@ -259,7 +259,7 @@ void EditorFileServer::_subthread_start(void *s) { } void EditorFileServer::_thread_start(void *s) { - EditorFileServer *self = (EditorFileServer *)s; + EditorFileServer *self = static_cast<EditorFileServer *>(s); while (!self->quit) { if (self->cmd == CMD_ACTIVATE) { self->server->listen(self->port); diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index 7807e72800..a1bb7ecf4e 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -47,7 +47,7 @@ class EditorFileServer : public Object { }; struct ClientData { - Thread *thread; + Thread *thread = nullptr; Ref<StreamPeerTCP> connection; Map<int, FileAccess *> files; EditorFileServer *efs = nullptr; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index ee7ed77957..bbbdd85a5a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -228,10 +228,11 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); bool fav_changed = false; for (int i = favorite_paths.size() - 1; i >= 0; i--) { - if (!da->dir_exists(favorite_paths[i])) { - favorite_paths.remove_at(i); - fav_changed = true; + if (da->dir_exists(favorite_paths[i]) || da->file_exists(favorite_paths[i])) { + continue; } + favorite_paths.remove_at(i); + fav_changed = true; } if (fav_changed) { EditorSettings::get_singleton()->set_favorites(favorite_paths); @@ -1427,18 +1428,18 @@ void FileSystemDock::_make_dir_confirm() { directory = directory.get_base_dir(); } - if (EditorFileSystem::get_singleton()->get_filesystem_path(directory + dir_name)) { - EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists.")); - return; - } - print_verbose("Making folder " + dir_name + " in " + directory); DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); Error err = da->change_dir(directory); - if (err == OK) { - err = da->make_dir(dir_name); + ERR_FAIL_COND_MSG(err != OK, "Cannot open directory '" + directory + "'."); + + if (da->dir_exists(dir_name)) { + EditorNode::get_singleton()->show_warning(TTR("Could not create folder. File with that name already exists.")); + return; } + err = da->make_dir(dir_name); + if (err == OK) { print_verbose("FileSystem: calling rescan."); _rescan(); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 92dac374ec..15fade2d95 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -102,57 +102,57 @@ private: FileSortOption file_sort = FILE_SORT_NAME; - VBoxContainer *scanning_vb; - ProgressBar *scanning_progress; - VSplitContainer *split_box; - VBoxContainer *file_list_vb; + VBoxContainer *scanning_vb = nullptr; + ProgressBar *scanning_progress = nullptr; + VSplitContainer *split_box = nullptr; + VBoxContainer *file_list_vb = nullptr; Set<String> favorites; - Button *button_toggle_display_mode; - Button *button_reload; - Button *button_file_list_display_mode; - Button *button_hist_next; - Button *button_hist_prev; - LineEdit *current_path; + Button *button_toggle_display_mode = nullptr; + Button *button_reload = nullptr; + Button *button_file_list_display_mode = nullptr; + Button *button_hist_next = nullptr; + Button *button_hist_prev = nullptr; + LineEdit *current_path = nullptr; - HBoxContainer *toolbar2_hbc; - LineEdit *tree_search_box; - MenuButton *tree_button_sort; + HBoxContainer *toolbar2_hbc = nullptr; + LineEdit *tree_search_box = nullptr; + MenuButton *tree_button_sort = nullptr; - LineEdit *file_list_search_box; - MenuButton *file_list_button_sort; + LineEdit *file_list_search_box = nullptr; + MenuButton *file_list_button_sort = nullptr; String searched_string; Vector<String> uncollapsed_paths_before_search; - TextureRect *search_icon; - HBoxContainer *path_hb; + TextureRect *search_icon = nullptr; + HBoxContainer *path_hb = nullptr; FileListDisplayMode file_list_display_mode; DisplayMode display_mode; DisplayMode old_display_mode; - PopupMenu *file_list_popup; - PopupMenu *tree_popup; - - DependencyEditor *deps_editor; - DependencyEditorOwners *owners_editor; - DependencyRemoveDialog *remove_dialog; - - EditorDirDialog *move_dialog; - ConfirmationDialog *rename_dialog; - LineEdit *rename_dialog_text; - ConfirmationDialog *duplicate_dialog; - LineEdit *duplicate_dialog_text; - ConfirmationDialog *make_dir_dialog; - LineEdit *make_dir_dialog_text; - ConfirmationDialog *make_scene_dialog; - LineEdit *make_scene_dialog_text; - ConfirmationDialog *overwrite_dialog; - ScriptCreateDialog *make_script_dialog; - ShaderCreateDialog *make_shader_dialog; - CreateDialog *new_resource_dialog; + PopupMenu *file_list_popup = nullptr; + PopupMenu *tree_popup = nullptr; + + DependencyEditor *deps_editor = nullptr; + DependencyEditorOwners *owners_editor = nullptr; + DependencyRemoveDialog *remove_dialog = nullptr; + + EditorDirDialog *move_dialog = nullptr; + ConfirmationDialog *rename_dialog = nullptr; + LineEdit *rename_dialog_text = nullptr; + ConfirmationDialog *duplicate_dialog = nullptr; + LineEdit *duplicate_dialog_text = nullptr; + ConfirmationDialog *make_dir_dialog = nullptr; + LineEdit *make_dir_dialog_text = nullptr; + ConfirmationDialog *make_scene_dialog = nullptr; + LineEdit *make_scene_dialog_text = nullptr; + ConfirmationDialog *overwrite_dialog = nullptr; + ScriptCreateDialog *make_script_dialog = nullptr; + ShaderCreateDialog *make_shader_dialog = nullptr; + CreateDialog *new_resource_dialog = nullptr; bool always_show_folders = false; @@ -181,8 +181,8 @@ private: bool updating_tree = false; int tree_update_id; - Tree *tree; - ItemList *files; + Tree *tree = nullptr; + ItemList *files = nullptr; bool import_dock_needs_update = false; bool holding_branch = false; diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp index 1ce363c651..0dfaaaa1f4 100644 --- a/editor/find_in_files.cpp +++ b/editor/find_in_files.cpp @@ -449,7 +449,7 @@ Set<String> FindInFilesDialog::get_filter() const { // Could check the _filters_preferences but it might not have been generated yet. Set<String> filters; for (int i = 0; i < _filters_container->get_child_count(); ++i) { - CheckBox *cb = (CheckBox *)_filters_container->get_child(i); + CheckBox *cb = static_cast<CheckBox *>(_filters_container->get_child(i)); if (cb->is_pressed()) { filters.insert(cb->get_text()); } @@ -489,7 +489,7 @@ void FindInFilesDialog::_on_folder_button_pressed() { void FindInFilesDialog::custom_action(const String &p_action) { for (int i = 0; i < _filters_container->get_child_count(); ++i) { - CheckBox *cb = (CheckBox *)_filters_container->get_child(i); + CheckBox *cb = static_cast<CheckBox *>(_filters_container->get_child(i)); _filters_preferences[cb->get_text()] = cb->is_pressed(); } diff --git a/editor/find_in_files.h b/editor/find_in_files.h index cf14f3d5c3..9def190b5b 100644 --- a/editor/find_in_files.h +++ b/editor/find_in_files.h @@ -132,18 +132,18 @@ private: void _on_replace_text_submitted(String text); FindInFilesMode _mode; - LineEdit *_search_text_line_edit; - - Label *_replace_label; - LineEdit *_replace_text_line_edit; - - LineEdit *_folder_line_edit; - CheckBox *_match_case_checkbox; - CheckBox *_whole_words_checkbox; - Button *_find_button; - Button *_replace_button; - FileDialog *_folder_dialog; - HBoxContainer *_filters_container; + LineEdit *_search_text_line_edit = nullptr; + + Label *_replace_label = nullptr; + LineEdit *_replace_text_line_edit = nullptr; + + LineEdit *_folder_line_edit = nullptr; + CheckBox *_match_case_checkbox = nullptr; + CheckBox *_whole_words_checkbox = nullptr; + Button *_find_button = nullptr; + Button *_replace_button = nullptr; + FileDialog *_folder_dialog = nullptr; + HBoxContainer *_filters_container = nullptr; HashMap<String, bool> _filters_preferences; }; @@ -201,20 +201,20 @@ private: void set_progress_visible(bool visible); void clear(); - FindInFiles *_finder; - Label *_search_text_label; - Tree *_results_display; - Label *_status_label; - Button *_refresh_button; - Button *_cancel_button; - ProgressBar *_progress_bar; + FindInFiles *_finder = nullptr; + Label *_search_text_label = nullptr; + Tree *_results_display = nullptr; + Label *_status_label = nullptr; + Button *_refresh_button = nullptr; + Button *_cancel_button = nullptr; + ProgressBar *_progress_bar = nullptr; Map<String, TreeItem *> _file_items; Map<TreeItem *, Result> _result_items; bool _with_replace = false; - HBoxContainer *_replace_container; - LineEdit *_replace_line_edit; - Button *_replace_all_button; + HBoxContainer *_replace_container = nullptr; + LineEdit *_replace_line_edit = nullptr; + Button *_replace_all_button = nullptr; }; #endif // FIND_IN_FILES_H diff --git a/editor/groups_editor.h b/editor/groups_editor.h index aa70ac5bc4..b6a6204013 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -43,32 +43,32 @@ class GroupDialog : public AcceptDialog { GDCLASS(GroupDialog, AcceptDialog); - ConfirmationDialog *error; + ConfirmationDialog *error = nullptr; - SceneTree *scene_tree; - TreeItem *groups_root; + SceneTree *scene_tree = nullptr; + TreeItem *groups_root = nullptr; - LineEdit *add_group_text; - Button *add_group_button; + LineEdit *add_group_text = nullptr; + Button *add_group_button = nullptr; - Tree *groups; + Tree *groups = nullptr; - Tree *nodes_to_add; - TreeItem *add_node_root; - LineEdit *add_filter; + Tree *nodes_to_add = nullptr; + TreeItem *add_node_root = nullptr; + LineEdit *add_filter = nullptr; - Tree *nodes_to_remove; - TreeItem *remove_node_root; - LineEdit *remove_filter; + Tree *nodes_to_remove = nullptr; + TreeItem *remove_node_root = nullptr; + LineEdit *remove_filter = nullptr; - Label *group_empty; + Label *group_empty = nullptr; - Button *add_button; - Button *remove_button; + Button *add_button = nullptr; + Button *remove_button = nullptr; String selected_group; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void _group_selected(); @@ -111,15 +111,15 @@ public: class GroupsEditor : public VBoxContainer { GDCLASS(GroupsEditor, VBoxContainer); - Node *node; + Node *node = nullptr; - GroupDialog *group_dialog; + GroupDialog *group_dialog = nullptr; - LineEdit *group_name; - Button *add; - Tree *tree; + LineEdit *group_name = nullptr; + Button *add = nullptr; + Tree *tree = nullptr; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void update_tree(); void _add_group(const String &p_group = ""); diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h index 7b2a9184a4..c1e868403f 100644 --- a/editor/import/dynamic_font_import_settings.h +++ b/editor/import/dynamic_font_import_settings.h @@ -66,7 +66,7 @@ class DynamicFontImportSettings : public ConfirmationDialog { List<ResourceImporter::ImportOption> options_variations; List<ResourceImporter::ImportOption> options_general; - EditorLocaleDialog *locale_select; + EditorLocaleDialog *locale_select = nullptr; Vector<String> script_codes; // Root layout diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h index b51f342729..3cf708740b 100644 --- a/editor/import/scene_import_settings.h +++ b/editor/import/scene_import_settings.h @@ -62,26 +62,26 @@ class SceneImportSettings : public ConfirmationDialog { Node *scene = nullptr; - HSplitContainer *tree_split; - HSplitContainer *property_split; - TabContainer *data_mode; - Tree *scene_tree; - Tree *mesh_tree; - Tree *material_tree; + HSplitContainer *tree_split = nullptr; + HSplitContainer *property_split = nullptr; + TabContainer *data_mode = nullptr; + Tree *scene_tree = nullptr; + Tree *mesh_tree = nullptr; + Tree *material_tree = nullptr; - EditorInspector *inspector; + EditorInspector *inspector = nullptr; - SubViewport *base_viewport; + SubViewport *base_viewport = nullptr; - Camera3D *camera; + Camera3D *camera = nullptr; bool first_aabb = false; AABB contents_aabb; - DirectionalLight3D *light; + DirectionalLight3D *light = nullptr; Ref<ArrayMesh> selection_mesh; - MeshInstance3D *node_selected; + MeshInstance3D *node_selected = nullptr; - MeshInstance3D *mesh_preview; + MeshInstance3D *mesh_preview = nullptr; Ref<SphereMesh> material_preview; Ref<StandardMaterial3D> collider_mat; @@ -95,9 +95,9 @@ class SceneImportSettings : public ConfirmationDialog { struct MaterialData { bool has_import_id; Ref<Material> material; - TreeItem *scene_node; - TreeItem *mesh_node; - TreeItem *material_node; + TreeItem *scene_node = nullptr; + TreeItem *mesh_node = nullptr; + TreeItem *material_node = nullptr; float cam_rot_x = -Math_PI / 4; float cam_rot_y = -Math_PI / 4; @@ -110,8 +110,8 @@ class SceneImportSettings : public ConfirmationDialog { struct MeshData { bool has_import_id; Ref<Mesh> mesh; - TreeItem *scene_node; - TreeItem *mesh_node; + TreeItem *scene_node = nullptr; + TreeItem *mesh_node = nullptr; float cam_rot_x = -Math_PI / 4; float cam_rot_y = -Math_PI / 4; @@ -122,14 +122,14 @@ class SceneImportSettings : public ConfirmationDialog { struct AnimationData { Ref<Animation> animation; - TreeItem *scene_node; + TreeItem *scene_node = nullptr; Map<StringName, Variant> settings; }; Map<String, AnimationData> animation_map; struct NodeData { - Node *node; - TreeItem *scene_node; + Node *node = nullptr; + TreeItem *scene_node = nullptr; Map<StringName, Variant> settings; }; Map<String, NodeData> node_map; @@ -158,20 +158,20 @@ class SceneImportSettings : public ConfirmationDialog { Map<StringName, Variant> defaults; - SceneImportSettingsData *scene_import_settings_data; + SceneImportSettingsData *scene_import_settings_data = nullptr; void _re_import(); String base_path; - MenuButton *action_menu; + MenuButton *action_menu = nullptr; - ConfirmationDialog *external_paths; - Tree *external_path_tree; - EditorFileDialog *save_path; - OptionButton *external_extension_type; + ConfirmationDialog *external_paths = nullptr; + Tree *external_path_tree = nullptr; + EditorFileDialog *save_path = nullptr; + OptionButton *external_extension_type = nullptr; - EditorFileDialog *item_save_path; + EditorFileDialog *item_save_path = nullptr; void _menu_callback(int p_id); void _save_dir_callback(const String &p_path); diff --git a/editor/import_defaults_editor.h b/editor/import_defaults_editor.h index ed94fe6156..f0433f6065 100644 --- a/editor/import_defaults_editor.h +++ b/editor/import_defaults_editor.h @@ -41,13 +41,13 @@ class EditorInspector; class ImportDefaultsEditor : public VBoxContainer { GDCLASS(ImportDefaultsEditor, VBoxContainer) - OptionButton *importers; - Button *save_defaults; - Button *reset_defaults; + OptionButton *importers = nullptr; + Button *save_defaults = nullptr; + Button *reset_defaults = nullptr; - EditorInspector *inspector; + EditorInspector *inspector = nullptr; - ImportDefaultsEditorSettings *settings; + ImportDefaultsEditorSettings *settings = nullptr; void _update_importer(); void _importer_selected(int p_index); diff --git a/editor/import_dock.h b/editor/import_dock.h index c5cdc4ac40..f522b0bced 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -45,25 +45,25 @@ class ImportDockParameters; class ImportDock : public VBoxContainer { GDCLASS(ImportDock, VBoxContainer); - Label *imported; - OptionButton *import_as; - MenuButton *preset; - EditorInspector *import_opts; + Label *imported = nullptr; + OptionButton *import_as = nullptr; + MenuButton *preset = nullptr; + EditorInspector *import_opts = nullptr; List<PropertyInfo> properties; Map<StringName, Variant> property_values; - ConfirmationDialog *reimport_confirm; - Label *label_warning; - Button *import; + ConfirmationDialog *reimport_confirm = nullptr; + Label *label_warning = nullptr; + Button *import = nullptr; - Control *advanced_spacer; - Button *advanced; + Control *advanced_spacer = nullptr; + Button *advanced = nullptr; - ImportDockParameters *params; + ImportDockParameters *params = nullptr; - VBoxContainer *content; - Label *select_a_resource; + VBoxContainer *content = nullptr; + Label *select_a_resource = nullptr; void _preset_selected(int p_idx); void _importer_selected(int i_idx); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 821e4dde11..f0fe48f4fc 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -250,7 +250,7 @@ void InspectorDock::_resource_file_selected(String p_file) { } void InspectorDock::_save_resource(bool save_as) { - ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); + ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -265,7 +265,7 @@ void InspectorDock::_save_resource(bool save_as) { } void InspectorDock::_unref_resource() { - ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); + ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -276,7 +276,7 @@ void InspectorDock::_unref_resource() { } void InspectorDock::_copy_resource() { - ObjectID current = EditorNode::get_singleton()->get_editor_history()->get_current(); + ObjectID current = EditorNode::get_singleton()->get_editor_selection_history()->get_current(); Object *current_obj = current.is_valid() ? ObjectDB::get_instance(current) : nullptr; ERR_FAIL_COND(!Object::cast_to<Resource>(current_obj)); @@ -300,7 +300,7 @@ void InspectorDock::_prepare_resource_extra_popup() { } void InspectorDock::_prepare_history() { - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); int history_to = MAX(0, editor_history->get_history_len() - 25); @@ -352,7 +352,7 @@ void InspectorDock::_prepare_history() { void InspectorDock::_select_history(int p_idx) { //push it to the top, it is not correct, but it's more useful - ObjectID id = EditorNode::get_singleton()->get_editor_history()->get_history_obj(p_idx); + ObjectID id = EditorNode::get_singleton()->get_editor_selection_history()->get_history_obj(p_idx); Object *obj = ObjectDB::get_instance(id); if (!obj) { return; @@ -380,13 +380,13 @@ void InspectorDock::_resource_selected(const RES &p_res, const String &p_propert } void InspectorDock::_edit_forward() { - if (EditorNode::get_singleton()->get_editor_history()->next()) { + if (EditorNode::get_singleton()->get_editor_selection_history()->next()) { EditorNode::get_singleton()->edit_current(); } } void InspectorDock::_edit_back() { - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); if ((current && editor_history->previous()) || editor_history->get_path_size() == 1) { EditorNode::get_singleton()->edit_current(); } @@ -476,7 +476,7 @@ void InspectorDock::clear() { } void InspectorDock::update(Object *p_object) { - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); backward_button->set_disabled(editor_history->is_at_beginning()); forward_button->set_disabled(editor_history->is_at_end()); @@ -635,7 +635,7 @@ InspectorDock::InspectorDock(EditorData &p_editor_data) { HBoxContainer *subresource_hb = memnew(HBoxContainer); add_child(subresource_hb); - editor_path = memnew(EditorPath(EditorNode::get_singleton()->get_editor_history())); + editor_path = memnew(EditorPath(EditorNode::get_singleton()->get_editor_selection_history())); editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); subresource_hb->add_child(editor_path); diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 7e653c4750..86733c992d 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -70,34 +70,34 @@ class InspectorDock : public VBoxContainer { OBJECT_METHOD_BASE = 500 }; - EditorData *editor_data; + EditorData *editor_data = nullptr; - EditorInspector *inspector; + EditorInspector *inspector = nullptr; - Object *current; + Object *current = nullptr; - Button *backward_button; - Button *forward_button; + Button *backward_button = nullptr; + Button *forward_button = nullptr; - EditorFileDialog *load_resource_dialog; - CreateDialog *new_resource_dialog; - Button *resource_new_button; - Button *resource_load_button; - MenuButton *resource_save_button; - MenuButton *resource_extra_button; - MenuButton *history_menu; - LineEdit *search; + EditorFileDialog *load_resource_dialog = nullptr; + CreateDialog *new_resource_dialog = nullptr; + Button *resource_new_button = nullptr; + Button *resource_load_button = nullptr; + MenuButton *resource_save_button = nullptr; + MenuButton *resource_extra_button = nullptr; + MenuButton *history_menu = nullptr; + LineEdit *search = nullptr; - Button *open_docs_button; - MenuButton *object_menu; - EditorPath *editor_path; + Button *open_docs_button = nullptr; + MenuButton *object_menu = nullptr; + EditorPath *editor_path = nullptr; - Button *warning; - AcceptDialog *warning_dialog; + Button *warning = nullptr; + AcceptDialog *warning_dialog = nullptr; int current_option = -1; - ConfirmationDialog *unique_resources_confirmation; - Tree *unique_resources_list_tree; + ConfirmationDialog *unique_resources_confirmation = nullptr; + Tree *unique_resources_list_tree = nullptr; EditorPropertyNameProcessor::Style property_name_style; diff --git a/editor/localization_editor.h b/editor/localization_editor.h index 3424ba7c55..966ef0f36e 100644 --- a/editor/localization_editor.h +++ b/editor/localization_editor.h @@ -40,22 +40,22 @@ class EditorFileDialog; class LocalizationEditor : public VBoxContainer { GDCLASS(LocalizationEditor, VBoxContainer); - Tree *translation_list; + Tree *translation_list = nullptr; - EditorLocaleDialog *locale_select; - EditorFileDialog *translation_file_open; + EditorLocaleDialog *locale_select = nullptr; + EditorFileDialog *translation_file_open = nullptr; - Button *translation_res_option_add_button; - EditorFileDialog *translation_res_file_open_dialog; - EditorFileDialog *translation_res_option_file_open_dialog; - Tree *translation_remap; - Tree *translation_remap_options; + Button *translation_res_option_add_button = nullptr; + EditorFileDialog *translation_res_file_open_dialog = nullptr; + EditorFileDialog *translation_res_option_file_open_dialog = nullptr; + Tree *translation_remap = nullptr; + Tree *translation_remap_options = nullptr; - Tree *translation_pot_list; - EditorFileDialog *pot_file_open_dialog; - EditorFileDialog *pot_generate_dialog; + Tree *translation_pot_list = nullptr; + EditorFileDialog *pot_file_open_dialog = nullptr; + EditorFileDialog *pot_generate_dialog = nullptr; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; bool updating_translations = false; String localization_changed; diff --git a/editor/node_dock.h b/editor/node_dock.h index 4c814ab65f..35af1a8121 100644 --- a/editor/node_dock.h +++ b/editor/node_dock.h @@ -38,15 +38,15 @@ class ConnectionsDock; class NodeDock : public VBoxContainer { GDCLASS(NodeDock, VBoxContainer); - Button *connections_button; - Button *groups_button; + Button *connections_button = nullptr; + Button *groups_button = nullptr; - ConnectionsDock *connections; - GroupsEditor *groups; + ConnectionsDock *connections = nullptr; + GroupsEditor *groups = nullptr; - HBoxContainer *mode_hb; + HBoxContainer *mode_hb = nullptr; - Label *select_a_node; + Label *select_a_node = nullptr; private: static NodeDock *singleton; diff --git a/editor/plugin_config_dialog.h b/editor/plugin_config_dialog.h index 0dc2e84a98..76fec636f3 100644 --- a/editor/plugin_config_dialog.h +++ b/editor/plugin_config_dialog.h @@ -41,18 +41,18 @@ class PluginConfigDialog : public ConfirmationDialog { GDCLASS(PluginConfigDialog, ConfirmationDialog); - LineEdit *name_edit; - LineEdit *subfolder_edit; - TextEdit *desc_edit; - LineEdit *author_edit; - LineEdit *version_edit; - OptionButton *script_option_edit; - LineEdit *script_edit; - CheckBox *active_edit; + LineEdit *name_edit = nullptr; + LineEdit *subfolder_edit = nullptr; + TextEdit *desc_edit = nullptr; + LineEdit *author_edit = nullptr; + LineEdit *version_edit = nullptr; + OptionButton *script_option_edit = nullptr; + LineEdit *script_edit = nullptr; + CheckBox *active_edit = nullptr; - TextureRect *name_validation; - TextureRect *subfolder_validation; - TextureRect *script_validation; + TextureRect *name_validation = nullptr; + TextureRect *subfolder_validation = nullptr; + TextureRect *script_validation = nullptr; bool _edit_mode; diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h index c0e7c1be2e..b0483cbb62 100644 --- a/editor/plugins/abstract_polygon_2d_editor.h +++ b/editor/plugins/abstract_polygon_2d_editor.h @@ -40,9 +40,9 @@ class CanvasItemEditor; class AbstractPolygon2DEditor : public HBoxContainer { GDCLASS(AbstractPolygon2DEditor, HBoxContainer); - Button *button_create; - Button *button_edit; - Button *button_delete; + Button *button_create = nullptr; + Button *button_edit = nullptr; + Button *button_delete = nullptr; struct Vertex { Vertex() {} @@ -85,9 +85,9 @@ class AbstractPolygon2DEditor : public HBoxContainer { bool _polygon_editing_enabled; - CanvasItemEditor *canvas_item_editor; - Panel *panel; - ConfirmationDialog *create_resource; + CanvasItemEditor *canvas_item_editor = nullptr; + Panel *panel = nullptr; + ConfirmationDialog *create_resource = nullptr; protected: enum { @@ -99,7 +99,7 @@ protected: int mode; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; virtual void _menu_option(int p_option); void _wip_changed(); @@ -149,7 +149,7 @@ public: class AbstractPolygon2DEditorPlugin : public EditorPlugin { GDCLASS(AbstractPolygon2DEditorPlugin, EditorPlugin); - AbstractPolygon2DEditor *polygon_editor; + AbstractPolygon2DEditor *polygon_editor = nullptr; String klass; public: diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h index 54cded6048..816c2555ca 100644 --- a/editor/plugins/animation_blend_space_1d_editor.h +++ b/editor/plugins/animation_blend_space_1d_editor.h @@ -45,36 +45,36 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { Ref<AnimationNodeBlendSpace1D> blend_space; - HBoxContainer *goto_parent_hb; - Button *goto_parent; - - PanelContainer *panel; - Button *tool_blend; - Button *tool_select; - Button *tool_create; - VSeparator *tool_erase_sep; - Button *tool_erase; - Button *snap; - SpinBox *snap_value; - - LineEdit *label_value; - SpinBox *max_value; - SpinBox *min_value; - - HBoxContainer *edit_hb; - SpinBox *edit_value; - Button *open_editor; + HBoxContainer *goto_parent_hb = nullptr; + Button *goto_parent = nullptr; + + PanelContainer *panel = nullptr; + Button *tool_blend = nullptr; + Button *tool_select = nullptr; + Button *tool_create = nullptr; + VSeparator *tool_erase_sep = nullptr; + Button *tool_erase = nullptr; + Button *snap = nullptr; + SpinBox *snap_value = nullptr; + + LineEdit *label_value = nullptr; + SpinBox *max_value = nullptr; + SpinBox *min_value = nullptr; + + HBoxContainer *edit_hb = nullptr; + SpinBox *edit_value = nullptr; + Button *open_editor = nullptr; int selected_point; - Control *blend_space_draw; + Control *blend_space_draw = nullptr; - PanelContainer *error_panel; - Label *error_label; + PanelContainer *error_panel = nullptr; + Label *error_label = nullptr; bool updating; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; static AnimationNodeBlendSpace1DEditor *singleton; @@ -87,8 +87,8 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { void _labels_changed(String); void _snap_toggled(); - PopupMenu *menu; - PopupMenu *animations_menu; + PopupMenu *menu = nullptr; + PopupMenu *animations_menu = nullptr; Vector<String> animations_to_add; float add_point_pos; Vector<real_t> points; @@ -108,7 +108,7 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin { void _edit_point_pos(double); void _open_editor(); - EditorFileDialog *open_file; + EditorFileDialog *open_file = nullptr; Ref<AnimationNode> file_loaded; void _file_opened(const String &p_file); diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index 933d2bd96d..db54e84254 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -45,43 +45,43 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { Ref<AnimationNodeBlendSpace2D> blend_space; - PanelContainer *panel; - Button *tool_blend; - Button *tool_select; - Button *tool_create; - Button *tool_triangle; - VSeparator *tool_erase_sep; - Button *tool_erase; - Button *snap; - SpinBox *snap_x; - SpinBox *snap_y; - OptionButton *interpolation; - - Button *auto_triangles; - - LineEdit *label_x; - LineEdit *label_y; - SpinBox *max_x_value; - SpinBox *min_x_value; - SpinBox *max_y_value; - SpinBox *min_y_value; - - HBoxContainer *edit_hb; - SpinBox *edit_x; - SpinBox *edit_y; - Button *open_editor; + PanelContainer *panel = nullptr; + Button *tool_blend = nullptr; + Button *tool_select = nullptr; + Button *tool_create = nullptr; + Button *tool_triangle = nullptr; + VSeparator *tool_erase_sep = nullptr; + Button *tool_erase = nullptr; + Button *snap = nullptr; + SpinBox *snap_x = nullptr; + SpinBox *snap_y = nullptr; + OptionButton *interpolation = nullptr; + + Button *auto_triangles = nullptr; + + LineEdit *label_x = nullptr; + LineEdit *label_y = nullptr; + SpinBox *max_x_value = nullptr; + SpinBox *min_x_value = nullptr; + SpinBox *max_y_value = nullptr; + SpinBox *min_y_value = nullptr; + + HBoxContainer *edit_hb = nullptr; + SpinBox *edit_x = nullptr; + SpinBox *edit_y = nullptr; + Button *open_editor = nullptr; int selected_point; int selected_triangle; - Control *blend_space_draw; + Control *blend_space_draw = nullptr; - PanelContainer *error_panel; - Label *error_label; + PanelContainer *error_panel = nullptr; + Label *error_label = nullptr; bool updating; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; static AnimationNodeBlendSpace2DEditor *singleton; @@ -94,8 +94,8 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { void _labels_changed(String); void _snap_toggled(); - PopupMenu *menu; - PopupMenu *animations_menu; + PopupMenu *menu = nullptr; + PopupMenu *animations_menu = nullptr; Vector<String> animations_to_add; Vector2 add_point_pos; Vector<Vector2> points; @@ -123,7 +123,7 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { StringName get_blend_position_path() const; - EditorFileDialog *open_file; + EditorFileDialog *open_file = nullptr; Ref<AnimationNode> file_loaded; void _file_opened(const String &p_file); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h index c111f9245e..cacf8379f9 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.h +++ b/editor/plugins/animation_blend_tree_editor_plugin.h @@ -47,19 +47,19 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { GDCLASS(AnimationNodeBlendTreeEditor, AnimationTreeNodeEditorPlugin); Ref<AnimationNodeBlendTree> blend_tree; - GraphEdit *graph; - MenuButton *add_node; + GraphEdit *graph = nullptr; + MenuButton *add_node = nullptr; Vector2 position_from_popup_menu; bool use_position_from_popup_menu; - PanelContainer *error_panel; - Label *error_label; + PanelContainer *error_panel = nullptr; + Label *error_label = nullptr; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; - AcceptDialog *filter_dialog; - Tree *filters; - CheckBox *filter_enabled; + AcceptDialog *filter_dialog = nullptr; + Tree *filters = nullptr; + CheckBox *filter_enabled = nullptr; Map<StringName, ProgressBar *> animations; Vector<EditorProperty *> visible_properties; @@ -122,7 +122,7 @@ class AnimationNodeBlendTreeEditor : public AnimationTreeNodeEditorPlugin { void _update_editor_settings(); void _update_theme(); - EditorFileDialog *open_file; + EditorFileDialog *open_file = nullptr; Ref<AnimationNode> file_loaded; void _file_opened(const String &p_file); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ab8e2ca54a..af7c092d03 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1267,7 +1267,7 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) { } } -void AnimationPlayerEditor::unhandled_key_input(const Ref<InputEvent> &p_ev) { +void AnimationPlayerEditor::shortcut_input(const Ref<InputEvent> &p_ev) { ERR_FAIL_COND(p_ev.is_null()); Ref<InputEventKey> k = p_ev; @@ -1750,7 +1750,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug last_active = false; timeline_position = 0; - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); add_child(track_editor); track_editor->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index 5bb32e25e6..4f6a9c534f 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -46,8 +46,8 @@ class AnimationPlayerEditorPlugin; class AnimationPlayerEditor : public VBoxContainer { GDCLASS(AnimationPlayerEditor, VBoxContainer); - AnimationPlayerEditorPlugin *plugin; - AnimationPlayer *player; + AnimationPlayerEditorPlugin *plugin = nullptr; + AnimationPlayer *player = nullptr; enum { TOOL_NEW_ANIM, @@ -88,31 +88,31 @@ class AnimationPlayerEditor : public VBoxContainer { RESOURCE_SAVE }; - OptionButton *animation; - Button *stop; - Button *play; - Button *play_from; - Button *play_bw; - Button *play_bw_from; - Button *autoplay; - - MenuButton *tool_anim; - Button *onion_toggle; - MenuButton *onion_skinning; - Button *pin; - SpinBox *frame; - LineEdit *scale; - LineEdit *name; - Label *name_title; - UndoRedo *undo_redo; + OptionButton *animation = nullptr; + Button *stop = nullptr; + Button *play = nullptr; + Button *play_from = nullptr; + Button *play_bw = nullptr; + Button *play_bw_from = nullptr; + Button *autoplay = nullptr; + + MenuButton *tool_anim = nullptr; + Button *onion_toggle = nullptr; + MenuButton *onion_skinning = nullptr; + Button *pin = nullptr; + SpinBox *frame = nullptr; + LineEdit *scale = nullptr; + LineEdit *name = nullptr; + Label *name_title = nullptr; + UndoRedo *undo_redo = nullptr; Ref<Texture2D> autoplay_icon; Ref<Texture2D> reset_icon; Ref<ImageTexture> autoplay_reset_icon; bool last_active; float timeline_position; - EditorFileDialog *file; - ConfirmationDialog *delete_dialog; + EditorFileDialog *file = nullptr; + ConfirmationDialog *delete_dialog = nullptr; struct BlendEditor { AcceptDialog *dialog = nullptr; @@ -121,14 +121,14 @@ class AnimationPlayerEditor : public VBoxContainer { } blend_editor; - ConfirmationDialog *name_dialog; - ConfirmationDialog *error_dialog; + ConfirmationDialog *name_dialog = nullptr; + ConfirmationDialog *error_dialog = nullptr; int name_dialog_op = TOOL_NEW_ANIM; bool updating; bool updating_blends; - AnimationTrackEditor *track_editor; + AnimationTrackEditor *track_editor = nullptr; static AnimationPlayerEditor *singleton; // Onion skinning. @@ -204,7 +204,7 @@ class AnimationPlayerEditor : public VBoxContainer { void _animation_key_editor_seek(float p_pos, bool p_drag, bool p_timeline_only = false); void _animation_key_editor_anim_len_changed(float p_len); - virtual void unhandled_key_input(const Ref<InputEvent> &p_ev) override; + virtual void shortcut_input(const Ref<InputEvent> &p_ev) override; void _animation_tool_menu(int p_option); void _onion_skinning_menu(int p_option); @@ -250,7 +250,7 @@ public: class AnimationPlayerEditorPlugin : public EditorPlugin { GDCLASS(AnimationPlayerEditorPlugin, EditorPlugin); - AnimationPlayerEditor *anim_editor; + AnimationPlayerEditor *anim_editor = nullptr; protected: void _notification(int p_what); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index bd0c1afd19..f0dabed652 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -499,7 +499,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co accent.a *= 0.6; } - Ref<Texture2D> icons[6] = { + const Ref<Texture2D> icons[6] = { get_theme_icon(SNAME("TransitionImmediateBig"), SNAME("EditorIcons")), get_theme_icon(SNAME("TransitionSyncBig"), SNAME("EditorIcons")), get_theme_icon(SNAME("TransitionEndBig"), SNAME("EditorIcons")), diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h index 03991d00f9..bf3f7e93cf 100644 --- a/editor/plugins/animation_state_machine_editor.h +++ b/editor/plugins/animation_state_machine_editor.h @@ -47,36 +47,36 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { Ref<AnimationNodeStateMachine> state_machine; - Button *tool_select; - Button *tool_create; - Button *tool_connect; - Popup *name_edit_popup; - LineEdit *name_edit; + Button *tool_select = nullptr; + Button *tool_create = nullptr; + Button *tool_connect = nullptr; + Popup *name_edit_popup = nullptr; + LineEdit *name_edit = nullptr; - HBoxContainer *tool_erase_hb; - Button *tool_erase; - Button *tool_autoplay; - Button *tool_end; + HBoxContainer *tool_erase_hb = nullptr; + Button *tool_erase = nullptr; + Button *tool_autoplay = nullptr; + Button *tool_end = nullptr; - OptionButton *transition_mode; - OptionButton *play_mode; + OptionButton *transition_mode = nullptr; + OptionButton *play_mode = nullptr; - PanelContainer *panel; + PanelContainer *panel = nullptr; StringName selected_node; - HScrollBar *h_scroll; - VScrollBar *v_scroll; + HScrollBar *h_scroll = nullptr; + VScrollBar *v_scroll = nullptr; - Control *state_machine_draw; - Control *state_machine_play_pos; + Control *state_machine_draw = nullptr; + Control *state_machine_play_pos = nullptr; - PanelContainer *error_panel; - Label *error_label; + PanelContainer *error_panel = nullptr; + Label *error_label = nullptr; bool updating; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; static AnimationNodeStateMachineEditor *singleton; @@ -87,8 +87,8 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { void _update_graph(); - PopupMenu *menu; - PopupMenu *animations_menu; + PopupMenu *menu = nullptr; + PopupMenu *animations_menu = nullptr; Vector<String> animations_to_add; Vector2 add_node_pos; @@ -166,7 +166,7 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin { float error_time; String error_text; - EditorFileDialog *open_file; + EditorFileDialog *open_file = nullptr; Ref<AnimationNode> file_loaded; void _file_opened(const String &p_file); diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index 5442584a40..ab4ef5a001 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -52,11 +52,11 @@ public: class AnimationTreeEditor : public VBoxContainer { GDCLASS(AnimationTreeEditor, VBoxContainer); - ScrollContainer *path_edit; - HBoxContainer *path_hb; + ScrollContainer *path_edit = nullptr; + HBoxContainer *path_hb = nullptr; - AnimationTree *tree; - MarginContainer *editor_base; + AnimationTree *tree = nullptr; + MarginContainer *editor_base = nullptr; Vector<String> button_path; Vector<String> edited_path; @@ -96,8 +96,8 @@ public: class AnimationTreeEditorPlugin : public EditorPlugin { GDCLASS(AnimationTreeEditorPlugin, EditorPlugin); - AnimationTreeEditor *anim_tree_editor; - Button *button; + AnimationTreeEditor *anim_tree_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "AnimationTree"; } diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 20bd145299..405ece1471 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -640,7 +640,7 @@ void EditorAssetLibrary::_update_repository_options() { } } -void EditorAssetLibrary::unhandled_key_input(const Ref<InputEvent> &p_event) { +void EditorAssetLibrary::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); const Ref<InputEventKey> key = p_event; @@ -1541,7 +1541,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { description = nullptr; set_process(true); - set_process_unhandled_key_input(true); // Global shortcuts since there is no main element to be focused. + set_process_shortcut_input(true); // Global shortcuts since there is no main element to be focused. downloads_scroll = memnew(ScrollContainer); downloads_scroll->set_vertical_scroll_mode(ScrollContainer::SCROLL_MODE_DISABLED); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 493ffc4033..96830c31fd 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -53,12 +53,12 @@ class EditorAssetLibraryItem : public PanelContainer { GDCLASS(EditorAssetLibraryItem, PanelContainer); - TextureButton *icon; - LinkButton *title; - LinkButton *category; - LinkButton *author; + TextureButton *icon = nullptr; + LinkButton *title = nullptr; + LinkButton *category = nullptr; + LinkButton *author = nullptr; TextureRect *stars[5]; - Label *price; + Label *price = nullptr; int asset_id; int category_id; @@ -83,11 +83,11 @@ public: class EditorAssetLibraryItemDescription : public ConfirmationDialog { GDCLASS(EditorAssetLibraryItemDescription, ConfirmationDialog); - EditorAssetLibraryItem *item; - RichTextLabel *description; - ScrollContainer *previews; - HBoxContainer *preview_hb; - PanelContainer *previews_bg; + EditorAssetLibraryItem *item = nullptr; + RichTextLabel *description = nullptr; + ScrollContainer *previews = nullptr; + HBoxContainer *preview_hb = nullptr; + PanelContainer *previews_bg = nullptr; struct Preview { int id = 0; @@ -98,7 +98,7 @@ class EditorAssetLibraryItemDescription : public ConfirmationDialog { }; Vector<Preview> preview_images; - TextureRect *preview; + TextureRect *preview = nullptr; void set_image(int p_type, int p_index, const Ref<Texture2D> &p_image); @@ -130,19 +130,19 @@ public: class EditorAssetLibraryItemDownload : public MarginContainer { GDCLASS(EditorAssetLibraryItemDownload, MarginContainer); - PanelContainer *panel; - TextureRect *icon; - Label *title; - ProgressBar *progress; - Button *install_button; - Button *retry_button; - TextureButton *dismiss_button; + PanelContainer *panel = nullptr; + TextureRect *icon = nullptr; + Label *title = nullptr; + ProgressBar *progress = nullptr; + Button *install_button = nullptr; + Button *retry_button = nullptr; + TextureButton *dismiss_button = nullptr; - AcceptDialog *download_error; - HTTPRequest *download; + AcceptDialog *download_error = nullptr; + HTTPRequest *download = nullptr; String host; String sha256; - Label *status; + Label *status = nullptr; int prev_status; @@ -150,7 +150,7 @@ class EditorAssetLibraryItemDownload : public MarginContainer { bool external_install; - EditorAssetInstaller *asset_installer; + EditorAssetInstaller *asset_installer = nullptr; void _close(); void _make_request(); @@ -176,35 +176,35 @@ class EditorAssetLibrary : public PanelContainer { String host; - EditorFileDialog *asset_open; - EditorAssetInstaller *asset_installer; + EditorFileDialog *asset_open = nullptr; + EditorAssetInstaller *asset_installer = nullptr; void _asset_open(); void _asset_file_selected(const String &p_file); void _update_repository_options(); - PanelContainer *library_scroll_bg; - ScrollContainer *library_scroll; - VBoxContainer *library_vb; - Label *library_loading; - Label *library_error; - LineEdit *filter; - Timer *filter_debounce_timer; - OptionButton *categories; - OptionButton *repository; - OptionButton *sort; - HBoxContainer *error_hb; - TextureRect *error_tr; - Label *error_label; - MenuButton *support; - - HBoxContainer *contents; - - HBoxContainer *asset_top_page; - GridContainer *asset_items; - HBoxContainer *asset_bottom_page; - - HTTPRequest *request; + PanelContainer *library_scroll_bg = nullptr; + ScrollContainer *library_scroll = nullptr; + VBoxContainer *library_vb = nullptr; + Label *library_loading = nullptr; + Label *library_error = nullptr; + LineEdit *filter = nullptr; + Timer *filter_debounce_timer = nullptr; + OptionButton *categories = nullptr; + OptionButton *repository = nullptr; + OptionButton *sort = nullptr; + HBoxContainer *error_hb = nullptr; + TextureRect *error_tr = nullptr; + Label *error_label = nullptr; + MenuButton *support = nullptr; + + HBoxContainer *contents = nullptr; + + HBoxContainer *asset_top_page = nullptr; + GridContainer *asset_items = nullptr; + HBoxContainer *asset_bottom_page = nullptr; + + HTTPRequest *request = nullptr; bool templates_only; bool initial_loading; @@ -260,7 +260,7 @@ class EditorAssetLibrary : public PanelContainer { HBoxContainer *_make_pages(int p_page, int p_page_count, int p_page_len, int p_total_items, int p_current_items); // - EditorAssetLibraryItemDescription *description; + EditorAssetLibraryItemDescription *description = nullptr; // enum RequestType { @@ -273,8 +273,8 @@ class EditorAssetLibrary : public PanelContainer { RequestType requesting; Dictionary category_map; - ScrollContainer *downloads_scroll; - HBoxContainer *downloads_hb; + ScrollContainer *downloads_scroll = nullptr; + HBoxContainer *downloads_hb = nullptr; void _install_asset(); @@ -304,7 +304,7 @@ class EditorAssetLibrary : public PanelContainer { protected: static void _bind_methods(); void _notification(int p_what); - virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; public: void disable_community_support(); @@ -315,7 +315,7 @@ public: class AssetLibraryEditorPlugin : public EditorPlugin { GDCLASS(AssetLibraryEditorPlugin, EditorPlugin); - EditorAssetLibrary *addon_library; + EditorAssetLibrary *addon_library = nullptr; public: virtual String get_name() const override { return "AssetLib"; } diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h index 2478210430..0d927bddd5 100644 --- a/editor/plugins/audio_stream_editor_plugin.h +++ b/editor/plugins/audio_stream_editor_plugin.h @@ -75,7 +75,7 @@ public: class AudioStreamEditorPlugin : public EditorPlugin { GDCLASS(AudioStreamEditorPlugin, EditorPlugin); - AudioStreamEditor *audio_editor; + AudioStreamEditor *audio_editor = nullptr; public: virtual String get_name() const override { return "Audio"; } diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h index c1f71d3b1b..a8164f9b85 100644 --- a/editor/plugins/camera_3d_editor_plugin.h +++ b/editor/plugins/camera_3d_editor_plugin.h @@ -37,9 +37,9 @@ class Camera3DEditor : public Control { GDCLASS(Camera3DEditor, Control); - Panel *panel; - Button *preview; - Node *node; + Panel *panel = nullptr; + Button *preview = nullptr; + Node *node = nullptr; void _pressed(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 764f467192..a90e151adb 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -475,7 +475,7 @@ real_t CanvasItemEditor::snap_angle(real_t p_target, real_t p_start) const { } } -void CanvasItemEditor::unhandled_key_input(const Ref<InputEvent> &p_ev) { +void CanvasItemEditor::shortcut_input(const Ref<InputEvent> &p_ev) { ERR_FAIL_COND(p_ev.is_null()); Ref<InputEventKey> k = p_ev; @@ -860,7 +860,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite } void CanvasItemEditor::_snap_changed() { - ((SnapDialog *)snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); + static_cast<SnapDialog *>(snap_dialog)->get_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); grid_step_multiplier = 0; viewport->update(); } @@ -1504,7 +1504,7 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) { } } - DragType dragger[] = { + const DragType dragger[] = { DRAG_ANCHOR_TOP_LEFT, DRAG_ANCHOR_TOP_RIGHT, DRAG_ANCHOR_BOTTOM_RIGHT, @@ -1635,14 +1635,14 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) { Rect2 rect = canvas_item->_edit_get_rect(); Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); - Vector2 endpoints[4] = { + const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), xform.xform(rect.position + rect.size), xform.xform(rect.position + Vector2(0, rect.size.y)) }; - DragType dragger[] = { + const DragType dragger[] = { DRAG_TOP_LEFT, DRAG_TOP, DRAG_TOP_RIGHT, @@ -2318,7 +2318,6 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { Vector<_SelectResult> selection = Vector<_SelectResult>(); // Retrieve the canvas items - selection = Vector<_SelectResult>(); _get_canvas_items_at_pos(click, selection); if (!selection.is_empty()) { canvas_item = selection[0].item; @@ -2572,7 +2571,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { void CanvasItemEditor::_update_cursor() { // Compute an eventual rotation of the cursor - CursorShape rotation_array[4] = { CURSOR_HSIZE, CURSOR_BDIAGSIZE, CURSOR_VSIZE, CURSOR_FDIAGSIZE }; + const CursorShape rotation_array[4] = { CURSOR_HSIZE, CURSOR_BDIAGSIZE, CURSOR_VSIZE, CURSOR_FDIAGSIZE }; int rotation_array_index = 0; List<CanvasItem *> selection = _get_edited_canvas_items(); @@ -3150,7 +3149,6 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { if (dragged_anchor >= 0) { // Draw the 4 lines when dragged - bool anchor_snapped; Color color_snapped = Color(0.64, 0.93, 0.67, 0.5); Vector2 corners_pos[4]; @@ -3164,7 +3162,7 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) { real_t anchor_val = (i >= 2) ? ANCHOR_END - anchors_values[i] : anchors_values[i]; line_starts[i] = corners_pos[i].lerp(corners_pos[(i + 1) % 4], anchor_val); line_ends[i] = corners_pos[(i + 3) % 4].lerp(corners_pos[(i + 2) % 4], anchor_val); - anchor_snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; + bool anchor_snapped = anchors_values[i] == 0.0 || anchors_values[i] == 0.5 || anchors_values[i] == 1.0; viewport->draw_line(line_starts[i], line_ends[i], anchor_snapped ? color_snapped : color_base, (i == dragged_anchor || (i + 3) % 4 == dragged_anchor) ? 2 : 1); } @@ -3328,7 +3326,7 @@ void CanvasItemEditor::_draw_selection() { // Draw the selected items position / surrounding boxes if (canvas_item->_edit_use_rect()) { Rect2 rect = canvas_item->_edit_get_rect(); - Vector2 endpoints[4] = { + const Vector2 endpoints[4] = { xform.xform(rect.position), xform.xform(rect.position + Vector2(rect.size.x, 0)), xform.xform(rect.position + rect.size), @@ -4103,7 +4101,7 @@ void CanvasItemEditor::_button_tool_select(int p_index) { } void CanvasItemEditor::_insert_animation_keys(bool p_location, bool p_rotation, bool p_scale, bool p_on_existing) { - Map<Node *, Object *> &selection = editor_selection->get_selection(); + const Map<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); @@ -4269,7 +4267,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { snap_config_menu->get_popup()->set_item_checked(idx, snap_pixel); } break; case SNAP_CONFIGURE: { - ((SnapDialog *)snap_dialog)->set_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); + static_cast<SnapDialog *>(snap_dialog)->set_fields(grid_offset, grid_step, primary_grid_steps, snap_rotation_offset, snap_rotation_step, snap_scale_step); snap_dialog->popup_centered(Size2(220, 160) * EDSCALE); } break; case SKELETON_SHOW_BONES: { @@ -4414,7 +4412,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { case ANIM_COPY_POSE: { pose_clipboard.clear(); - Map<Node *, Object *> &selection = editor_selection->get_selection(); + const Map<Node *, Object *> &selection = editor_selection->get_selection(); for (const KeyValue<Node *, Object *> &E : selection) { CanvasItem *canvas_item = Object::cast_to<CanvasItem>(E.key); @@ -5322,7 +5320,7 @@ CanvasItemEditor::CanvasItemEditor() { ED_SHORTCUT("canvas_item_editor/zoom_800_percent", TTR("Zoom to 800%"), Key::KEY_4); ED_SHORTCUT("canvas_item_editor/zoom_1600_percent", TTR("Zoom to 1600%"), Key::KEY_5); - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); // Update the menus' checkboxes call_deferred(SNAME("set_state"), get_state()); @@ -5735,7 +5733,6 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p if (root_node) { target_node = root_node; } else { - drop_pos = p_point; target_node = nullptr; } } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 1a9d49a4a8..26852ea8ed 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -183,16 +183,16 @@ private: bool selection_menu_additive_selection; Tool tool = TOOL_SELECT; - Control *viewport; - Control *viewport_scrollable; + Control *viewport = nullptr; + Control *viewport_scrollable = nullptr; - HScrollBar *h_scroll; - VScrollBar *v_scroll; - HBoxContainer *hb; + HScrollBar *h_scroll = nullptr; + VScrollBar *v_scroll = nullptr; + HBoxContainer *hb = nullptr; // Used for secondary menu items which are displayed depending on the currently selected node // (such as MeshInstance's "Mesh" menu). - PanelContainer *context_menu_container; - HBoxContainer *hbc_context_menu; + PanelContainer *context_menu_container = nullptr; + HBoxContainer *hbc_context_menu = nullptr; Transform2D transform; GridVisibility grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING; @@ -293,47 +293,47 @@ private: }; List<PoseClipboard> pose_clipboard; - Button *select_button; + Button *select_button = nullptr; - Button *move_button; - Button *scale_button; - Button *rotate_button; + Button *move_button = nullptr; + Button *scale_button = nullptr; + Button *rotate_button = nullptr; - Button *list_select_button; - Button *pivot_button; - Button *pan_button; + Button *list_select_button = nullptr; + Button *pivot_button = nullptr; + Button *pan_button = nullptr; - Button *ruler_button; + Button *ruler_button = nullptr; - Button *smart_snap_button; - Button *grid_snap_button; - MenuButton *snap_config_menu; - PopupMenu *smartsnap_config_popup; + Button *smart_snap_button = nullptr; + Button *grid_snap_button = nullptr; + MenuButton *snap_config_menu = nullptr; + PopupMenu *smartsnap_config_popup = nullptr; - Button *lock_button; - Button *unlock_button; + Button *lock_button = nullptr; + Button *unlock_button = nullptr; - Button *group_button; - Button *ungroup_button; + Button *group_button = nullptr; + Button *ungroup_button = nullptr; - MenuButton *skeleton_menu; - Button *override_camera_button; - MenuButton *view_menu; - PopupMenu *grid_menu; - HBoxContainer *animation_hb; - MenuButton *animation_menu; + MenuButton *skeleton_menu = nullptr; + Button *override_camera_button = nullptr; + MenuButton *view_menu = nullptr; + PopupMenu *grid_menu = nullptr; + HBoxContainer *animation_hb = nullptr; + MenuButton *animation_menu = nullptr; - Button *key_loc_button; - Button *key_rot_button; - Button *key_scale_button; - Button *key_insert_button; - Button *key_auto_insert_button; + Button *key_loc_button = nullptr; + Button *key_rot_button = nullptr; + Button *key_scale_button = nullptr; + Button *key_insert_button = nullptr; + Button *key_auto_insert_button = nullptr; - PopupMenu *selection_menu; - PopupMenu *add_node_menu; + PopupMenu *selection_menu = nullptr; + PopupMenu *add_node_menu = nullptr; - Control *top_ruler; - Control *left_ruler; + Control *top_ruler = nullptr; + Control *left_ruler = nullptr; Point2 drag_start_origin; DragType drag_type = DRAG_NONE; @@ -374,9 +374,9 @@ private: void _find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D()); bool _select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append); - ConfirmationDialog *snap_dialog; + ConfirmationDialog *snap_dialog = nullptr; - CanvasItem *ref_item; + CanvasItem *ref_item = nullptr; void _save_canvas_item_state(List<CanvasItem *> p_canvas_items, bool save_bones = false); void _restore_canvas_item_state(List<CanvasItem *> p_canvas_items, bool restore_bones = false); @@ -400,7 +400,7 @@ private: void _prepare_grid_menu(); void _on_grid_menu_id_pressed(int p_id); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; List<CanvasItem *> _get_edited_canvas_items(bool retrieve_locked = false, bool remove_canvas_item_if_parent_in_selection = true); Rect2 _get_encompassing_rect_from_list(List<CanvasItem *> p_list); @@ -413,7 +413,7 @@ private: void _keying_changed(); - virtual void unhandled_key_input(const Ref<InputEvent> &p_ev) override; + virtual void shortcut_input(const Ref<InputEvent> &p_ev) override; void _draw_text_at_position(Point2 p_position, String p_string, Side p_side); void _draw_margin_at_position(int p_value, Point2 p_position, Side p_side); @@ -476,8 +476,8 @@ private: const SnapTarget p_snap_target, List<const CanvasItem *> p_exceptions, const Node *p_current); - VBoxContainer *controls_vb; - EditorZoomWidget *zoom_widget; + VBoxContainer *controls_vb = nullptr; + EditorZoomWidget *zoom_widget = nullptr; void _update_zoom(real_t p_zoom); void _shortcut_zoom_set(real_t p_zoom); void _zoom_on_position(real_t p_zoom, Point2 p_position = Point2()); @@ -488,9 +488,9 @@ private: void _update_override_camera_button(bool p_game_running); - HSplitContainer *left_panel_split; - HSplitContainer *right_panel_split; - VSplitContainer *bottom_split; + HSplitContainer *left_panel_split = nullptr; + HSplitContainer *right_panel_split = nullptr; + VSplitContainer *bottom_split = nullptr; void _update_context_menu_stylebox(); @@ -555,7 +555,7 @@ public: void focus_selection(); - EditorSelection *editor_selection; + EditorSelection *editor_selection = nullptr; CanvasItemEditor(); }; @@ -563,7 +563,7 @@ public: class CanvasItemEditorPlugin : public EditorPlugin { GDCLASS(CanvasItemEditorPlugin, EditorPlugin); - CanvasItemEditor *canvas_item_editor; + CanvasItemEditor *canvas_item_editor = nullptr; public: virtual String get_name() const override { return "2D"; } @@ -589,18 +589,18 @@ class CanvasItemEditorViewport : public Control { Vector<String> texture_node_types; Vector<String> selected_files; - Node *target_node; + Node *target_node = nullptr; Point2 drop_pos; - EditorData *editor_data; - CanvasItemEditor *canvas_item_editor; - Control *preview_node; - AcceptDialog *accept; - AcceptDialog *selector; - Label *selector_label; - Label *label; - Label *label_desc; - VBoxContainer *btn_group; + EditorData *editor_data = nullptr; + CanvasItemEditor *canvas_item_editor = nullptr; + Control *preview_node = nullptr; + AcceptDialog *accept = nullptr; + AcceptDialog *selector = nullptr; + Label *selector_label = nullptr; + Label *label = nullptr; + Label *label_desc = nullptr; + VBoxContainer *btn_group = nullptr; Ref<ButtonGroup> button_group; void _on_mouse_exit(); diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 5d769e7987..f018376e4b 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -38,10 +38,7 @@ void CollisionPolygon2DEditor::_set_node(Node *p_polygon) { node = Object::cast_to<CollisionPolygon2D>(p_polygon); } -CollisionPolygon2DEditor::CollisionPolygon2DEditor() : - AbstractPolygon2DEditor() { - node = nullptr; -} +CollisionPolygon2DEditor::CollisionPolygon2DEditor() {} CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin() : AbstractPolygon2DEditorPlugin(memnew(CollisionPolygon2DEditor), "CollisionPolygon2D") { diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h index bdd4228b3b..0225d5d620 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.h +++ b/editor/plugins/collision_polygon_2d_editor_plugin.h @@ -37,7 +37,7 @@ class CollisionPolygon2DEditor : public AbstractPolygon2DEditor { GDCLASS(CollisionPolygon2DEditor, AbstractPolygon2DEditor); - CollisionPolygon2D *node; + CollisionPolygon2D *node = nullptr; protected: virtual Node2D *_get_node() const override; diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 033ea3db93..da9e9f339f 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -61,9 +61,9 @@ class CollisionShape2DEditor : public Control { Point2(1, -1), }; - UndoRedo *undo_redo; - CanvasItemEditor *canvas_item_editor; - CollisionShape2D *node; + UndoRedo *undo_redo = nullptr; + CanvasItemEditor *canvas_item_editor = nullptr; + CollisionShape2D *node = nullptr; Vector<Point2> handles; @@ -96,7 +96,7 @@ public: class CollisionShape2DEditorPlugin : public EditorPlugin { GDCLASS(CollisionShape2DEditorPlugin, EditorPlugin); - CollisionShape2DEditor *collision_shape_2d_editor; + CollisionShape2DEditor *collision_shape_2d_editor = nullptr; public: virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); } diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h index 37d218abb9..96451f7dcf 100644 --- a/editor/plugins/control_editor_plugin.h +++ b/editor/plugins/control_editor_plugin.h @@ -70,7 +70,7 @@ public: class EditorPropertyAnchorsPreset : public EditorProperty { GDCLASS(EditorPropertyAnchorsPreset, EditorProperty); - OptionButton *options; + OptionButton *options = nullptr; void _option_selected(int p_which); @@ -94,9 +94,9 @@ class EditorPropertySizeFlags : public EditorProperty { SIZE_FLAGS_PRESET_CUSTOM, }; - OptionButton *flag_presets; - CheckBox *flag_expand; - VBoxContainer *flag_options; + OptionButton *flag_presets = nullptr; + CheckBox *flag_expand = nullptr; + VBoxContainer *flag_options = nullptr; Vector<CheckBox *> flag_checks; bool vertical = false; @@ -128,8 +128,8 @@ public: class ControlEditorToolbar : public HBoxContainer { GDCLASS(ControlEditorToolbar, HBoxContainer); - UndoRedo *undo_redo; - EditorSelection *editor_selection; + UndoRedo *undo_redo = nullptr; + EditorSelection *editor_selection = nullptr; enum MenuOption { ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT, @@ -198,12 +198,12 @@ class ControlEditorToolbar : public HBoxContainer { CONTAINERS_V_PRESET_SHRINK_END, }; - MenuButton *anchor_presets_menu; - PopupMenu *anchors_popup; - MenuButton *container_h_presets_menu; - MenuButton *container_v_presets_menu; + MenuButton *anchor_presets_menu = nullptr; + PopupMenu *anchors_popup = nullptr; + MenuButton *container_h_presets_menu = nullptr; + MenuButton *container_v_presets_menu = nullptr; - Button *anchor_mode_button; + Button *anchor_mode_button = nullptr; bool anchors_mode = false; @@ -239,7 +239,7 @@ public: class ControlEditorPlugin : public EditorPlugin { GDCLASS(ControlEditorPlugin, EditorPlugin); - ControlEditorToolbar *toolbar; + ControlEditorToolbar *toolbar = nullptr; public: virtual String get_name() const override { return "Control"; } diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h index b10ed73e38..cc59bc924f 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.h +++ b/editor/plugins/cpu_particles_2d_editor_plugin.h @@ -55,22 +55,22 @@ class CPUParticles2DEditorPlugin : public EditorPlugin { EMISSION_MODE_BORDER_DIRECTED }; - CPUParticles2D *particles; + CPUParticles2D *particles = nullptr; - EditorFileDialog *file; + EditorFileDialog *file = nullptr; - HBoxContainer *toolbar; - MenuButton *menu; + HBoxContainer *toolbar = nullptr; + MenuButton *menu = nullptr; - SpinBox *epoints; + SpinBox *epoints = nullptr; - ConfirmationDialog *emission_mask; - OptionButton *emission_mask_mode; - CheckBox *emission_colors; + ConfirmationDialog *emission_mask = nullptr; + OptionButton *emission_mask_mode = nullptr; + CheckBox *emission_colors = nullptr; String source_emission_file; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void _file_selected(const String &p_file); void _menu_callback(int p_idx); void _generate_emission_mask(); diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index 0501936574..70f2da4b2d 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -44,7 +44,7 @@ class CPUParticles3DEditor : public GPUParticles3DEditorBase { }; - CPUParticles3D *node; + CPUParticles3D *node = nullptr; void _menu_option(int); @@ -65,7 +65,7 @@ public: class CPUParticles3DEditorPlugin : public EditorPlugin { GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin); - CPUParticles3DEditor *particles_editor; + CPUParticles3DEditor *particles_editor = nullptr; public: virtual String get_name() const override { return "CPUParticles3D"; } diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index 4aba2fffd0..5cf3b16a06 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -99,8 +99,8 @@ private: Transform2D _world_to_view; Ref<Curve> _curve_ref; - PopupMenu *_context_menu; - PopupMenu *_presets_menu; + PopupMenu *_context_menu = nullptr; + PopupMenu *_presets_menu = nullptr; Array _undo_data; bool _has_undo_data; diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h index c024526285..10e1a27933 100644 --- a/editor/plugins/debugger_editor_plugin.h +++ b/editor/plugins/debugger_editor_plugin.h @@ -41,9 +41,9 @@ class DebuggerEditorPlugin : public EditorPlugin { GDCLASS(DebuggerEditorPlugin, EditorPlugin); private: - MenuButton *debug_menu; - EditorFileServer *file_server; - PopupMenu *instances_menu; + MenuButton *debug_menu = nullptr; + EditorFileServer *file_server = nullptr; + PopupMenu *instances_menu = nullptr; enum MenuOptions { RUN_FILE_SERVER, diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index f94ce632e9..75f68617d1 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -56,26 +56,26 @@ class GPUParticles2DEditorPlugin : public EditorPlugin { EMISSION_MODE_BORDER_DIRECTED }; - GPUParticles2D *particles; + GPUParticles2D *particles = nullptr; List<GPUParticles2D *> selected_particles; - EditorFileDialog *file; + EditorFileDialog *file = nullptr; - HBoxContainer *toolbar; - MenuButton *menu; + HBoxContainer *toolbar = nullptr; + MenuButton *menu = nullptr; - SpinBox *epoints; + SpinBox *epoints = nullptr; - ConfirmationDialog *generate_visibility_rect; - SpinBox *generate_seconds; + ConfirmationDialog *generate_visibility_rect = nullptr; + SpinBox *generate_seconds = nullptr; - ConfirmationDialog *emission_mask; - OptionButton *emission_mask_mode; - CheckBox *emission_colors; + ConfirmationDialog *emission_mask = nullptr; + OptionButton *emission_mask_mode = nullptr; + CheckBox *emission_colors = nullptr; String source_emission_file; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void _file_selected(const String &p_file); void _menu_callback(int p_idx); void _generate_visibility_rect(); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index 39aa596ece..190fb9954b 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -41,16 +41,16 @@ class GPUParticles3DEditorBase : public Control { GDCLASS(GPUParticles3DEditorBase, Control); protected: - Node3D *base_node; - Panel *panel; - MenuButton *options; - HBoxContainer *particles_editor_hb; + Node3D *base_node = nullptr; + Panel *panel = nullptr; + MenuButton *options = nullptr; + HBoxContainer *particles_editor_hb = nullptr; - SceneTreeDialog *emission_tree_dialog; + SceneTreeDialog *emission_tree_dialog = nullptr; - ConfirmationDialog *emission_dialog; - SpinBox *emission_amount; - OptionButton *emission_fill; + ConfirmationDialog *emission_dialog = nullptr; + SpinBox *emission_amount = nullptr; + OptionButton *emission_fill = nullptr; Vector<Face3> geometry; @@ -67,9 +67,9 @@ public: class GPUParticles3DEditor : public GPUParticles3DEditorBase { GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase); - ConfirmationDialog *generate_aabb; - SpinBox *generate_seconds; - GPUParticles3D *node; + ConfirmationDialog *generate_aabb = nullptr; + SpinBox *generate_seconds = nullptr; + GPUParticles3D *node = nullptr; enum Menu { MENU_OPTION_GENERATE_AABB, @@ -101,7 +101,7 @@ public: class GPUParticles3DEditorPlugin : public EditorPlugin { GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin); - GPUParticles3DEditor *particles_editor; + GPUParticles3DEditor *particles_editor = nullptr; public: virtual String get_name() const override { return "GPUParticles3D"; } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h index f6e4fd3dec..684279039a 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h @@ -41,12 +41,12 @@ class EditorFileDialog; class GPUParticlesCollisionSDF3DEditorPlugin : public EditorPlugin { GDCLASS(GPUParticlesCollisionSDF3DEditorPlugin, EditorPlugin); - GPUParticlesCollisionSDF3D *col_sdf; + GPUParticlesCollisionSDF3D *col_sdf = nullptr; - HBoxContainer *bake_hb; - Button *bake; + HBoxContainer *bake_hb = nullptr; + Button *bake = nullptr; - EditorFileDialog *probe_file; + EditorFileDialog *probe_file = nullptr; static EditorProgress *tmp_progress; static void bake_func_begin(int p_steps); diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h index 9857ea018d..26bf76fecd 100644 --- a/editor/plugins/gradient_editor_plugin.h +++ b/editor/plugins/gradient_editor_plugin.h @@ -65,9 +65,9 @@ class GradientReverseButton : public BaseButton { class EditorInspectorPluginGradient : public EditorInspectorPlugin { GDCLASS(EditorInspectorPluginGradient, EditorInspectorPlugin); - GradientEditor *editor; - HBoxContainer *gradient_tools_hbox; - GradientReverseButton *reverse_btn; + GradientEditor *editor = nullptr; + HBoxContainer *gradient_tools_hbox = nullptr; + GradientReverseButton *reverse_btn = nullptr; void _reverse_button_pressed(); diff --git a/editor/plugins/input_event_editor_plugin.h b/editor/plugins/input_event_editor_plugin.h index ab948462ab..3c658a86e9 100644 --- a/editor/plugins/input_event_editor_plugin.h +++ b/editor/plugins/input_event_editor_plugin.h @@ -38,11 +38,11 @@ class InputEventConfigContainer : public HBoxContainer { GDCLASS(InputEventConfigContainer, HBoxContainer); - Label *input_event_text; - Button *open_config_button; + Label *input_event_text = nullptr; + Button *open_config_button = nullptr; Ref<InputEvent> input_event; - InputEventConfigurationDialog *config_dialog; + InputEventConfigurationDialog *config_dialog = nullptr; void _config_dialog_confirmed(); void _configure_pressed(); diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index 6a5ead58d0..4fbc8188b9 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -102,10 +102,7 @@ void LightOccluder2DEditor::_create_resource() { _menu_option(MODE_CREATE); } -LightOccluder2DEditor::LightOccluder2DEditor() : - AbstractPolygon2DEditor() { - node = nullptr; -} +LightOccluder2DEditor::LightOccluder2DEditor() {} LightOccluder2DEditorPlugin::LightOccluder2DEditorPlugin() : AbstractPolygon2DEditorPlugin(memnew(LightOccluder2DEditor), "LightOccluder2D") { diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h index 557e8bf292..aeee12b5b6 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.h +++ b/editor/plugins/light_occluder_2d_editor_plugin.h @@ -37,7 +37,7 @@ class LightOccluder2DEditor : public AbstractPolygon2DEditor { GDCLASS(LightOccluder2DEditor, AbstractPolygon2DEditor); - LightOccluder2D *node; + LightOccluder2D *node = nullptr; Ref<OccluderPolygon2D> _ensure_occluder() const; diff --git a/editor/plugins/lightmap_gi_editor_plugin.h b/editor/plugins/lightmap_gi_editor_plugin.h index e658230181..1202efe8fc 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.h +++ b/editor/plugins/lightmap_gi_editor_plugin.h @@ -41,11 +41,11 @@ class EditorFileDialog; class LightmapGIEditorPlugin : public EditorPlugin { GDCLASS(LightmapGIEditorPlugin, EditorPlugin); - LightmapGI *lightmap; + LightmapGI *lightmap = nullptr; - Button *bake; + Button *bake = nullptr; - EditorFileDialog *file_dialog; + EditorFileDialog *file_dialog = nullptr; static EditorProgress *tmp_progress; static bool bake_func_step(float p_progress, const String &p_description, void *, bool p_refresh); static void bake_func_end(uint64_t p_time_started); diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 0f81b17cb3..31053f90b8 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -56,10 +56,7 @@ void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, con undo_redo->add_undo_method(node, "set_points", p_previous); } -Line2DEditor::Line2DEditor() : - AbstractPolygon2DEditor() { - node = nullptr; -} +Line2DEditor::Line2DEditor() {} Line2DEditorPlugin::Line2DEditorPlugin() : AbstractPolygon2DEditorPlugin(memnew(Line2DEditor), "Line2D") { diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h index 307cf11207..0d407b3150 100644 --- a/editor/plugins/line_2d_editor_plugin.h +++ b/editor/plugins/line_2d_editor_plugin.h @@ -37,7 +37,7 @@ class Line2DEditor : public AbstractPolygon2DEditor { GDCLASS(Line2DEditor, AbstractPolygon2DEditor); - Line2D *node; + Line2D *node = nullptr; protected: virtual Node2D *_get_node() const override; diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index daa864cfa1..eb004568d0 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -270,7 +270,7 @@ void EditorInspectorPluginMaterial::_undo_redo_inspector_callback(Object *p_undo Texture2D *texture = Object::cast_to<Texture2D>(p_new_value); if (texture) { if (p_property == "roughness_texture") { - if (base_material->get_texture(StandardMaterial3D::TEXTURE_ROUGHNESS).is_null() && texture) { + if (base_material->get_texture(StandardMaterial3D::TEXTURE_ROUGHNESS).is_null()) { undo_redo->add_do_property(p_edited, "roughness", 1.0); bool valid = false; @@ -280,7 +280,7 @@ void EditorInspectorPluginMaterial::_undo_redo_inspector_callback(Object *p_undo } } } else if (p_property == "metallic_texture") { - if (base_material->get_texture(StandardMaterial3D::TEXTURE_METALLIC).is_null() && texture) { + if (base_material->get_texture(StandardMaterial3D::TEXTURE_METALLIC).is_null()) { undo_redo->add_do_property(p_edited, "metallic", 1.0); bool valid = false; diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 37464c98fe..3554b3c1e9 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -44,17 +44,17 @@ class MeshEditor : public SubViewportContainer { float rot_x; float rot_y; - SubViewport *viewport; - MeshInstance3D *mesh_instance; - Node3D *rotation; - DirectionalLight3D *light1; - DirectionalLight3D *light2; - Camera3D *camera; + SubViewport *viewport = nullptr; + MeshInstance3D *mesh_instance = nullptr; + Node3D *rotation = nullptr; + DirectionalLight3D *light1 = nullptr; + DirectionalLight3D *light2 = nullptr; + Camera3D *camera = nullptr; Ref<Mesh> mesh; - TextureButton *light_1_switch; - TextureButton *light_2_switch; + TextureButton *light_1_switch = nullptr; + TextureButton *light_2_switch = nullptr; void _button_pressed(Node *p_button); bool first_enter; diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp index 8f285cb7f9..d33803213a 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp @@ -75,7 +75,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); StaticBody3D *body = memnew(StaticBody3D); - body->add_child(cshape); + body->add_child(cshape, true); Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner(); @@ -110,7 +110,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) { CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(shape); StaticBody3D *body = memnew(StaticBody3D); - body->add_child(cshape); + body->add_child(cshape, true); Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner(); diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h index 9c59c5fb9f..36d8eacd98 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.h +++ b/editor/plugins/mesh_instance_3d_editor_plugin.h @@ -51,17 +51,17 @@ class MeshInstance3DEditor : public Control { MENU_OPTION_DEBUG_UV2, }; - MeshInstance3D *node; + MeshInstance3D *node = nullptr; - MenuButton *options; + MenuButton *options = nullptr; - ConfirmationDialog *outline_dialog; - SpinBox *outline_size; + ConfirmationDialog *outline_dialog = nullptr; + SpinBox *outline_size = nullptr; - AcceptDialog *err_dialog; + AcceptDialog *err_dialog = nullptr; - AcceptDialog *debug_uv_dialog; - Control *debug_uv; + AcceptDialog *debug_uv_dialog = nullptr; + Control *debug_uv = nullptr; Vector<Vector2> uv_lines; void _menu_option(int p_option); @@ -84,7 +84,7 @@ public: class MeshInstance3DEditorPlugin : public EditorPlugin { GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin); - MeshInstance3DEditor *mesh_editor; + MeshInstance3DEditor *mesh_editor = nullptr; public: virtual String get_name() const override { return "MeshInstance3D"; } diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h index 6bc992869b..85ead35534 100644 --- a/editor/plugins/mesh_library_editor_plugin.h +++ b/editor/plugins/mesh_library_editor_plugin.h @@ -43,10 +43,10 @@ class MeshLibraryEditor : public Control { Ref<MeshLibrary> mesh_library; - MenuButton *menu; - ConfirmationDialog *cd_remove; - ConfirmationDialog *cd_update; - EditorFileDialog *file; + MenuButton *menu = nullptr; + ConfirmationDialog *cd_remove = nullptr; + ConfirmationDialog *cd_update = nullptr; + EditorFileDialog *file = nullptr; bool apply_xforms; int to_erase; @@ -81,7 +81,7 @@ public: class MeshLibraryEditorPlugin : public EditorPlugin { GDCLASS(MeshLibraryEditorPlugin, EditorPlugin); - MeshLibraryEditor *mesh_library_editor; + MeshLibraryEditor *mesh_library_editor = nullptr; public: virtual String get_name() const override { return "MeshLibrary"; } diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h index 846e6d17f3..9f5e85216c 100644 --- a/editor/plugins/multimesh_editor_plugin.h +++ b/editor/plugins/multimesh_editor_plugin.h @@ -43,26 +43,26 @@ class MultiMeshEditor : public Control { friend class MultiMeshEditorPlugin; - AcceptDialog *err_dialog; - MenuButton *options; - MultiMeshInstance3D *_last_pp_node; + AcceptDialog *err_dialog = nullptr; + MenuButton *options = nullptr; + MultiMeshInstance3D *_last_pp_node = nullptr; bool browsing_source; - Panel *panel; - MultiMeshInstance3D *node; + Panel *panel = nullptr; + MultiMeshInstance3D *node = nullptr; - LineEdit *surface_source; - LineEdit *mesh_source; + LineEdit *surface_source = nullptr; + LineEdit *mesh_source = nullptr; - SceneTreeDialog *std; + SceneTreeDialog *std = nullptr; - ConfirmationDialog *populate_dialog; - OptionButton *populate_axis; - HSlider *populate_rotate_random; - HSlider *populate_tilt_random; - SpinBox *populate_scale_random; - SpinBox *populate_scale; - SpinBox *populate_amount; + ConfirmationDialog *populate_dialog = nullptr; + OptionButton *populate_axis = nullptr; + HSlider *populate_rotate_random = nullptr; + HSlider *populate_tilt_random = nullptr; + SpinBox *populate_scale_random = nullptr; + SpinBox *populate_scale = nullptr; + SpinBox *populate_amount = nullptr; enum Menu { MENU_OPTION_POPULATE @@ -85,7 +85,7 @@ public: class MultiMeshEditorPlugin : public EditorPlugin { GDCLASS(MultiMeshEditorPlugin, EditorPlugin); - MultiMeshEditor *multimesh_editor; + MultiMeshEditor *multimesh_editor = nullptr; public: virtual String get_name() const override { return "MultiMesh"; } diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index fe31f254df..17eaf45bb5 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -112,10 +112,7 @@ void NavigationPolygonEditor::_create_resource() { _menu_option(MODE_CREATE); } -NavigationPolygonEditor::NavigationPolygonEditor() : - AbstractPolygon2DEditor() { - node = nullptr; -} +NavigationPolygonEditor::NavigationPolygonEditor() {} NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin() : AbstractPolygon2DEditorPlugin(memnew(NavigationPolygonEditor), "NavigationRegion2D") { diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 16fbb241e9..7550b75fa3 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h @@ -37,7 +37,7 @@ class NavigationPolygonEditor : public AbstractPolygon2DEditor { GDCLASS(NavigationPolygonEditor, AbstractPolygon2DEditor); - NavigationRegion2D *node; + NavigationRegion2D *node = nullptr; Ref<NavigationPolygon> _ensure_navpoly() const; diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index fa55651d26..3b67b898e3 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -70,14 +70,14 @@ class EditorNode3DGizmo : public Node3DGizmo { bool valid; bool hidden; Vector<Instance> instances; - Node3D *spatial_node; + Node3D *spatial_node = nullptr; void _set_spatial_node(Node *p_node) { set_spatial_node(Object::cast_to<Node3D>(p_node)); } protected: static void _bind_methods(); - EditorNode3DGizmoPlugin *gizmo_plugin; + EditorNode3DGizmoPlugin *gizmo_plugin = nullptr; GDVIRTUAL0(_redraw) GDVIRTUAL2RC(String, _get_handle_name, int, bool) @@ -618,7 +618,7 @@ public: class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin); - Timer *update_timer; + Timer *update_timer = nullptr; uint64_t update_idx = 0; void incremental_update_gizmos(); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index eab477adb7..855fc2b2a9 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -369,7 +369,7 @@ Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) co } int Node3DEditorViewport::get_selected_count() const { - Map<Node *, Object *> &selection = editor_selection->get_selection(); + const Map<Node *, Object *> &selection = editor_selection->get_selection(); int count = 0; @@ -2467,7 +2467,7 @@ void Node3DEditorViewport::_notification(int p_what) { _update_camera(delta); - Map<Node *, Object *> &selection = editor_selection->get_selection(); + const Map<Node *, Object *> &selection = editor_selection->get_selection(); bool changed = false; bool exist = false; @@ -6848,7 +6848,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() { } } -void Node3DEditor::unhandled_key_input(const Ref<InputEvent> &p_event) { +void Node3DEditor::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); if (!is_visible_in_tree()) { @@ -7893,7 +7893,7 @@ Node3DEditor::Node3DEditor() { selected = nullptr; - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); add_to_group("_spatial_editor_group"); EDITOR_DEF("editors/3d/manipulator_gizmo_size", 80); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 5c0bfab34e..d5d50c743c 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -190,27 +190,27 @@ private: ViewType view_type; void _menu_option(int p_option); void _set_auto_orthogonal(); - Node3D *preview_node; - AABB *preview_bounds; + Node3D *preview_node = nullptr; + AABB *preview_bounds = nullptr; Vector<String> selected_files; - AcceptDialog *accept; + AcceptDialog *accept = nullptr; - Node *target_node; + Node *target_node = nullptr; Point2 drop_pos; - EditorData *editor_data; - EditorSelection *editor_selection; - UndoRedo *undo_redo; + EditorData *editor_data = nullptr; + EditorSelection *editor_selection = nullptr; + UndoRedo *undo_redo = nullptr; - CheckBox *preview_camera; - SubViewportContainer *subviewport_container; + CheckBox *preview_camera = nullptr; + SubViewportContainer *subviewport_container = nullptr; - MenuButton *view_menu; - PopupMenu *display_submenu; + MenuButton *view_menu = nullptr; + PopupMenu *display_submenu = nullptr; - Control *surface; - SubViewport *viewport; - Camera3D *camera; + Control *surface = nullptr; + SubViewport *viewport = nullptr; + Camera3D *camera = nullptr; bool transforming; bool orthogonal; bool auto_orthogonal; @@ -221,17 +221,17 @@ private: real_t freelook_speed; Vector2 previous_mouse_position; - Label *info_label; - Label *cinema_label; - Label *locked_label; - Label *zoom_limit_label; + Label *info_label = nullptr; + Label *cinema_label = nullptr; + Label *locked_label = nullptr; + Label *zoom_limit_label = nullptr; - VBoxContainer *top_right_vbox; - ViewportRotationControl *rotation_control; - Gradient *frame_time_gradient; - Label *cpu_time_label; - Label *gpu_time_label; - Label *fps_label; + VBoxContainer *top_right_vbox = nullptr; + ViewportRotationControl *rotation_control = nullptr; + Gradient *frame_time_gradient = nullptr; + Label *cpu_time_label = nullptr; + Label *gpu_time_label = nullptr; + Label *fps_label = nullptr; struct _RayResult { Node3D *item = nullptr; @@ -274,7 +274,7 @@ private: bool clicked_wants_append; bool selection_in_progress = false; - PopupMenu *selection_menu; + PopupMenu *selection_menu = nullptr; enum NavigationZoomStyle { NAVIGATION_ZOOM_VERTICAL, @@ -375,9 +375,9 @@ private: void _sinput(const Ref<InputEvent> &p_event); void _update_freelook(real_t delta); - Node3DEditor *spatial_editor; + Node3DEditor *spatial_editor = nullptr; - Camera3D *previewing; + Camera3D *previewing = nullptr; Camera3D *preview = nullptr; bool previewing_cinema; @@ -455,7 +455,7 @@ public: Transform3D original_local; Transform3D last_xform; // last transform bool last_xform_dirty; - Node3D *sp; + Node3D *sp = nullptr; RID sbox_instance; RID sbox_instance_offset; RID sbox_instance_xray; @@ -537,13 +537,13 @@ public: }; private: - EditorSelection *editor_selection; + EditorSelection *editor_selection = nullptr; - Node3DEditorViewportContainer *viewport_base; + Node3DEditorViewportContainer *viewport_base = nullptr; Node3DEditorViewport *viewports[VIEWPORTS_COUNT]; - VSplitContainer *shader_split; - HSplitContainer *left_panel_split; - HSplitContainer *right_panel_split; + VSplitContainer *shader_split = nullptr; + HSplitContainer *left_panel_split = nullptr; + HSplitContainer *right_panel_split = nullptr; ///// @@ -588,7 +588,7 @@ private: Ref<StandardMaterial3D> cursor_material; // Scene drag and drop support - Node3D *preview_node; + Node3D *preview_node = nullptr; AABB preview_bounds; struct Gizmo { @@ -628,31 +628,31 @@ private: Button *tool_button[TOOL_MAX]; Button *tool_option_button[TOOL_OPT_MAX]; - MenuButton *transform_menu; - PopupMenu *gizmos_menu; - MenuButton *view_menu; + MenuButton *transform_menu = nullptr; + PopupMenu *gizmos_menu = nullptr; + MenuButton *view_menu = nullptr; - AcceptDialog *accept; + AcceptDialog *accept = nullptr; - ConfirmationDialog *snap_dialog; - ConfirmationDialog *xform_dialog; - ConfirmationDialog *settings_dialog; + ConfirmationDialog *snap_dialog = nullptr; + ConfirmationDialog *xform_dialog = nullptr; + ConfirmationDialog *settings_dialog = nullptr; bool snap_enabled; bool snap_key_enabled; - LineEdit *snap_translate; - LineEdit *snap_rotate; - LineEdit *snap_scale; + LineEdit *snap_translate = nullptr; + LineEdit *snap_rotate = nullptr; + LineEdit *snap_scale = nullptr; LineEdit *xform_translate[3]; LineEdit *xform_rotate[3]; LineEdit *xform_scale[3]; - OptionButton *xform_type; + OptionButton *xform_type = nullptr; - VBoxContainer *settings_vbc; - SpinBox *settings_fov; - SpinBox *settings_znear; - SpinBox *settings_zfar; + VBoxContainer *settings_vbc = nullptr; + SpinBox *settings_fov = nullptr; + SpinBox *settings_znear = nullptr; + SpinBox *settings_zfar = nullptr; void _snap_changed(); void _snap_update(); @@ -662,14 +662,14 @@ private: void _menu_gizmo_toggled(int p_option); void _update_camera_override_button(bool p_game_running); void _update_camera_override_viewport(Object *p_viewport); - HBoxContainer *hbc_menu; + HBoxContainer *hbc_menu = nullptr; // Used for secondary menu items which are displayed depending on the currently selected node // (such as MeshInstance's "Mesh" menu). - PanelContainer *context_menu_container; - HBoxContainer *hbc_context_menu; + PanelContainer *context_menu_container = nullptr; + HBoxContainer *hbc_context_menu = nullptr; void _generate_selection_boxes(); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; int camera_override_viewport_id; @@ -683,13 +683,13 @@ private: void _toggle_maximize_view(Object *p_viewport); - Node *custom_camera; + Node *custom_camera = nullptr; Object *_get_editor_data(Object *p_what); Ref<Environment> viewport_environment; - Node3D *selected; + Node3D *selected = nullptr; void _request_gizmo(Object *p_obj); void _set_subgizmo_selection(Object *p_obj, Ref<Node3DGizmo> p_gizmo, int p_id, Transform3D p_transform = Transform3D()); @@ -712,18 +712,18 @@ private: uint32_t world_env_count = 0; uint32_t directional_light_count = 0; - Button *sun_button; - Label *sun_state; - Label *sun_title; - VBoxContainer *sun_vb; - Popup *sun_environ_popup; - Control *sun_direction; - EditorSpinSlider *sun_angle_altitude; - EditorSpinSlider *sun_angle_azimuth; - ColorPickerButton *sun_color; - EditorSpinSlider *sun_energy; - EditorSpinSlider *sun_max_distance; - Button *sun_add_to_scene; + Button *sun_button = nullptr; + Label *sun_state = nullptr; + Label *sun_title = nullptr; + VBoxContainer *sun_vb = nullptr; + Popup *sun_environ_popup = nullptr; + Control *sun_direction = nullptr; + EditorSpinSlider *sun_angle_altitude = nullptr; + EditorSpinSlider *sun_angle_azimuth = nullptr; + ColorPickerButton *sun_color = nullptr; + EditorSpinSlider *sun_energy = nullptr; + EditorSpinSlider *sun_max_distance = nullptr; + Button *sun_add_to_scene = nullptr; void _sun_direction_draw(); void _sun_direction_input(const Ref<InputEvent> &p_event); @@ -734,23 +734,23 @@ private: Ref<Shader> sun_direction_shader; Ref<ShaderMaterial> sun_direction_material; - Button *environ_button; - Label *environ_state; - Label *environ_title; - VBoxContainer *environ_vb; - ColorPickerButton *environ_sky_color; - ColorPickerButton *environ_ground_color; - EditorSpinSlider *environ_energy; - Button *environ_ao_button; - Button *environ_glow_button; - Button *environ_tonemap_button; - Button *environ_gi_button; - Button *environ_add_to_scene; - - Button *sun_environ_settings; - - DirectionalLight3D *preview_sun; - WorldEnvironment *preview_environment; + Button *environ_button = nullptr; + Label *environ_state = nullptr; + Label *environ_title = nullptr; + VBoxContainer *environ_vb = nullptr; + ColorPickerButton *environ_sky_color = nullptr; + ColorPickerButton *environ_ground_color = nullptr; + EditorSpinSlider *environ_energy = nullptr; + Button *environ_ao_button = nullptr; + Button *environ_glow_button = nullptr; + Button *environ_tonemap_button = nullptr; + Button *environ_gi_button = nullptr; + Button *environ_add_to_scene = nullptr; + + Button *sun_environ_settings = nullptr; + + DirectionalLight3D *preview_sun = nullptr; + WorldEnvironment *preview_environment = nullptr; Ref<Environment> environment; Ref<ProceduralSkyMaterial> sky_material; @@ -770,7 +770,7 @@ private: protected: void _notification(int p_what); //void _gui_input(InputEvent p_event); - virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; static void _bind_methods(); @@ -868,7 +868,7 @@ public: class Node3DEditorPlugin : public EditorPlugin { GDCLASS(Node3DEditorPlugin, EditorPlugin); - Node3DEditor *spatial_editor; + Node3DEditor *spatial_editor = nullptr; public: Node3DEditor *get_spatial_editor() { return spatial_editor; } diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.h b/editor/plugins/occluder_instance_3d_editor_plugin.h index 24f31b2ea8..360b7297cf 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.h +++ b/editor/plugins/occluder_instance_3d_editor_plugin.h @@ -40,11 +40,11 @@ class EditorFileDialog; class OccluderInstance3DEditorPlugin : public EditorPlugin { GDCLASS(OccluderInstance3DEditorPlugin, EditorPlugin); - OccluderInstance3D *occluder_instance; + OccluderInstance3D *occluder_instance = nullptr; - Button *bake; + Button *bake = nullptr; - EditorFileDialog *file_dialog; + EditorFileDialog *file_dialog = nullptr; void _bake_select_file(const String &p_file); void _bake(); diff --git a/editor/plugins/ot_features_plugin.h b/editor/plugins/ot_features_plugin.h index fcbc8692ca..6639148080 100644 --- a/editor/plugins/ot_features_plugin.h +++ b/editor/plugins/ot_features_plugin.h @@ -38,7 +38,7 @@ class OpenTypeFeaturesEditor : public EditorProperty { GDCLASS(OpenTypeFeaturesEditor, EditorProperty); - EditorSpinSlider *spin; + EditorSpinSlider *spin = nullptr; bool setting = true; void _value_changed(double p_val); Button *button = nullptr; diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index 926a859f8b..ff74aeedf7 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -40,14 +40,14 @@ class CanvasItemEditor; class Path2DEditor : public HBoxContainer { GDCLASS(Path2DEditor, HBoxContainer); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; - CanvasItemEditor *canvas_item_editor; - Panel *panel; - Path2D *node; + CanvasItemEditor *canvas_item_editor = nullptr; + Panel *panel = nullptr; + Path2D *node = nullptr; - HBoxContainer *base_hb; - Separator *sep; + HBoxContainer *base_hb = nullptr; + Separator *sep = nullptr; enum Mode { MODE_CREATE, @@ -58,12 +58,12 @@ class Path2DEditor : public HBoxContainer { }; Mode mode; - Button *curve_create; - Button *curve_edit; - Button *curve_edit_curve; - Button *curve_del; - Button *curve_close; - MenuButton *handle_menu; + Button *curve_create = nullptr; + Button *curve_edit = nullptr; + Button *curve_edit_curve = nullptr; + Button *curve_del = nullptr; + Button *curve_close = nullptr; + MenuButton *handle_menu = nullptr; bool mirror_handle_angle; bool mirror_handle_length; @@ -110,7 +110,7 @@ public: class Path2DEditorPlugin : public EditorPlugin { GDCLASS(Path2DEditorPlugin, EditorPlugin); - Path2DEditor *path2d_editor; + Path2DEditor *path2d_editor = nullptr; public: virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) override { return path2d_editor->forward_gui_input(p_event); } diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index 3c6ca65437..72c24732c0 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -40,7 +40,7 @@ class Path3DGizmo : public EditorNode3DGizmo { GDCLASS(Path3DGizmo, EditorNode3DGizmo); - Path3D *path; + Path3D *path = nullptr; mutable Vector3 original; mutable float orig_in_length; mutable float orig_out_length; @@ -70,14 +70,14 @@ public: class Path3DEditorPlugin : public EditorPlugin { GDCLASS(Path3DEditorPlugin, EditorPlugin); - Separator *sep; - Button *curve_create; - Button *curve_edit; - Button *curve_del; - Button *curve_close; - MenuButton *handle_menu; + Separator *sep = nullptr; + Button *curve_create = nullptr; + Button *curve_edit = nullptr; + Button *curve_del = nullptr; + Button *curve_close = nullptr; + MenuButton *handle_menu = nullptr; - Path3D *path; + Path3D *path = nullptr; void _update_theme(); diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index e815a9c9f6..9dc89133c4 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -82,8 +82,7 @@ void PhysicalBone3DEditor::show() { spatial_editor_hb->show(); } -PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin() : - physical_bone_editor() {} +PhysicalBone3DEditorPlugin::PhysicalBone3DEditorPlugin() {} void PhysicalBone3DEditorPlugin::make_visible(bool p_visible) { if (p_visible) { diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h index 4051644b54..93e722a432 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.h +++ b/editor/plugins/physical_bone_3d_editor_plugin.h @@ -39,8 +39,8 @@ class PhysicalBone3DEditor : public Object { GDCLASS(PhysicalBone3DEditor, Object); - HBoxContainer *spatial_editor_hb; - Button *button_transform_joint; + HBoxContainer *spatial_editor_hb = nullptr; + Button *button_transform_joint = nullptr; PhysicalBone3D *selected = nullptr; diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 2812c4aaaf..8566e92b22 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1228,9 +1228,7 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { return p_target; } -Polygon2DEditor::Polygon2DEditor() : - AbstractPolygon2DEditor() { - node = nullptr; +Polygon2DEditor::Polygon2DEditor() { snap_offset = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_offset", Vector2()); snap_step = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_step", Vector2(10, 10)); use_snap = EditorSettings::get_singleton()->get_project_metadata("polygon_2d_uv_editor", "snap_enabled", false); diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 0a5def902c..4403d1e9c7 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -68,38 +68,38 @@ class Polygon2DEditor : public AbstractPolygon2DEditor { Button *uv_edit_mode[4]; Ref<ButtonGroup> uv_edit_group; - Polygon2D *node; + Polygon2D *node = nullptr; UVMode uv_mode; - AcceptDialog *uv_edit; + AcceptDialog *uv_edit = nullptr; Button *uv_button[UV_MODE_MAX]; - Button *b_snap_enable; - Button *b_snap_grid; - Panel *uv_edit_draw; - HSlider *uv_zoom; - SpinBox *uv_zoom_value; - HScrollBar *uv_hscroll; - VScrollBar *uv_vscroll; - MenuButton *uv_menu; - TextureRect *uv_icon_zoom; + Button *b_snap_enable = nullptr; + Button *b_snap_grid = nullptr; + Panel *uv_edit_draw = nullptr; + HSlider *uv_zoom = nullptr; + SpinBox *uv_zoom_value = nullptr; + HScrollBar *uv_hscroll = nullptr; + VScrollBar *uv_vscroll = nullptr; + MenuButton *uv_menu = nullptr; + TextureRect *uv_icon_zoom = nullptr; Ref<ViewPanner> uv_panner; void _uv_scroll_callback(Vector2 p_scroll_vec, bool p_alt); void _uv_pan_callback(Vector2 p_scroll_vec); void _uv_zoom_callback(Vector2 p_scroll_vec, Vector2 p_origin, bool p_alt); - VBoxContainer *bone_scroll_main_vb; - ScrollContainer *bone_scroll; - VBoxContainer *bone_scroll_vb; - Button *sync_bones; - HSlider *bone_paint_strength; - SpinBox *bone_paint_radius; - Label *bone_paint_radius_label; + VBoxContainer *bone_scroll_main_vb = nullptr; + ScrollContainer *bone_scroll = nullptr; + VBoxContainer *bone_scroll_vb = nullptr; + Button *sync_bones = nullptr; + HSlider *bone_paint_strength = nullptr; + SpinBox *bone_paint_radius = nullptr; + Label *bone_paint_radius_label = nullptr; bool bone_painting; int bone_painting_bone; Vector<float> prev_weights; Vector2 bone_paint_pos; - AcceptDialog *grid_settings; + AcceptDialog *grid_settings = nullptr; void _sync_bones(); void _update_bone_list(); @@ -123,9 +123,9 @@ class Polygon2DEditor : public AbstractPolygon2DEditor { Vector2 uv_drag_from; bool updating_uv_scroll; - AcceptDialog *error; + AcceptDialog *error = nullptr; - Button *button_uv; + Button *button_uv = nullptr; bool use_snap; bool snap_show_grid; diff --git a/editor/plugins/polygon_3d_editor_plugin.h b/editor/plugins/polygon_3d_editor_plugin.h index e92dcaf319..3ad7a4df58 100644 --- a/editor/plugins/polygon_3d_editor_plugin.h +++ b/editor/plugins/polygon_3d_editor_plugin.h @@ -41,7 +41,7 @@ class CanvasItemEditor; class Polygon3DEditor : public HBoxContainer { GDCLASS(Polygon3DEditor, HBoxContainer); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; enum Mode { MODE_CREATE, MODE_EDIT, @@ -50,21 +50,21 @@ class Polygon3DEditor : public HBoxContainer { Mode mode; - Button *button_create; - Button *button_edit; + Button *button_create = nullptr; + Button *button_edit = nullptr; Ref<StandardMaterial3D> line_material; Ref<StandardMaterial3D> handle_material; - Panel *panel; - Node3D *node; + Panel *panel = nullptr; + Node3D *node = nullptr; Ref<Resource> node_resource; Ref<ImmediateMesh> imesh; - MeshInstance3D *imgeom; - MeshInstance3D *pointsm; + MeshInstance3D *imgeom = nullptr; + MeshInstance3D *pointsm = nullptr; Ref<ArrayMesh> m; - MenuButton *options; + MenuButton *options = nullptr; int edited_point; Vector2 edited_point_pos; @@ -98,7 +98,7 @@ public: class Polygon3DEditorPlugin : public EditorPlugin { GDCLASS(Polygon3DEditorPlugin, EditorPlugin); - Polygon3DEditor *polygon_editor; + Polygon3DEditor *polygon_editor = nullptr; public: virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override { return polygon_editor->forward_spatial_gui_input(p_camera, p_event); } diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp index e4c1c69804..2a7b3c7a55 100644 --- a/editor/plugins/replication_editor_plugin.cpp +++ b/editor/plugins/replication_editor_plugin.cpp @@ -217,7 +217,7 @@ void ReplicationEditor::update_keying() { /// TODO make keying usable. #if 0 bool keying_enabled = false; - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); if (is_visible_in_tree() && config.is_valid() && editor_history->get_path_size() > 0) { Object *obj = ObjectDB::get_instance(editor_history->get_path_object(0)); keying_enabled = Object::cast_to<Node>(obj) != nullptr; @@ -305,7 +305,7 @@ void ReplicationEditor::property_keyed(const String &p_property) { ERR_FAIL_COND(!current || config.is_null()); Node *root = current->get_node(current->get_root_path()); ERR_FAIL_COND(!root); - EditorHistory *history = EditorNode::get_singleton()->get_editor_history(); + EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history(); ERR_FAIL_COND(history->get_path_size() == 0); Node *node = Object::cast_to<Node>(ObjectDB::get_instance(history->get_path_object(0))); ERR_FAIL_COND(!node); diff --git a/editor/plugins/replication_editor_plugin.h b/editor/plugins/replication_editor_plugin.h index 46274d188c..08e86d1617 100644 --- a/editor/plugins/replication_editor_plugin.h +++ b/editor/plugins/replication_editor_plugin.h @@ -51,7 +51,7 @@ private: Ref<SceneReplicationConfig> config; NodePath deleting; - Tree *tree; + Tree *tree = nullptr; bool keying = false; Ref<Texture2D> _get_class_icon(const Node *p_node); @@ -84,7 +84,7 @@ class ReplicationEditorPlugin : public EditorPlugin { GDCLASS(ReplicationEditorPlugin, EditorPlugin); private: - ReplicationEditor *repl_editor; + ReplicationEditor *repl_editor = nullptr; void _node_removed(Node *p_node); void _keying_changed(); diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h index 8e81239f1b..0b799c13c6 100644 --- a/editor/plugins/resource_preloader_editor_plugin.h +++ b/editor/plugins/resource_preloader_editor_plugin.h @@ -47,16 +47,16 @@ class ResourcePreloaderEditor : public PanelContainer { BUTTON_REMOVE }; - Button *load; - Button *paste; - Tree *tree; + Button *load = nullptr; + Button *paste = nullptr; + Tree *tree = nullptr; bool loading_scene; - EditorFileDialog *file; + EditorFileDialog *file = nullptr; - AcceptDialog *dialog; + AcceptDialog *dialog = nullptr; - ResourcePreloader *preloader; + ResourcePreloader *preloader = nullptr; void _load_pressed(); void _files_load_request(const Vector<String> &p_paths); @@ -66,7 +66,7 @@ class ResourcePreloaderEditor : public PanelContainer { void _cell_button_pressed(Object *p_item, int p_column, int p_id); void _item_edited(); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; @@ -87,8 +87,8 @@ public: class ResourcePreloaderEditorPlugin : public EditorPlugin { GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin); - ResourcePreloaderEditor *preloader_editor; - Button *button; + ResourcePreloaderEditor *preloader_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "ResourcePreloader"; } diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h index c2866f269b..5b8c1d77b3 100644 --- a/editor/plugins/root_motion_editor_plugin.h +++ b/editor/plugins/root_motion_editor_plugin.h @@ -38,12 +38,12 @@ class EditorPropertyRootMotion : public EditorProperty { GDCLASS(EditorPropertyRootMotion, EditorProperty); - Button *assign; - Button *clear; + Button *assign = nullptr; + Button *clear = nullptr; NodePath base_hint; - ConfirmationDialog *filter_dialog; - Tree *filters; + ConfirmationDialog *filter_dialog = nullptr; + Tree *filters = nullptr; void _confirmed(); void _node_assign(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bbaf2bef98..0f45415c4d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1232,9 +1232,6 @@ void ScriptEditor::_menu_option(int p_option) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); - script_editor->call_deferred(SNAME("_menu_option"), p_option); - previous_scripts.push_back(path); //repeat the operation - return; } } else { EditorNode::get_singleton()->load_resource(res_path); @@ -1250,7 +1247,6 @@ void ScriptEditor::_menu_option(int p_option) { edit(scr); file_dialog_option = -1; - return; } else { Error error; Ref<TextFile> text_file = _load_text_file(path, &error); @@ -1261,7 +1257,6 @@ void ScriptEditor::_menu_option(int p_option) { if (text_file.is_valid()) { edit(text_file); file_dialog_option = -1; - return; } } } break; @@ -3024,7 +3019,7 @@ void ScriptEditor::input(const Ref<InputEvent> &p_event) { } } -void ScriptEditor::unhandled_key_input(const Ref<InputEvent> &p_event) { +void ScriptEditor::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) { @@ -3296,15 +3291,8 @@ void ScriptEditor::_help_class_open(const String &p_class) { void ScriptEditor::_help_class_goto(const String &p_desc) { String cname = p_desc.get_slice(":", 1); - for (int i = 0; i < tab_container->get_tab_count(); i++) { - EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_tab_control(i)); - - if (eh && eh->get_class() == cname) { - _go_to_tab(i); - eh->go_to_help(p_desc); - _update_script_names(); - return; - } + if (_help_tab_goto(cname, p_desc)) { + return; } EditorHelp *eh = memnew(EditorHelp); @@ -3318,6 +3306,22 @@ void ScriptEditor::_help_class_goto(const String &p_desc) { _sort_list_on_update = true; _update_script_names(); _save_layout(); + + call_deferred("_help_tab_goto", cname, p_desc); +} + +bool ScriptEditor::_help_tab_goto(const String &p_name, const String &p_desc) { + for (int i = 0; i < tab_container->get_tab_count(); i++) { + EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_tab_control(i)); + + if (eh && eh->get_class() == p_name) { + _go_to_tab(i); + eh->go_to_help(p_desc); + _update_script_names(); + return true; + } + } + return false; } void ScriptEditor::update_doc(const String &p_name) { @@ -3606,6 +3610,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections); ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open); + ClassDB::bind_method("_help_tab_goto", &ScriptEditor::_help_tab_goto); ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts); ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview); ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts); @@ -3745,7 +3750,7 @@ ScriptEditor::ScriptEditor() { ED_SHORTCUT("script_editor/next_script", TTR("Next Script"), KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::PERIOD); ED_SHORTCUT("script_editor/prev_script", TTR("Previous Script"), KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::COMMA); set_process_input(true); - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); file_menu = memnew(MenuButton); file_menu->set_text(TTR("File")); @@ -3960,7 +3965,7 @@ void ScriptEditorPlugin::edit(Object *p_object) { Script *p_script = Object::cast_to<Script>(p_object); String res_path = p_script->get_path().get_slice("::", 0); - if (p_script->is_built_in()) { + if (p_script->is_built_in() && !res_path.is_empty()) { if (ResourceLoader::get_resource_type(res_path) == "PackedScene") { if (!EditorNode::get_singleton()->is_scene_open(res_path)) { EditorNode::get_singleton()->load_scene(res_path); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index a99e269d46..7885ffe2c5 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -102,8 +102,8 @@ public: class ScriptEditorQuickOpen : public ConfirmationDialog { GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog); - LineEdit *search_box; - Tree *search_options; + LineEdit *search_box = nullptr; + Tree *search_options = nullptr; String function; void _update_search(); @@ -242,55 +242,55 @@ class ScriptEditor : public PanelContainer { DISPLAY_FULL_PATH, }; - HBoxContainer *menu_hb; - MenuButton *file_menu; - MenuButton *edit_menu; - MenuButton *script_search_menu; - MenuButton *debug_menu; - PopupMenu *context_menu; - Timer *autosave_timer; + HBoxContainer *menu_hb = nullptr; + MenuButton *file_menu = nullptr; + MenuButton *edit_menu = nullptr; + MenuButton *script_search_menu = nullptr; + MenuButton *debug_menu = nullptr; + PopupMenu *context_menu = nullptr; + Timer *autosave_timer = nullptr; uint64_t idle; - PopupMenu *recent_scripts; - PopupMenu *theme_submenu; - - Button *help_search; - Button *site_search; - EditorHelpSearch *help_search_dialog; - - ItemList *script_list; - HSplitContainer *script_split; - ItemList *members_overview; - LineEdit *filter_scripts; - LineEdit *filter_methods; - VBoxContainer *scripts_vbox; - VBoxContainer *overview_vbox; - HBoxContainer *buttons_hbox; - Label *filename; - Button *members_overview_alphabeta_sort_button; + PopupMenu *recent_scripts = nullptr; + PopupMenu *theme_submenu = nullptr; + + Button *help_search = nullptr; + Button *site_search = nullptr; + EditorHelpSearch *help_search_dialog = nullptr; + + ItemList *script_list = nullptr; + HSplitContainer *script_split = nullptr; + ItemList *members_overview = nullptr; + LineEdit *filter_scripts = nullptr; + LineEdit *filter_methods = nullptr; + VBoxContainer *scripts_vbox = nullptr; + VBoxContainer *overview_vbox = nullptr; + HBoxContainer *buttons_hbox = nullptr; + Label *filename = nullptr; + Button *members_overview_alphabeta_sort_button = nullptr; bool members_overview_enabled; - ItemList *help_overview; + ItemList *help_overview = nullptr; bool help_overview_enabled; - VSplitContainer *list_split; - TabContainer *tab_container; - EditorFileDialog *file_dialog; - AcceptDialog *error_dialog; - ConfirmationDialog *erase_tab_confirm; - ScriptCreateDialog *script_create_dialog; - Button *scripts_visible; - FindReplaceBar *find_replace_bar; + VSplitContainer *list_split = nullptr; + TabContainer *tab_container = nullptr; + EditorFileDialog *file_dialog = nullptr; + AcceptDialog *error_dialog = nullptr; + ConfirmationDialog *erase_tab_confirm = nullptr; + ScriptCreateDialog *script_create_dialog = nullptr; + Button *scripts_visible = nullptr; + FindReplaceBar *find_replace_bar = nullptr; String current_theme; - TextureRect *script_icon; - Label *script_name_label; + TextureRect *script_icon = nullptr; + Label *script_name_label = nullptr; - Button *script_back; - Button *script_forward; + Button *script_back = nullptr; + Button *script_forward = nullptr; - FindInFilesDialog *find_in_files_dialog; - FindInFilesPanel *find_in_files; - Button *find_in_files_button; + FindInFilesDialog *find_in_files_dialog = nullptr; + FindInFilesPanel *find_in_files = nullptr; + Button *find_in_files_button = nullptr; enum { SCRIPT_EDITOR_FUNC_MAX = 32, @@ -320,8 +320,8 @@ class ScriptEditor : public PanelContainer { bool _has_script_tab() const; void _prepare_file_menu(); - Tree *disk_changed_list; - ConfirmationDialog *disk_changed; + Tree *disk_changed_list = nullptr; + ConfirmationDialog *disk_changed = nullptr; bool restoring_layout; @@ -361,7 +361,7 @@ class ScriptEditor : public PanelContainer { void _update_selected_editor_menu(); - EditorScriptCodeCompletionCache *completion_cache; + EditorScriptCodeCompletionCache *completion_cache = nullptr; void _editor_stop(); @@ -426,7 +426,7 @@ class ScriptEditor : public PanelContainer { void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); virtual void input(const Ref<InputEvent> &p_event) override; - virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; void _script_list_gui_input(const Ref<InputEvent> &ev); void _make_script_list_context_menu(); @@ -440,6 +440,7 @@ class ScriptEditor : public PanelContainer { void _help_class_open(const String &p_class); void _help_class_goto(const String &p_desc); + bool _help_tab_goto(const String &p_name, const String &p_desc); void _update_history_arrows(); void _save_history(); void _go_to_tab(int p_idx); @@ -528,7 +529,7 @@ public: class ScriptEditorPlugin : public EditorPlugin { GDCLASS(ScriptEditorPlugin, EditorPlugin); - ScriptEditor *script_editor; + ScriptEditor *script_editor = nullptr; public: virtual String get_name() const override { return "Script"; } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index c1b0a32fc7..4626f10b8d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -699,6 +699,9 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<ScriptLa } String hint; Error err = script->get_language()->complete_code(p_code, script->get_path(), base, r_options, r_force, hint); + + r_options->sort_custom_inplace<CodeCompletionOptionCompare>(); + if (err == OK) { code_editor->get_text_editor()->set_code_hint(hint); } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 5c3a66404e..c1c4b0af54 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -256,4 +256,51 @@ public: ~ScriptTextEditor(); }; +const int KIND_COUNT = 10; +// The order in which to sort code completion options. +const ScriptLanguage::CodeCompletionKind KIND_SORT_ORDER[KIND_COUNT] = { + ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE, + ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, + ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION, + ScriptLanguage::CODE_COMPLETION_KIND_ENUM, + ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, + ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, + ScriptLanguage::CODE_COMPLETION_KIND_CLASS, + ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH, + ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH, + ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT, +}; + +// The custom comparer which will sort completion options. +struct CodeCompletionOptionCompare { + _FORCE_INLINE_ bool operator()(const ScriptLanguage::CodeCompletionOption &l, const ScriptLanguage::CodeCompletionOption &r) const { + if (l.location == r.location) { + // If locations are same, sort on kind + if (l.kind == r.kind) { + // If kinds are same, sort alphanumeric + return l.display < r.display; + } + + // Sort kinds based on the const sorting array defined above. Lower index = higher priority. + int l_index = -1; + int r_index = -1; + for (int i = 0; i < KIND_COUNT; i++) { + const ScriptLanguage::CodeCompletionKind kind = KIND_SORT_ORDER[i]; + l_index = kind == l.kind ? i : l_index; + r_index = kind == r.kind ? i : r_index; + + if (l_index != -1 && r_index != -1) { + return l_index < r_index; + } + } + + // This return should never be hit unless something goes wrong. + // l and r should always have a Kind which is in the sort order array. + return l.display < r.display; + } + + return l.location < r.location; + } +}; + #endif // SCRIPT_TEXT_EDITOR_H diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 600b14362e..067711c75c 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -108,19 +108,19 @@ class ShaderEditor : public PanelContainer { HELP_DOCS, }; - MenuButton *edit_menu; - MenuButton *search_menu; - PopupMenu *bookmarks_menu; - MenuButton *help_menu; - PopupMenu *context_menu; + MenuButton *edit_menu = nullptr; + MenuButton *search_menu = nullptr; + PopupMenu *bookmarks_menu = nullptr; + MenuButton *help_menu = nullptr; + PopupMenu *context_menu = nullptr; RichTextLabel *warnings_panel = nullptr; uint64_t idle; - GotoLineDialog *goto_line_dialog; - ConfirmationDialog *erase_tab_confirm; - ConfirmationDialog *disk_changed; + GotoLineDialog *goto_line_dialog = nullptr; + ConfirmationDialog *erase_tab_confirm = nullptr; + ConfirmationDialog *disk_changed = nullptr; - ShaderTextEditor *shader_editor; + ShaderTextEditor *shader_editor = nullptr; void _menu_option(int p_option); mutable Ref<Shader> shader; @@ -161,8 +161,8 @@ class ShaderEditorPlugin : public EditorPlugin { GDCLASS(ShaderEditorPlugin, EditorPlugin); bool _2d; - ShaderEditor *shader_editor; - Button *button; + ShaderEditor *shader_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "Shader"; } diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h index 5ee2d01dbf..1ebd644282 100644 --- a/editor/plugins/shader_file_editor_plugin.h +++ b/editor/plugins/shader_file_editor_plugin.h @@ -48,10 +48,10 @@ class ShaderFileEditor : public PanelContainer { Ref<RDShaderFile> shader_file; - HBoxContainer *stage_hb; - ItemList *versions; + HBoxContainer *stage_hb = nullptr; + ItemList *versions = nullptr; Button *stages[RD::SHADER_STAGE_MAX]; - RichTextLabel *error_text; + RichTextLabel *error_text = nullptr; void _update_version(const StringName &p_version_txt, const RenderingDevice::ShaderStage p_stage); void _version_selected(int p_stage); @@ -74,8 +74,8 @@ public: class ShaderFileEditorPlugin : public EditorPlugin { GDCLASS(ShaderFileEditorPlugin, EditorPlugin); - ShaderFileEditor *shader_editor; - Button *button; + ShaderFileEditor *shader_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "ShaderFile"; } diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h index 004dac7b05..295725b751 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.h +++ b/editor/plugins/skeleton_2d_editor_plugin.h @@ -43,10 +43,10 @@ class Skeleton2DEditor : public Control { MENU_OPTION_MAKE_REST, }; - Skeleton2D *node; + Skeleton2D *node = nullptr; - MenuButton *options; - AcceptDialog *err_dialog; + MenuButton *options = nullptr; + AcceptDialog *err_dialog = nullptr; void _menu_option(int p_option); @@ -65,7 +65,7 @@ public: class Skeleton2DEditorPlugin : public EditorPlugin { GDCLASS(Skeleton2DEditorPlugin, EditorPlugin); - Skeleton2DEditor *sprite_editor; + Skeleton2DEditor *sprite_editor = nullptr; public: virtual String get_name() const override { return "Skeleton2D"; } diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 2dbb552428..911e39a34f 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -60,10 +60,10 @@ class BoneTransformEditor : public VBoxContainer { Rect2 background_rects[5]; - Skeleton3D *skeleton; + Skeleton3D *skeleton = nullptr; // String property; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; bool toggle_enabled = false; bool updating = false; @@ -108,26 +108,26 @@ class Skeleton3DEditor : public VBoxContainer { Transform3D relative_rest; // Relative to skeleton node. }; - EditorInspectorPluginSkeleton *editor_plugin; + EditorInspectorPluginSkeleton *editor_plugin = nullptr; - Skeleton3D *skeleton; + Skeleton3D *skeleton = nullptr; Tree *joint_tree = nullptr; BoneTransformEditor *rest_editor = nullptr; BoneTransformEditor *pose_editor = nullptr; - VSeparator *separator; + VSeparator *separator = nullptr; MenuButton *skeleton_options = nullptr; - Button *edit_mode_button; + Button *edit_mode_button = nullptr; bool edit_mode = false; - HBoxContainer *animation_hb; - Button *key_loc_button; - Button *key_rot_button; - Button *key_scale_button; - Button *key_insert_button; - Button *key_insert_all_button; + HBoxContainer *animation_hb = nullptr; + Button *key_loc_button = nullptr; + Button *key_rot_button = nullptr; + Button *key_scale_button = nullptr; + Button *key_insert_button = nullptr; + Button *key_insert_all_button = nullptr; EditorFileDialog *file_dialog = nullptr; @@ -163,7 +163,7 @@ class Skeleton3DEditor : public VBoxContainer { void set_bone_options_enabled(const bool p_bone_options_enabled); // Handle. - MeshInstance3D *handles_mesh_instance; + MeshInstance3D *handles_mesh_instance = nullptr; Ref<ImmediateMesh> handles_mesh; Ref<ShaderMaterial> handle_material; Ref<Shader> handle_shader; @@ -220,7 +220,7 @@ class EditorInspectorPluginSkeleton : public EditorInspectorPlugin { friend class Skeleton3DEditorPlugin; - Skeleton3DEditor *skel_editor; + Skeleton3DEditor *skel_editor = nullptr; public: virtual bool can_handle(Object *p_object) override; @@ -230,7 +230,7 @@ public: class Skeleton3DEditorPlugin : public EditorPlugin { GDCLASS(Skeleton3DEditorPlugin, EditorPlugin); - EditorInspectorPluginSkeleton *skeleton_plugin; + EditorInspectorPluginSkeleton *skeleton_plugin = nullptr; public: virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) override; diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h index f71e788232..26aead6d67 100644 --- a/editor/plugins/skeleton_ik_3d_editor_plugin.h +++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h @@ -38,9 +38,9 @@ class SkeletonIK3D; class SkeletonIK3DEditorPlugin : public EditorPlugin { GDCLASS(SkeletonIK3DEditorPlugin, EditorPlugin); - SkeletonIK3D *skeleton_ik; + SkeletonIK3D *skeleton_ik = nullptr; - Button *play_btn; + Button *play_btn = nullptr; void _play(); diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index 46953b0937..8e3dc19c7e 100644 --- a/editor/plugins/sprite_2d_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -47,16 +47,16 @@ class Sprite2DEditor : public Control { Menu selected_menu_item; - Sprite2D *node; + Sprite2D *node = nullptr; - MenuButton *options; + MenuButton *options = nullptr; - ConfirmationDialog *outline_dialog; + ConfirmationDialog *outline_dialog = nullptr; - AcceptDialog *err_dialog; + AcceptDialog *err_dialog = nullptr; - ConfirmationDialog *debug_uv_dialog; - Control *debug_uv; + ConfirmationDialog *debug_uv_dialog = nullptr; + Control *debug_uv = nullptr; Vector<Vector2> uv_lines; Vector<Vector<Vector2>> outline_lines; Vector<Vector<Vector2>> computed_outline_lines; @@ -64,10 +64,10 @@ class Sprite2DEditor : public Control { Vector<Vector2> computed_uv; Vector<int> computed_indices; - SpinBox *simplification; - SpinBox *grow_pixels; - SpinBox *shrink_pixels; - Button *update_preview; + SpinBox *simplification = nullptr; + SpinBox *grow_pixels = nullptr; + SpinBox *shrink_pixels = nullptr; + Button *update_preview = nullptr; void _menu_option(int p_option); @@ -98,7 +98,7 @@ public: class Sprite2DEditorPlugin : public EditorPlugin { GDCLASS(Sprite2DEditorPlugin, EditorPlugin); - Sprite2DEditor *sprite_editor; + Sprite2DEditor *sprite_editor = nullptr; public: virtual String get_name() const override { return "Sprite2D"; } diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 872a88e262..b0213012a2 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -48,48 +48,48 @@ class EditorFileDialog; class SpriteFramesEditor : public HSplitContainer { GDCLASS(SpriteFramesEditor, HSplitContainer); - Button *load; - Button *load_sheet; - Button *_delete; - Button *copy; - Button *paste; - Button *empty; - Button *empty2; - Button *move_up; - Button *move_down; - Button *zoom_out; - Button *zoom_reset; - Button *zoom_in; - ItemList *tree; + Button *load = nullptr; + Button *load_sheet = nullptr; + Button *_delete = nullptr; + Button *copy = nullptr; + Button *paste = nullptr; + Button *empty = nullptr; + Button *empty2 = nullptr; + Button *move_up = nullptr; + Button *move_down = nullptr; + Button *zoom_out = nullptr; + Button *zoom_reset = nullptr; + Button *zoom_in = nullptr; + ItemList *tree = nullptr; bool loading_scene; int sel; - Button *new_anim; - Button *remove_anim; + Button *new_anim = nullptr; + Button *remove_anim = nullptr; - Tree *animations; - SpinBox *anim_speed; - CheckButton *anim_loop; + Tree *animations = nullptr; + SpinBox *anim_speed = nullptr; + CheckButton *anim_loop = nullptr; - EditorFileDialog *file; + EditorFileDialog *file = nullptr; - AcceptDialog *dialog; + AcceptDialog *dialog = nullptr; - SpriteFrames *frames; + SpriteFrames *frames = nullptr; StringName edited_anim; - ConfirmationDialog *delete_dialog; - - ConfirmationDialog *split_sheet_dialog; - ScrollContainer *split_sheet_scroll; - TextureRect *split_sheet_preview; - SpinBox *split_sheet_h; - SpinBox *split_sheet_v; - Button *split_sheet_zoom_out; - Button *split_sheet_zoom_reset; - Button *split_sheet_zoom_in; - EditorFileDialog *file_split_sheet; + ConfirmationDialog *delete_dialog = nullptr; + + ConfirmationDialog *split_sheet_dialog = nullptr; + ScrollContainer *split_sheet_scroll = nullptr; + TextureRect *split_sheet_preview = nullptr; + SpinBox *split_sheet_h = nullptr; + SpinBox *split_sheet_v = nullptr; + Button *split_sheet_zoom_out = nullptr; + Button *split_sheet_zoom_reset = nullptr; + Button *split_sheet_zoom_in = nullptr; + EditorFileDialog *file_split_sheet = nullptr; Set<int> frames_selected; Set<int> frames_toggled_by_mouse_hover; int last_frame_selected; @@ -129,7 +129,7 @@ class SpriteFramesEditor : public HSplitContainer { bool updating; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; @@ -164,8 +164,8 @@ public: class SpriteFramesEditorPlugin : public EditorPlugin { GDCLASS(SpriteFramesEditorPlugin, EditorPlugin); - SpriteFramesEditor *frames_editor; - Button *button; + SpriteFramesEditor *frames_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "SpriteFrames"; } diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index bdebebbe1c..663440ae31 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -40,7 +40,7 @@ class StyleBoxPreview : public VBoxContainer { GDCLASS(StyleBoxPreview, VBoxContainer); - Control *preview; + Control *preview = nullptr; Ref<StyleBox> stylebox; void _sb_changed(); diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h index 1349003a9c..a475f6eba3 100644 --- a/editor/plugins/text_control_editor_plugin.h +++ b/editor/plugins/text_control_editor_plugin.h @@ -100,7 +100,7 @@ public: class TextControlEditorPlugin : public EditorPlugin { GDCLASS(TextControlEditorPlugin, EditorPlugin); - TextControlEditor *text_ctl_editor; + TextControlEditor *text_ctl_editor = nullptr; public: virtual String get_name() const override { return "TextControlFontEditor"; } diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h index d418032477..2f7f6f83bb 100644 --- a/editor/plugins/texture_3d_editor_plugin.h +++ b/editor/plugins/texture_3d_editor_plugin.h @@ -39,14 +39,14 @@ class Texture3DEditor : public Control { GDCLASS(Texture3DEditor, Control); - SpinBox *layer; - Label *info; + SpinBox *layer = nullptr; + Label *info = nullptr; Ref<Texture3D> texture; Ref<Shader> shader; Ref<ShaderMaterial> material; - Control *texture_rect; + Control *texture_rect = nullptr; void _make_shaders(); diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h index 1c59ec4db0..830916e954 100644 --- a/editor/plugins/texture_layered_editor_plugin.h +++ b/editor/plugins/texture_layered_editor_plugin.h @@ -39,8 +39,8 @@ class TextureLayeredEditor : public Control { GDCLASS(TextureLayeredEditor, Control); - SpinBox *layer; - Label *info; + SpinBox *layer = nullptr; + Label *info = nullptr; Ref<TextureLayered> texture; Ref<Shader> shaders[3]; @@ -48,7 +48,7 @@ class TextureLayeredEditor : public Control { float x_rot = 0; float y_rot = 0; - Control *texture_rect; + Control *texture_rect = nullptr; void _make_shaders(); diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index 041742c28a..1e1cc2b7b2 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -52,23 +52,23 @@ class TextureRegionEditor : public VBoxContainer { }; friend class TextureRegionEditorPlugin; - OptionButton *snap_mode_button; - Button *zoom_in; - Button *zoom_reset; - Button *zoom_out; - HBoxContainer *hb_grid; //For showing/hiding the grid controls when changing the SnapMode - SpinBox *sb_step_y; - SpinBox *sb_step_x; - SpinBox *sb_off_y; - SpinBox *sb_off_x; - SpinBox *sb_sep_y; - SpinBox *sb_sep_x; - Panel *edit_draw; - - VScrollBar *vscroll; - HScrollBar *hscroll; - - UndoRedo *undo_redo; + OptionButton *snap_mode_button = nullptr; + Button *zoom_in = nullptr; + Button *zoom_reset = nullptr; + Button *zoom_out = nullptr; + HBoxContainer *hb_grid = nullptr; //For showing/hiding the grid controls when changing the SnapMode + SpinBox *sb_step_y = nullptr; + SpinBox *sb_step_x = nullptr; + SpinBox *sb_off_y = nullptr; + SpinBox *sb_off_x = nullptr; + SpinBox *sb_sep_y = nullptr; + SpinBox *sb_sep_x = nullptr; + Panel *edit_draw = nullptr; + + VScrollBar *vscroll = nullptr; + HScrollBar *hscroll = nullptr; + + UndoRedo *undo_redo = nullptr; Vector2 draw_ofs; float draw_zoom; @@ -79,9 +79,9 @@ class TextureRegionEditor : public VBoxContainer { Vector2 snap_step; Vector2 snap_separation; - Sprite2D *node_sprite_2d; - Sprite3D *node_sprite_3d; - NinePatchRect *node_ninepatch; + Sprite2D *node_sprite_2d = nullptr; + Sprite3D *node_sprite_3d = nullptr; + NinePatchRect *node_ninepatch = nullptr; Ref<StyleBoxTexture> obj_styleBox; Ref<AtlasTexture> atlas_tex; @@ -146,8 +146,8 @@ class TextureRegionEditorPlugin : public EditorPlugin { GDCLASS(TextureRegionEditorPlugin, EditorPlugin); bool manually_hidden; - Button *texture_region_button; - TextureRegionEditor *region_editor; + Button *texture_region_button = nullptr; + TextureRegionEditor *region_editor = nullptr; protected: static void _bind_methods(); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 7c1b0cda3e..4b49fbb186 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -75,9 +75,9 @@ class ThemeItemImportTree : public VBoxContainer { Map<ThemeItem, ItemCheckedState> selected_items; - LineEdit *import_items_filter; + LineEdit *import_items_filter = nullptr; - Tree *import_items_tree; + Tree *import_items_tree = nullptr; List<TreeItem *> tree_color_items; List<TreeItem *> tree_constant_items; List<TreeItem *> tree_font_items; @@ -92,57 +92,57 @@ class ThemeItemImportTree : public VBoxContainer { IMPORT_ITEM_DATA = 2, }; - TextureRect *select_colors_icon; - Label *select_colors_label; - Button *select_all_colors_button; - Button *select_full_colors_button; - Button *deselect_all_colors_button; - Label *total_selected_colors_label; - - TextureRect *select_constants_icon; - Label *select_constants_label; - Button *select_all_constants_button; - Button *select_full_constants_button; - Button *deselect_all_constants_button; - Label *total_selected_constants_label; - - TextureRect *select_fonts_icon; - Label *select_fonts_label; - Button *select_all_fonts_button; - Button *select_full_fonts_button; - Button *deselect_all_fonts_button; - Label *total_selected_fonts_label; - - TextureRect *select_font_sizes_icon; - Label *select_font_sizes_label; - Button *select_all_font_sizes_button; - Button *select_full_font_sizes_button; - Button *deselect_all_font_sizes_button; - Label *total_selected_font_sizes_label; - - TextureRect *select_icons_icon; - Label *select_icons_label; - Button *select_all_icons_button; - Button *select_full_icons_button; - Button *deselect_all_icons_button; - Label *total_selected_icons_label; - - TextureRect *select_styleboxes_icon; - Label *select_styleboxes_label; - Button *select_all_styleboxes_button; - Button *select_full_styleboxes_button; - Button *deselect_all_styleboxes_button; - Label *total_selected_styleboxes_label; - - HBoxContainer *select_icons_warning_hb; - TextureRect *select_icons_warning_icon; - Label *select_icons_warning; - - Button *import_collapse_types_button; - Button *import_expand_types_button; - Button *import_select_all_button; - Button *import_select_full_button; - Button *import_deselect_all_button; + TextureRect *select_colors_icon = nullptr; + Label *select_colors_label = nullptr; + Button *select_all_colors_button = nullptr; + Button *select_full_colors_button = nullptr; + Button *deselect_all_colors_button = nullptr; + Label *total_selected_colors_label = nullptr; + + TextureRect *select_constants_icon = nullptr; + Label *select_constants_label = nullptr; + Button *select_all_constants_button = nullptr; + Button *select_full_constants_button = nullptr; + Button *deselect_all_constants_button = nullptr; + Label *total_selected_constants_label = nullptr; + + TextureRect *select_fonts_icon = nullptr; + Label *select_fonts_label = nullptr; + Button *select_all_fonts_button = nullptr; + Button *select_full_fonts_button = nullptr; + Button *deselect_all_fonts_button = nullptr; + Label *total_selected_fonts_label = nullptr; + + TextureRect *select_font_sizes_icon = nullptr; + Label *select_font_sizes_label = nullptr; + Button *select_all_font_sizes_button = nullptr; + Button *select_full_font_sizes_button = nullptr; + Button *deselect_all_font_sizes_button = nullptr; + Label *total_selected_font_sizes_label = nullptr; + + TextureRect *select_icons_icon = nullptr; + Label *select_icons_label = nullptr; + Button *select_all_icons_button = nullptr; + Button *select_full_icons_button = nullptr; + Button *deselect_all_icons_button = nullptr; + Label *total_selected_icons_label = nullptr; + + TextureRect *select_styleboxes_icon = nullptr; + Label *select_styleboxes_label = nullptr; + Button *select_all_styleboxes_button = nullptr; + Button *select_full_styleboxes_button = nullptr; + Button *deselect_all_styleboxes_button = nullptr; + Label *total_selected_styleboxes_label = nullptr; + + HBoxContainer *select_icons_warning_hb = nullptr; + TextureRect *select_icons_warning_icon = nullptr; + Label *select_icons_warning = nullptr; + + Button *import_collapse_types_button = nullptr; + Button *import_expand_types_button = nullptr; + Button *import_select_all_button = nullptr; + Button *import_select_full_button = nullptr; + Button *import_deselect_all_button = nullptr; void _update_items_tree(); void _toggle_type_items(bool p_collapse); @@ -186,31 +186,31 @@ class ThemeTypeEditor; class ThemeItemEditorDialog : public AcceptDialog { GDCLASS(ThemeItemEditorDialog, AcceptDialog); - ThemeTypeEditor *theme_type_editor; + ThemeTypeEditor *theme_type_editor = nullptr; Ref<Theme> edited_theme; - TabContainer *tc; + TabContainer *tc = nullptr; enum TypesTreeAction { TYPES_TREE_REMOVE_ITEM, }; - Tree *edit_type_list; - LineEdit *edit_add_type_value; + Tree *edit_type_list = nullptr; + LineEdit *edit_add_type_value = nullptr; String edited_item_type; - Button *edit_items_add_color; - Button *edit_items_add_constant; - Button *edit_items_add_font; - Button *edit_items_add_font_size; - Button *edit_items_add_icon; - Button *edit_items_add_stylebox; - Button *edit_items_remove_class; - Button *edit_items_remove_custom; - Button *edit_items_remove_all; - Tree *edit_items_tree; - Label *edit_items_message; + Button *edit_items_add_color = nullptr; + Button *edit_items_add_constant = nullptr; + Button *edit_items_add_font = nullptr; + Button *edit_items_add_font_size = nullptr; + Button *edit_items_add_icon = nullptr; + Button *edit_items_add_stylebox = nullptr; + Button *edit_items_remove_class = nullptr; + Button *edit_items_remove_custom = nullptr; + Button *edit_items_remove_all = nullptr; + Tree *edit_items_tree = nullptr; + Label *edit_items_message = nullptr; enum ItemsTreeAction { ITEMS_TREE_RENAME_ITEM, @@ -218,10 +218,10 @@ class ThemeItemEditorDialog : public AcceptDialog { ITEMS_TREE_REMOVE_DATA_TYPE, }; - ConfirmationDialog *edit_theme_item_dialog; - VBoxContainer *edit_theme_item_old_vb; - Label *theme_item_old_name; - LineEdit *theme_item_name; + ConfirmationDialog *edit_theme_item_dialog = nullptr; + VBoxContainer *edit_theme_item_old_vb = nullptr; + Label *theme_item_old_name = nullptr; + LineEdit *theme_item_name = nullptr; enum ItemPopupMode { CREATE_THEME_ITEM, @@ -233,15 +233,15 @@ class ThemeItemEditorDialog : public AcceptDialog { String edit_item_old_name; Theme::DataType edit_item_data_type = Theme::DATA_TYPE_MAX; - ThemeItemImportTree *import_default_theme_items; - ThemeItemImportTree *import_editor_theme_items; - ThemeItemImportTree *import_other_theme_items; + ThemeItemImportTree *import_default_theme_items = nullptr; + ThemeItemImportTree *import_editor_theme_items = nullptr; + ThemeItemImportTree *import_other_theme_items = nullptr; - LineEdit *import_another_theme_value; - Button *import_another_theme_button; - EditorFileDialog *import_another_theme_dialog; + LineEdit *import_another_theme_value = nullptr; + Button *import_another_theme_button = nullptr; + EditorFileDialog *import_another_theme_dialog = nullptr; - ConfirmationDialog *confirm_closing_dialog; + ConfirmationDialog *confirm_closing_dialog = nullptr; void ok_pressed() override; void _close_dialog(); @@ -288,9 +288,9 @@ class ThemeTypeDialog : public ConfirmationDialog { String pre_submitted_value; - LineEdit *add_type_filter; - ItemList *add_type_options; - ConfirmationDialog *add_type_confirmation; + LineEdit *add_type_filter = nullptr; + ItemList *add_type_options = nullptr; + ConfirmationDialog *add_type_confirmation = nullptr; void _dialog_about_to_show(); void ok_pressed() override; @@ -332,22 +332,22 @@ class ThemeTypeEditor : public MarginContainer { LeadingStylebox leading_stylebox; - OptionButton *theme_type_list; - Button *add_type_button; + OptionButton *theme_type_list = nullptr; + Button *add_type_button = nullptr; - CheckButton *show_default_items_button; + CheckButton *show_default_items_button = nullptr; - TabContainer *data_type_tabs; - VBoxContainer *color_items_list; - VBoxContainer *constant_items_list; - VBoxContainer *font_items_list; - VBoxContainer *font_size_items_list; - VBoxContainer *icon_items_list; - VBoxContainer *stylebox_items_list; + TabContainer *data_type_tabs = nullptr; + VBoxContainer *color_items_list = nullptr; + VBoxContainer *constant_items_list = nullptr; + VBoxContainer *font_items_list = nullptr; + VBoxContainer *font_size_items_list = nullptr; + VBoxContainer *icon_items_list = nullptr; + VBoxContainer *stylebox_items_list = nullptr; - LineEdit *type_variation_edit; - Button *type_variation_button; - Label *type_variation_locked; + LineEdit *type_variation_edit = nullptr; + Button *type_variation_button = nullptr; + Label *type_variation_locked = nullptr; enum TypeDialogMode { ADD_THEME_TYPE, @@ -355,10 +355,10 @@ class ThemeTypeEditor : public MarginContainer { }; TypeDialogMode add_type_mode = ADD_THEME_TYPE; - ThemeTypeDialog *add_type_dialog; + ThemeTypeDialog *add_type_dialog = nullptr; Vector<Control *> focusables; - Timer *update_debounce_timer; + Timer *update_debounce_timer = nullptr; VBoxContainer *_create_item_list(Theme::DataType p_data_type); void _update_type_list(); @@ -417,15 +417,15 @@ class ThemeEditor : public VBoxContainer { Ref<Theme> theme; - TabBar *preview_tabs; - PanelContainer *preview_tabs_content; - Button *add_preview_button; - EditorFileDialog *preview_scene_dialog; + TabBar *preview_tabs = nullptr; + PanelContainer *preview_tabs_content = nullptr; + Button *add_preview_button = nullptr; + EditorFileDialog *preview_scene_dialog = nullptr; - ThemeTypeEditor *theme_type_editor; + ThemeTypeEditor *theme_type_editor = nullptr; - Label *theme_name; - ThemeItemEditorDialog *theme_edit_dialog; + Label *theme_name = nullptr; + ThemeItemEditorDialog *theme_edit_dialog = nullptr; void _theme_save_button_cbk(bool p_save_as); void _theme_edit_button_cbk(); @@ -452,8 +452,8 @@ public: class ThemeEditorPlugin : public EditorPlugin { GDCLASS(ThemeEditorPlugin, EditorPlugin); - ThemeEditor *theme_editor; - Button *button; + ThemeEditor *theme_editor = nullptr; + Button *button = nullptr; public: virtual String get_name() const override { return "Theme"; } diff --git a/editor/plugins/theme_editor_preview.h b/editor/plugins/theme_editor_preview.h index 48111df399..d05916afae 100644 --- a/editor/plugins/theme_editor_preview.h +++ b/editor/plugins/theme_editor_preview.h @@ -41,10 +41,10 @@ class ThemeEditorPreview : public VBoxContainer { GDCLASS(ThemeEditorPreview, VBoxContainer); - ScrollContainer *preview_container; - ColorRect *preview_bg; - MarginContainer *preview_overlay; - Control *picker_overlay; + ScrollContainer *preview_container = nullptr; + ColorRect *preview_bg = nullptr; + MarginContainer *preview_overlay = nullptr; + Control *picker_overlay = nullptr; Control *hovered_control = nullptr; struct ThemeCache { @@ -69,9 +69,9 @@ class ThemeEditorPreview : public VBoxContainer { void _reset_picker_overlay(); protected: - HBoxContainer *preview_toolbar; - MarginContainer *preview_content; - Button *picker_button; + HBoxContainer *preview_toolbar = nullptr; + MarginContainer *preview_content = nullptr; + Button *picker_button = nullptr; void add_preview_overlay(Control *p_overlay); @@ -96,7 +96,7 @@ class SceneThemeEditorPreview : public ThemeEditorPreview { Ref<PackedScene> loaded_scene; - Button *reload_scene_button; + Button *reload_scene_button = nullptr; void _reload_scene(); diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h index 6cf555247d..9502d93f6b 100644 --- a/editor/plugins/tiles/atlas_merging_dialog.h +++ b/editor/plugins/tiles/atlas_merging_dialog.h @@ -49,19 +49,19 @@ private: LocalVector<Map<Vector2i, Vector2i>> merged_mapping; Ref<TileSet> tile_set; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; // Settings. int next_line_after_column = 30; // GUI. - ItemList *atlas_merging_atlases_list; - EditorPropertyVector2i *texture_region_size_editor_property; - EditorPropertyInteger *columns_editor_property; - TextureRect *preview; - Label *select_2_atlases_label; - EditorFileDialog *editor_file_dialog; - Button *merge_button; + ItemList *atlas_merging_atlases_list = nullptr; + EditorPropertyVector2i *texture_region_size_editor_property = nullptr; + EditorPropertyInteger *columns_editor_property = nullptr; + TextureRect *preview = nullptr; + Label *select_2_atlases_label = nullptr; + EditorFileDialog *editor_file_dialog = nullptr; + Button *merge_button = nullptr; void _property_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing); diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index caf3ef9e4b..6e74858b08 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -45,8 +45,8 @@ class TileAtlasView : public Control { GDCLASS(TileAtlasView, Control); private: - TileSet *tile_set; - TileSetAtlasSource *tile_set_atlas_source; + TileSet *tile_set = nullptr; + TileSetAtlasSource *tile_set_atlas_source = nullptr; int source_id = TileSet::INVALID_SOURCE; enum DragType { @@ -55,9 +55,9 @@ private: }; DragType drag_type = DRAG_TYPE_NONE; float previous_zoom = 1.0; - EditorZoomWidget *zoom_widget; - Button *button_center_view; - CenterContainer *center_container; + EditorZoomWidget *zoom_widget = nullptr; + Button *button_center_view = nullptr; + CenterContainer *center_container = nullptr; Vector2 panning; void _update_zoom_and_panning(bool p_zoom_on_mouse_pos = false); void _zoom_widget_changed(); @@ -72,41 +72,41 @@ private: Map<Vector2, Map<int, Rect2i>> alternative_tiles_rect_cache; void _update_alternative_tiles_rect_cache(); - MarginContainer *margin_container; + MarginContainer *margin_container = nullptr; int margin_container_paddings[4] = { 0, 0, 0, 0 }; - HBoxContainer *hbox; - Label *missing_source_label; + HBoxContainer *hbox = nullptr; + Label *missing_source_label = nullptr; // Background - Control *background_left; + Control *background_left = nullptr; void _draw_background_left(); - Control *background_right; + Control *background_right = nullptr; void _draw_background_right(); // Left side. - Control *base_tiles_root_control; + Control *base_tiles_root_control = nullptr; void _base_tiles_root_control_gui_input(const Ref<InputEvent> &p_event); - Control *base_tiles_drawing_root; + Control *base_tiles_drawing_root = nullptr; - Control *base_tiles_draw; + Control *base_tiles_draw = nullptr; void _draw_base_tiles(); - Control *base_tiles_texture_grid; + Control *base_tiles_texture_grid = nullptr; void _draw_base_tiles_texture_grid(); - Control *base_tiles_shape_grid; + Control *base_tiles_shape_grid = nullptr; void _draw_base_tiles_shape_grid(); Size2i _compute_base_tiles_control_size(); // Right side. - Control *alternative_tiles_root_control; + Control *alternative_tiles_root_control = nullptr; void _alternative_tiles_root_control_gui_input(const Ref<InputEvent> &p_event); - Control *alternative_tiles_drawing_root; + Control *alternative_tiles_drawing_root = nullptr; - Control *alternatives_draw; + Control *alternatives_draw = nullptr; void _draw_alternatives(); Size2i _compute_alternative_tiles_control_size(); diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 99724760a7..3ac9eacb05 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -93,7 +93,7 @@ private: bool multiple_polygon_mode = false; bool use_undo_redo = true; - UndoRedo *editor_undo_redo; + UndoRedo *editor_undo_redo = nullptr; // UI int hovered_polygon_index = -1; @@ -113,20 +113,20 @@ private: Vector2 drag_last_pos; PackedVector2Array drag_old_polygon; - HBoxContainer *toolbar; + HBoxContainer *toolbar = nullptr; Ref<ButtonGroup> tools_button_group; - Button *button_create; - Button *button_edit; - Button *button_delete; - Button *button_pixel_snap; - MenuButton *button_advanced_menu; + Button *button_create = nullptr; + Button *button_edit = nullptr; + Button *button_delete = nullptr; + Button *button_pixel_snap = nullptr; + MenuButton *button_advanced_menu = nullptr; Vector<Point2> in_creation_polygon; - Panel *panel; - Control *base_control; - EditorZoomWidget *editor_zoom_widget; - Button *button_center_view; + Panel *panel = nullptr; + Control *base_control = nullptr; + EditorZoomWidget *editor_zoom_widget = nullptr; + Button *button_center_view = nullptr; Vector2 panning; Ref<Texture2D> background_texture; @@ -188,12 +188,12 @@ class TileDataDefaultEditor : public TileDataEditor { private: // Toolbar HBoxContainer *toolbar = memnew(HBoxContainer); - Button *picker_button; + Button *picker_button = nullptr; // UI Ref<Texture2D> tile_bool_checked; Ref<Texture2D> tile_bool_unchecked; - Label *label; + Label *label = nullptr; EditorProperty *property_editor = nullptr; @@ -214,7 +214,7 @@ private: protected: DummyObject *dummy_object = memnew(DummyObject); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; StringName type; String property; @@ -268,7 +268,7 @@ private: int occlusion_layer = -1; // UI - GenericTilePolygonEditor *polygon_editor; + GenericTilePolygonEditor *polygon_editor = nullptr; void _polygon_changed(PackedVector2Array p_polygon); @@ -279,7 +279,7 @@ private: virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; protected: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; virtual void _tile_set_changed() override; @@ -299,7 +299,7 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { int physics_layer = -1; // UI - GenericTilePolygonEditor *polygon_editor; + GenericTilePolygonEditor *polygon_editor = nullptr; DummyObject *dummy_object = memnew(DummyObject); Map<StringName, EditorProperty *> property_editors; @@ -314,7 +314,7 @@ class TileDataCollisionEditor : public TileDataDefaultEditor { virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; protected: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; virtual void _tile_set_changed() override; @@ -335,7 +335,7 @@ class TileDataTerrainsEditor : public TileDataEditor { private: // Toolbar HBoxContainer *toolbar = memnew(HBoxContainer); - Button *picker_button; + Button *picker_button = nullptr; // Painting state. enum DragType { @@ -352,7 +352,7 @@ private: Variant drag_painted_value; // UI - Label *label; + Label *label = nullptr; DummyObject *dummy_object = memnew(DummyObject); EditorPropertyEnum *terrain_set_property_editor = nullptr; EditorPropertyEnum *terrain_property_editor = nullptr; @@ -366,7 +366,7 @@ protected: void _notification(int p_what); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; public: virtual Control *get_toolbar() override { return toolbar; }; @@ -388,7 +388,7 @@ private: PackedVector2Array navigation_polygon; // UI - GenericTilePolygonEditor *polygon_editor; + GenericTilePolygonEditor *polygon_editor = nullptr; void _polygon_changed(PackedVector2Array p_polygon); @@ -399,7 +399,7 @@ private: virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, Map<TileMapCell, Variant> p_previous_values, Variant p_new_value) override; protected: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; virtual void _tile_set_changed() override; diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index d09061015f..3a0293f48f 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -51,8 +51,8 @@ class UndoRedo; class TileMapEditorPlugin : public Object { public: struct TabData { - Control *toolbar; - Control *panel; + Control *toolbar = nullptr; + Control *panel = nullptr; }; virtual Vector<TabData> get_tabs() const { @@ -69,33 +69,33 @@ class TileMapEditorTilesPlugin : public TileMapEditorPlugin { GDCLASS(TileMapEditorTilesPlugin, TileMapEditorPlugin); private: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; ObjectID tile_map_id; int tile_map_layer = -1; virtual void edit(ObjectID p_tile_map_id, int p_tile_map_layer) override; ///// Toolbar ///// - HBoxContainer *toolbar; + HBoxContainer *toolbar = nullptr; Ref<ButtonGroup> tool_buttons_group; - Button *select_tool_button; - Button *paint_tool_button; - Button *line_tool_button; - Button *rect_tool_button; - Button *bucket_tool_button; + Button *select_tool_button = nullptr; + Button *paint_tool_button = nullptr; + Button *line_tool_button = nullptr; + Button *rect_tool_button = nullptr; + Button *bucket_tool_button = nullptr; - HBoxContainer *tools_settings; + HBoxContainer *tools_settings = nullptr; - VSeparator *tools_settings_vsep; - Button *picker_button; - Button *erase_button; + VSeparator *tools_settings_vsep = nullptr; + Button *picker_button = nullptr; + Button *erase_button = nullptr; - VSeparator *tools_settings_vsep_2; - CheckBox *bucket_contiguous_checkbox; - CheckBox *random_tile_checkbox; + VSeparator *tools_settings_vsep_2 = nullptr; + CheckBox *bucket_contiguous_checkbox = nullptr; + CheckBox *random_tile_checkbox = nullptr; float scattering = 0.0; - Label *scatter_label; - SpinBox *scatter_spinbox; + Label *scatter_label = nullptr; + SpinBox *scatter_spinbox = nullptr; void _on_random_tile_checkbox_toggled(bool p_pressed); void _on_scattering_spinbox_changed(double p_value); @@ -148,12 +148,12 @@ private: void _tab_changed(); ///// Bottom panel tiles //// - VBoxContainer *tiles_bottom_panel; - Label *missing_source_label; - Label *invalid_source_label; + VBoxContainer *tiles_bottom_panel = nullptr; + Label *missing_source_label = nullptr; + Label *invalid_source_label = nullptr; - ItemList *sources_list; - MenuButton *source_sort_button; + ItemList *sources_list = nullptr; + MenuButton *source_sort_button = nullptr; Ref<Texture2D> missing_atlas_texture_icon; void _update_tile_set_sources_list(); @@ -162,18 +162,18 @@ private: // Atlas sources. TileMapCell hovered_tile; - TileAtlasView *tile_atlas_view; - HSplitContainer *atlas_sources_split_container; + TileAtlasView *tile_atlas_view = nullptr; + HSplitContainer *atlas_sources_split_container = nullptr; bool tile_set_dragging_selection = false; Vector2i tile_set_drag_start_mouse_pos; - Control *tile_atlas_control; + Control *tile_atlas_control = nullptr; void _tile_atlas_control_mouse_exited(); void _tile_atlas_control_gui_input(const Ref<InputEvent> &p_event); void _tile_atlas_control_draw(); - Control *alternative_tiles_control; + Control *alternative_tiles_control = nullptr; void _tile_alternatives_control_draw(); void _tile_alternatives_control_mouse_exited(); void _tile_alternatives_control_gui_input(const Ref<InputEvent> &p_event); @@ -182,7 +182,7 @@ private: void _set_source_sort(int p_sort); // Scenes collection sources. - ItemList *scene_tiles_list; + ItemList *scene_tiles_list = nullptr; void _update_scenes_collection_view(); void _scene_thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud); @@ -190,9 +190,9 @@ private: void _scenes_list_nothing_selected(); ///// Bottom panel patterns //// - VBoxContainer *patterns_bottom_panel; - ItemList *patterns_item_list; - Label *patterns_help_label; + VBoxContainer *patterns_bottom_panel = nullptr; + ItemList *patterns_item_list = nullptr; + Label *patterns_help_label = nullptr; void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event); void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture); bool select_last_pattern = false; @@ -220,32 +220,32 @@ class TileMapEditorTerrainsPlugin : public TileMapEditorPlugin { GDCLASS(TileMapEditorTerrainsPlugin, TileMapEditorPlugin); private: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; ObjectID tile_map_id; int tile_map_layer = -1; virtual void edit(ObjectID p_tile_map_id, int p_tile_map_layer) override; // Toolbar. - HBoxContainer *toolbar; + HBoxContainer *toolbar = nullptr; Ref<ButtonGroup> tool_buttons_group; - Button *paint_tool_button; - Button *line_tool_button; - Button *rect_tool_button; - Button *bucket_tool_button; + Button *paint_tool_button = nullptr; + Button *line_tool_button = nullptr; + Button *rect_tool_button = nullptr; + Button *bucket_tool_button = nullptr; - HBoxContainer *tools_settings; + HBoxContainer *tools_settings = nullptr; - VSeparator *tools_settings_vsep; - Button *picker_button; - Button *erase_button; + VSeparator *tools_settings_vsep = nullptr; + Button *picker_button = nullptr; + Button *erase_button = nullptr; - VSeparator *tools_settings_vsep_2; - CheckBox *bucket_contiguous_checkbox; + VSeparator *tools_settings_vsep_2 = nullptr; + CheckBox *bucket_contiguous_checkbox = nullptr; void _update_toolbar(); // Main vbox. - VBoxContainer *main_vbox_container; + VBoxContainer *main_vbox_container = nullptr; // TileMap editing. bool has_mouse = false; @@ -278,8 +278,8 @@ private: void _update_selection(); // Bottom panel. - Tree *terrains_tree; - ItemList *terrains_tile_list; + Tree *terrains_tree = nullptr; + ItemList *terrains_tile_list = nullptr; // Cache. LocalVector<LocalVector<Set<TileSet::TerrainsPattern>>> per_terrain_terrains_patterns; @@ -306,7 +306,7 @@ class TileMapEditor : public VBoxContainer { GDCLASS(TileMapEditor, VBoxContainer); private: - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; bool tileset_changed_needs_update = false; ObjectID tile_map_id; int tile_map_layer = -1; @@ -315,24 +315,24 @@ private: Vector<TileMapEditorPlugin *> tile_map_editor_plugins; // Toolbar. - HBoxContainer *tile_map_toolbar; + HBoxContainer *tile_map_toolbar = nullptr; - PopupMenu *layers_selection_popup; - Button *layers_selection_button; - Button *toogle_highlight_selected_layer_button; + PopupMenu *layers_selection_popup = nullptr; + Button *layers_selection_button = nullptr; + Button *toogle_highlight_selected_layer_button = nullptr; void _layers_selection_button_draw(); void _layers_selection_button_pressed(); void _layers_selection_id_pressed(int p_id); - Button *toggle_grid_button; + Button *toggle_grid_button = nullptr; void _on_grid_toggled(bool p_pressed); - MenuButton *advanced_menu_button; + MenuButton *advanced_menu_button = nullptr; void _advanced_menu_button_id_pressed(int p_id); // Bottom panel. - Label *missing_tileset_label; - TabBar *tabs_bar; + Label *missing_tileset_label = nullptr; + TabBar *tabs_bar = nullptr; LocalVector<TileMapEditorPlugin::TabData> tabs_data; LocalVector<TileMapEditorPlugin *> tabs_plugins; void _update_bottom_panel(); diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.h b/editor/plugins/tiles/tile_proxies_manager_dialog.h index 3f1461391e..00866544be 100644 --- a/editor/plugins/tiles/tile_proxies_manager_dialog.h +++ b/editor/plugins/tiles/tile_proxies_manager_dialog.h @@ -43,24 +43,24 @@ private: int commited_actions_count = 0; Ref<TileSet> tile_set; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; TileMapCell from; TileMapCell to; // GUI - ItemList *source_level_list; - ItemList *coords_level_list; - ItemList *alternative_level_list; + ItemList *source_level_list = nullptr; + ItemList *coords_level_list = nullptr; + ItemList *alternative_level_list = nullptr; - EditorPropertyInteger *source_from_property_editor; - EditorPropertyVector2i *coords_from_property_editor; - EditorPropertyInteger *alternative_from_property_editor; - EditorPropertyInteger *source_to_property_editor; - EditorPropertyVector2i *coords_to_property_editor; - EditorPropertyInteger *alternative_to_property_editor; + EditorPropertyInteger *source_from_property_editor = nullptr; + EditorPropertyVector2i *coords_from_property_editor = nullptr; + EditorPropertyInteger *alternative_from_property_editor = nullptr; + EditorPropertyInteger *source_to_property_editor = nullptr; + EditorPropertyVector2i *coords_to_property_editor = nullptr; + EditorPropertyInteger *alternative_to_property_editor = nullptr; - PopupMenu *popup_menu; + PopupMenu *popup_menu = nullptr; void _right_clicked(int p_item, Vector2 p_local_mouse_pos, Object *p_item_list); void _menu_id_pressed(int p_id); void _delete_selected_bindings(); diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 4a90b821f8..b26b7edbfa 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -85,7 +85,7 @@ public: GDCLASS(AtlasTileProxyObject, Object); private: - TileSetAtlasSourceEditor *tiles_set_atlas_source_editor; + TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr; TileSetAtlasSource *tile_set_atlas_source = nullptr; Set<TileSelection> tiles = Set<TileSelection>(); @@ -114,16 +114,16 @@ private: TileSetAtlasSource *tile_set_atlas_source = nullptr; int tile_set_atlas_source_id = TileSet::INVALID_SOURCE; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; bool tile_set_changed_needs_update = false; // -- Properties painting -- - VBoxContainer *tile_data_painting_editor_container; - Label *tile_data_editors_label; - Button *tile_data_editor_dropdown_button; - Popup *tile_data_editors_popup; - Tree *tile_data_editors_tree; + VBoxContainer *tile_data_painting_editor_container = nullptr; + Label *tile_data_editors_label = nullptr; + Button *tile_data_editor_dropdown_button = nullptr; + Popup *tile_data_editors_popup = nullptr; + Tree *tile_data_editors_tree = nullptr; void _tile_data_editor_dropdown_button_draw(); void _tile_data_editor_dropdown_button_pressed(); @@ -135,21 +135,21 @@ private: void _tile_data_editors_tree_selected(); // -- Inspector -- - AtlasTileProxyObject *tile_proxy_object; - Label *tile_inspector_label; - EditorInspector *tile_inspector; - Label *tile_inspector_no_tile_selected_label; + AtlasTileProxyObject *tile_proxy_object = nullptr; + Label *tile_inspector_label = nullptr; + EditorInspector *tile_inspector = nullptr; + Label *tile_inspector_no_tile_selected_label = nullptr; String selected_property; void _inspector_property_selected(String p_property); - TileSetAtlasSourceProxyObject *atlas_source_proxy_object; - Label *atlas_source_inspector_label; - EditorInspector *atlas_source_inspector; + TileSetAtlasSourceProxyObject *atlas_source_proxy_object = nullptr; + Label *atlas_source_inspector_label = nullptr; + EditorInspector *atlas_source_inspector = nullptr; // -- Atlas view -- - HBoxContainer *toolbox; - Label *tile_atlas_view_missing_source_label; - TileAtlasView *tile_atlas_view; + HBoxContainer *toolbox = nullptr; + Label *tile_atlas_view_missing_source_label = nullptr; + TileAtlasView *tile_atlas_view = nullptr; // Dragging enum DragType { @@ -202,17 +202,17 @@ private: // Tool buttons. Ref<ButtonGroup> tools_button_group; - Button *tool_setup_atlas_source_button; - Button *tool_select_button; - Button *tool_paint_button; - Label *tool_tile_id_label; + Button *tool_setup_atlas_source_button = nullptr; + Button *tool_select_button = nullptr; + Button *tool_paint_button = nullptr; + Label *tool_tile_id_label = nullptr; // Tool settings. - HBoxContainer *tool_settings; - VSeparator *tool_settings_vsep; - HBoxContainer *tool_settings_tile_data_toolbar_container; - Button *tools_settings_erase_button; - MenuButton *tool_advanced_menu_buttom; + HBoxContainer *tool_settings = nullptr; + VSeparator *tool_settings_vsep = nullptr; + HBoxContainer *tool_settings_tile_data_toolbar_container = nullptr; + Button *tools_settings_erase_button = nullptr; + MenuButton *tool_advanced_menu_buttom = nullptr; // Selection. Set<TileSelection> selection; @@ -223,12 +223,12 @@ private: // A control on the tile atlas to draw and handle input events. Vector2i hovered_base_tile_coords = TileSetSource::INVALID_ATLAS_COORDS; - PopupMenu *base_tile_popup_menu; - PopupMenu *empty_base_tile_popup_menu; + PopupMenu *base_tile_popup_menu = nullptr; + PopupMenu *empty_base_tile_popup_menu = nullptr; Ref<Texture2D> resize_handle; Ref<Texture2D> resize_handle_disabled; - Control *tile_atlas_control; - Control *tile_atlas_control_unscaled; + Control *tile_atlas_control = nullptr; + Control *tile_atlas_control_unscaled = nullptr; void _tile_atlas_control_draw(); void _tile_atlas_control_unscaled_draw(); void _tile_atlas_control_mouse_exited(); @@ -238,9 +238,9 @@ private: // A control over the alternative tiles. Vector3i hovered_alternative_tile_coords = Vector3i(TileSetSource::INVALID_ATLAS_COORDS.x, TileSetSource::INVALID_ATLAS_COORDS.y, TileSetSource::INVALID_TILE_ALTERNATIVE); - PopupMenu *alternative_tile_popup_menu; - Control *alternative_tiles_control; - Control *alternative_tiles_control_unscaled; + PopupMenu *alternative_tile_popup_menu = nullptr; + Control *alternative_tiles_control = nullptr; + Control *alternative_tiles_control_unscaled = nullptr; void _tile_alternatives_control_draw(); void _tile_alternatives_control_unscaled_draw(); void _tile_alternatives_control_mouse_exited(); @@ -264,7 +264,7 @@ private: // -- Misc -- void _auto_create_tiles(); void _auto_remove_tiles(); - AcceptDialog *confirm_auto_create_tiles; + AcceptDialog *confirm_auto_create_tiles = nullptr; void _tile_set_changed(); void _tile_proxy_object_changed(String p_what); @@ -293,7 +293,7 @@ class EditorPropertyTilePolygon : public EditorProperty { void _add_focusable_children(Node *p_node); - GenericTilePolygonEditor *generic_tile_polygon_editor; + GenericTilePolygonEditor *generic_tile_polygon_editor = nullptr; void _polygons_changed(); public: diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index b79b37cf2e..e633de37b0 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -47,18 +47,18 @@ class TileSetEditor : public VBoxContainer { private: Ref<TileSet> tile_set; bool tile_set_changed_needs_update = false; - HSplitContainer *split_container; + HSplitContainer *split_container = nullptr; // TabBar. - HBoxContainer *tile_set_toolbar; - TabBar *tabs_bar; + HBoxContainer *tile_set_toolbar = nullptr; + TabBar *tabs_bar = nullptr; // Tiles. - Label *no_source_selected_label; - TileSetAtlasSourceEditor *tile_set_atlas_source_editor; - TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor; + Label *no_source_selected_label = nullptr; + TileSetAtlasSourceEditor *tile_set_atlas_source_editor = nullptr; + TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; void _drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); bool _can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; @@ -66,11 +66,11 @@ private: void _update_sources_list(int force_selected_id = -1); // Sources management. - Button *sources_delete_button; - MenuButton *sources_add_button; - MenuButton *source_sort_button; - MenuButton *sources_advanced_menu_button; - ItemList *sources_list; + Button *sources_delete_button = nullptr; + MenuButton *sources_add_button = nullptr; + MenuButton *source_sort_button = nullptr; + MenuButton *sources_advanced_menu_button = nullptr; + ItemList *sources_list = nullptr; Ref<Texture2D> missing_texture_texture; void _source_selected(int p_source_index); void _source_delete_pressed(); @@ -78,12 +78,12 @@ private: void _sources_advanced_menu_id_pressed(int p_id_pressed); void _set_source_sort(int p_sort); - AtlasMergingDialog *atlas_merging_dialog; - TileProxiesManagerDialog *tile_proxies_manager_dialog; + AtlasMergingDialog *atlas_merging_dialog = nullptr; + TileProxiesManagerDialog *tile_proxies_manager_dialog = nullptr; // Patterns. - ItemList *patterns_item_list; - Label *patterns_help_label; + ItemList *patterns_item_list = nullptr; + Label *patterns_help_label = nullptr; void _patterns_item_list_gui_input(const Ref<InputEvent> &p_event); void _pattern_preview_done(Ref<TileMapPattern> p_pattern, Ref<Texture2D> p_texture); bool select_last_pattern = false; diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h index 8904e8524a..657bfca032 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h @@ -70,7 +70,7 @@ private: GDCLASS(SceneTileProxyObject, Object); private: - TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor; + TileSetScenesCollectionSourceEditor *tile_set_scenes_collection_source_editor = nullptr; TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr; int source_id; @@ -97,23 +97,23 @@ private: TileSetScenesCollectionSource *tile_set_scenes_collection_source = nullptr; int tile_set_source_id = -1; - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; bool tile_set_scenes_collection_source_changed_needs_update = false; // Source inspector. - TileSetScenesCollectionProxyObject *scenes_collection_source_proxy_object; - Label *scenes_collection_source_inspector_label; - EditorInspector *scenes_collection_source_inspector; + TileSetScenesCollectionProxyObject *scenes_collection_source_proxy_object = nullptr; + Label *scenes_collection_source_inspector_label = nullptr; + EditorInspector *scenes_collection_source_inspector = nullptr; // Tile inspector. - SceneTileProxyObject *tile_proxy_object; - Label *tile_inspector_label; - EditorInspector *tile_inspector; + SceneTileProxyObject *tile_proxy_object = nullptr; + Label *tile_inspector_label = nullptr; + EditorInspector *tile_inspector = nullptr; - ItemList *scene_tiles_list; - Button *scene_tile_add_button; - Button *scene_tile_delete_button; + ItemList *scene_tiles_list = nullptr; + Button *scene_tile_add_button = nullptr; + Button *scene_tile_delete_button = nullptr; void _tile_set_scenes_collection_source_changed(); void _scenes_collection_source_proxy_object_changed(String p_what); diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 4aabe0e6b7..543304346e 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -56,7 +56,7 @@ void TilesEditorPlugin::_pattern_preview_done() { } void TilesEditorPlugin::_thread_func(void *ud) { - TilesEditorPlugin *te = (TilesEditorPlugin *)ud; + TilesEditorPlugin *te = static_cast<TilesEditorPlugin *>(ud); te->_thread(); } diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index eeff4da4e9..a22e782b34 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -57,11 +57,11 @@ private: ObjectID tile_map_id; Ref<TileSet> tile_set; - Button *tilemap_editor_button; - TileMapEditor *tilemap_editor; + Button *tilemap_editor_button = nullptr; + TileMapEditor *tilemap_editor = nullptr; - Button *tileset_editor_button; - TileSetEditor *tileset_editor; + Button *tileset_editor_button = nullptr; + TileSetEditor *tileset_editor = nullptr; void _update_editors(); diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h index 956c5a334f..39a56de772 100644 --- a/editor/plugins/version_control_editor_plugin.h +++ b/editor/plugins/version_control_editor_plugin.h @@ -57,48 +57,48 @@ private: int staged_files_count; List<StringName> available_addons; - PopupMenu *version_control_actions; - ConfirmationDialog *metadata_dialog; - OptionButton *metadata_selection; - AcceptDialog *set_up_dialog; - VBoxContainer *set_up_vbc; - HBoxContainer *set_up_hbc; - Label *set_up_vcs_label; - OptionButton *set_up_choice; - PanelContainer *set_up_init_settings; - Button *set_up_init_button; - RichTextLabel *set_up_vcs_status; - Button *set_up_ok_button; + PopupMenu *version_control_actions = nullptr; + ConfirmationDialog *metadata_dialog = nullptr; + OptionButton *metadata_selection = nullptr; + AcceptDialog *set_up_dialog = nullptr; + VBoxContainer *set_up_vbc = nullptr; + HBoxContainer *set_up_hbc = nullptr; + Label *set_up_vcs_label = nullptr; + OptionButton *set_up_choice = nullptr; + PanelContainer *set_up_init_settings = nullptr; + Button *set_up_init_button = nullptr; + RichTextLabel *set_up_vcs_status = nullptr; + Button *set_up_ok_button = nullptr; HashMap<ChangeType, String> change_type_to_strings; HashMap<ChangeType, Color> change_type_to_color; - VBoxContainer *version_commit_dock; - VBoxContainer *commit_box_vbc; - HSplitContainer *stage_tools; - Tree *stage_files; - TreeItem *new_files; - TreeItem *modified_files; - TreeItem *renamed_files; - TreeItem *deleted_files; - TreeItem *typechange_files; - Label *staging_area_label; - HSplitContainer *stage_buttons; - Button *stage_all_button; - Button *stage_selected_button; - Button *refresh_button; - TextEdit *commit_message; - Button *commit_button; - Label *commit_status; - - PanelContainer *version_control_dock; - Button *version_control_dock_button; - VBoxContainer *diff_vbc; - HBoxContainer *diff_hbc; - Button *diff_refresh_button; - Label *diff_file_name; - Label *diff_heading; - RichTextLabel *diff; + VBoxContainer *version_commit_dock = nullptr; + VBoxContainer *commit_box_vbc = nullptr; + HSplitContainer *stage_tools = nullptr; + Tree *stage_files = nullptr; + TreeItem *new_files = nullptr; + TreeItem *modified_files = nullptr; + TreeItem *renamed_files = nullptr; + TreeItem *deleted_files = nullptr; + TreeItem *typechange_files = nullptr; + Label *staging_area_label = nullptr; + HSplitContainer *stage_buttons = nullptr; + Button *stage_all_button = nullptr; + Button *stage_selected_button = nullptr; + Button *refresh_button = nullptr; + TextEdit *commit_message = nullptr; + Button *commit_button = nullptr; + Label *commit_status = nullptr; + + PanelContainer *version_control_dock = nullptr; + Button *version_control_dock_button = nullptr; + VBoxContainer *diff_vbc = nullptr; + HBoxContainer *diff_hbc = nullptr; + Button *diff_refresh_button = nullptr; + Label *diff_file_name = nullptr; + Label *diff_heading = nullptr; + RichTextLabel *diff = nullptr; void _populate_available_vcs_names(); void _create_vcs_metadata_files(); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 580e71a788..1e7648bc43 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2061,10 +2061,8 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p if (!expression_node.is_null() && text_box) { Size2 box_size = size; - if (gn != nullptr) { - if (box_size.x < 150 * EDSCALE || box_size.y < 0) { - box_size.x = gn->get_size().x; - } + if (box_size.x < 150 * EDSCALE || box_size.y < 0) { + box_size.x = gn->get_size().x; } box_size.x -= text_box->get_offset(SIDE_LEFT); box_size.x -= 28 * EDSCALE; @@ -6035,8 +6033,8 @@ void VisualShaderNodePortPreview::_shader_changed() { //find if a material is also being edited and copy parameters to this one - for (int i = EditorNode::get_singleton()->get_editor_history()->get_path_size() - 1; i >= 0; i--) { - Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(i)); + for (int i = EditorNode::get_singleton()->get_editor_selection_history()->get_path_size() - 1; i >= 0; i--) { + Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_selection_history()->get_path_object(i)); ShaderMaterial *src_mat; if (!object) { continue; diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h index 67bd1d5105..621e98beef 100644 --- a/editor/plugins/voxel_gi_editor_plugin.h +++ b/editor/plugins/voxel_gi_editor_plugin.h @@ -41,12 +41,12 @@ struct EditorProgress; class VoxelGIEditorPlugin : public EditorPlugin { GDCLASS(VoxelGIEditorPlugin, EditorPlugin); - VoxelGI *voxel_gi; + VoxelGI *voxel_gi = nullptr; - HBoxContainer *bake_hb; - Button *bake; + HBoxContainer *bake_hb = nullptr; + Button *bake = nullptr; - EditorFileDialog *probe_file; + EditorFileDialog *probe_file = nullptr; static EditorProgress *tmp_progress; static void bake_func_begin(int p_steps); diff --git a/editor/pot_generator.cpp b/editor/pot_generator.cpp index f6839bae6b..5afd460831 100644 --- a/editor/pot_generator.cpp +++ b/editor/pot_generator.cpp @@ -46,8 +46,8 @@ void POTGenerator::_print_all_translation_strings() { print_line("msgid: " + E.key()); print_line("context: " + v_md[i].ctx); print_line("msgid_plural: " + v_md[i].plural); - for (Set<String>::Element *E = v_md[i].locations.front(); E; E = E->next()) { - print_line("location: " + E->get()); + for (Set<String>::Element *F = v_md[i].locations.front(); F; F = F->next()) { + print_line("location: " + F->get()); } } } diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h index 880e6bc9d4..f395750165 100644 --- a/editor/progress_dialog.h +++ b/editor/progress_dialog.h @@ -74,11 +74,11 @@ class ProgressDialog : public PopupPanel { ProgressBar *progress = nullptr; Label *state = nullptr; }; - HBoxContainer *cancel_hb; - Button *cancel; + HBoxContainer *cancel_hb = nullptr; + Button *cancel = nullptr; Map<String, Task> tasks; - VBoxContainer *main; + VBoxContainer *main = nullptr; uint64_t last_progress_tick; static ProgressDialog *singleton; diff --git a/editor/project_export.h b/editor/project_export.h index 057fd31168..4d1719d6eb 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -58,46 +58,46 @@ class ProjectExportDialog : public ConfirmationDialog { GDCLASS(ProjectExportDialog, ConfirmationDialog); private: - TabContainer *sections; + TabContainer *sections = nullptr; - MenuButton *add_preset; - Button *duplicate_preset; - Button *delete_preset; - ItemList *presets; + MenuButton *add_preset = nullptr; + Button *duplicate_preset = nullptr; + Button *delete_preset = nullptr; + ItemList *presets = nullptr; - LineEdit *name; - EditorPropertyPath *export_path; - EditorInspector *parameters; - CheckButton *runnable; + LineEdit *name = nullptr; + EditorPropertyPath *export_path = nullptr; + EditorInspector *parameters = nullptr; + CheckButton *runnable = nullptr; - Button *button_export; + Button *button_export = nullptr; bool updating = false; - AcceptDialog *error_dialog; - ConfirmationDialog *delete_confirm; + AcceptDialog *error_dialog = nullptr; + ConfirmationDialog *delete_confirm = nullptr; - OptionButton *export_filter; - LineEdit *include_filters; - LineEdit *exclude_filters; - Tree *include_files; + OptionButton *export_filter = nullptr; + LineEdit *include_filters = nullptr; + LineEdit *exclude_filters = nullptr; + Tree *include_files = nullptr; - Label *include_label; - MarginContainer *include_margin; + Label *include_label = nullptr; + MarginContainer *include_margin = nullptr; - Button *export_button; - Button *export_all_button; - AcceptDialog *export_all_dialog; + Button *export_button = nullptr; + Button *export_all_button = nullptr; + AcceptDialog *export_all_dialog = nullptr; - LineEdit *custom_features; - RichTextLabel *custom_feature_display; + LineEdit *custom_features = nullptr; + RichTextLabel *custom_feature_display = nullptr; - OptionButton *script_mode; - LineEdit *script_key; - Label *script_key_error; + OptionButton *script_mode = nullptr; + LineEdit *script_key = nullptr; + Label *script_key_error = nullptr; - Label *export_error; - Label *export_warning; - HBoxContainer *export_templates_error; + Label *export_error = nullptr; + Label *export_warning = nullptr; + HBoxContainer *export_templates_error = nullptr; String default_filename; @@ -127,15 +127,15 @@ private: bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); - EditorFileDialog *export_pck_zip; - EditorFileDialog *export_project; - CheckBox *export_debug; - CheckBox *export_pck_zip_debug; + EditorFileDialog *export_pck_zip = nullptr; + EditorFileDialog *export_project = nullptr; + CheckBox *export_debug = nullptr; + CheckBox *export_pck_zip_debug = nullptr; - CheckButton *enc_pck; - CheckButton *enc_directory; - LineEdit *enc_in_filters; - LineEdit *enc_ex_filters; + CheckButton *enc_pck = nullptr; + CheckButton *enc_directory = nullptr; + LineEdit *enc_in_filters = nullptr; + LineEdit *enc_ex_filters = nullptr; void _open_export_template_manager(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index cd95f97286..501cb88547 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -202,6 +202,9 @@ private: unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } if (String::utf8(fname).ends_with("project.godot")) { break; @@ -534,6 +537,9 @@ private: unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0); + if (ret != UNZ_OK) { + break; + } String path = String::utf8(fname); @@ -552,7 +558,10 @@ private: //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptrw(), data.size()); + ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); + if (ret != UNZ_OK) { + break; + } unzCloseCurrentFile(pkg); FileAccess *f = FileAccess::open(dir.plus_file(rel_path), FileAccess::WRITE); @@ -1903,7 +1912,7 @@ void ProjectManager::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - set_process_unhandled_key_input(is_visible_in_tree()); + set_process_shortcut_input(is_visible_in_tree()); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { @@ -1962,7 +1971,7 @@ void ProjectManager::_update_project_buttons() { erase_missing_btn->set_disabled(!_project_list->is_any_project_missing()); } -void ProjectManager::unhandled_key_input(const Ref<InputEvent> &p_ev) { +void ProjectManager::shortcut_input(const Ref<InputEvent> &p_ev) { ERR_FAIL_COND(p_ev.is_null()); Ref<InputEventKey> k = p_ev; diff --git a/editor/project_manager.h b/editor/project_manager.h index 4f053793fd..9cea6e163f 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -126,7 +126,7 @@ class ProjectManager : public Control { void _install_project(const String &p_zip_path, const String &p_title); void _dim_window(); - virtual void unhandled_key_input(const Ref<InputEvent> &p_ev) override; + virtual void shortcut_input(const Ref<InputEvent> &p_ev) override; void _files_dropped(PackedStringArray p_files, int p_screen); void _version_button_pressed(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 1318287dc8..fa83a58cff 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -49,7 +49,7 @@ void ProjectSettingsEditor::popup_project_settings() { _add_feature_overrides(); general_settings_inspector->update_category_list(); - set_process_unhandled_input(true); + set_process_shortcut_input(true); localization_editor->update_translations(); autoload_settings->update_autoload(); @@ -202,7 +202,7 @@ void ProjectSettingsEditor::_select_type(Variant::Type p_type) { type_box->select(type_box->get_item_index(p_type)); } -void ProjectSettingsEditor::unhandled_input(const Ref<InputEvent> &p_event) { +void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); const Ref<InputEventKey> k = p_event; @@ -351,7 +351,7 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar undo_redo->create_action(TTR("Edit Input Action Event")); } else if (event_count > old_event_count) { undo_redo->create_action(TTR("Add Input Action Event")); - } else if (event_count < old_event_count) { + } else { undo_redo->create_action(TTR("Remove Input Action Event")); } diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 5dc1ddc0a8..24d61db443 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -47,34 +47,34 @@ class ProjectSettingsEditor : public AcceptDialog { GDCLASS(ProjectSettingsEditor, AcceptDialog); static ProjectSettingsEditor *singleton; - ProjectSettings *ps; - Timer *timer; - - TabContainer *tab_container; - SectionedInspector *general_settings_inspector; - ActionMapEditor *action_map_editor; - LocalizationEditor *localization_editor; - EditorAutoloadSettings *autoload_settings; - ShaderGlobalsEditor *shaders_global_variables_editor; - EditorPluginSettings *plugin_settings; - - LineEdit *search_box; - CheckButton *advanced; - - LineEdit *property_box; - OptionButton *feature_box; - OptionButton *type_box; - Button *add_button; - Button *del_button; - - Label *restart_label; - TextureRect *restart_icon; - PanelContainer *restart_container; - Button *restart_close_button; - - ImportDefaultsEditor *import_defaults_editor; - EditorData *data; - UndoRedo *undo_redo; + ProjectSettings *ps = nullptr; + Timer *timer = nullptr; + + TabContainer *tab_container = nullptr; + SectionedInspector *general_settings_inspector = nullptr; + ActionMapEditor *action_map_editor = nullptr; + LocalizationEditor *localization_editor = nullptr; + EditorAutoloadSettings *autoload_settings = nullptr; + ShaderGlobalsEditor *shaders_global_variables_editor = nullptr; + EditorPluginSettings *plugin_settings = nullptr; + + LineEdit *search_box = nullptr; + CheckButton *advanced = nullptr; + + LineEdit *property_box = nullptr; + OptionButton *feature_box = nullptr; + OptionButton *type_box = nullptr; + Button *add_button = nullptr; + Button *del_button = nullptr; + + Label *restart_label = nullptr; + TextureRect *restart_icon = nullptr; + PanelContainer *restart_container = nullptr; + Button *restart_close_button = nullptr; + + ImportDefaultsEditor *import_defaults_editor = nullptr; + EditorData *data = nullptr; + UndoRedo *undo_redo = nullptr; void _advanced_toggled(bool p_button_pressed); void _property_box_changed(const String &p_text); @@ -82,7 +82,7 @@ class ProjectSettingsEditor : public AcceptDialog { void _feature_selected(int p_index); void _select_type(Variant::Type p_type); - virtual void unhandled_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; String _get_setting_name() const; void _setting_edited(const String &p_name); diff --git a/editor/property_editor.h b/editor/property_editor.h index 73306e0bc2..1a4d88f7fa 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -95,11 +95,11 @@ class CustomPropertyEditor : public PopupPanel { EASING_OUT_IN }; - PopupMenu *menu; - SceneTreeDialog *scene_tree; - EditorFileDialog *file; - EditorLocaleDialog *locale; - ConfirmationDialog *error; + PopupMenu *menu = nullptr; + SceneTreeDialog *scene_tree = nullptr; + EditorFileDialog *file = nullptr; + EditorLocaleDialog *locale = nullptr; + ConfirmationDialog *error = nullptr; String name; Variant::Type type; Variant v; @@ -107,34 +107,34 @@ class CustomPropertyEditor : public PopupPanel { int hint; String hint_text; HBoxContainer *value_hboxes[MAX_VALUE_EDITORS / 4]; - VBoxContainer *value_vbox; + VBoxContainer *value_vbox = nullptr; LineEdit *value_editor[MAX_VALUE_EDITORS]; int focused_value_editor; Label *value_label[MAX_VALUE_EDITORS]; HScrollBar *scroll[4]; - HBoxContainer *action_hboxes; + HBoxContainer *action_hboxes = nullptr; Button *action_buttons[MAX_ACTION_BUTTONS]; - MenuButton *type_button; + MenuButton *type_button = nullptr; Vector<String> inheritors_array; - TextureRect *texture_preview; - ColorPicker *color_picker; - TextEdit *text_edit; + TextureRect *texture_preview = nullptr; + ColorPicker *color_picker = nullptr; + TextEdit *text_edit = nullptr; bool read_only = false; bool picking_viewport; - GridContainer *checks20gc; + GridContainer *checks20gc = nullptr; CheckBox *checks20[20]; - SpinBox *spinbox; - HSlider *slider; + SpinBox *spinbox = nullptr; + HSlider *slider = nullptr; - Control *easing_draw; - CreateDialog *create_dialog; - PropertySelector *property_select; + Control *easing_draw = nullptr; + CreateDialog *create_dialog = nullptr; + PropertySelector *property_select = nullptr; - Object *owner; + Object *owner = nullptr; bool updating = false; - PropertyValueEvaluator *evaluator; + PropertyValueEvaluator *evaluator = nullptr; void _text_edit_changed(); void _file_selected(String p_file); diff --git a/editor/property_selector.h b/editor/property_selector.h index 7e629a847e..597804da31 100644 --- a/editor/property_selector.h +++ b/editor/property_selector.h @@ -38,8 +38,8 @@ class PropertySelector : public ConfirmationDialog { GDCLASS(PropertySelector, ConfirmationDialog); - LineEdit *search_box; - Tree *search_options; + LineEdit *search_box = nullptr; + Tree *search_options = nullptr; void _text_changed(const String &p_newtext); void _sbox_input(const Ref<InputEvent> &p_ie); @@ -48,14 +48,14 @@ class PropertySelector : public ConfirmationDialog { void _item_selected(); void _hide_requested(); - EditorHelpBit *help_bit; + EditorHelpBit *help_bit = nullptr; bool properties; String selected; Variant::Type type; String base_type; ObjectID script; - Object *instance; + Object *instance = nullptr; bool virtuals_only = false; Vector<Variant::Type> type_filter; diff --git a/editor/quick_open.h b/editor/quick_open.h index f50f09604c..843ef47711 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -39,8 +39,8 @@ class EditorQuickOpen : public ConfirmationDialog { GDCLASS(EditorQuickOpen, ConfirmationDialog); - LineEdit *search_box; - Tree *search_options; + LineEdit *search_box = nullptr; + Tree *search_options = nullptr; StringName base_type; bool allow_multi_select = false; diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index c9747795f0..d05e80fc04 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -62,41 +62,41 @@ class RenameDialog : public ConfirmationDialog { void _update_preview_int(int new_value = 0); static void _error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, bool p_editor_notify, ErrorHandlerType p_type); - SceneTreeEditor *scene_tree_editor; - UndoRedo *undo_redo; + SceneTreeEditor *scene_tree_editor = nullptr; + UndoRedo *undo_redo = nullptr; int global_count; - LineEdit *lne_search; - LineEdit *lne_replace; - LineEdit *lne_prefix; - LineEdit *lne_suffix; + LineEdit *lne_search = nullptr; + LineEdit *lne_replace = nullptr; + LineEdit *lne_prefix = nullptr; + LineEdit *lne_suffix = nullptr; - TabContainer *tabc_features; + TabContainer *tabc_features = nullptr; - CheckBox *cbut_substitute; - CheckButton *cbut_regex; - CheckBox *cbut_process; - CheckBox *chk_per_level_counter; + CheckBox *cbut_substitute = nullptr; + CheckButton *cbut_regex = nullptr; + CheckBox *cbut_process = nullptr; + CheckBox *chk_per_level_counter = nullptr; - Button *but_insert_name; - Button *but_insert_parent; - Button *but_insert_type; - Button *but_insert_scene; - Button *but_insert_root; - Button *but_insert_count; + Button *but_insert_name = nullptr; + Button *but_insert_parent = nullptr; + Button *but_insert_type = nullptr; + Button *but_insert_scene = nullptr; + Button *but_insert_root = nullptr; + Button *but_insert_count = nullptr; - SpinBox *spn_count_start; - SpinBox *spn_count_step; - SpinBox *spn_count_padding; + SpinBox *spn_count_start = nullptr; + SpinBox *spn_count_step = nullptr; + SpinBox *spn_count_padding = nullptr; - OptionButton *opt_style; - OptionButton *opt_case; + OptionButton *opt_style = nullptr; + OptionButton *opt_case = nullptr; - Label *lbl_preview_title; - Label *lbl_preview; + Label *lbl_preview_title = nullptr; + Label *lbl_preview = nullptr; List<Pair<NodePath, String>> to_rename; - Node *preview_node; + Node *preview_node = nullptr; bool lock_preview_update; ErrorHandlerList eh; bool has_errors; diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h index 981829a871..121a86e9f0 100644 --- a/editor/reparent_dialog.h +++ b/editor/reparent_dialog.h @@ -41,8 +41,8 @@ class ReparentDialog : public ConfirmationDialog { GDCLASS(ReparentDialog, ConfirmationDialog); - SceneTreeEditor *tree; - CheckBox *keep_transform; + SceneTreeEditor *tree = nullptr; + CheckBox *keep_transform = nullptr; void _reparent(); void _cancel(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1d3b18a7d1..71ea625013 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -79,7 +79,7 @@ void SceneTreeDock::input(const Ref<InputEvent> &p_event) { } } -void SceneTreeDock::unhandled_key_input(const Ref<InputEvent> &p_event) { +void SceneTreeDock::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); if (get_viewport()->gui_get_focus_owner() && get_viewport()->gui_get_focus_owner()->is_text_field()) { @@ -2012,7 +2012,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { bool entire_scene = false; - for (Node *E : remove_list) { + for (const Node *E : remove_list) { if (E == edited_scene) { entire_scene = true; } @@ -2075,8 +2075,8 @@ void SceneTreeDock::_delete_confirm(bool p_cut) { _push_item(nullptr); - // Fixes the EditorHistory from still offering deleted notes - EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); + // Fixes the EditorSelectionHistory from still offering deleted notes + EditorSelectionHistory *editor_history = EditorNode::get_singleton()->get_editor_selection_history(); editor_history->cleanup_history(); InspectorDock::get_singleton()->call("_prepare_history"); } @@ -3476,7 +3476,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec add_child(quick_open); quick_open->connect("quick_open", callable_mp(this, &SceneTreeDock::_quick_open)); - set_process_unhandled_key_input(true); + set_process_shortcut_input(true); delete_dialog = memnew(ConfirmationDialog); add_child(delete_dialog); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 938f83725d..599fb01203 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -109,29 +109,29 @@ class SceneTreeDock : public VBoxContainer { bool reset_create_dialog = false; int current_option; - CreateDialog *create_dialog; + CreateDialog *create_dialog = nullptr; #ifdef MODULE_REGEX_ENABLED - RenameDialog *rename_dialog; + RenameDialog *rename_dialog = nullptr; #endif // MODULE_REGEX_ENABLED - Button *button_add; - Button *button_instance; - Button *button_create_script; - Button *button_detach_script; - MenuButton *button_tree_menu; + Button *button_add = nullptr; + Button *button_instance = nullptr; + Button *button_create_script = nullptr; + Button *button_detach_script = nullptr; + MenuButton *button_tree_menu = nullptr; - Button *button_2d; - Button *button_3d; - Button *button_ui; - Button *button_custom; - Button *button_clipboard; + Button *button_2d = nullptr; + Button *button_3d = nullptr; + Button *button_ui = nullptr; + Button *button_custom = nullptr; + Button *button_clipboard = nullptr; - HBoxContainer *button_hb; + HBoxContainer *button_hb = nullptr; Button *edit_local, *edit_remote; - SceneTreeEditor *scene_tree; - Control *remote_tree; + SceneTreeEditor *scene_tree = nullptr; + Control *remote_tree = nullptr; - HBoxContainer *tool_hbc; + HBoxContainer *tool_hbc = nullptr; void _tool_selected(int p_tool, bool p_confirm_override = false); void _property_selected(int p_idx); void _node_collapsed(Object *p_obj); @@ -140,40 +140,40 @@ class SceneTreeDock : public VBoxContainer { String resource_drop_path; void _perform_property_drop(Node *p_node, String p_property, RES p_res); - EditorData *editor_data; - EditorSelection *editor_selection; + EditorData *editor_data = nullptr; + EditorSelection *editor_selection = nullptr; List<Node *> node_clipboard; String clipboard_source_scene; HashMap<String, Map<RES, RES>> clipboard_resource_remap; - ScriptCreateDialog *script_create_dialog; - ShaderCreateDialog *shader_create_dialog; - AcceptDialog *accept; - ConfirmationDialog *delete_dialog; - ConfirmationDialog *editable_instance_remove_dialog; - ConfirmationDialog *placeholder_editable_instance_remove_dialog; + ScriptCreateDialog *script_create_dialog = nullptr; + ShaderCreateDialog *shader_create_dialog = nullptr; + AcceptDialog *accept = nullptr; + ConfirmationDialog *delete_dialog = nullptr; + ConfirmationDialog *editable_instance_remove_dialog = nullptr; + ConfirmationDialog *placeholder_editable_instance_remove_dialog = nullptr; - ReparentDialog *reparent_dialog; - EditorQuickOpen *quick_open; - EditorFileDialog *new_scene_from_dialog; + ReparentDialog *reparent_dialog = nullptr; + EditorQuickOpen *quick_open = nullptr; + EditorFileDialog *new_scene_from_dialog = nullptr; - LineEdit *filter; - TextureRect *filter_icon; + LineEdit *filter = nullptr; + TextureRect *filter_icon = nullptr; - PopupMenu *menu; - PopupMenu *menu_subresources; - PopupMenu *menu_properties; - ConfirmationDialog *clear_inherit_confirm; + PopupMenu *menu = nullptr; + PopupMenu *menu_subresources = nullptr; + PopupMenu *menu_properties = nullptr; + ConfirmationDialog *clear_inherit_confirm = nullptr; bool first_enter = true; void _create(); void _do_create(Node *p_parent); - Node *scene_root; - Node *edited_scene; + Node *scene_root = nullptr; + Node *edited_scene = nullptr; - VBoxContainer *create_root_dialog; + VBoxContainer *create_root_dialog = nullptr; String selected_favorite_root; Ref<ShaderMaterial> selected_shader_material; @@ -220,7 +220,7 @@ class SceneTreeDock : public VBoxContainer { void _nodes_drag_begin(); virtual void input(const Ref<InputEvent> &p_event) override; - virtual void unhandled_key_input(const Ref<InputEvent> &p_event) override; + virtual void shortcut_input(const Ref<InputEvent> &p_event) override; void _import_subscene(); diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 2466b8576a..547a5b57ca 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -41,7 +41,7 @@ class SceneTreeEditor : public Control { GDCLASS(SceneTreeEditor, Control); - EditorSelection *editor_selection; + EditorSelection *editor_selection = nullptr; enum SceneTreeEditorButton { BUTTON_SUBSCENE = 0, @@ -55,14 +55,14 @@ class SceneTreeEditor : public Control { BUTTON_PIN = 8, }; - Tree *tree; - Node *selected; + Tree *tree = nullptr; + Node *selected = nullptr; ObjectID instance_node; String filter; - AcceptDialog *error; - AcceptDialog *warning; + AcceptDialog *error = nullptr; + AcceptDialog *warning = nullptr; bool auto_expand_selected = true; bool connect_to_script_mode = false; @@ -96,7 +96,7 @@ class SceneTreeEditor : public Control { bool show_enabled_subscene = false; void _renamed(); - UndoRedo *undo_redo; + UndoRedo *undo_redo = nullptr; Set<Node *> marked; bool marked_selectable = false; @@ -125,7 +125,7 @@ class SceneTreeEditor : public Control { void _warning_changed(Node *p_for_node); - Timer *update_timer; + Timer *update_timer = nullptr; List<StringName> *script_types; bool _is_script_type(const StringName &p_type) const; @@ -166,10 +166,10 @@ public: class SceneTreeDialog : public ConfirmationDialog { GDCLASS(SceneTreeDialog, ConfirmationDialog); - SceneTreeEditor *tree; + SceneTreeEditor *tree = nullptr; //Button *select; //Button *cancel; - LineEdit *filter; + LineEdit *filter = nullptr; void _select(); void _cancel(); diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index e9f634e2c0..c7d8cfc38a 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -45,27 +45,27 @@ class EditorFileDialog; class ScriptCreateDialog : public ConfirmationDialog { GDCLASS(ScriptCreateDialog, ConfirmationDialog); - LineEdit *class_name; - Label *error_label; - Label *path_error_label; - Label *builtin_warning_label; - Label *script_name_warning_label; - Label *template_info_label; - PanelContainer *status_panel; - LineEdit *parent_name; - Button *parent_browse_button; - Button *parent_search_button; - OptionButton *language_menu; - OptionButton *template_menu; - LineEdit *file_path; - LineEdit *internal_name; - Button *path_button; - EditorFileDialog *file_browse; - CheckBox *internal; - CheckBox *use_templates; - VBoxContainer *path_vb; - AcceptDialog *alert; - CreateDialog *select_class; + LineEdit *class_name = nullptr; + Label *error_label = nullptr; + Label *path_error_label = nullptr; + Label *builtin_warning_label = nullptr; + Label *script_name_warning_label = nullptr; + Label *template_info_label = nullptr; + PanelContainer *status_panel = nullptr; + LineEdit *parent_name = nullptr; + Button *parent_browse_button = nullptr; + Button *parent_search_button = nullptr; + OptionButton *language_menu = nullptr; + OptionButton *template_menu = nullptr; + LineEdit *file_path = nullptr; + LineEdit *internal_name = nullptr; + Button *path_button = nullptr; + EditorFileDialog *file_browse = nullptr; + CheckBox *internal = nullptr; + CheckBox *use_templates = nullptr; + VBoxContainer *path_vb = nullptr; + AcceptDialog *alert = nullptr; + CreateDialog *select_class = nullptr; bool is_browsing_parent = false; String template_inactive_message; String initial_bp; @@ -89,7 +89,7 @@ class ScriptCreateDialog : public ConfirmationDialog { Control *name_controls[2]; Vector<ScriptLanguage::ScriptTemplate> template_list; - ScriptLanguage *language; + ScriptLanguage *language = nullptr; String base_type; diff --git a/editor/shader_globals_editor.h b/editor/shader_globals_editor.h index 3b337e07de..d29052eaee 100644 --- a/editor/shader_globals_editor.h +++ b/editor/shader_globals_editor.h @@ -43,12 +43,12 @@ class ShaderGlobalsEditorInterface; class ShaderGlobalsEditor : public VBoxContainer { GDCLASS(ShaderGlobalsEditor, VBoxContainer) - ShaderGlobalsEditorInterface *interface; - EditorInspector *inspector; + ShaderGlobalsEditorInterface *interface = nullptr; + EditorInspector *inspector = nullptr; - LineEdit *variable_name; - OptionButton *variable_type; - Button *variable_add; + LineEdit *variable_name = nullptr; + OptionButton *variable_type = nullptr; + Button *variable_add = nullptr; void _variable_added(); void _variable_deleted(const String &p_variable); diff --git a/editor/translations/extract.py b/editor/translations/extract.py index 4a7e87e271..bd32fc01c7 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -3,6 +3,7 @@ import enum import fnmatch import os +import os.path import re import shutil import subprocess @@ -113,15 +114,23 @@ message_patterns = { r'RTRN\("(?P<message>([^"\\]|\\.)*)", "(?P<plural_message>([^"\\]|\\.)*)",[^,)]+?(, "(?P<context>([^"\\]|\\.)*)")?\)' ): ExtractType.TEXT, re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, - re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH, + re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?(_BASIC)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, + re.compile(r'GLOBAL_DEF_BASIC\(vformat\("(?P<message>layer_names/\w+)/layer_%d"'): ExtractType.PROPERTY_PATH, re.compile(r'EDITOR_DEF(_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, re.compile( + r'EDITOR_SETTING(_USAGE)?\(Variant::[_A-Z0-9]+, [_A-Z0-9]+, "(?P<message>[^"]+?)",' + ): ExtractType.PROPERTY_PATH, + re.compile( r'(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]' ): ExtractType.PROPERTY_PATH, re.compile( r"(?!#define )LIMPL_PROPERTY(_RANGE)?\(Variant::[_A-Z0-9]+, (?P<message>[^,]+?)," ): ExtractType.PROPERTY_PATH, re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP, + re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH, +} +theme_property_patterns = { + re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH, } @@ -195,6 +204,10 @@ def process_file(f, fname): translator_comment = "" current_group = "" + patterns = message_patterns + if os.path.basename(fname) == "default_theme.cpp": + patterns = {**message_patterns, **theme_property_patterns} + while l: # Detect translator comments. @@ -212,7 +225,7 @@ def process_file(f, fname): translator_comment = translator_comment[:-1] # Remove extra \n at the end. if not reading_translator_comment: - for pattern, extract_type in message_patterns.items(): + for pattern, extract_type in patterns.items(): for m in pattern.finditer(l): location = os.path.relpath(fname).replace("\\", "/") if line_nb: @@ -231,6 +244,8 @@ def process_file(f, fname): msg = msg[len(current_group) :] else: current_group = "" + if "." in msg: # Strip feature tag. + msg = msg.split(".", 1)[0] for part in msg.split("/"): _add_message(_process_editor_string(part), msg_plural, msgctx, location, translator_comment) elif extract_type == ExtractType.GROUP: |