summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/action_map_editor.cpp105
-rw-r--r--editor/action_map_editor.h45
-rw-r--r--editor/animation_bezier_editor.cpp3
-rw-r--r--editor/animation_bezier_editor.h4
-rw-r--r--editor/animation_track_editor.cpp19
-rw-r--r--editor/animation_track_editor.h123
-rw-r--r--editor/code_editor.h60
-rw-r--r--editor/connections_dialog.h50
-rw-r--r--editor/create_dialog.cpp61
-rw-r--r--editor/create_dialog.h12
-rw-r--r--editor/debugger/debug_adapter/debug_adapter_protocol.h2
-rw-r--r--editor/debugger/editor_debugger_inspector.h2
-rw-r--r--editor/debugger/editor_network_profiler.h12
-rw-r--r--editor/debugger/editor_performance_profiler.h6
-rw-r--r--editor/debugger/editor_profiler.h20
-rw-r--r--editor/debugger/editor_visual_profiler.h22
-rw-r--r--editor/debugger/script_editor_debugger.cpp4
-rw-r--r--editor/debugger/script_editor_debugger.h78
-rw-r--r--editor/dependency_editor.cpp2
-rw-r--r--editor/dependency_editor.h26
-rw-r--r--editor/doc_tools.cpp14
-rw-r--r--editor/editor_about.h10
-rw-r--r--editor/editor_asset_installer.cpp16
-rw-r--r--editor/editor_asset_installer.h6
-rw-r--r--editor/editor_audio_buses.h56
-rw-r--r--editor/editor_autoload_settings.cpp2
-rw-r--r--editor/editor_command_palette.h4
-rw-r--r--editor/editor_data.cpp2
-rw-r--r--editor/editor_dir_dialog.cpp11
-rw-r--r--editor/editor_dir_dialog.h10
-rw-r--r--editor/editor_export.cpp56
-rw-r--r--editor/editor_export.h6
-rw-r--r--editor/editor_feature_profile.cpp13
-rw-r--r--editor/editor_feature_profile.h30
-rw-r--r--editor/editor_file_dialog.cpp18
-rw-r--r--editor/editor_file_dialog.h80
-rw-r--r--editor/editor_file_system.cpp431
-rw-r--r--editor/editor_file_system.h10
-rw-r--r--editor/editor_folding.cpp2
-rw-r--r--editor/editor_fonts.cpp2
-rw-r--r--editor/editor_help.h28
-rw-r--r--editor/editor_help_search.cpp6
-rw-r--r--editor/editor_help_search.h14
-rw-r--r--editor/editor_inspector.cpp4
-rw-r--r--editor/editor_inspector.h58
-rw-r--r--editor/editor_layouts_dialog.h6
-rw-r--r--editor/editor_log.cpp5
-rw-r--r--editor/editor_log.h16
-rw-r--r--editor/editor_node.cpp22
-rw-r--r--editor/editor_node.h232
-rw-r--r--editor/editor_path.h10
-rw-r--r--editor/editor_paths.cpp11
-rw-r--r--editor/editor_plugin_settings.cpp2
-rw-r--r--editor/editor_plugin_settings.h8
-rw-r--r--editor/editor_properties.h84
-rw-r--r--editor/editor_properties_array_dict.h42
-rw-r--r--editor/editor_resource_picker.h6
-rw-r--r--editor/editor_resource_preview.cpp30
-rw-r--r--editor/editor_run.cpp5
-rw-r--r--editor/editor_run_script.h2
-rw-r--r--editor/editor_sectioned_inspector.h6
-rw-r--r--editor/editor_settings.cpp38
-rw-r--r--editor/editor_settings.h2
-rw-r--r--editor/editor_settings_dialog.cpp6
-rw-r--r--editor/editor_settings_dialog.h30
-rw-r--r--editor/editor_spin_slider.h2
-rw-r--r--editor/editor_themes.cpp4
-rw-r--r--editor/editor_toaster.h8
-rw-r--r--editor/editor_translation.cpp6
-rw-r--r--editor/editor_vcs_interface.cpp8
-rw-r--r--editor/editor_zoom_widget.h6
-rw-r--r--editor/export_template_manager.cpp65
-rw-r--r--editor/export_template_manager.h40
-rw-r--r--editor/fileserver/editor_file_server.cpp10
-rw-r--r--editor/fileserver/editor_file_server.h4
-rw-r--r--editor/filesystem_dock.cpp47
-rw-r--r--editor/filesystem_dock.h78
-rw-r--r--editor/find_in_files.cpp22
-rw-r--r--editor/find_in_files.h44
-rw-r--r--editor/groups_editor.h44
-rw-r--r--editor/icons/AnimationLibrary.svg1
-rw-r--r--editor/icons/ArrayOccluder3D.svg1
-rw-r--r--editor/icons/BoxOccluder3D.svg1
-rw-r--r--editor/icons/GuiVsplitBg.svg1
-rw-r--r--editor/icons/Occluder3D.svg2
-rw-r--r--editor/icons/PolygonOccluder3D.svg1
-rw-r--r--editor/icons/QuadOccluder3D.svg1
-rw-r--r--editor/icons/SphereOccluder3D.svg1
-rw-r--r--editor/import/dynamic_font_import_settings.h2
-rw-r--r--editor/import/editor_import_collada.cpp9
-rw-r--r--editor/import/resource_importer_csv_translation.cpp5
-rw-r--r--editor/import/resource_importer_image.cpp11
-rw-r--r--editor/import/resource_importer_layered_texture.cpp4
-rw-r--r--editor/import/resource_importer_obj.cpp8
-rw-r--r--editor/import/resource_importer_scene.cpp20
-rw-r--r--editor/import/resource_importer_shader_file.cpp4
-rw-r--r--editor/import/resource_importer_texture.cpp8
-rw-r--r--editor/import/resource_importer_texture.h2
-rw-r--r--editor/import/resource_importer_wav.cpp19
-rw-r--r--editor/import/scene_import_settings.h54
-rw-r--r--editor/import_defaults_editor.h10
-rw-r--r--editor/import_dock.h24
-rw-r--r--editor/inspector_dock.h40
-rw-r--r--editor/localization_editor.h24
-rw-r--r--editor/node_dock.h12
-rw-r--r--editor/plugin_config_dialog.cpp6
-rw-r--r--editor/plugin_config_dialog.h22
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.h16
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.h52
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.h64
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h18
-rw-r--r--editor/plugins/animation_library_editor.cpp689
-rw-r--r--editor/plugins/animation_library_editor.h119
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp457
-rw-r--r--editor/plugins/animation_player_editor_plugin.h74
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp2
-rw-r--r--editor/plugins/animation_state_machine_editor.h44
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h12
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp29
-rw-r--r--editor/plugins/asset_library_editor_plugin.h102
-rw-r--r--editor/plugins/audio_stream_editor_plugin.h2
-rw-r--r--editor/plugins/camera_3d_editor_plugin.h6
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp27
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h118
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp5
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h2
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h8
-rw-r--r--editor/plugins/control_editor_plugin.h24
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.h18
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.h4
-rw-r--r--editor/plugins/curve_editor_plugin.h4
-rw-r--r--editor/plugins/debugger_editor_plugin.h6
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.h22
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.h24
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.h8
-rw-r--r--editor/plugins/gradient_editor_plugin.h6
-rw-r--r--editor/plugins/input_event_editor_plugin.h6
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp5
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h2
-rw-r--r--editor/plugins/lightmap_gi_editor_plugin.h6
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp5
-rw-r--r--editor/plugins/line_2d_editor_plugin.h2
-rw-r--r--editor/plugins/material_editor_plugin.cpp4
-rw-r--r--editor/plugins/mesh_editor_plugin.h16
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h16
-rw-r--r--editor/plugins/mesh_library_editor_plugin.h10
-rw-r--r--editor/plugins/multimesh_editor_plugin.h32
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp5
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h2
-rw-r--r--editor/plugins/node_3d_editor_gizmos.h6
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp8
-rw-r--r--editor/plugins/node_3d_editor_plugin.h172
-rw-r--r--editor/plugins/occluder_instance_3d_editor_plugin.h6
-rw-r--r--editor/plugins/ot_features_plugin.h2
-rw-r--r--editor/plugins/path_2d_editor_plugin.h26
-rw-r--r--editor/plugins/path_3d_editor_plugin.h16
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.cpp3
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.h4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h42
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.h18
-rw-r--r--editor/plugins/replication_editor_plugin.h4
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h18
-rw-r--r--editor/plugins/root_motion_editor_plugin.h8
-rw-r--r--editor/plugins/script_editor_plugin.cpp66
-rw-r--r--editor/plugins/script_editor_plugin.h95
-rw-r--r--editor/plugins/script_text_editor.cpp3
-rw-r--r--editor/plugins/script_text_editor.h47
-rw-r--r--editor/plugins/shader_editor_plugin.h22
-rw-r--r--editor/plugins/shader_file_editor_plugin.h10
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.h8
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h30
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.h4
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.h22
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h70
-rw-r--r--editor/plugins/style_box_editor_plugin.h2
-rw-r--r--editor/plugins/text_control_editor_plugin.h2
-rw-r--r--editor/plugins/texture_3d_editor_plugin.h6
-rw-r--r--editor/plugins/texture_layered_editor_plugin.h6
-rw-r--r--editor/plugins/texture_region_editor_plugin.h44
-rw-r--r--editor/plugins/theme_editor_plugin.h212
-rw-r--r--editor/plugins/theme_editor_preview.h16
-rw-r--r--editor/plugins/tiles/atlas_merging_dialog.h16
-rw-r--r--editor/plugins/tiles/tile_atlas_view.h36
-rw-r--r--editor/plugins/tiles/tile_data_editors.h46
-rw-r--r--editor/plugins/tiles/tile_map_editor.h110
-rw-r--r--editor/plugins/tiles/tile_proxies_manager_dialog.h22
-rw-r--r--editor/plugins/tiles/tile_set_atlas_source_editor.h70
-rw-r--r--editor/plugins/tiles/tile_set_editor.h32
-rw-r--r--editor/plugins/tiles/tile_set_scenes_collection_source_editor.h22
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp2
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.h8
-rw-r--r--editor/plugins/version_control_editor_plugin.h76
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp6
-rw-r--r--editor/plugins/voxel_gi_editor_plugin.h8
-rw-r--r--editor/pot_generator.cpp10
-rw-r--r--editor/pot_generator.h2
-rw-r--r--editor/progress_dialog.h6
-rw-r--r--editor/project_export.h74
-rw-r--r--editor/project_manager.cpp47
-rw-r--r--editor/project_manager.h4
-rw-r--r--editor/project_settings_editor.cpp6
-rw-r--r--editor/project_settings_editor.h58
-rw-r--r--editor/property_editor.h38
-rw-r--r--editor/property_selector.h8
-rw-r--r--editor/quick_open.h4
-rw-r--r--editor/rename_dialog.h50
-rw-r--r--editor/reparent_dialog.h4
-rw-r--r--editor/scene_tree_dock.cpp13
-rw-r--r--editor/scene_tree_dock.h74
-rw-r--r--editor/scene_tree_editor.h18
-rw-r--r--editor/script_create_dialog.cpp14
-rw-r--r--editor/script_create_dialog.h44
-rw-r--r--editor/shader_create_dialog.cpp6
-rw-r--r--editor/shader_globals_editor.h10
215 files changed, 3761 insertions, 3047 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index 96931efd3b..86b40a311e 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -61,29 +61,37 @@ static const char *_joy_axis_descriptions[(size_t)JoyAxis::MAX * 2] = {
TTRC("Joystick 4 Down"),
};
-String InputEventConfigurationDialog::get_event_text(const Ref<InputEvent> &p_event) {
+String InputEventConfigurationDialog::get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const {
ERR_FAIL_COND_V_MSG(p_event.is_null(), String(), "Provided event is not a valid instance of InputEvent");
- // Joypad motion events will display slightly differently than what the event->as_text() provides. See #43660.
- Ref<InputEventJoypadMotion> jpmotion = p_event;
- if (jpmotion.is_valid()) {
+ String text = p_event->as_text();
+
+ Ref<InputEventMouse> mouse = p_event;
+ Ref<InputEventJoypadMotion> jp_motion = p_event;
+ Ref<InputEventJoypadButton> jp_button = p_event;
+ if (jp_motion.is_valid()) {
+ // Joypad motion events will display slightly differently than what the event->as_text() provides. See #43660.
String desc = TTR("Unknown Joypad Axis");
- if (jpmotion->get_axis() < JoyAxis::MAX) {
- desc = RTR(_joy_axis_descriptions[2 * (size_t)jpmotion->get_axis() + (jpmotion->get_axis_value() < 0 ? 0 : 1)]);
+ if (jp_motion->get_axis() < JoyAxis::MAX) {
+ desc = RTR(_joy_axis_descriptions[2 * (size_t)jp_motion->get_axis() + (jp_motion->get_axis_value() < 0 ? 0 : 1)]);
}
- return vformat("Joypad Axis %s %s (%s)", itos((int64_t)jpmotion->get_axis()), jpmotion->get_axis_value() < 0 ? "-" : "+", desc);
- } else {
- return p_event->as_text();
+ text = vformat("Joypad Axis %s %s (%s)", itos((int64_t)jp_motion->get_axis()), jp_motion->get_axis_value() < 0 ? "-" : "+", desc);
+ }
+ if (p_include_device && (mouse.is_valid() || jp_button.is_valid() || jp_motion.is_valid())) {
+ String device_string = _get_device_string(p_event->get_device());
+ text += vformat(" - %s", device_string);
}
+
+ return text;
}
-void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event) {
+void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection) {
if (p_event.is_valid()) {
event = p_event;
// Update Label
- event_as_text->set_text(get_event_text(event));
+ event_as_text->set_text(get_event_text(event, true));
Ref<InputEventKey> k = p_event;
Ref<InputEventMouseButton> mb = p_event;
@@ -122,7 +130,7 @@ void InputEventConfigurationDialog::_set_event(const Ref<InputEvent> &p_event) {
additional_options_container->show();
// Update selected item in input list.
- if (k.is_valid() || joyb.is_valid() || joym.is_valid() || mb.is_valid()) {
+ if (p_update_input_list_selection && (k.is_valid() || joyb.is_valid() || joym.is_valid() || mb.is_valid())) {
TreeItem *category = input_list_tree->get_root()->get_first_child();
while (category) {
TreeItem *input_item = category->get_first_child();
@@ -234,10 +242,13 @@ void InputEventConfigurationDialog::_listen_window_input(const Ref<InputEvent> &
}
}
+ // Create an editable reference
+ Ref<InputEvent> received_event = p_event;
+
// Check what the type is and if it is allowed.
- Ref<InputEventKey> k = p_event;
- Ref<InputEventJoypadButton> joyb = p_event;
- Ref<InputEventJoypadMotion> joym = p_event;
+ Ref<InputEventKey> k = received_event;
+ Ref<InputEventJoypadButton> joyb = received_event;
+ Ref<InputEventJoypadMotion> joym = received_event;
int type = 0;
if (k.is_valid()) {
@@ -266,7 +277,7 @@ void InputEventConfigurationDialog::_listen_window_input(const Ref<InputEvent> &
}
if (k.is_valid()) {
- k->set_pressed(false); // to avoid serialisation of 'pressed' property - doesn't matter for actions anyway.
+ k->set_pressed(false); // To avoid serialisation of 'pressed' property - doesn't matter for actions anyway.
// Maintain physical keycode option state
if (physical_key_checkbox->is_pressed()) {
k->set_keycode(Key::NONE);
@@ -275,15 +286,17 @@ void InputEventConfigurationDialog::_listen_window_input(const Ref<InputEvent> &
}
}
- Ref<InputEventWithModifiers> mod = p_event;
+ Ref<InputEventWithModifiers> mod = received_event;
if (mod.is_valid()) {
// Maintain store command option state
mod->set_store_command(store_command_checkbox->is_pressed());
-
mod->set_window_id(0);
}
- _set_event(p_event);
+ // Maintain device selection.
+ received_event->set_device(_get_current_device());
+
+ _set_event(received_event);
set_input_as_handled();
}
@@ -331,7 +344,7 @@ void InputEventConfigurationDialog::_update_input_list() {
Ref<InputEventMouseButton> mb;
mb.instantiate();
mb->set_button_index(mouse_buttons[i]);
- String desc = get_event_text(mb);
+ String desc = get_event_text(mb, false);
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
continue;
@@ -354,7 +367,7 @@ void InputEventConfigurationDialog::_update_input_list() {
Ref<InputEventJoypadButton> joyb;
joyb.instantiate();
joyb->set_button_index((JoyButton)i);
- String desc = get_event_text(joyb);
+ String desc = get_event_text(joyb, false);
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
continue;
@@ -380,7 +393,7 @@ void InputEventConfigurationDialog::_update_input_list() {
joym.instantiate();
joym->set_axis((JoyAxis)axis);
joym->set_axis_value(direction);
- String desc = get_event_text(joym);
+ String desc = get_event_text(joym, false);
if (!search_term.is_empty() && desc.findn(search_term) == -1) {
continue;
@@ -495,7 +508,7 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
k->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
k->set_store_command(store_command_checkbox->is_pressed());
- _set_event(k);
+ _set_event(k, false);
} break;
case InputEventConfigurationDialog::INPUT_MOUSE_BUTTON: {
MouseButton idx = (MouseButton)(int)selected->get_meta("__index");
@@ -510,12 +523,19 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
mb->set_meta_pressed(mod_checkboxes[MOD_META]->is_pressed());
mb->set_store_command(store_command_checkbox->is_pressed());
- _set_event(mb);
+ // Maintain selected device
+ mb->set_device(_get_current_device());
+
+ _set_event(mb, false);
} break;
case InputEventConfigurationDialog::INPUT_JOY_BUTTON: {
JoyButton idx = (JoyButton)(int)selected->get_meta("__index");
Ref<InputEventJoypadButton> jb = InputEventJoypadButton::create_reference(idx);
- _set_event(jb);
+
+ // Maintain selected device
+ jb->set_device(_get_current_device());
+
+ _set_event(jb, false);
} break;
case InputEventConfigurationDialog::INPUT_JOY_MOTION: {
JoyAxis axis = (JoyAxis)(int)selected->get_meta("__axis");
@@ -525,24 +545,35 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
jm.instantiate();
jm->set_axis(axis);
jm->set_axis_value(value);
- _set_event(jm);
+
+ // Maintain selected device
+ jm->set_device(_get_current_device());
+
+ _set_event(jm, false);
} break;
}
}
-void InputEventConfigurationDialog::_set_current_device(int i_device) {
- device_id_option->select(i_device + 1);
+void InputEventConfigurationDialog::_device_selection_changed(int p_option_button_index) {
+ // Subtract 1 as option index 0 corresponds to "All Devices" (value of -1)
+ // and option index 1 corresponds to device 0, etc...
+ event->set_device(p_option_button_index - 1);
+ event_as_text->set_text(get_event_text(event, true));
+}
+
+void InputEventConfigurationDialog::_set_current_device(int p_device) {
+ device_id_option->select(p_device + 1);
}
int InputEventConfigurationDialog::_get_current_device() const {
return device_id_option->get_selected() - 1;
}
-String InputEventConfigurationDialog::_get_device_string(int i_device) const {
- if (i_device == InputMap::ALL_DEVICES) {
+String InputEventConfigurationDialog::_get_device_string(int p_device) const {
+ if (p_device == InputMap::ALL_DEVICES) {
return TTR("All Devices");
}
- return TTR("Device") + " " + itos(i_device);
+ return TTR("Device") + " " + itos(p_device);
}
void InputEventConfigurationDialog::_notification(int p_what) {
@@ -588,6 +619,9 @@ void InputEventConfigurationDialog::popup_and_configure(const Ref<InputEvent> &p
// Switch to "Listen" tab
tab_container->set_current_tab(0);
+
+ // Select "All Devices" by default.
+ device_id_option->select(0);
}
popup_centered();
@@ -673,12 +707,13 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() {
device_id_option = memnew(OptionButton);
device_id_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- device_container->add_child(device_id_option);
-
for (int i = -1; i < 8; i++) {
device_id_option->add_item(_get_device_string(i));
}
- _set_current_device(0);
+ device_id_option->connect("item_selected", callable_mp(this, &InputEventConfigurationDialog::_device_selection_changed));
+ _set_current_device(InputMap::ALL_DEVICES);
+ device_container->add_child(device_id_option);
+
device_container->hide();
additional_options_container->add_child(device_container);
@@ -1096,7 +1131,7 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
TreeItem *event_item = action_tree->create_item(action_item);
// First Column - Text
- event_item->set_text(0, event_config_dialog->get_event_text(event)); // Need to us the special description for JoypadMotion here, so don't use as_text() directly.
+ event_item->set_text(0, event_config_dialog->get_event_text(event, true));
event_item->set_meta("__event", event);
event_item->set_meta("__index", evnt_idx);
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h
index 34c70c942e..0da7708422 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,11 +93,11 @@ 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);
+ void _set_event(const Ref<InputEvent> &p_event, bool p_update_input_list_selection = true);
void _tab_selected(int p_tab);
void _listen_window_input(const Ref<InputEvent> &p_event);
@@ -110,9 +110,10 @@ private:
void _store_command_toggled(bool p_checked);
void _physical_keycode_toggled(bool p_checked);
- void _set_current_device(int i_device);
+ void _device_selection_changed(int p_option_button_index);
+ void _set_current_device(int p_device);
int _get_current_device() const;
- String _get_device_string(int i_device) const;
+ String _get_device_string(int p_device) const;
protected:
void _notification(int p_what);
@@ -121,7 +122,7 @@ public:
// Pass an existing event to configure it. Alternatively, pass no event to start with a blank configuration.
void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>());
Ref<InputEvent> get_event() const;
- String get_event_text(const Ref<InputEvent> &p_event);
+ String get_event_text(const Ref<InputEvent> &p_event, bool p_include_device) const;
void set_allowed_input_types(int p_type_masks);
@@ -149,7 +150,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 +160,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 dc69a8cb08..53631c1e3b 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -1961,11 +1961,21 @@ void AnimationTrackEdit::_notification(int p_what) {
int limit = timeline->get_name_limit();
+ if (track % 2 == 1) {
+ // Draw a background over odd lines to make long lists of tracks easier to read.
+ draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), Color(0.5, 0.5, 0.5, 0.05));
+ }
+
+ if (hovered) {
+ // Draw hover feedback.
+ draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), Color(0.5, 0.5, 0.5, 0.1));
+ }
+
if (has_focus()) {
Color accent = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
accent.a *= 0.7;
// Offside so the horizontal sides aren't cutoff.
- draw_rect(Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)), accent, false);
+ draw_style_box(get_theme_stylebox(SNAME("Focus"), SNAME("EditorStyles")), Rect2(Point2(1 * EDSCALE, 0), get_size() - Size2(1 * EDSCALE, 0)));
}
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
@@ -2236,7 +2246,14 @@ void AnimationTrackEdit::_notification(int p_what) {
}
} break;
+ case NOTIFICATION_MOUSE_ENTER:
+ hovered = true;
+ update();
+ break;
case NOTIFICATION_MOUSE_EXIT:
+ hovered = false;
+ update();
+ [[fallthrough]];
case NOTIFICATION_DRAG_END: {
cancel_drop();
} break;
diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h
index 1baebc469e..a8a5d11c12 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,8 +169,9 @@ class AnimationTrackEdit : public Control {
Ref<Texture2D> type_icon;
Ref<Texture2D> selected_icon;
- PopupMenu *menu;
+ PopupMenu *menu = nullptr;
+ bool hovered = false;
bool clicking_on_name = false;
void _zoom_changed();
@@ -194,7 +195,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 +286,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 +324,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 +337,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 +354,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 +420,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 +441,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 +465,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/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.cpp b/editor/create_dialog.cpp
index f9858aa514..fbb61a1614 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -377,17 +377,17 @@ void CreateDialog::_confirmed() {
return;
}
- FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE);
- if (f) {
- f->store_line(selected_item);
-
- for (int i = 0; i < MIN(32, recent->get_item_count()); i++) {
- if (recent->get_item_text(i) != selected_item) {
- f->store_line(recent->get_item_text(i));
+ {
+ Ref<FileAccess> f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE);
+ if (f.is_valid()) {
+ f->store_line(selected_item);
+
+ for (int i = 0; i < MIN(32, recent->get_item_count()); i++) {
+ if (recent->get_item_text(i) != selected_item) {
+ f->store_line(recent->get_item_text(i));
+ }
}
}
-
- memdelete(f);
}
// To prevent, emitting an error from the transient window (shader dialog for example) hide this dialog before emitting the "create" signal.
@@ -647,25 +647,26 @@ void CreateDialog::_save_and_update_favorite_list() {
favorites->clear();
TreeItem *root = favorites->create_item();
- FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE);
- if (f) {
- for (int i = 0; i < favorite_list.size(); i++) {
- String l = favorite_list[i];
- String name = l.get_slicec(' ', 0);
- if (!(ClassDB::class_exists(name) || ScriptServer::is_global_class(name))) {
- continue;
- }
- f->store_line(l);
+ {
+ Ref<FileAccess> f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE);
+ if (f.is_valid()) {
+ for (int i = 0; i < favorite_list.size(); i++) {
+ String l = favorite_list[i];
+ String name = l.get_slicec(' ', 0);
+ if (!(ClassDB::class_exists(name) || ScriptServer::is_global_class(name))) {
+ continue;
+ }
+ f->store_line(l);
- if (_is_class_disabled_by_feature_profile(name)) {
- continue;
- }
+ if (_is_class_disabled_by_feature_profile(name)) {
+ continue;
+ }
- TreeItem *ti = favorites->create_item(root);
- ti->set_text(0, l);
- ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback));
+ TreeItem *ti = favorites->create_item(root);
+ ti->set_text(0, l);
+ ti->set_icon(0, EditorNode::get_singleton()->get_class_icon(name, icon_fallback));
+ }
}
- memdelete(f);
}
emit_signal(SNAME("favorites_updated"));
@@ -673,8 +674,8 @@ void CreateDialog::_save_and_update_favorite_list() {
void CreateDialog::_load_favorites_and_history() {
String dir = EditorSettings::get_singleton()->get_project_settings_dir();
- FileAccess *f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(dir.plus_file("create_recent." + base_type), FileAccess::READ);
+ if (f.is_valid()) {
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
String name = l.get_slicec(' ', 0);
@@ -683,12 +684,10 @@ void CreateDialog::_load_favorites_and_history() {
recent->add_item(l, EditorNode::get_singleton()->get_class_icon(name, icon_fallback));
}
}
-
- memdelete(f);
}
f = FileAccess::open(dir.plus_file("favorites." + base_type), FileAccess::READ);
- if (f) {
+ if (f.is_valid()) {
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
@@ -696,8 +695,6 @@ void CreateDialog::_load_favorites_and_history() {
favorite_list.push_back(l);
}
}
-
- memdelete(f);
}
}
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.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_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.cpp b/editor/debugger/script_editor_debugger.cpp
index 1e8753acc0..3a3b35f8a5 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -164,7 +164,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
switch (file_dialog_purpose) {
case SAVE_MONITORS_CSV: {
Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINT("Failed to open " + p_file);
@@ -209,7 +209,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
} break;
case SAVE_VRAM_CSV: {
Error err;
- FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINT("Failed to open " + p_file);
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.cpp b/editor/dependency_editor.cpp
index 95b3a02631..35f40a159a 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -749,7 +749,7 @@ void OrphanResourcesDialog::_find_to_delete(TreeItem *p_item, List<String> &path
}
void OrphanResourcesDialog::_delete_confirm() {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
for (const String &E : paths) {
da->remove(E);
EditorFileSystem::get_singleton()->update_file(E);
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/doc_tools.cpp b/editor/doc_tools.cpp
index adad8fdba8..16cbc0f34d 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -1035,8 +1035,8 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
Error DocTools::load_classes(const String &p_dir) {
Error err;
- DirAccessRef da = DirAccess::open(p_dir, &err);
- if (!da) {
+ Ref<DirAccess> da = DirAccess::open(p_dir, &err);
+ if (da.is_null()) {
return err;
}
@@ -1063,8 +1063,8 @@ Error DocTools::load_classes(const String &p_dir) {
Error DocTools::erase_classes(const String &p_dir) {
Error err;
- DirAccessRef da = DirAccess::open(p_dir, &err);
- if (!da) {
+ Ref<DirAccess> da = DirAccess::open(p_dir, &err);
+ if (da.is_null()) {
return err;
}
@@ -1273,7 +1273,7 @@ Error DocTools::_load(Ref<XMLParser> parser) {
return OK;
}
-static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) {
+static void _write_string(Ref<FileAccess> f, int p_tablevel, const String &p_string) {
if (p_string.is_empty()) {
return;
}
@@ -1284,7 +1284,7 @@ static void _write_string(FileAccess *f, int p_tablevel, const String &p_string)
f->store_string(tab + p_string + "\n");
}
-static void _write_method_doc(FileAccess *f, const String &p_name, Vector<DocData::MethodDoc> &p_method_docs) {
+static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<DocData::MethodDoc> &p_method_docs) {
if (!p_method_docs.is_empty()) {
p_method_docs.sort();
_write_string(f, 1, "<" + p_name + "s>");
@@ -1350,7 +1350,7 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
Error err;
String save_file = save_path.plus_file(c.name + ".xml");
- FileAccessRef f = FileAccess::open(save_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> f = FileAccess::open(save_file, FileAccess::WRITE, &err);
ERR_CONTINUE_MSG(err != OK, "Can't write doc file: " + save_file + ".");
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..7dcb9a4088 100644
--- a/editor/editor_asset_installer.cpp
+++ b/editor/editor_asset_installer.cpp
@@ -64,8 +64,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
package_path = p_path;
Set<String> files_sorted;
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
if (!pkg) {
@@ -238,8 +237,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
}
void EditorAssetInstaller::ok_pressed() {
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
if (!pkg) {
@@ -259,6 +257,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);
@@ -277,7 +278,7 @@ void EditorAssetInstaller::ok_pressed() {
dirpath = dirpath.substr(0, dirpath.length() - 1);
}
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
da->make_dir(dirpath);
} else {
Vector<uint8_t> data;
@@ -288,10 +289,9 @@ void EditorAssetInstaller::ok_pressed() {
unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
- FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
} else {
failed_files.push_back(path);
}
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 a5e76ba0c0..a58a279faa 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -824,7 +824,7 @@ void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorSel
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_elem_idx = es.history_current;
p_history->history = es.history_stored;
diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp
index 866f28c03b..8494991892 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())) {
+ Ref<DirAccess> d = DirAccess::open(dir);
+ ERR_FAIL_COND_MSG(d.is_null(), "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.cpp b/editor/editor_export.cpp
index a1081fcbfb..a822c5fb5f 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -327,12 +327,12 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa
}
}
- FileAccessEncrypted *fae = nullptr;
- FileAccess *ftmp = pd->f;
+ Ref<FileAccessEncrypted> fae;
+ Ref<FileAccess> ftmp = pd->f;
if (sd.encrypted) {
- fae = memnew(FileAccessEncrypted);
- ERR_FAIL_COND_V(!fae, ERR_SKIP);
+ fae.instantiate();
+ ERR_FAIL_COND_V(fae.is_null(), ERR_SKIP);
Error err = fae->open_and_parse(ftmp, p_key, FileAccessEncrypted::MODE_WRITE_AES256, false);
ERR_FAIL_COND_V(err != OK, ERR_SKIP);
@@ -342,9 +342,8 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa
// Store file content.
ftmp->store_buffer(p_data.ptr(), p_data.size());
- if (fae) {
+ if (fae.is_valid()) {
fae->release();
- memdelete(fae);
}
int pad = _get_pad(PCK_PADDING, pd->f->get_position());
@@ -480,7 +479,7 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<S
}
}
-void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
+void EditorExportPlatform::_edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
da->list_dir_begin();
String cur_dir = da->get_current_dir().replace("\\", "/");
if (!cur_dir.ends_with("/")) {
@@ -542,10 +541,9 @@ void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &
filters.push_back(f);
}
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- ERR_FAIL_NULL(da);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ ERR_FAIL_COND(da.is_null());
_edit_files_with_filter(da, filters, r_list, exclude);
- memdelete(da);
}
void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) {
@@ -1130,12 +1128,12 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
EditorProgress ep("savepack", TTR("Packing"), 102, true);
// Create the temporary export directory if it doesn't exist.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir_recursive(EditorPaths::get_singleton()->get_cache_dir());
String tmppath = EditorPaths::get_singleton()->get_cache_dir().plus_file("packtmp");
- FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE);
- ERR_FAIL_COND_V_MSG(!ftmp, ERR_CANT_CREATE, "Cannot create file '" + tmppath + "'.");
+ Ref<FileAccess> ftmp = FileAccess::open(tmppath, FileAccess::WRITE);
+ ERR_FAIL_COND_V_MSG(ftmp.is_null(), ERR_CANT_CREATE, "Cannot create file '" + tmppath + "'.");
PackData pd;
pd.ep = &ep;
@@ -1144,7 +1142,9 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
Error err = export_project_files(p_preset, p_debug, _save_pack_file, &pd, _add_shared_object);
- memdelete(ftmp); //close tmp file
+ // Close temp file.
+ pd.f.unref();
+ ftmp.unref();
if (err != OK) {
DirAccess::remove_file_or_error(tmppath);
@@ -1154,19 +1154,19 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
pd.file_ofs.sort(); //do sort, so we can do binary search later
- FileAccess *f;
+ Ref<FileAccess> f;
int64_t embed_pos = 0;
if (!p_embed) {
// Regular output to separate PCK file
f = FileAccess::open(p_path, FileAccess::WRITE);
- if (!f) {
+ if (f.is_null()) {
DirAccess::remove_file_or_error(tmppath);
ERR_FAIL_V(ERR_CANT_CREATE);
}
} else {
// Append to executable
f = FileAccess::open(p_path, FileAccess::READ_WRITE);
- if (!f) {
+ if (f.is_null()) {
DirAccess::remove_file_or_error(tmppath);
ERR_FAIL_V(ERR_FILE_CANT_OPEN);
}
@@ -1211,8 +1211,8 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
f->store_32(pd.file_ofs.size()); //amount of files
- FileAccessEncrypted *fae = nullptr;
- FileAccess *fhead = f;
+ Ref<FileAccessEncrypted> fae;
+ Ref<FileAccess> fhead = f;
if (enc_pck && enc_directory) {
String script_key = p_preset->get_script_encryption_key().to_lower();
@@ -1243,8 +1243,8 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
key.write[i] = v;
}
}
- fae = memnew(FileAccessEncrypted);
- ERR_FAIL_COND_V(!fae, ERR_SKIP);
+ fae.instantiate();
+ ERR_FAIL_COND_V(fae.is_null(), ERR_SKIP);
err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_WRITE_AES256, false);
ERR_FAIL_COND_V(err != OK, ERR_SKIP);
@@ -1272,9 +1272,8 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
fhead->store_32(flags);
}
- if (fae) {
+ if (fae.is_valid()) {
fae->release();
- memdelete(fae);
}
int header_padding = _get_pad(PCK_PADDING, f->get_position());
@@ -1290,8 +1289,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
// Save the rest of the data.
ftmp = FileAccess::open(tmppath, FileAccess::READ);
- if (!ftmp) {
- memdelete(f);
+ if (ftmp.is_null()) {
DirAccess::remove_file_or_error(tmppath);
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't open file to read from path '" + String(tmppath) + "'.");
}
@@ -1307,7 +1305,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
f->store_buffer(buf, got);
}
- memdelete(ftmp);
+ ftmp.unref(); // Close temp file.
if (p_embed) {
// Ensure embedded data ends at a 64-bit multiple
@@ -1326,7 +1324,6 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
}
}
- memdelete(f);
DirAccess::remove_file_or_error(tmppath);
return OK;
@@ -1335,8 +1332,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
EditorProgress ep("savezip", TTR("Packing"), 102, true);
- FileAccess *src_f;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io);
ZipData zd;
@@ -1839,7 +1835,7 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
return ERR_FILE_NOT_FOUND;
}
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir_recursive(p_path.get_base_dir());
Error err = da->copy(template_path, p_path, get_chmod_flags());
diff --git a/editor/editor_export.h b/editor/editor_export.h
index 7c61e7cff6..236f4d129c 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -184,7 +184,7 @@ private:
};
struct PackData {
- FileAccess *f = nullptr;
+ Ref<FileAccess> f;
Vector<SavedData> file_ofs;
EditorProgress *ep = nullptr;
Vector<SharedObject> *so_files = nullptr;
@@ -207,7 +207,7 @@ private:
static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
- void _edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude);
+ void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude);
void _edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude);
static Error _add_shared_object(void *p_userdata, const SharedObject &p_so);
@@ -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.cpp b/editor/editor_feature_profile.cpp
index cf45848ed3..a20f112b2a 100644
--- a/editor/editor_feature_profile.cpp
+++ b/editor/editor_feature_profile.cpp
@@ -198,13 +198,12 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) {
data["disabled_features"] = dis_features;
- FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
+ Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_CREATE, "Cannot create file '" + p_path + "'.");
JSON json;
String text = json.stringify(data, "\t");
f->store_string(text);
- f->close();
return OK;
}
@@ -350,8 +349,8 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
}
Vector<String> profiles;
- DirAccessRef d = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
- ERR_FAIL_COND_MSG(!d, "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
+ Ref<DirAccess> d = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
+ ERR_FAIL_COND_MSG(d.is_null(), "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
d->list_dir_begin();
while (true) {
@@ -453,8 +452,8 @@ void EditorFeatureProfileManager::_profile_action(int p_action) {
void EditorFeatureProfileManager::_erase_selected_profile() {
String selected = _get_selected_profile();
ERR_FAIL_COND(selected.is_empty());
- DirAccessRef da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
- ERR_FAIL_COND_MSG(!da, "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
+ Ref<DirAccess> da = DirAccess::open(EditorSettings::get_singleton()->get_feature_profiles_dir());
+ ERR_FAIL_COND_MSG(da.is_null(), "Cannot open directory '" + EditorSettings::get_singleton()->get_feature_profiles_dir() + "'.");
da->remove(selected + ".profile");
if (selected == current_profile) {
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..dca69ffd5f 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);
@@ -1065,7 +1065,6 @@ void EditorFileDialog::set_access(Access p_access) {
if (access == p_access) {
return;
}
- memdelete(dir_access);
switch (p_access) {
case ACCESS_FILESYSTEM: {
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -1099,16 +1098,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();
@@ -1851,5 +1852,4 @@ EditorFileDialog::~EditorFileDialog() {
if (unregister_func) {
unregister_func(this);
}
- memdelete(dir_access);
}
diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h
index a747255ce8..db2a2ab09f 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;
+ Ref<DirAccess> dir_access;
+ 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 2b98a4b02a..099dfe69d5 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -218,81 +218,80 @@ void EditorFileSystem::_scan_filesystem() {
String project = ProjectSettings::get_singleton()->get_resource_path();
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME);
- FileAccess *f = FileAccess::open(fscache, FileAccess::READ);
-
- bool first = true;
- if (f) {
- //read the disk cache
- while (!f->eof_reached()) {
- String l = f->get_line().strip_edges();
- if (first) {
- if (first_scan) {
- // only use this on first scan, afterwards it gets ignored
- // this is so on first reimport we synchronize versions, then
- // we don't care until editor restart. This is for usability mainly so
- // your workflow is not killed after changing a setting by forceful reimporting
- // everything there is.
- filesystem_settings_version_for_import = l.strip_edges();
- if (filesystem_settings_version_for_import != ResourceFormatImporter::get_singleton()->get_import_settings_hash()) {
- revalidate_import_files = true;
+ {
+ Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::READ);
+
+ bool first = true;
+ if (f.is_valid()) {
+ //read the disk cache
+ while (!f->eof_reached()) {
+ String l = f->get_line().strip_edges();
+ if (first) {
+ if (first_scan) {
+ // only use this on first scan, afterwards it gets ignored
+ // this is so on first reimport we synchronize versions, then
+ // we don't care until editor restart. This is for usability mainly so
+ // your workflow is not killed after changing a setting by forceful reimporting
+ // everything there is.
+ filesystem_settings_version_for_import = l.strip_edges();
+ if (filesystem_settings_version_for_import != ResourceFormatImporter::get_singleton()->get_import_settings_hash()) {
+ revalidate_import_files = true;
+ }
}
+ first = false;
+ continue;
+ }
+ if (l.is_empty()) {
+ continue;
}
- first = false;
- continue;
- }
- if (l.is_empty()) {
- continue;
- }
- if (l.begins_with("::")) {
- Vector<String> split = l.split("::");
- ERR_CONTINUE(split.size() != 3);
- String name = split[1];
+ if (l.begins_with("::")) {
+ Vector<String> split = l.split("::");
+ ERR_CONTINUE(split.size() != 3);
+ String name = split[1];
- cpath = name;
+ cpath = name;
- } else {
- Vector<String> split = l.split("::");
- ERR_CONTINUE(split.size() != 9);
- String name = split[0];
- String file;
-
- file = name;
- name = cpath.plus_file(name);
-
- FileCache fc;
- fc.type = split[1];
- fc.uid = split[2].to_int();
- fc.modification_time = split[3].to_int();
- fc.import_modification_time = split[4].to_int();
- fc.import_valid = split[5].to_int() != 0;
- fc.import_group_file = split[6].strip_edges();
- fc.script_class_name = split[7].get_slice("<>", 0);
- fc.script_class_extends = split[7].get_slice("<>", 1);
- fc.script_class_icon_path = split[7].get_slice("<>", 2);
-
- String deps = split[8].strip_edges();
- if (deps.length()) {
- Vector<String> dp = deps.split("<>");
- for (int i = 0; i < dp.size(); i++) {
- String path = dp[i];
- fc.deps.push_back(path);
+ } else {
+ Vector<String> split = l.split("::");
+ ERR_CONTINUE(split.size() != 9);
+ String name = split[0];
+ String file;
+
+ file = name;
+ name = cpath.plus_file(name);
+
+ FileCache fc;
+ fc.type = split[1];
+ fc.uid = split[2].to_int();
+ fc.modification_time = split[3].to_int();
+ fc.import_modification_time = split[4].to_int();
+ fc.import_valid = split[5].to_int() != 0;
+ fc.import_group_file = split[6].strip_edges();
+ fc.script_class_name = split[7].get_slice("<>", 0);
+ fc.script_class_extends = split[7].get_slice("<>", 1);
+ fc.script_class_icon_path = split[7].get_slice("<>", 2);
+
+ String deps = split[8].strip_edges();
+ if (deps.length()) {
+ Vector<String> dp = deps.split("<>");
+ for (int i = 0; i < dp.size(); i++) {
+ String path = dp[i];
+ fc.deps.push_back(path);
+ }
}
- }
- file_cache[name] = fc;
+ file_cache[name] = fc;
+ }
}
}
-
- f->close();
- memdelete(f);
}
String update_cache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4");
if (FileAccess::exists(update_cache)) {
{
- FileAccessRef f2 = FileAccess::open(update_cache, FileAccess::READ);
+ Ref<FileAccess> f2 = FileAccess::open(update_cache, FileAccess::READ);
String l = f2->get_line().strip_edges();
while (!l.is_empty()) {
file_cache.erase(l); //erase cache for this, so it gets updated
@@ -300,7 +299,7 @@ void EditorFileSystem::_scan_filesystem() {
}
}
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
d->remove(update_cache); //bye bye update cache
}
@@ -314,14 +313,12 @@ void EditorFileSystem::_scan_filesystem() {
new_filesystem = memnew(EditorFileSystemDirectory);
new_filesystem->parent = nullptr;
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
d->change_dir("res://");
_scan_new_dir(new_filesystem, d, sp);
file_cache.clear(); //clear caches, no longer needed
- memdelete(d);
-
if (!first_scan) {
//on the first scan this is done from the main thread after re-importing
_save_filesystem_cache();
@@ -335,13 +332,11 @@ void EditorFileSystem::_save_filesystem_cache() {
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(CACHE_FILE_NAME);
- FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!f, "Cannot create file '" + fscache + "'. Check user write permissions.");
+ Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions.");
f->store_line(filesystem_settings_version_for_import);
_save_filesystem_cache(filesystem, f);
- f->close();
- memdelete(f);
}
void EditorFileSystem::_thread_func(void *_userdata) {
@@ -364,9 +359,9 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
}
Error err;
- FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
+ Ref<FileAccess> f = FileAccess::open(p_path + ".import", FileAccess::READ, &err);
- if (!f) { //no import file, do reimport
+ if (f.is_null()) { //no import file, do reimport
return true;
}
@@ -400,7 +395,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
break;
} else if (err != OK) {
ERR_PRINT("ResourceFormatImporter::load - '" + p_path + ".import:" + itos(lines) + "' error '" + error_text + "'.");
- memdelete(f);
return false; //parse error, try reimport manually (Avoid reimport loop on broken file)
}
@@ -431,8 +425,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
}
}
- memdelete(f);
-
if (importer_name == "keep") {
return false; //keep mode, do not reimport
}
@@ -453,8 +445,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
// Read the md5's from a separate file (so the import parameters aren't dependent on the file version
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_path);
- FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::READ, &err);
- if (!md5s) { // No md5's stored for this resource
+ Ref<FileAccess> md5s = FileAccess::open(base_path + ".md5", FileAccess::READ, &err);
+ if (md5s.is_null()) { // No md5's stored for this resource
return true;
}
@@ -472,7 +464,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
break;
} else if (err != OK) {
ERR_PRINT("ResourceFormatImporter::load - '" + p_path + ".import.md5:" + itos(lines) + "' error '" + error_text + "'.");
- memdelete(md5s);
return false; // parse error
}
if (!assign.is_empty()) {
@@ -485,7 +476,6 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
}
}
}
- memdelete(md5s);
//imported files are gone, reimport
for (const String &E : to_check) {
@@ -742,7 +732,7 @@ EditorFileSystem::ScanProgress EditorFileSystem::ScanProgress::get_sub(int p_cur
return sp;
}
-void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) {
+void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAccess> &da, const ScanProgress &p_progress) {
List<String> dirs;
List<String> files;
@@ -967,7 +957,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
//then scan files and directories and check what's different
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
Error ret = da->change_dir(cd);
ERR_FAIL_COND_MSG(ret != OK, "Cannot change to '" + cd + "' folder.");
@@ -998,10 +988,9 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
efd->parent = p_dir;
efd->name = f;
- DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
d->change_dir(cd.plus_file(f));
_scan_new_dir(efd, d, p_progress.get_sub(1, 1));
- memdelete(d);
ItemAction ia;
ia.action = ItemAction::ACTION_DIR_ADD;
@@ -1137,7 +1126,7 @@ void EditorFileSystem::_delete_internal_files(String p_file) {
if (FileAccess::exists(p_file + ".import")) {
List<String> paths;
ResourceFormatImporter::get_singleton()->get_internal_resource_path_list(p_file, &paths);
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
for (const String &E : paths) {
da->remove(E);
}
@@ -1282,7 +1271,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem() {
return filesystem;
}
-void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file) {
+void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir, Ref<FileAccess> p_file) {
if (!p_dir) {
return; //none
}
@@ -1467,8 +1456,8 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p
void EditorFileSystem::_save_late_updated_files() {
//files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file
String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update4");
- FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!f, "Cannot create file '" + fscache + "'. Check user write permissions.");
+ Ref<FileAccess> f = FileAccess::open(fscache, FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + fscache + "'. Check user write permissions.");
for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) {
f->store_line(E->get());
}
@@ -1713,78 +1702,78 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
for (const KeyValue<String, Map<StringName, Variant>> &E : source_file_options) {
const String &file = E.key;
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(file);
- FileAccessRef f = FileAccess::open(file + ".import", FileAccess::WRITE);
- ERR_FAIL_COND_V_MSG(!f, ERR_FILE_CANT_OPEN, "Cannot open import file '" + file + ".import'.");
-
- //write manually, as order matters ([remap] has to go first for performance).
- f->store_line("[remap]");
- f->store_line("");
- f->store_line("importer=\"" + importer->get_importer_name() + "\"");
- int version = importer->get_format_version();
- if (version > 0) {
- f->store_line("importer_version=" + itos(version));
- }
- if (!importer->get_resource_type().is_empty()) {
- f->store_line("type=\"" + importer->get_resource_type() + "\"");
- }
-
Vector<String> dest_paths;
+ {
+ Ref<FileAccess> f = FileAccess::open(file + ".import", FileAccess::WRITE);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_FILE_CANT_OPEN, "Cannot open import file '" + file + ".import'.");
+
+ //write manually, as order matters ([remap] has to go first for performance).
+ f->store_line("[remap]");
+ f->store_line("");
+ f->store_line("importer=\"" + importer->get_importer_name() + "\"");
+ int version = importer->get_format_version();
+ if (version > 0) {
+ f->store_line("importer_version=" + itos(version));
+ }
+ if (!importer->get_resource_type().is_empty()) {
+ f->store_line("type=\"" + importer->get_resource_type() + "\"");
+ }
- if (err == OK) {
- String path = base_path + "." + importer->get_save_extension();
- f->store_line("path=\"" + path + "\"");
- dest_paths.push_back(path);
- }
-
- f->store_line("group_file=" + Variant(p_group_file).get_construct_string());
-
- if (err == OK) {
- f->store_line("valid=true");
- } else {
- f->store_line("valid=false");
- }
- f->store_line("[deps]\n");
+ if (err == OK) {
+ String path = base_path + "." + importer->get_save_extension();
+ f->store_line("path=\"" + path + "\"");
+ dest_paths.push_back(path);
+ }
- f->store_line("");
+ f->store_line("group_file=" + Variant(p_group_file).get_construct_string());
- f->store_line("source_file=" + Variant(file).get_construct_string());
- if (dest_paths.size()) {
- Array dp;
- for (int i = 0; i < dest_paths.size(); i++) {
- dp.push_back(dest_paths[i]);
+ if (err == OK) {
+ f->store_line("valid=true");
+ } else {
+ f->store_line("valid=false");
}
- f->store_line("dest_files=" + Variant(dp).get_construct_string() + "\n");
- }
- f->store_line("[params]");
- f->store_line("");
+ f->store_line("[deps]\n");
- //store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
+ f->store_line("");
- List<ResourceImporter::ImportOption> options;
- importer->get_import_options(file, &options);
- //set default values
- for (const ResourceImporter::ImportOption &F : options) {
- String base = F.option.name;
- Variant v = F.default_value;
- if (source_file_options[file].has(base)) {
- v = source_file_options[file][base];
+ f->store_line("source_file=" + Variant(file).get_construct_string());
+ if (dest_paths.size()) {
+ Array dp;
+ for (int i = 0; i < dest_paths.size(); i++) {
+ dp.push_back(dest_paths[i]);
+ }
+ f->store_line("dest_files=" + Variant(dp).get_construct_string() + "\n");
+ }
+ f->store_line("[params]");
+ f->store_line("");
+
+ //store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
+
+ List<ResourceImporter::ImportOption> options;
+ importer->get_import_options(file, &options);
+ //set default values
+ for (const ResourceImporter::ImportOption &F : options) {
+ String base = F.option.name;
+ Variant v = F.default_value;
+ if (source_file_options[file].has(base)) {
+ v = source_file_options[file][base];
+ }
+ String value;
+ VariantWriter::write_to_string(v, value);
+ f->store_line(base + "=" + value);
}
- String value;
- VariantWriter::write_to_string(v, value);
- f->store_line(base + "=" + value);
}
- f->close();
-
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
- FileAccessRef md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
- ERR_FAIL_COND_V_MSG(!md5s, ERR_FILE_CANT_OPEN, "Cannot open MD5 file '" + base_path + ".md5'.");
+ {
+ Ref<FileAccess> md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
+ ERR_FAIL_COND_V_MSG(md5s.is_null(), ERR_FILE_CANT_OPEN, "Cannot open MD5 file '" + base_path + ".md5'.");
- md5s->store_line("source_md5=\"" + FileAccess::get_md5(file) + "\"");
- if (dest_paths.size()) {
- md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
+ md5s->store_line("source_md5=\"" + FileAccess::get_md5(file) + "\"");
+ if (dest_paths.size()) {
+ md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
+ }
}
- md5s->close();
EditorFileSystemDirectory *fs = nullptr;
int cpos = -1;
@@ -1930,106 +1919,104 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName
//as import is complete, save the .import file
- FileAccess *f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!f, "Cannot open file from path '" + p_file + ".import'.");
-
- //write manually, as order matters ([remap] has to go first for performance).
- f->store_line("[remap]");
- f->store_line("");
- f->store_line("importer=\"" + importer->get_importer_name() + "\"");
- int version = importer->get_format_version();
- if (version > 0) {
- f->store_line("importer_version=" + itos(version));
- }
- if (!importer->get_resource_type().is_empty()) {
- f->store_line("type=\"" + importer->get_resource_type() + "\"");
- }
-
- if (uid == ResourceUID::INVALID_ID) {
- uid = ResourceUID::get_singleton()->create_id();
- }
+ Vector<String> dest_paths;
+ {
+ Ref<FileAccess> f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(f.is_null(), "Cannot open file from path '" + p_file + ".import'.");
- f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); //store in readable format
+ //write manually, as order matters ([remap] has to go first for performance).
+ f->store_line("[remap]");
+ f->store_line("");
+ f->store_line("importer=\"" + importer->get_importer_name() + "\"");
+ int version = importer->get_format_version();
+ if (version > 0) {
+ f->store_line("importer_version=" + itos(version));
+ }
+ if (!importer->get_resource_type().is_empty()) {
+ f->store_line("type=\"" + importer->get_resource_type() + "\"");
+ }
- Vector<String> dest_paths;
+ if (uid == ResourceUID::INVALID_ID) {
+ uid = ResourceUID::get_singleton()->create_id();
+ }
- if (err == OK) {
- if (importer->get_save_extension().is_empty()) {
- //no path
- } else if (import_variants.size()) {
- //import with variants
- for (const String &E : import_variants) {
- String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension();
+ f->store_line("uid=\"" + ResourceUID::get_singleton()->id_to_text(uid) + "\""); //store in readable format
- f->store_line("path." + E + "=\"" + path + "\"");
+ if (err == OK) {
+ if (importer->get_save_extension().is_empty()) {
+ //no path
+ } else if (import_variants.size()) {
+ //import with variants
+ for (const String &E : import_variants) {
+ String path = base_path.c_escape() + "." + E + "." + importer->get_save_extension();
+
+ f->store_line("path." + E + "=\"" + path + "\"");
+ dest_paths.push_back(path);
+ }
+ } else {
+ String path = base_path + "." + importer->get_save_extension();
+ f->store_line("path=\"" + path + "\"");
dest_paths.push_back(path);
}
+
} else {
- String path = base_path + "." + importer->get_save_extension();
- f->store_line("path=\"" + path + "\"");
- dest_paths.push_back(path);
+ f->store_line("valid=false");
}
- } else {
- f->store_line("valid=false");
- }
+ if (metadata != Variant()) {
+ f->store_line("metadata=" + metadata.get_construct_string());
+ }
- if (metadata != Variant()) {
- f->store_line("metadata=" + metadata.get_construct_string());
- }
+ f->store_line("");
- f->store_line("");
+ f->store_line("[deps]\n");
- f->store_line("[deps]\n");
+ if (gen_files.size()) {
+ Array genf;
+ for (const String &E : gen_files) {
+ genf.push_back(E);
+ dest_paths.push_back(E);
+ }
- if (gen_files.size()) {
- Array genf;
- for (const String &E : gen_files) {
- genf.push_back(E);
- dest_paths.push_back(E);
+ String value;
+ VariantWriter::write_to_string(genf, value);
+ f->store_line("files=" + value);
+ f->store_line("");
}
- String value;
- VariantWriter::write_to_string(genf, value);
- f->store_line("files=" + value);
- f->store_line("");
- }
-
- f->store_line("source_file=" + Variant(p_file).get_construct_string());
+ f->store_line("source_file=" + Variant(p_file).get_construct_string());
- if (dest_paths.size()) {
- Array dp;
- for (int i = 0; i < dest_paths.size(); i++) {
- dp.push_back(dest_paths[i]);
+ if (dest_paths.size()) {
+ Array dp;
+ for (int i = 0; i < dest_paths.size(); i++) {
+ dp.push_back(dest_paths[i]);
+ }
+ f->store_line("dest_files=" + Variant(dp).get_construct_string() + "\n");
}
- f->store_line("dest_files=" + Variant(dp).get_construct_string() + "\n");
- }
- f->store_line("[params]");
- f->store_line("");
+ f->store_line("[params]");
+ f->store_line("");
- //store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
+ //store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
- for (const ResourceImporter::ImportOption &E : opts) {
- String base = E.option.name;
- String value;
- VariantWriter::write_to_string(params[base], value);
- f->store_line(base + "=" + value);
+ for (const ResourceImporter::ImportOption &E : opts) {
+ String base = E.option.name;
+ String value;
+ VariantWriter::write_to_string(params[base], value);
+ f->store_line(base + "=" + value);
+ }
}
- f->close();
- memdelete(f);
-
// Store the md5's of the various files. These are stored separately so that the .import files can be version controlled.
- FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!md5s, "Cannot open MD5 file '" + base_path + ".md5'.");
+ {
+ Ref<FileAccess> md5s = FileAccess::open(base_path + ".md5", FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(md5s.is_null(), "Cannot open MD5 file '" + base_path + ".md5'.");
- md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"");
- if (dest_paths.size()) {
- md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
+ md5s->store_line("source_md5=\"" + FileAccess::get_md5(p_file) + "\"");
+ if (dest_paths.size()) {
+ md5s->store_line("dest_md5=\"" + FileAccess::get_multiple_md5(dest_paths) + "\"\n");
+ }
}
- md5s->close();
- memdelete(md5s);
//update modified times, to avoid reimport
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
@@ -2342,14 +2329,14 @@ bool EditorFileSystem::_scan_extensions() {
String extension_list_config_file = NativeExtension::get_extension_list_config_file();
if (extensions.size()) {
if (extensions_added.size() || extensions_removed.size()) { //extensions were added or removed
- FileAccessRef f = FileAccess::open(extension_list_config_file, FileAccess::WRITE);
+ Ref<FileAccess> f = FileAccess::open(extension_list_config_file, FileAccess::WRITE);
for (const String &E : extensions) {
f->store_line(E);
}
}
} else {
if (loaded_extensions.size() || FileAccess::exists(extension_list_config_file)) { //extensions were removed
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
da->remove(extension_list_config_file);
}
}
@@ -2438,7 +2425,7 @@ EditorFileSystem::EditorFileSystem() {
new_filesystem = nullptr;
// This should probably also work on Unix and use the string it returns for FAT32 or exFAT
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
using_fat32_or_exfat = (da->get_filesystem_type() == "FAT32" || da->get_filesystem_type() == "exFAT");
scan_total = 0;
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 0ddac65839..81811d2eb0 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 {
@@ -167,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;
@@ -184,7 +184,7 @@ class EditorFileSystem : public Node {
void _save_late_updated_files();
- EditorFileSystemDirectory *filesystem;
+ EditorFileSystemDirectory *filesystem = nullptr;
static EditorFileSystem *singleton;
@@ -213,7 +213,7 @@ class EditorFileSystem : public Node {
};
void _save_filesystem_cache();
- void _save_filesystem_cache(EditorFileSystemDirectory *p_dir, FileAccess *p_file);
+ void _save_filesystem_cache(EditorFileSystemDirectory *p_dir, Ref<FileAccess> p_file);
bool _find_file(const String &p_file, EditorFileSystemDirectory **r_d, int &r_file_pos) const;
@@ -225,7 +225,7 @@ class EditorFileSystem : public Node {
Set<String> valid_extensions;
Set<String> import_extensions;
- void _scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress);
+ void _scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAccess> &da, const ScanProgress &p_progress);
Thread thread_sources;
bool scanning_changes = false;
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp
index 8d6ebd1154..548f05217e 100644
--- a/editor/editor_folding.cpp
+++ b/editor/editor_folding.cpp
@@ -131,7 +131,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
ERR_FAIL_NULL(p_scene);
- FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
+ Ref<FileAccess> file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
if (!file_check->file_exists(p_path)) { //This can happen when creating scene from FilesystemDock. It has path, but no file.
return;
}
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index 66fe3c4838..3e18499b97 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -218,7 +218,7 @@ Ref<FontData> load_cached_internal_font(const uint8_t *p_data, size_t p_size, Te
}
void editor_register_fonts(Ref<Theme> p_theme) {
- DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
/* Custom font */
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 52f7366dd7..99e30593a9 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -416,7 +416,7 @@ void EditorNode::_version_control_menu_option(int p_idx) {
void EditorNode::_update_title() {
const String appname = ProjectSettings::get_singleton()->get("application/config/name");
- String title = (appname.is_empty() ? "Unnamed Project" : appname) + String(" - ") + VERSION_NAME;
+ String title = (appname.is_empty() ? TTR("Unnamed Project") : appname) + String(" - ") + VERSION_NAME;
const String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_scene_file_path() : String();
if (!edited.is_empty()) {
// Display the edited scene name before the program name so that it can be seen in the OS task bar.
@@ -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;
@@ -935,7 +935,7 @@ void EditorNode::_fs_changed() {
}
if (export_preset.is_null()) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists("res://export_presets.cfg")) {
export_error = vformat(
"Invalid export preset name: %s.\nThe following presets were detected in this project's `export_presets.cfg`:\n\n",
@@ -1058,7 +1058,7 @@ void EditorNode::_scan_external_changes() {
// Check if any edited scene has changed.
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (editor_data.get_scene_path(i) == "" || !da->file_exists(editor_data.get_scene_path(i))) {
continue;
}
@@ -3854,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);
@@ -4261,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);
@@ -5478,7 +5478,7 @@ void EditorNode::_global_menu_new_window(const Variant &p_tag) {
}
}
-void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
+void EditorNode::_dropped_files(const Vector<String> &p_files) {
String to_path = ProjectSettings::get_singleton()->globalize_path(FileSystemDock::get_singleton()->get_selected_path());
_add_dropped_files_recursive(p_files, to_path);
@@ -5487,7 +5487,7 @@ void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
}
void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, String to_path) {
- DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < p_files.size(); i++) {
String from = p_files[i];
@@ -5496,7 +5496,7 @@ void EditorNode::_add_dropped_files_recursive(const Vector<String> &p_files, Str
if (dir->dir_exists(from)) {
Vector<String> sub_files;
- DirAccessRef sub_dir = DirAccess::open(from);
+ Ref<DirAccess> sub_dir = DirAccess::open(from);
sub_dir->list_dir_begin();
String next_file = sub_dir->get_next();
@@ -5773,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);
}
@@ -7168,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);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 7d24cfe758..c6c1f09938 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -275,161 +275,161 @@ private:
bool _initializing_plugins = false;
Map<String, EditorPlugin *> addon_name_to_plugin;
- PanelContainer *scene_root_parent;
- Control *theme_base;
- Control *gui_base;
- VBoxContainer *main_vbox;
- OptionButton *rendering_driver;
+ PanelContainer *scene_root_parent = nullptr;
+ Control *theme_base = nullptr;
+ Control *gui_base = nullptr;
+ VBoxContainer *main_vbox = nullptr;
+ OptionButton *rendering_driver = nullptr;
- ConfirmationDialog *video_restart_dialog;
+ ConfirmationDialog *video_restart_dialog = nullptr;
int rendering_driver_current;
String rendering_driver_request;
// Split containers.
- 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;
- VSplitContainer *center_split;
+ 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;
+ 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;
+ PopupMenu *recent_scenes = nullptr;
String _recent_scene;
List<String> previous_scenes;
String defer_load_scene;
- Node *_last_instantiated_scene;
-
- 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;
+ 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;
-
- 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;
+ MenuButton *update_spinner = nullptr;
- HBoxContainer *main_editor_button_vb;
+ HBoxContainer *main_editor_button_vb = nullptr;
Vector<Button *> main_editor_buttons;
Vector<EditorPlugin *> editor_table;
- AudioStreamPreviewGenerator *audio_preview_gen;
- ProgressDialog *progress_dialog;
- BackgroundProgress *progress_hb;
+ AudioStreamPreviewGenerator *audio_preview_gen = nullptr;
+ ProgressDialog *progress_dialog = nullptr;
+ BackgroundProgress *progress_hb = nullptr;
- DependencyErrorDialog *dependency_error;
+ DependencyErrorDialog *dependency_error = nullptr;
Map<String, Set<String>> dependency_errors;
- DependencyEditor *dependency_fixer;
- OrphanResourcesDialog *orphan_resources;
- ConfirmationDialog *open_imported;
- Button *new_inherited_button;
+ 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;
- Button *dock_float;
- Button *dock_tab_move_left;
- Button *dock_tab_move_right;
- Control *dock_select;
- PopupPanel *dock_select_popup;
+ 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];
TabContainer *dock_slot[DOCK_SLOT_MAX];
- Timer *dock_drag_timer;
+ 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;
Vector<BottomPanelItem> bottom_panel_items;
- 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;
+ 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;
- Tree *disk_changed_list;
- ConfirmationDialog *disk_changed;
+ Tree *disk_changed_list = nullptr;
+ ConfirmationDialog *disk_changed = nullptr;
bool scene_distraction_free = false;
bool script_distraction_free = false;
@@ -447,8 +447,8 @@ private:
int current_menu_option;
- SubViewport *scene_root; // Root of the scene being edited.
- Object *current;
+ SubViewport *scene_root = nullptr; // Root of the scene being edited.
+ Object *current = nullptr;
Ref<Resource> saving_resource;
@@ -464,8 +464,8 @@ private:
uint64_t saved_version;
uint64_t last_checked_version;
- DynamicFontImportSettings *fontdata_import_settings;
- SceneImportSettings *scene_import_settings;
+ DynamicFontImportSettings *fontdata_import_settings = nullptr;
+ SceneImportSettings *scene_import_settings = nullptr;
String import_reload_fn;
@@ -485,7 +485,7 @@ private:
static Vector<EditorNodeInitCallback> _init_callbacks;
static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
- EditorNode *en = (EditorNode *)ud;
+ EditorNode *en = static_cast<EditorNode *>(ud);
if (!en->dependency_errors.has(p_path)) {
en->dependency_errors[p_path] = Set<String>();
}
@@ -575,7 +575,7 @@ private:
void _open_recent_scene(int p_idx);
void _global_menu_scene(const Variant &p_tag);
void _global_menu_new_window(const Variant &p_tag);
- void _dropped_files(const Vector<String> &p_files, int p_screen);
+ void _dropped_files(const Vector<String> &p_files);
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
void _update_from_settings();
@@ -585,7 +585,7 @@ private:
void _exit_editor(int p_exit_code);
- virtual void unhandled_input(const Ref<InputEvent> &p_event) override;
+ virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
bool has_main_screen() const { return true; }
diff --git a/editor/editor_path.h b/editor/editor_path.h
index 1e19344d9e..afc7a20bad 100644
--- a/editor/editor_path.h
+++ b/editor/editor_path.h
@@ -42,12 +42,12 @@ class EditorSelectionHistory;
class EditorPath : public Button {
GDCLASS(EditorPath, Button);
- EditorSelectionHistory *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;
diff --git a/editor/editor_paths.cpp b/editor/editor_paths.cpp
index 7b454055e0..a5c2fe093c 100644
--- a/editor/editor_paths.cpp
+++ b/editor/editor_paths.cpp
@@ -97,7 +97,7 @@ EditorPaths::EditorPaths() {
exe_path = exe_path.plus_file("../../..").simplify_path();
}
{
- DirAccessRef d = DirAccess::create_for_path(exe_path);
+ Ref<DirAccess> d = DirAccess::create_for_path(exe_path);
if (d->file_exists(exe_path + "/._sc_")) {
self_contained = true;
@@ -141,7 +141,7 @@ EditorPaths::EditorPaths() {
// Validate or create each dir and its relevant subdirectories.
- DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
// Data dir.
{
@@ -197,7 +197,7 @@ EditorPaths::EditorPaths() {
// Nothing to create, use shared editor data dir for shader cache.
Engine::get_singleton()->set_shader_cache_path(data_dir);
} else {
- DirAccessRef dir_res = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> dir_res = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (dir_res->change_dir(project_data_dir) != OK) {
dir_res->make_dir_recursive(project_data_dir);
if (dir_res->change_dir(project_data_dir) != OK) {
@@ -210,10 +210,9 @@ EditorPaths::EditorPaths() {
String project_data_gdignore_file_path = project_data_dir.plus_file(".gdignore");
if (!FileAccess::exists(project_data_gdignore_file_path)) {
// Add an empty .gdignore file to avoid scan.
- FileAccessRef f = FileAccess::open(project_data_gdignore_file_path, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(project_data_gdignore_file_path, FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_line("");
- f->close();
} else {
ERR_PRINT("Failed to create file " + project_data_gdignore_file_path);
}
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index b6f48c7536..b728ce64c9 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -161,7 +161,7 @@ void EditorPluginSettings::_cell_button_pressed(Object *p_item, int p_column, in
}
Vector<String> EditorPluginSettings::_get_plugins(const String &p_dir) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
Error err = da->change_dir(p_dir);
if (err != OK) {
return Vector<String>();
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.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_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_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 2bc92427e5..8541918e88 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -199,14 +199,12 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
if (has_small_texture) {
ResourceSaver::save(cache_base + "_small.png", r_small_texture);
}
- FileAccess *f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE);
- ERR_FAIL_COND_MSG(!f, "Cannot create file '" + cache_base + ".txt'. Check user write permissions.");
+ Ref<FileAccess> f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE);
+ ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + cache_base + ".txt'. Check user write permissions.");
f->store_line(itos(thumbnail_size));
f->store_line(itos(has_small_texture));
f->store_line(itos(FileAccess::get_modified_time(p_item.path)));
f->store_line(FileAccess::get_md5(p_item.path));
- f->close();
- memdelete(f);
}
}
}
@@ -251,8 +249,8 @@ void EditorResourcePreview::_iterate() {
//does not have it, try to load a cached thumbnail
String file = cache_base + ".txt";
- FileAccess *f = FileAccess::open(file, FileAccess::READ);
- if (!f) {
+ Ref<FileAccess> f = FileAccess::open(file, FileAccess::READ);
+ if (f.is_null()) {
// No cache found, generate
_generate_preview(texture, small_texture, item, cache_base);
} else {
@@ -265,33 +263,31 @@ void EditorResourcePreview::_iterate() {
if (tsize != thumbnail_size) {
cache_valid = false;
- memdelete(f);
+ f.unref();
} else if (last_modtime != modtime) {
String last_md5 = f->get_line();
String md5 = FileAccess::get_md5(item.path);
- memdelete(f);
+ f.unref();
if (last_md5 != md5) {
cache_valid = false;
-
} else {
//update modified time
- f = FileAccess::open(file, FileAccess::WRITE);
- if (!f) {
+ Ref<FileAccess> f2 = FileAccess::open(file, FileAccess::WRITE);
+ if (f2.is_null()) {
// Not returning as this would leave the thread hanging and would require
// some proper cleanup/disabling of resource preview generation.
ERR_PRINT("Cannot create file '" + file + "'. Check user write permissions.");
} else {
- f->store_line(itos(thumbnail_size));
- f->store_line(itos(has_small_texture));
- f->store_line(itos(modtime));
- f->store_line(md5);
- memdelete(f);
+ f2->store_line(itos(thumbnail_size));
+ f2->store_line(itos(has_small_texture));
+ f2->store_line(itos(modtime));
+ f2->store_line(md5);
}
}
} else {
- memdelete(f);
+ f.unref();
}
if (cache_valid) {
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..4acbc32e7c 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")
@@ -842,7 +842,7 @@ void EditorSettings::create() {
if (EditorPaths::get_singleton()->are_paths_valid()) {
// Validate editor config file.
- DirAccessRef dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir());
+ Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir());
String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
config_file_path = EditorPaths::get_singleton()->get_config_dir().plus_file(config_file_name);
if (!dir->file_exists(config_file_name)) {
@@ -1151,12 +1151,11 @@ void EditorSettings::set_favorites(const Vector<String> &p_favorites) {
} else {
favorites_file = get_project_settings_dir().plus_file("favorites");
}
- FileAccess *f = FileAccess::open(favorites_file, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::WRITE);
+ if (f.is_valid()) {
for (int i = 0; i < favorites.size(); i++) {
f->store_line(favorites[i]);
}
- memdelete(f);
}
}
@@ -1172,12 +1171,11 @@ void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) {
} else {
recent_dirs_file = get_project_settings_dir().plus_file("recent_dirs");
}
- FileAccess *f = FileAccess::open(recent_dirs_file, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(recent_dirs_file, FileAccess::WRITE);
+ if (f.is_valid()) {
for (int i = 0; i < recent_dirs.size(); i++) {
f->store_line(recent_dirs[i]);
}
- memdelete(f);
}
}
@@ -1195,24 +1193,22 @@ void EditorSettings::load_favorites_and_recent_dirs() {
favorites_file = get_project_settings_dir().plus_file("favorites");
recent_dirs_file = get_project_settings_dir().plus_file("recent_dirs");
}
- FileAccess *f = FileAccess::open(favorites_file, FileAccess::READ);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(favorites_file, FileAccess::READ);
+ if (f.is_valid()) {
String line = f->get_line().strip_edges();
while (!line.is_empty()) {
favorites.push_back(line);
line = f->get_line().strip_edges();
}
- memdelete(f);
}
f = FileAccess::open(recent_dirs_file, FileAccess::READ);
- if (f) {
+ if (f.is_valid()) {
String line = f->get_line().strip_edges();
while (!line.is_empty()) {
recent_dirs.push_back(line);
line = f->get_line().strip_edges();
}
- memdelete(f);
}
}
@@ -1227,8 +1223,8 @@ bool EditorSettings::is_dark_theme() {
void EditorSettings::list_text_editor_themes() {
String themes = "Default,Godot 2,Custom";
- DirAccessRef d = DirAccess::open(get_text_editor_themes_dir());
- if (d) {
+ Ref<DirAccess> d = DirAccess::open(get_text_editor_themes_dir());
+ if (d.is_valid()) {
List<String> custom_themes;
d->list_dir_begin();
String file = d->get_next();
@@ -1293,8 +1289,8 @@ bool EditorSettings::import_text_editor_theme(String p_file) {
return false;
}
- DirAccessRef d = DirAccess::open(get_text_editor_themes_dir());
- if (d) {
+ Ref<DirAccess> d = DirAccess::open(get_text_editor_themes_dir());
+ if (d.is_valid()) {
d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file()));
return true;
}
@@ -1345,8 +1341,8 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension, c
if (!p_custom_path.is_empty()) {
template_dir = p_custom_path;
}
- DirAccessRef d = DirAccess::open(template_dir);
- if (d) {
+ Ref<DirAccess> d = DirAccess::open(template_dir);
+ if (d.is_valid()) {
d->list_dir_begin();
String file = d->get_next();
while (!file.is_empty()) {
@@ -1365,7 +1361,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 +1385,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_themes.cpp b/editor/editor_themes.cpp
index 1fea759a90..f4082746d8 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1220,10 +1220,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons")));
theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
- // H/VSplitContainer
- theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiVsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
- theme->set_stylebox("bg", "HSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiHsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1));
-
theme->set_icon("grabber", "VSplitContainer", theme->get_icon(SNAME("GuiVsplitter"), SNAME("EditorIcons")));
theme->set_icon("grabber", "HSplitContainer", theme->get_icon(SNAME("GuiHsplitter"), SNAME("EditorIcons")));
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_translation.cpp b/editor/editor_translation.cpp
index f64adcf0a1..b08e5807e7 100644
--- a/editor/editor_translation.cpp
+++ b/editor/editor_translation.cpp
@@ -59,7 +59,8 @@ void load_editor_translations(const String &p_locale) {
int ret = Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
ERR_FAIL_COND_MSG(ret == -1, "Compressed file is corrupt.");
- FileAccessMemory *fa = memnew(FileAccessMemory);
+ Ref<FileAccessMemory> fa;
+ fa.instantiate();
fa->open_custom(data.ptr(), data.size());
Ref<Translation> tr = TranslationLoaderPO::load_translation(fa);
@@ -84,7 +85,8 @@ void load_doc_translations(const String &p_locale) {
int ret = Compression::decompress(data.ptrw(), dtl->uncomp_size, dtl->data, dtl->comp_size, Compression::MODE_DEFLATE);
ERR_FAIL_COND_MSG(ret == -1, "Compressed file is corrupt.");
- FileAccessMemory *fa = memnew(FileAccessMemory);
+ Ref<FileAccessMemory> fa;
+ fa.instantiate();
fa->open_custom(data.ptr(), data.size());
Ref<Translation> tr = TranslationLoaderPO::load_translation(fa);
diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp
index 0954779300..3f2012cc16 100644
--- a/editor/editor_vcs_interface.cpp
+++ b/editor/editor_vcs_interface.cpp
@@ -168,21 +168,19 @@ void EditorVCSInterface::set_singleton(EditorVCSInterface *p_singleton) {
void EditorVCSInterface::create_vcs_metadata_files(VCSMetadata p_vcs_metadata_type, String &p_dir) {
if (p_vcs_metadata_type == VCSMetadata::GIT) {
- FileAccess *f = FileAccess::open(p_dir.plus_file(".gitignore"), FileAccess::WRITE);
- if (!f) {
+ Ref<FileAccess> f = FileAccess::open(p_dir.plus_file(".gitignore"), FileAccess::WRITE);
+ if (f.is_null()) {
ERR_FAIL_MSG(TTR("Couldn't create .gitignore in project path."));
} else {
f->store_line("# Godot 4+ specific ignores");
f->store_line(".godot/");
- memdelete(f);
}
f = FileAccess::open(p_dir.plus_file(".gitattributes"), FileAccess::WRITE);
- if (!f) {
+ if (f.is_null()) {
ERR_FAIL_MSG(TTR("Couldn't create .gitattributes in project path."));
} else {
f->store_line("# Normalize EOL for all files that Git considers text files.");
f->store_line("* text=auto eol=lf");
- memdelete(f);
}
}
}
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..06c179e77c 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -44,7 +44,7 @@
void ExportTemplateManager::_update_template_status() {
// Fetch installed templates from the file system.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
Error err = da->change_dir(templates_dir);
@@ -194,7 +194,7 @@ void ExportTemplateManager::_download_template_completed(int p_status, int p_cod
bool ret = _install_file_selected(path, true);
if (ret) {
// Clean up downloaded file.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = da->remove(path);
if (err != OK) {
EditorNode::get_singleton()->add_io_error(TTR("Cannot remove temporary file:") + "\n" + path + "\n");
@@ -374,10 +374,7 @@ void ExportTemplateManager::_install_file() {
}
bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_skip_progress) {
- // unzClose() will take care of closing the file stored in the unzFile,
- // so we don't need to `memdelete(fa)` in this method.
- FileAccess *fa = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&fa);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
@@ -395,6 +392,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 +404,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;
@@ -435,7 +438,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
return false;
}
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version);
Error err = d->make_dir_recursive(template_path);
if (err != OK) {
@@ -455,7 +458,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 +477,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("/");
@@ -480,8 +489,8 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
base_dir = base_dir.substr(contents_dir.length(), file_path.length()).trim_prefix("/");
file = base_dir.plus_file(file);
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- ERR_CONTINUE(!da);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ ERR_CONTINUE(da.is_null());
String output_dir = template_path.plus_file(base_dir);
@@ -496,16 +505,16 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
}
String to_write = template_path.plus_file(file);
- FileAccessRef f = FileAccess::open(to_write, FileAccess::WRITE);
+ Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
- if (!f) {
+ if (f.is_null()) {
ret = unzGoToNextFile(pkg);
fc++;
ERR_CONTINUE_MSG(true, "Can't open file from path '" + String(to_write) + "'.");
}
f->store_buffer(data.ptr(), data.size());
-
+ f.unref(); // close file.
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
#endif
@@ -530,7 +539,7 @@ void ExportTemplateManager::_uninstall_template(const String &p_version) {
}
void ExportTemplateManager::_uninstall_template_confirmed() {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
const String &templates_dir = EditorSettings::get_singleton()->get_templates_dir();
Error err = da->change_dir(templates_dir);
@@ -644,17 +653,16 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
// To support custom Android builds, we install the Java source code and buildsystem
// from android_source.zip to the project's res://android folder.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- ERR_FAIL_COND_V(!da, ERR_CANT_CREATE);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ ERR_FAIL_COND_V(da.is_null(), ERR_CANT_CREATE);
// Make res://android dir (if it does not exist).
da->make_dir("android");
{
// Add version, to ensure building won't work if template and Godot version don't match.
- FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::WRITE);
- ERR_FAIL_COND_V(!f, ERR_CANT_CREATE);
+ Ref<FileAccess> f = FileAccess::open("res://android/.build_version", FileAccess::WRITE);
+ ERR_FAIL_COND_V(f.is_null(), ERR_CANT_CREATE);
f->store_line(VERSION_FULL_CONFIG);
- f->close();
}
// Create the android plugins directory.
@@ -665,16 +673,14 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
ERR_FAIL_COND_V(err != OK, err);
{
// Add an empty .gdignore file to avoid scan.
- FileAccessRef f = FileAccess::open("res://android/build/.gdignore", FileAccess::WRITE);
- ERR_FAIL_COND_V(!f, ERR_CANT_CREATE);
+ Ref<FileAccess> f = FileAccess::open("res://android/build/.gdignore", FileAccess::WRITE);
+ ERR_FAIL_COND_V(f.is_null(), ERR_CANT_CREATE);
f->store_line("");
- f->close();
}
// Uncompress source template.
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
@@ -697,6 +703,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();
@@ -716,10 +725,10 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
}
String to_write = String("res://android/build").plus_file(path);
- FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(to_write, FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
+ f.unref(); // close file.
#ifndef WINDOWS_ENABLED
FileAccess::set_unix_permissions(to_write, (info.external_fa >> 16) & 0x01FF);
#endif
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..46fb767c00 100644
--- a/editor/fileserver/editor_file_server.cpp
+++ b/editor/fileserver/editor_file_server.cpp
@@ -46,14 +46,13 @@ void EditorFileServer::_close_client(ClientData *cd) {
cd->efs->to_wait.insert(cd->thread);
}
while (cd->files.size()) {
- memdelete(cd->files.front()->get());
cd->files.erase(cd->files.front());
}
memdelete(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];
@@ -181,8 +180,8 @@ void EditorFileServer::_subthread_start(void *s) {
break;
}
- FileAccess *fa = FileAccess::open(s2, FileAccess::READ);
- if (!fa) {
+ Ref<FileAccess> fa = FileAccess::open(s2, FileAccess::READ);
+ if (fa.is_null()) {
//not found, continue
encode_uint32(id, buf4);
cd->connection->put_data(buf4, 4);
@@ -249,7 +248,6 @@ void EditorFileServer::_subthread_start(void *s) {
case FileAccessNetwork::COMMAND_CLOSE: {
print_verbose("CLOSED");
ERR_CONTINUE(!cd->files.has(id));
- memdelete(cd->files[id]);
cd->files.erase(id);
} break;
}
@@ -259,7 +257,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..ccebd1465d 100644
--- a/editor/fileserver/editor_file_server.h
+++ b/editor/fileserver/editor_file_server.h
@@ -47,9 +47,9 @@ class EditorFileServer : public Object {
};
struct ClientData {
- Thread *thread;
+ Thread *thread = nullptr;
Ref<StreamPeerTCP> connection;
- Map<int, FileAccess *> files;
+ Map<int, Ref<FileAccess>> files;
EditorFileServer *efs = nullptr;
bool quit = false;
};
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index ee7ed77957..a45568db48 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -225,13 +225,14 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
Vector<String> favorite_paths = EditorSettings::get_singleton()->get_favorites();
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> 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);
@@ -538,7 +539,7 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
if (target_path.ends_with("/")) {
target_path = target_path.substr(0, target_path.length() - 1);
}
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists(p_path)) {
path = target_path;
} else if (da->dir_exists(p_path)) {
@@ -1182,7 +1183,7 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
_get_all_items_in_dir(EditorFileSystem::get_singleton()->get_filesystem_path(old_path), file_changed_paths, folder_changed_paths);
}
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
print_verbose("Moving " + old_path + " -> " + new_path);
Error err = da->rename(old_path, new_path);
if (err == OK) {
@@ -1240,7 +1241,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
return;
}
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
print_verbose("Duplicating " + old_path + " -> " + new_path);
Error err = p_item.is_file ? da->copy(old_path, new_path) : da->copy_dir(old_path, new_path);
if (err == OK) {
@@ -1259,7 +1260,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
cfg->save(new_path + ".import");
} else if (p_item.is_file && (old_path.get_extension() == "tscn" || old_path.get_extension() == "tres")) {
// FIXME: Quick hack to fix text resources. This should be fixed properly.
- FileAccessRef file = FileAccess::open(old_path, FileAccess::READ, &err);
+ Ref<FileAccess> file = FileAccess::open(old_path, FileAccess::READ, &err);
if (err == OK) {
PackedStringArray lines = file->get_as_utf8_string().split("\n");
String line = lines[0];
@@ -1268,7 +1269,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
line = line.substr(0, line.find(" uid")) + "]";
lines.write[0] = line;
- FileAccessRef file2 = FileAccess::open(new_path, FileAccess::WRITE, &err);
+ Ref<FileAccess> file2 = FileAccess::open(new_path, FileAccess::WRITE, &err);
if (err == OK) {
file2->store_string(String("\n").join(lines));
}
@@ -1427,17 +1428,17 @@ void FileSystemDock::_make_dir_confirm() {
directory = directory.get_base_dir();
}
- if (EditorFileSystem::get_singleton()->get_filesystem_path(directory + dir_name)) {
+ print_verbose("Making folder " + dir_name + " in " + directory);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Error err = da->change_dir(directory);
+ 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;
}
- 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 = da->make_dir(dir_name);
if (err == OK) {
print_verbose("FileSystem: calling rescan.");
@@ -1478,7 +1479,7 @@ void FileSystemDock::_make_scene_confirm() {
scene_name = directory.plus_file(scene_name);
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists(scene_name)) {
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
return;
@@ -1493,7 +1494,7 @@ void FileSystemDock::_file_removed(String p_file) {
// Find the closest parent directory available, in case multiple items were deleted along the same path.
path = p_file.get_base_dir();
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
while (!da->dir_exists(path)) {
path = path.get_base_dir();
}
@@ -1506,7 +1507,7 @@ void FileSystemDock::_folder_removed(String p_folder) {
// Find the closest parent directory available, in case multiple items were deleted along the same path.
path = p_folder.get_base_dir();
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
while (!da->dir_exists(path)) {
path = path.get_base_dir();
}
@@ -1545,7 +1546,7 @@ void FileSystemDock::_rename_operation_confirm() {
}
// Present a more user friendly warning for name conflict.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
#if defined(WINDOWS_ENABLED) || defined(UWP_ENABLED)
// Workaround case insensitivity on Windows.
if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) {
@@ -1598,7 +1599,7 @@ void FileSystemDock::_duplicate_operation_confirm() {
String new_path = base_dir.plus_file(new_name);
// Present a more user friendly warning for name conflict
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->file_exists(new_path) || da->dir_exists(new_path)) {
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
return;
@@ -2353,7 +2354,7 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
int exist_counter = 1;
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
while (da->file_exists(new_path) || da->dir_exists(new_path)) {
exist_counter++;
new_path = vformat(new_path_base, exist_counter);
@@ -2830,7 +2831,7 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &f
return;
}
- DirAccessRef da = DirAccess::open(p_path);
+ Ref<DirAccess> da = DirAccess::open(p_path);
da->list_dir_begin();
String n = da->get_next();
while (!n.is_empty()) {
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..41191271a1 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -211,8 +211,8 @@ float FindInFiles::get_progress() const {
}
void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
- DirAccessRef dir = DirAccess::open(path);
- if (!dir) {
+ Ref<DirAccess> dir = DirAccess::open(path);
+ if (dir.is_null()) {
print_verbose("Cannot open directory! " + path);
return;
}
@@ -253,8 +253,8 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
}
void FindInFiles::_scan_file(String fpath) {
- FileAccessRef f = FileAccess::open(fpath, FileAccess::READ);
- if (!f) {
+ Ref<FileAccess> f = FileAccess::open(fpath, FileAccess::READ);
+ if (f.is_null()) {
print_verbose(String("Cannot open file ") + fpath);
return;
}
@@ -274,8 +274,6 @@ void FindInFiles::_scan_file(String fpath) {
emit_signal(SNAME(SIGNAL_RESULT_FOUND), fpath, line_number, begin, end, line);
}
}
-
- f->close();
}
void FindInFiles::_bind_methods() {
@@ -449,7 +447,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 +487,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();
}
@@ -873,7 +871,7 @@ void FindInFilesPanel::_on_replace_all_clicked() {
// Same as get_line, but preserves line ending characters.
class ConservativeGetLine {
public:
- String get_line(FileAccess *f) {
+ String get_line(Ref<FileAccess> f) {
_line_buffer.clear();
char32_t c = f->get_8();
@@ -908,8 +906,8 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
// If there are unsaved changes, the user will be asked on focus,
// however that means either losing changes or losing replaces.
- FileAccessRef f = FileAccess::open(fpath, FileAccess::READ);
- ERR_FAIL_COND_MSG(!f, "Cannot open file from path '" + fpath + "'.");
+ Ref<FileAccess> f = FileAccess::open(fpath, FileAccess::READ);
+ ERR_FAIL_COND_MSG(f.is_null(), "Cannot open file from path '" + fpath + "'.");
String buffer;
int current_line = 1;
@@ -958,8 +956,6 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
ERR_FAIL_COND_MSG(err != OK, "Cannot create file in path '" + fpath + "'.");
f->store_string(buffer);
-
- f->close();
}
String FindInFilesPanel::get_replace_text() {
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/icons/AnimationLibrary.svg b/editor/icons/AnimationLibrary.svg
new file mode 100644
index 0000000000..0bac67d302
--- /dev/null
+++ b/editor/icons/AnimationLibrary.svg
@@ -0,0 +1 @@
+<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M14.519 2.006A6 6 0 0 0 8.599 8a6 6 0 0 0 5.92 5.994v-1.01a1 1 0 0 1-.92-.984 1 1 0 0 1 .92-.984V4.984a1 1 0 0 1-.92-.984 1 1 0 0 1 .92-.984Zm-3.432 2.996a1 1 0 0 1 .547.133 1 1 0 0 1 .367 1.365 1 1 0 0 1-1.367.365A1 1 0 0 1 10.27 5.5a1 1 0 0 1 .818-.498ZM11.111 9a1 1 0 0 1 .89.5 1 1 0 0 1-.367 1.365 1 1 0 0 1-1.365-.365 1 1 0 0 1 .365-1.365A1 1 0 0 1 11.111 9Z" style="fill:#e0e0e0;fill-opacity:1"/><path d="M11.094 2.104a6 6 0 0 0-5.92 5.994 6 6 0 0 0 5.92 5.994v-.023a5.795 6.506 0 0 1-2.89-3.104 1 1 0 0 1-1.36-.367 1 1 0 0 1 .365-1.365 1 1 0 0 1 .475-.135 5.795 6.506 0 0 1-.076-.984 5.795 6.506 0 0 1 .082-1.027 1 1 0 0 1-.48-.124 1 1 0 0 1-.366-1.365 1 1 0 0 1 .818-.498 1 1 0 0 1 .547.133 1 1 0 0 1 .004.002 5.795 6.506 0 0 1 2.881-3.076z" style="fill:#e0e0e0;fill-opacity:1"/><path d="M7.616 2.104a6 6 0 0 0-5.92 5.994 6 6 0 0 0 5.92 5.994v-.023a5.795 6.506 0 0 1-2.89-3.104 1 1 0 0 1-1.36-.367 1 1 0 0 1 .366-1.365 1 1 0 0 1 .474-.135 5.795 6.506 0 0 1-.076-.984 5.795 6.506 0 0 1 .082-1.027 1 1 0 0 1-.48-.124 1 1 0 0 1-.366-1.365 1 1 0 0 1 .819-.498 1 1 0 0 1 .547.133 1 1 0 0 1 .003.002 5.795 6.506 0 0 1 2.881-3.076z" style="fill:#e0e0e0;fill-opacity:1"/></svg>
diff --git a/editor/icons/ArrayOccluder3D.svg b/editor/icons/ArrayOccluder3D.svg
new file mode 100644
index 0000000000..ac45821897
--- /dev/null
+++ b/editor/icons/ArrayOccluder3D.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m13 1c-1.104569 0-2 .8954305-2 2s.895431 2 2 2 2-.8954305 2-2-.895431-2-2-2zm-2 7v3h-3v2h3v3h2v-3h3v-2h-3v-3zm-8 3c-1.1045695 0-2 .895431-2 2s.8954305 2 2 2 2-.895431 2-2-.8954305-2-2-2z" fill="#ffca5f"/></svg>
diff --git a/editor/icons/BoxOccluder3D.svg b/editor/icons/BoxOccluder3D.svg
new file mode 100644
index 0000000000..3cee3db532
--- /dev/null
+++ b/editor/icons/BoxOccluder3D.svg
@@ -0,0 +1 @@
+<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m8 .88867188-.5058594.25390622a4.5 4.5 0 0 1 1.3789063 2.2988281l3.0664061 1.5332032-3.5546874 1.7753906a4.5 4.5 0 0 1 -1.6796875 1.6601562l.2949219.1464844v3.9414064l-4-2.001953v-1.7636721a4.5 4.5 0 0 1 -2-1.4179688v4.2968749l7 3.5 7-3.5v-7.2226561zm5 5.66796872v3.9394534l-4 2.001953v-3.9414064z"/><path d="m8 .88867188-.5058594.25390622a4.5 4.5 0 0 1 1.5058594 3.3574219 4.5 4.5 0 0 1 -4.5 4.5 4.5 4.5 0 0 1 -3.5-1.6855469v4.2968749l7 3.5 7-3.5v-7.2226561z" fill="#ffca5f"/></svg>
diff --git a/editor/icons/GuiVsplitBg.svg b/editor/icons/GuiVsplitBg.svg
deleted file mode 100644
index 9844fc2018..0000000000
--- a/editor/icons/GuiVsplitBg.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg height="8" viewBox="0 0 8 7.9999995" width="8" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h8v8h-8z" fill-opacity=".098039"/></svg>
diff --git a/editor/icons/Occluder3D.svg b/editor/icons/Occluder3D.svg
index 850e2651af..c91a77781b 100644
--- a/editor/icons/Occluder3D.svg
+++ b/editor/icons/Occluder3D.svg
@@ -1 +1 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.90625 1a7 7 0 0 0 -1.2988281.1386719 4.5 4.5 0 0 1 3.3925781 4.3613281 4.5 4.5 0 0 1 -4.5 4.5 4.5 4.5 0 0 1 -4.359375-3.3886719 7 7 0 0 0 -.140625 1.3886719 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0 -7-7 7 7 0 0 0 -.09375 0z" fill="#ffca5f" stroke-width=".365215"/></svg>
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m13 1a2 2 0 0 0 -1.730469 1h-3.0273435a4.5 4.5 0 0 1 .7285156 2h2.3007809a2 2 0 0 0 .728516.7304688v5.8554692l-3.6933594-3.6933599a4.5 4.5 0 0 1 -1.4140625 1.4140625l3.6933599 3.6933594h-5.8574224a2 2 0 0 0 -.7285156-.730469v-2.3046872a4.5 4.5 0 0 1 -2-.7285157v3.0351559a2 2 0 0 0 -1 1.728516 2 2 0 0 0 2 2 2 2 0 0 0 1.7304688-1h6.5410152a2 2 0 0 0 1.728516 1 2 2 0 0 0 2-2 2 2 0 0 0 -1.03125-1.75h.03125v-6.5214844a2 2 0 0 0 1-1.7285156 2 2 0 0 0 -2-2z" fill="#ffca5f"/></svg>
diff --git a/editor/icons/PolygonOccluder3D.svg b/editor/icons/PolygonOccluder3D.svg
new file mode 100644
index 0000000000..fc87e5e086
--- /dev/null
+++ b/editor/icons/PolygonOccluder3D.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#ffca5f" stroke-linejoin="round"><path d="m8.2421875 2a4.5 4.5 0 0 1 .7578125 2.5 4.5 4.5 0 0 1 -4.5 4.5 4.5 4.5 0 0 1 -2.5-.7636719v5.7636719h12l-6-6 6-6z" stroke-width="2"/><path d="m7.328125 1c.6472144.5230929 1.136703 1.2154082 1.4140625 2h2.8437505l-2.7675786 2.767578c-.2943505.9927946-.9220914 1.8536963-1.7773438 2.4375.0343146.1879491.1217471.3621363.2519532.501953l4.2929692 4.292969h-8.585938v-4.267578c-.785054-.2784421-1.4774185-.7693178-2-1.417969v6.685547c.0000552.552262.4477381.999945 1 1h12c.890637-.00035 1.336587-1.077036.707031-1.707031l-5.2929685-5.292969 5.2929685-5.292969c.629556-.6299945.183606-1.7066812-.707031-1.707031z"/></g></svg>
diff --git a/editor/icons/QuadOccluder3D.svg b/editor/icons/QuadOccluder3D.svg
new file mode 100644
index 0000000000..16da6f420f
--- /dev/null
+++ b/editor/icons/QuadOccluder3D.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.328125 1c.6472144.5230929 1.136703 1.2154082 1.4140625 2h4.2578125v8.585938l-4.6933594-4.6933599c-.3593282.5714479-.8426146 1.0547343-1.4140625 1.4140625l4.6933599 4.6933594h-8.585938v-4.2675781c-.785054-.2784421-1.4774185-.7693176-2-1.4179688v7.6855469h14v-14z" fill="#ffca5f"/></svg>
diff --git a/editor/icons/SphereOccluder3D.svg b/editor/icons/SphereOccluder3D.svg
new file mode 100644
index 0000000000..850e2651af
--- /dev/null
+++ b/editor/icons/SphereOccluder3D.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.90625 1a7 7 0 0 0 -1.2988281.1386719 4.5 4.5 0 0 1 3.3925781 4.3613281 4.5 4.5 0 0 1 -4.5 4.5 4.5 4.5 0 0 1 -4.359375-3.3886719 7 7 0 0 0 -.140625 1.3886719 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0 -7-7 7 7 0 0 0 -.09375 0z" fill="#ffca5f" stroke-width=".365215"/></svg>
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/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 69fa64c24c..97fc33ad25 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1801,7 +1801,14 @@ Node *EditorSceneFormatImporterCollada::import_scene(const String &p_path, uint3
name = state.animations[i]->get_name();
}
- ap->add_animation(name, state.animations[i]);
+ Ref<AnimationLibrary> library;
+ if (!ap->has_animation_library("")) {
+ library.instantiate();
+ ap->add_animation_library("", library);
+ } else {
+ library = ap->get_animation_library("");
+ }
+ library->add_animation(name, state.animations[i]);
}
state.scene->add_child(ap, true);
ap->set_owner(state.scene);
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index f0ee14bdcb..ee6500a643 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -88,9 +88,8 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
break;
}
- FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ);
-
- ERR_FAIL_COND_V_MSG(!f, ERR_INVALID_PARAMETER, "Cannot open file from path '" + p_source_file + "'.");
+ Ref<FileAccess> f = FileAccess::open(p_source_file, FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_INVALID_PARAMETER, "Cannot open file from path '" + p_source_file + "'.");
Vector<String> line = f->get_csv_line(delimiter);
ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR);
diff --git a/editor/import/resource_importer_image.cpp b/editor/import/resource_importer_image.cpp
index e6a822d827..8514df76bb 100644
--- a/editor/import/resource_importer_image.cpp
+++ b/editor/import/resource_importer_image.cpp
@@ -71,10 +71,9 @@ void ResourceImporterImage::get_import_options(const String &p_path, List<Import
}
Error ResourceImporterImage::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
- FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
-
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'.");
+ Ref<FileAccess> f = FileAccess::open(p_source_file, FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, "Cannot open file from path '" + p_source_file + "'.");
uint64_t len = f->get_length();
Vector<uint8_t> data;
@@ -82,10 +81,8 @@ Error ResourceImporterImage::import(const String &p_source_file, const String &p
f->get_buffer(data.ptrw(), len);
- memdelete(f);
-
f = FileAccess::open(p_save_path + ".image", FileAccess::WRITE);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file in path '" + p_save_path + ".image'.");
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_CREATE, "Cannot create file in path '" + p_save_path + ".image'.");
//save the header GDIM
const uint8_t header[4] = { 'G', 'D', 'I', 'M' };
@@ -95,8 +92,6 @@ Error ResourceImporterImage::import(const String &p_source_file, const String &p
//SAVE the actual image
f->store_buffer(data.ptr(), len);
- memdelete(f);
-
return OK;
}
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 9ddee9c058..7c0c99cd29 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -257,7 +257,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
}
}
- FileAccessRef f = FileAccess::open(p_to_path, FileAccess::WRITE);
+ Ref<FileAccess> f = FileAccess::open(p_to_path, FileAccess::WRITE);
f->store_8('G');
f->store_8('S');
f->store_8('T');
@@ -280,8 +280,6 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
for (int i = 0; i < mipmap_images.size(); i++) {
ResourceImporterTexture::save_to_ctex_format(f, mipmap_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy);
}
-
- f->close();
}
Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 9042f1e32c..308eb9cefa 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -44,8 +44,8 @@ uint32_t EditorOBJImporter::get_import_flags() const {
}
static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D>> &material_map, List<String> *r_missing_deps) {
- FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
+ Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path));
Ref<StandardMaterial3D> current;
String current_name;
@@ -203,8 +203,8 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand
}
static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_single_mesh, bool p_generate_tangents, bool p_optimize, Vector3 p_scale_mesh, Vector3 p_offset_mesh, List<String> *r_missing_deps) {
- FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
- ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
+ Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
+ ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
Ref<ArrayMesh> mesh;
mesh.instantiate();
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index e7c605aaf0..bfa71bfda4 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -473,7 +473,9 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<I
if (_teststr(animname, loop_strings[i])) {
anim->set_loop_mode(Animation::LoopMode::LOOP_LINEAR);
animname = _fixstr(animname, loop_strings[i]);
- ap->rename_animation(E, animname);
+
+ Ref<AnimationLibrary> library = ap->get_animation_library(ap->find_animation_library(anim));
+ library->rename_animation(E, animname);
}
}
}
@@ -1019,7 +1021,8 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref<
Ref<Animation> saved_anim = _save_animation_to_file(anim, save, path, keep_custom);
if (saved_anim != anim) {
- ap->add_animation(name, saved_anim); //replace
+ Ref<AnimationLibrary> al = ap->get_animation_library(ap->find_animation_library(anim));
+ al->add_animation(name, saved_anim); //replace
}
}
}
@@ -1109,6 +1112,7 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_
}
Ref<Animation> default_anim = anim->get_animation("default");
+ Ref<AnimationLibrary> al = anim->get_animation_library(anim->find_animation(default_anim));
for (int i = 0; i < p_clips.size(); i += 7) {
String name = p_clips[i];
@@ -1246,15 +1250,16 @@ void ResourceImporterScene::_create_clips(AnimationPlayer *anim, const Array &p_
new_anim->set_loop_mode(loop_mode);
new_anim->set_length(to - from);
- anim->add_animation(name, new_anim);
+
+ al->add_animation(name, new_anim);
Ref<Animation> saved_anim = _save_animation_to_file(new_anim, save_to_file, save_to_path, keep_current);
if (saved_anim != new_anim) {
- anim->add_animation(name, saved_anim);
+ al->add_animation(name, saved_anim);
}
}
- anim->remove_animation("default"); //remove default (no longer needed)
+ al->remove_animation("default"); // Remove default (no longer needed).
}
void ResourceImporterScene::_optimize_animations(AnimationPlayer *anim, float p_max_lin_error, float p_max_ang_error, float p_max_angle) {
@@ -2086,14 +2091,13 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
_generate_meshes(scene, mesh_data, gen_lods, create_shadow_meshes, LightBakeMode(light_bake_mode), lightmap_texel_size, src_lightmap_cache, mesh_lightmap_caches);
if (mesh_lightmap_caches.size()) {
- FileAccessRef f = FileAccess::open(p_source_file + ".unwrap_cache", FileAccess::WRITE);
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(p_source_file + ".unwrap_cache", FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_32(mesh_lightmap_caches.size());
for (int i = 0; i < mesh_lightmap_caches.size(); i++) {
String md5 = String::md5(mesh_lightmap_caches[i].ptr());
f->store_buffer(mesh_lightmap_caches[i].ptr(), mesh_lightmap_caches[i].size());
}
- f->close();
}
}
err = OK;
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp
index cc34259a2d..1d70a47daa 100644
--- a/editor/import/resource_importer_shader_file.cpp
+++ b/editor/import/resource_importer_shader_file.cpp
@@ -82,7 +82,7 @@ static String _include_function(const String &p_path, void *userpointer) {
include = base_path->plus_file(include);
}
- FileAccessRef file_inc = FileAccess::open(include, FileAccess::READ, &err);
+ Ref<FileAccess> file_inc = FileAccess::open(include, FileAccess::READ, &err);
if (err != OK) {
return String();
}
@@ -93,7 +93,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
/* STEP 1, Read shader code */
Error err;
- FileAccessRef file = FileAccess::open(p_source_file, FileAccess::READ, &err);
+ Ref<FileAccess> file = FileAccess::open(p_source_file, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
ERR_FAIL_COND_V(!file.operator->(), ERR_CANT_OPEN);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index e2fa624fc6..de51a28c5a 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -229,7 +229,7 @@ void ResourceImporterTexture::get_import_options(const String &p_path, List<Impo
}
}
-void ResourceImporterTexture::save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) {
+void ResourceImporterTexture::save_to_ctex_format(Ref<FileAccess> f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) {
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/force_png") ||
@@ -322,8 +322,8 @@ void ResourceImporterTexture::save_to_ctex_format(FileAccess *f, const Ref<Image
}
void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) {
- FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
- ERR_FAIL_NULL(f);
+ Ref<FileAccess> f = FileAccess::open(p_to_path, FileAccess::WRITE);
+ ERR_FAIL_COND(f.is_null());
f->store_8('G');
f->store_8('S');
f->store_8('T');
@@ -399,8 +399,6 @@ void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String
Image::UsedChannels used_channels = image->detect_used_channels(csource);
save_to_ctex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality);
-
- memdelete(f);
}
Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h
index b3a68260fc..b932c598a2 100644
--- a/editor/import/resource_importer_texture.h
+++ b/editor/import/resource_importer_texture.h
@@ -77,7 +77,7 @@ protected:
void _save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel);
public:
- static void save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality);
+ static void save_to_ctex_format(Ref<FileAccess> f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality);
static ResourceImporterTexture *get_singleton() { return singleton; }
virtual String get_importer_name() const override;
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 68d1d23dd8..154970f7ed 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -97,7 +97,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
/* STEP 1, READ WAVE FILE */
Error err;
- FileAccess *file = FileAccess::open(p_source_file, FileAccess::READ, &err);
+ Ref<FileAccess> file = FileAccess::open(p_source_file, FileAccess::READ, &err);
ERR_FAIL_COND_V_MSG(err != OK, ERR_CANT_OPEN, "Cannot open file '" + p_source_file + "'.");
@@ -107,8 +107,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->get_buffer((uint8_t *)&riff, 4); //RIFF
if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') {
- file->close();
- memdelete(file);
ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
}
@@ -122,8 +120,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->get_buffer((uint8_t *)&wave, 4); //RIFF
if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') {
- file->close();
- memdelete(file);
ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, "Not a WAV file (no WAVE RIFF header).");
}
@@ -166,15 +162,11 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
//Consider revision for engine version 3.0
compression_code = file->get_16();
if (compression_code != 1 && compression_code != 3) {
- file->close();
- memdelete(file);
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
}
format_channels = file->get_16();
if (format_channels != 1 && format_channels != 2) {
- file->close();
- memdelete(file);
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Format not supported for WAVE file (not stereo or mono).");
}
@@ -185,8 +177,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
format_bits = file->get_16(); // bits per sample
if (format_bits % 8 || format_bits == 0) {
- file->close();
- memdelete(file);
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32).");
}
@@ -206,8 +196,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
frames = chunksize;
if (format_channels == 0) {
- file->close();
- memdelete(file);
ERR_FAIL_COND_V(format_channels == 0, ERR_INVALID_DATA);
}
frames /= format_channels;
@@ -254,8 +242,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
if (file->eof_reached()) {
- file->close();
- memdelete(file);
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Premature end of file.");
}
}
@@ -295,9 +281,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->seek(file_pos + chunksize);
}
- file->close();
- memdelete(file);
-
// STEP 2, APPLY CONVERSIONS
bool is16 = format_bits != 8;
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.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.cpp b/editor/plugin_config_dialog.cpp
index 02cc95e14a..755bf7ce07 100644
--- a/editor/plugin_config_dialog.cpp
+++ b/editor/plugin_config_dialog.cpp
@@ -50,8 +50,8 @@ void PluginConfigDialog::_on_confirmed() {
String path = "res://addons/" + subfolder_edit->get_text();
if (!_edit_mode) {
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- if (!d || d->make_dir_recursive(path) != OK) {
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ if (d.is_null() || d->make_dir_recursive(path) != OK) {
return;
}
}
@@ -137,7 +137,7 @@ void PluginConfigDialog::_on_required_text_changed(const String &) {
subfolder_validation->set_texture(invalid_icon);
subfolder_validation->set_tooltip(TTR("Subfolder name is not a valid folder name."));
} else {
- DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);
String path = "res://addons/" + subfolder_edit->get_text();
if (dir->dir_exists(path) && !_edit_mode) { // Only show this error if in "create" mode.
is_valid = false;
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_library_editor.cpp b/editor/plugins/animation_library_editor.cpp
new file mode 100644
index 0000000000..2e9a82a7c2
--- /dev/null
+++ b/editor/plugins/animation_library_editor.cpp
@@ -0,0 +1,689 @@
+/*************************************************************************/
+/* animation_library_editor.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "animation_library_editor.h"
+#include "editor/editor_file_dialog.h"
+#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
+
+void AnimationLibraryEditor::set_animation_player(Object *p_player) {
+ player = p_player;
+}
+
+void AnimationLibraryEditor::_add_library() {
+ add_library_dialog->set_title(TTR("Library Name:"));
+ add_library_name->set_text("");
+ add_library_dialog->popup_centered();
+ add_library_name->grab_focus();
+ adding_animation = false;
+ adding_animation_to_library = StringName();
+ _add_library_validate("");
+}
+
+void AnimationLibraryEditor::_add_library_validate(const String &p_name) {
+ String error;
+
+ if (adding_animation) {
+ Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library);
+ ERR_FAIL_COND(al.is_null());
+ if (p_name == "") {
+ error = TTR("Animation name can't be empty.");
+
+ } else if (String(p_name).contains("/") || String(p_name).contains(":") || String(p_name).contains(",") || String(p_name).contains("[")) {
+ error = TTR("Animation name contains invalid characters: '/', ':', ',' or '['.");
+ } else if (al->has_animation(p_name)) {
+ error = TTR("Animation with the same name already exists.");
+ }
+
+ } else {
+ if (p_name == "" && bool(player->call("has_animation_library", ""))) {
+ error = TTR("Enter a library name.");
+ } else if (String(p_name).contains("/") || String(p_name).contains(":") || String(p_name).contains(",") || String(p_name).contains("[")) {
+ error = TTR("Library name contains invalid characters: '/', ':', ',' or '['.");
+ } else if (bool(player->call("has_animation_library", p_name))) {
+ error = TTR("Library with the same name already exists.");
+ }
+ }
+
+ if (error != "") {
+ add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ add_library_validate->set_text(error);
+ add_library_dialog->get_ok_button()->set_disabled(true);
+ } else {
+ add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
+ if (p_name == "") {
+ add_library_validate->set_text(TTR("Global library will be created."));
+ } else {
+ add_library_validate->set_text(TTR("Library name is valid."));
+ }
+ add_library_dialog->get_ok_button()->set_disabled(false);
+ }
+}
+
+void AnimationLibraryEditor::_add_library_confirm() {
+ if (adding_animation) {
+ String anim_name = add_library_name->get_text();
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library);
+ ERR_FAIL_COND(!al.is_valid());
+
+ Ref<Animation> anim;
+ anim.instantiate();
+
+ undo_redo->create_action(vformat(TTR("Add Animation to Library: %s"), anim_name));
+ undo_redo->add_do_method(al.ptr(), "add_animation", anim_name, anim);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", anim_name);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+
+ } else {
+ String lib_name = add_library_name->get_text();
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ Ref<AnimationLibrary> al;
+ al.instantiate();
+
+ undo_redo->create_action(vformat(TTR("Add Animation Library: %s"), lib_name));
+ undo_redo->add_do_method(player, "add_animation_library", lib_name, al);
+ undo_redo->add_undo_method(player, "remove_animation_library", lib_name);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ }
+}
+
+void AnimationLibraryEditor::_load_library() {
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("AnimationLibrary", &extensions);
+
+ file_dialog->set_title(TTR("Load Animation"));
+ file_dialog->clear_filters();
+ for (const String &K : extensions) {
+ file_dialog->add_filter("*." + K);
+ }
+
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
+ file_dialog->set_current_file("");
+ file_dialog->popup_centered_ratio();
+
+ file_dialog_action = FILE_DIALOG_ACTION_OPEN_LIBRARY;
+}
+
+void AnimationLibraryEditor::_file_popup_selected(int p_id) {
+ Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library);
+ Ref<Animation> anim;
+ if (file_dialog_animation != StringName()) {
+ anim = al->get_animation(file_dialog_animation);
+ ERR_FAIL_COND(anim.is_null());
+ }
+ switch (p_id) {
+ case FILE_MENU_SAVE_LIBRARY: {
+ if (al->get_path().is_resource_file()) {
+ EditorNode::get_singleton()->save_resource(al);
+ break;
+ }
+ [[fallthrough]];
+ }
+ case FILE_MENU_SAVE_AS_LIBRARY: {
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
+ file_dialog->set_title(TTR("Save Library"));
+ if (al->get_path().is_resource_file()) {
+ file_dialog->set_current_path(al->get_path());
+ } else {
+ file_dialog->set_current_file(String(file_dialog_library) + ".res");
+ }
+ file_dialog->clear_filters();
+ List<String> exts;
+ ResourceLoader::get_recognized_extensions_for_type("AnimationLibrary", &exts);
+ for (const String &K : exts) {
+ file_dialog->add_filter("*." + K);
+ }
+
+ file_dialog->popup_centered_ratio();
+ file_dialog_action = FILE_DIALOG_ACTION_SAVE_LIBRARY;
+ } break;
+ case FILE_MENU_MAKE_LIBRARY_UNIQUE: {
+ StringName lib_name = file_dialog_library;
+
+ Ref<AnimationLibrary> ald = al->duplicate();
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ undo_redo->create_action(vformat(TTR("Make Animation Library Unique: %s"), lib_name));
+ undo_redo->add_do_method(player, "remove_animation_library", lib_name);
+ undo_redo->add_do_method(player, "add_animation_library", lib_name, ald);
+ undo_redo->add_undo_method(player, "remove_animation_library", lib_name);
+ undo_redo->add_undo_method(player, "add_animation_library", lib_name, al);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+
+ } break;
+ case FILE_MENU_EDIT_LIBRARY: {
+ EditorNode::get_singleton()->push_item(al.ptr());
+ } break;
+
+ case FILE_MENU_SAVE_ANIMATION: {
+ if (anim->get_path().is_resource_file()) {
+ EditorNode::get_singleton()->save_resource(anim);
+ break;
+ }
+ [[fallthrough]];
+ }
+ case FILE_MENU_SAVE_AS_ANIMATION: {
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
+ file_dialog->set_title(TTR("Save Animation"));
+ if (anim->get_path().is_resource_file()) {
+ file_dialog->set_current_path(anim->get_path());
+ } else {
+ file_dialog->set_current_file(String(file_dialog_animation) + ".res");
+ }
+ file_dialog->clear_filters();
+ List<String> exts;
+ ResourceLoader::get_recognized_extensions_for_type("Animation", &exts);
+ for (const String &K : exts) {
+ file_dialog->add_filter("*." + K);
+ }
+
+ file_dialog->popup_centered_ratio();
+ file_dialog_action = FILE_DIALOG_ACTION_SAVE_ANIMATION;
+ } break;
+ case FILE_MENU_MAKE_ANIMATION_UNIQUE: {
+ StringName anim_name = file_dialog_animation;
+
+ Ref<Animation> animd = anim->duplicate();
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ undo_redo->create_action(vformat(TTR("Make Animation Unique: %s"), anim_name));
+ undo_redo->add_do_method(al.ptr(), "remove_animation", anim_name);
+ undo_redo->add_do_method(al.ptr(), "add_animation", anim_name, animd);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", anim_name);
+ undo_redo->add_undo_method(al.ptr(), "add_animation", anim_name, anim);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ } break;
+ case FILE_MENU_EDIT_ANIMATION: {
+ EditorNode::get_singleton()->push_item(anim.ptr());
+ } break;
+ }
+}
+void AnimationLibraryEditor::_load_file(String p_path) {
+ switch (file_dialog_action) {
+ case FILE_DIALOG_ACTION_OPEN_LIBRARY: {
+ Ref<AnimationLibrary> al = ResourceLoader::load(p_path);
+ if (al.is_null()) {
+ error_dialog->set_text(TTR("Invalid AnimationLibrary file."));
+ error_dialog->popup_centered();
+ return;
+ }
+
+ TypedArray<StringName> libs = player->call("get_animation_library_list");
+ for (int i = 0; i < libs.size(); i++) {
+ const StringName K = libs[i];
+ Ref<AnimationLibrary> al2 = player->call("get_animation_library", K);
+ if (al2 == al) {
+ error_dialog->set_text(TTR("This library is already added to the player."));
+ error_dialog->popup_centered();
+
+ return;
+ }
+ }
+
+ String name = p_path.get_file().get_basename();
+
+ int attempt = 1;
+
+ while (bool(player->call("has_animation_library", name))) {
+ attempt++;
+ name = p_path.get_file().get_basename() + " " + itos(attempt);
+ }
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(vformat(TTR("Add Animation Library: %s"), name));
+ undo_redo->add_do_method(player, "add_animation_library", name, al);
+ undo_redo->add_undo_method(player, "remove_animation_library", name);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ } break;
+ case FILE_DIALOG_ACTION_OPEN_ANIMATION: {
+ Ref<Animation> anim = ResourceLoader::load(p_path);
+ if (anim.is_null()) {
+ error_dialog->set_text(TTR("Invalid Animation file."));
+ error_dialog->popup_centered();
+ return;
+ }
+
+ Ref<AnimationLibrary> al = player->call("get_animation_library", adding_animation_to_library);
+ List<StringName> anims;
+ al->get_animation_list(&anims);
+ for (const StringName &K : anims) {
+ Ref<Animation> a2 = al->get_animation(K);
+ if (a2 == anim) {
+ error_dialog->set_text(TTR("This animation is already added to the library."));
+ error_dialog->popup_centered();
+ return;
+ }
+ }
+
+ String name = p_path.get_file().get_basename();
+
+ int attempt = 1;
+
+ while (al->has_animation(name)) {
+ attempt++;
+ name = p_path.get_file().get_basename() + " " + itos(attempt);
+ }
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(vformat(TTR("Load Animation into Library: %s"), name));
+ undo_redo->add_do_method(al.ptr(), "add_animation", name, anim);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", name);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ } break;
+
+ case FILE_DIALOG_ACTION_SAVE_LIBRARY: {
+ Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library);
+ String prev_path = al->get_path();
+ EditorNode::get_singleton()->save_resource_in_path(al, p_path);
+
+ if (al->get_path() != prev_path) { // Save successful.
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(vformat(TTR("Save Animation library to File: %s"), file_dialog_library));
+ undo_redo->add_do_method(al.ptr(), "set_path", al->get_path());
+ undo_redo->add_undo_method(al.ptr(), "set_path", prev_path);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ }
+
+ } break;
+ case FILE_DIALOG_ACTION_SAVE_ANIMATION: {
+ Ref<AnimationLibrary> al = player->call("get_animation_library", file_dialog_library);
+ Ref<Animation> anim;
+ if (file_dialog_animation != StringName()) {
+ anim = al->get_animation(file_dialog_animation);
+ ERR_FAIL_COND(anim.is_null());
+ }
+ String prev_path = anim->get_path();
+ EditorNode::get_singleton()->save_resource_in_path(anim, p_path);
+ if (anim->get_path() != prev_path) { // Save successful.
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(vformat(TTR("Save Animation to File: %s"), file_dialog_animation));
+ undo_redo->add_do_method(anim.ptr(), "set_path", anim->get_path());
+ undo_redo->add_undo_method(anim.ptr(), "set_path", prev_path);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ }
+ } break;
+ }
+}
+
+void AnimationLibraryEditor::_item_renamed() {
+ TreeItem *ti = tree->get_edited();
+ String text = ti->get_text(0);
+ String old_text = ti->get_metadata(0);
+ bool restore_text = false;
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ if (String(text).contains("/") || String(text).contains(":") || String(text).contains(",") || String(text).contains("[")) {
+ restore_text = true;
+ } else {
+ if (ti->get_parent() == tree->get_root()) {
+ // Renamed library
+
+ if (player->call("has_animation_library", text)) {
+ restore_text = true;
+ } else {
+ undo_redo->create_action(vformat(TTR("Rename Animation Library: %s"), text));
+ undo_redo->add_do_method(player, "rename_animation_library", old_text, text);
+ undo_redo->add_undo_method(player, "rename_animation_library", text, old_text);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ updating = true;
+ undo_redo->commit_action();
+ updating = false;
+ ti->set_metadata(0, text);
+ if (text == "") {
+ ti->set_suffix(0, TTR("[Global]"));
+ } else {
+ ti->set_suffix(0, "");
+ }
+ }
+ } else {
+ // Renamed anim
+ StringName library = ti->get_parent()->get_metadata(0);
+ Ref<AnimationLibrary> al = player->call("get_animation_library", library);
+
+ if (al.is_valid()) {
+ if (al->has_animation(text)) {
+ restore_text = true;
+ } else {
+ undo_redo->create_action(vformat(TTR("Rename Animation: %s"), text));
+ undo_redo->add_do_method(al.ptr(), "rename_animation", old_text, text);
+ undo_redo->add_undo_method(al.ptr(), "rename_animation", text, old_text);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ updating = true;
+ undo_redo->commit_action();
+ updating = false;
+
+ ti->set_metadata(0, text);
+ }
+ } else {
+ restore_text = true;
+ }
+ }
+ }
+
+ if (restore_text) {
+ ti->set_text(0, old_text);
+ }
+}
+
+void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int p_button) {
+ if (p_item->get_parent() == tree->get_root()) {
+ // Library
+ StringName lib_name = p_item->get_metadata(0);
+ Ref<AnimationLibrary> al = player->call("get_animation_library", lib_name);
+ switch (p_button) {
+ case LIB_BUTTON_ADD: {
+ add_library_dialog->set_title(TTR("Animation Name:"));
+ add_library_name->set_text("");
+ add_library_dialog->popup_centered();
+ add_library_name->grab_focus();
+ adding_animation = true;
+ adding_animation_to_library = p_item->get_metadata(0);
+ _add_library_validate("");
+ } break;
+ case LIB_BUTTON_LOAD: {
+ adding_animation_to_library = p_item->get_metadata(0);
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions);
+
+ file_dialog->clear_filters();
+ for (const String &K : extensions) {
+ file_dialog->add_filter("*." + K);
+ }
+
+ file_dialog->set_title(TTR("Load Animation"));
+ file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
+ file_dialog->set_current_file("");
+ file_dialog->popup_centered_ratio();
+
+ file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION;
+
+ } break;
+ case LIB_BUTTON_PASTE: {
+ Ref<Animation> anim = EditorSettings::get_singleton()->get_resource_clipboard();
+ if (!anim.is_valid()) {
+ error_dialog->set_text(TTR("No animation resource in clipboard!"));
+ error_dialog->popup_centered();
+ return;
+ }
+
+ anim = anim->duplicate(); // Users simply dont care about referencing, so making a copy works better here.
+
+ String base_name;
+ if (anim->get_name() != "") {
+ base_name = anim->get_name();
+ } else {
+ base_name = TTR("Pasted Animation");
+ }
+
+ String name = base_name;
+ int attempt = 1;
+ while (al->has_animation(name)) {
+ attempt++;
+ name = base_name + " " + itos(attempt);
+ }
+
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ undo_redo->create_action(vformat(TTR("Add Animation to Library: %s"), name));
+ undo_redo->add_do_method(al.ptr(), "add_animation", name, anim);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", name);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+
+ } break;
+ case LIB_BUTTON_FILE: {
+ file_popup->clear();
+ file_popup->add_item(TTR("Save"), FILE_MENU_SAVE_LIBRARY);
+ file_popup->add_item(TTR("Save As"), FILE_MENU_SAVE_AS_LIBRARY);
+ file_popup->add_separator();
+ file_popup->add_item(TTR("Make Unique"), FILE_MENU_MAKE_LIBRARY_UNIQUE);
+ file_popup->add_separator();
+ file_popup->add_item(TTR("Open in Inspector"), FILE_MENU_EDIT_LIBRARY);
+ Rect2 pos = tree->get_item_rect(p_item, 1, 0);
+ Vector2 popup_pos = tree->get_screen_position() + pos.position + Vector2(0, pos.size.height);
+ file_popup->popup(Rect2(popup_pos, Size2()));
+
+ file_dialog_animation = StringName();
+ file_dialog_library = lib_name;
+ } break;
+ case LIB_BUTTON_DELETE: {
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ undo_redo->create_action(vformat(TTR("Remove Animation Library: %s"), lib_name));
+ undo_redo->add_do_method(player, "remove_animation_library", lib_name);
+ undo_redo->add_undo_method(player, "add_animation_library", lib_name, al);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ } break;
+ }
+
+ } else {
+ // Animation
+ StringName lib_name = p_item->get_parent()->get_metadata(0);
+ StringName anim_name = p_item->get_metadata(0);
+ Ref<AnimationLibrary> al = player->call("get_animation_library", lib_name);
+ Ref<Animation> anim = al->get_animation(anim_name);
+ ERR_FAIL_COND(!anim.is_valid());
+ switch (p_button) {
+ case ANIM_BUTTON_COPY: {
+ if (anim->get_name() == "") {
+ anim->set_name(anim_name); // Keep the name around
+ }
+ EditorSettings::get_singleton()->set_resource_clipboard(anim);
+ } break;
+ case ANIM_BUTTON_FILE: {
+ file_popup->clear();
+ file_popup->add_item(TTR("Save"), FILE_MENU_SAVE_ANIMATION);
+ file_popup->add_item(TTR("Save As"), FILE_MENU_SAVE_AS_ANIMATION);
+ file_popup->add_separator();
+ file_popup->add_item(TTR("Make Unique"), FILE_MENU_MAKE_ANIMATION_UNIQUE);
+ file_popup->add_separator();
+ file_popup->add_item(TTR("Open in Inspector"), FILE_MENU_EDIT_ANIMATION);
+ Rect2 pos = tree->get_item_rect(p_item, 1, 0);
+ Vector2 popup_pos = tree->get_screen_position() + pos.position + Vector2(0, pos.size.height);
+ file_popup->popup(Rect2(popup_pos, Size2()));
+
+ file_dialog_animation = anim_name;
+ file_dialog_library = lib_name;
+
+ } break;
+ case ANIM_BUTTON_DELETE: {
+ UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
+ undo_redo->create_action(vformat(TTR("Remove Animation from Library: %s"), anim_name));
+ undo_redo->add_do_method(al.ptr(), "remove_animation", anim_name);
+ undo_redo->add_undo_method(al.ptr(), "add_animation", anim_name, anim);
+ undo_redo->add_do_method(this, "_update_editor", player);
+ undo_redo->add_undo_method(this, "_update_editor", player);
+ undo_redo->commit_action();
+ } break;
+ }
+ }
+}
+
+void AnimationLibraryEditor::update_tree() {
+ if (updating) {
+ return;
+ }
+
+ tree->clear();
+ ERR_FAIL_COND(!player);
+
+ Color ss_color = get_theme_color(SNAME("prop_subsection"), SNAME("Editor"));
+
+ TreeItem *root = tree->create_item();
+ TypedArray<StringName> libs = player->call("get_animation_library_list");
+
+ for (int i = 0; i < libs.size(); i++) {
+ const StringName K = libs[i];
+ TreeItem *libitem = tree->create_item(root);
+ libitem->set_text(0, K);
+ if (K == StringName()) {
+ libitem->set_suffix(0, TTR("[Global]"));
+ } else {
+ libitem->set_suffix(0, "");
+ }
+ libitem->set_editable(0, true);
+ libitem->set_metadata(0, K);
+ libitem->set_icon(0, get_theme_icon("AnimationLibrary", "EditorIcons"));
+ libitem->add_button(0, get_theme_icon("Add", "EditorIcons"), LIB_BUTTON_ADD, false, TTR("Add Animation to Library"));
+ libitem->add_button(0, get_theme_icon("Load", "EditorIcons"), LIB_BUTTON_LOAD, false, TTR("Load animation from file and add to library"));
+ libitem->add_button(0, get_theme_icon("ActionPaste", "EditorIcons"), LIB_BUTTON_PASTE, false, TTR("Paste Animation to Library from clipboard"));
+ Ref<AnimationLibrary> al = player->call("get_animation_library", K);
+ if (al->get_path().is_resource_file()) {
+ libitem->set_text(1, al->get_path().get_file());
+ libitem->set_tooltip(1, al->get_path());
+ } else {
+ libitem->set_text(1, TTR("[built-in]"));
+ }
+ libitem->add_button(1, get_theme_icon("Save", "EditorIcons"), LIB_BUTTON_FILE, false, TTR("Save animation library to resource on disk"));
+ libitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), LIB_BUTTON_DELETE, false, TTR("Remove animation library"));
+
+ libitem->set_custom_bg_color(0, ss_color);
+
+ List<StringName> animations;
+ al->get_animation_list(&animations);
+ for (const StringName &L : animations) {
+ TreeItem *anitem = tree->create_item(libitem);
+ anitem->set_text(0, L);
+ anitem->set_editable(0, true);
+ anitem->set_metadata(0, L);
+ anitem->set_icon(0, get_theme_icon("Animation", "EditorIcons"));
+ anitem->add_button(0, get_theme_icon("ActionCopy", "EditorIcons"), ANIM_BUTTON_COPY, false, TTR("Copy animation to clipboard"));
+ Ref<Animation> anim = al->get_animation(L);
+
+ if (anim->get_path().is_resource_file()) {
+ anitem->set_text(1, anim->get_path().get_file());
+ anitem->set_tooltip(1, anim->get_path());
+ } else {
+ anitem->set_text(1, TTR("[built-in]"));
+ }
+ anitem->add_button(1, get_theme_icon("Save", "EditorIcons"), ANIM_BUTTON_FILE, false, TTR("Save animation to resource on disk"));
+ anitem->add_button(1, get_theme_icon("Remove", "EditorIcons"), ANIM_BUTTON_DELETE, false, TTR("Remove animation from Library"));
+ }
+ }
+}
+
+void AnimationLibraryEditor::show_dialog() {
+ update_tree();
+ popup_centered_ratio(0.5);
+}
+
+void AnimationLibraryEditor::_update_editor(Object *p_player) {
+ emit_signal("update_editor", p_player);
+}
+
+void AnimationLibraryEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_update_editor", "player"), &AnimationLibraryEditor::_update_editor);
+ ADD_SIGNAL(MethodInfo("update_editor"));
+}
+
+AnimationLibraryEditor::AnimationLibraryEditor() {
+ set_title(TTR("Edit Animation Libraries"));
+
+ file_dialog = memnew(EditorFileDialog);
+ add_child(file_dialog);
+ file_dialog->connect("file_selected", callable_mp(this, &AnimationLibraryEditor::_load_file));
+
+ add_library_dialog = memnew(ConfirmationDialog);
+ VBoxContainer *dialog_vb = memnew(VBoxContainer);
+ add_library_name = memnew(LineEdit);
+ dialog_vb->add_child(add_library_name);
+ add_library_name->connect("text_changed", callable_mp(this, &AnimationLibraryEditor::_add_library_validate));
+ add_child(add_library_dialog);
+
+ add_library_validate = memnew(Label);
+ dialog_vb->add_child(add_library_validate);
+ add_library_dialog->add_child(dialog_vb);
+ add_library_dialog->connect("confirmed", callable_mp(this, &AnimationLibraryEditor::_add_library_confirm));
+ add_library_dialog->register_text_enter(add_library_name);
+
+ VBoxContainer *vb = memnew(VBoxContainer);
+ HBoxContainer *hb = memnew(HBoxContainer);
+ hb->add_spacer(true);
+ Button *b = memnew(Button(TTR("Add Library")));
+ b->connect("pressed", callable_mp(this, &AnimationLibraryEditor::_add_library));
+ hb->add_child(b);
+ b = memnew(Button(TTR("Load Library")));
+ b->connect("pressed", callable_mp(this, &AnimationLibraryEditor::_load_library));
+ hb->add_child(b);
+ vb->add_child(hb);
+ tree = memnew(Tree);
+ vb->add_child(tree);
+
+ tree->set_columns(2);
+ tree->set_column_titles_visible(true);
+ tree->set_column_title(0, TTR("Resource"));
+ tree->set_column_title(1, TTR("Storage"));
+ tree->set_column_expand(0, true);
+ tree->set_column_custom_minimum_width(1, EDSCALE * 250);
+ tree->set_column_expand(1, false);
+ tree->set_hide_root(true);
+ tree->set_hide_folding(true);
+ tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ tree->connect("item_edited", callable_mp(this, &AnimationLibraryEditor::_item_renamed));
+ tree->connect("button_pressed", callable_mp(this, &AnimationLibraryEditor::_button_pressed));
+
+ file_popup = memnew(PopupMenu);
+ add_child(file_popup);
+ file_popup->connect("id_pressed", callable_mp(this, &AnimationLibraryEditor::_file_popup_selected));
+
+ add_child(vb);
+
+ error_dialog = memnew(AcceptDialog);
+ error_dialog->set_title(TTR("Error:"));
+ add_child(error_dialog);
+}
diff --git a/editor/plugins/animation_library_editor.h b/editor/plugins/animation_library_editor.h
new file mode 100644
index 0000000000..5bd4e8d9e2
--- /dev/null
+++ b/editor/plugins/animation_library_editor.h
@@ -0,0 +1,119 @@
+/*************************************************************************/
+/* animation_library_editor.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef ANIMATION_LIBRARY_EDITOR_H
+#define ANIMATION_LIBRARY_EDITOR_H
+
+#include "editor/animation_track_editor.h"
+#include "editor/editor_plugin.h"
+#include "scene/animation/animation_player.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/tree.h"
+
+class EditorFileDialog;
+
+class AnimationLibraryEditor : public AcceptDialog {
+ GDCLASS(AnimationLibraryEditor, AcceptDialog)
+
+ enum {
+ LIB_BUTTON_ADD,
+ LIB_BUTTON_LOAD,
+ LIB_BUTTON_PASTE,
+ LIB_BUTTON_FILE,
+ LIB_BUTTON_DELETE,
+ };
+ enum {
+ ANIM_BUTTON_COPY,
+ ANIM_BUTTON_FILE,
+ ANIM_BUTTON_DELETE,
+ };
+
+ enum FileMenuAction {
+ FILE_MENU_SAVE_LIBRARY,
+ FILE_MENU_SAVE_AS_LIBRARY,
+ FILE_MENU_MAKE_LIBRARY_UNIQUE,
+ FILE_MENU_EDIT_LIBRARY,
+
+ FILE_MENU_SAVE_ANIMATION,
+ FILE_MENU_SAVE_AS_ANIMATION,
+ FILE_MENU_MAKE_ANIMATION_UNIQUE,
+ FILE_MENU_EDIT_ANIMATION,
+ };
+
+ enum FileDialogAction {
+ FILE_DIALOG_ACTION_OPEN_LIBRARY,
+ FILE_DIALOG_ACTION_SAVE_LIBRARY,
+ FILE_DIALOG_ACTION_OPEN_ANIMATION,
+ FILE_DIALOG_ACTION_SAVE_ANIMATION,
+ };
+
+ FileDialogAction file_dialog_action = FILE_DIALOG_ACTION_OPEN_ANIMATION;
+
+ StringName file_dialog_animation;
+ StringName file_dialog_library;
+
+ AcceptDialog *error_dialog = nullptr;
+ bool adding_animation = false;
+ StringName adding_animation_to_library;
+ EditorFileDialog *file_dialog = nullptr;
+ ConfirmationDialog *add_library_dialog = nullptr;
+ LineEdit *add_library_name = nullptr;
+ Label *add_library_validate = nullptr;
+ PopupMenu *file_popup = nullptr;
+
+ Tree *tree = nullptr;
+
+ Object *player = nullptr;
+
+ void _add_library();
+ void _add_library_validate(const String &p_name);
+ void _add_library_confirm();
+ void _load_library();
+ void _load_file(String p_path);
+
+ void _item_renamed();
+ void _button_pressed(TreeItem *p_item, int p_column, int p_button);
+
+ void _file_popup_selected(int p_id);
+
+ bool updating = false;
+
+protected:
+ void _update_editor(Object *p_player);
+ static void _bind_methods();
+
+public:
+ void set_animation_player(Object *p_player);
+ void show_dialog();
+ void update_tree();
+ AnimationLibraryEditor();
+};
+
+#endif // ANIMATIONPLAYERLIBRARYEDITOR_H
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index ab8e2ca54a..17a1bd1048 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -47,6 +47,8 @@
#include "scene/scene_string_names.h"
#include "servers/rendering_server.h"
+///////////////////////////////////
+
void AnimationPlayerEditor::_node_removed(Node *p_node) {
if (player && player == p_node) {
player = nullptr;
@@ -148,9 +150,7 @@ void AnimationPlayerEditor::_notification(int p_what) {
#define ITEM_ICON(m_item, m_icon) tool_anim->get_popup()->set_item_icon(tool_anim->get_popup()->get_item_index(m_item), get_theme_icon(SNAME(m_icon), SNAME("EditorIcons")))
ITEM_ICON(TOOL_NEW_ANIM, "New");
- ITEM_ICON(TOOL_LOAD_ANIM, "Load");
- ITEM_ICON(TOOL_SAVE_ANIM, "Save");
- ITEM_ICON(TOOL_SAVE_AS_ANIM, "Save");
+ ITEM_ICON(TOOL_ANIM_LIBRARY, "AnimationLibrary");
ITEM_ICON(TOOL_DUPLICATE_ANIM, "Duplicate");
ITEM_ICON(TOOL_RENAME_ANIM, "Rename");
ITEM_ICON(TOOL_EDIT_TRANSITIONS, "Blend");
@@ -166,7 +166,7 @@ void AnimationPlayerEditor::_autoplay_pressed() {
if (updating) {
return;
}
- if (animation->get_item_count() == 0) {
+ if (animation->has_selectable_items() == 0) {
return;
}
@@ -192,10 +192,7 @@ void AnimationPlayerEditor::_autoplay_pressed() {
}
void AnimationPlayerEditor::_play_pressed() {
- String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text(animation->get_selected());
- }
+ String current = _get_current();
if (!current.is_empty()) {
if (current == player->get_assigned_animation()) {
@@ -209,10 +206,7 @@ void AnimationPlayerEditor::_play_pressed() {
}
void AnimationPlayerEditor::_play_from_pressed() {
- String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text(animation->get_selected());
- }
+ String current = _get_current();
if (!current.is_empty()) {
float time = player->get_current_animation_position();
@@ -229,12 +223,15 @@ void AnimationPlayerEditor::_play_from_pressed() {
stop->set_pressed(false);
}
-void AnimationPlayerEditor::_play_bw_pressed() {
+String AnimationPlayerEditor::_get_current() const {
String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
+ if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count() && !animation->is_item_separator(animation->get_selected())) {
current = animation->get_item_text(animation->get_selected());
}
-
+ return current;
+}
+void AnimationPlayerEditor::_play_bw_pressed() {
+ String current = _get_current();
if (!current.is_empty()) {
if (current == player->get_assigned_animation()) {
player->stop(); //so it won't blend with itself
@@ -247,10 +244,7 @@ void AnimationPlayerEditor::_play_bw_pressed() {
}
void AnimationPlayerEditor::_play_bw_from_pressed() {
- String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text(animation->get_selected());
- }
+ String current = _get_current();
if (!current.is_empty()) {
float time = player->get_current_animation_position();
@@ -282,10 +276,7 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
}
// when selecting an animation, the idea is that the only interesting behavior
// ui-wise is that it should play/blend the next one if currently playing
- String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text(animation->get_selected());
- }
+ String current = _get_current();
if (!current.is_empty()) {
player->set_assigned_animation(current);
@@ -330,6 +321,20 @@ void AnimationPlayerEditor::_animation_new() {
break;
}
+ List<StringName> libraries;
+ player->get_animation_library_list(&libraries);
+ library->clear();
+ for (const StringName &K : libraries) {
+ library->add_item((K == StringName()) ? String(TTR("[Global]")) : String(K));
+ library->set_item_metadata(0, String(K));
+ }
+
+ if (libraries.size() > 1) {
+ library->show();
+ } else {
+ library->hide();
+ }
+
name->set_text(base);
name_dialog->popup_centered(Size2(300, 90));
name->select_all();
@@ -337,7 +342,7 @@ void AnimationPlayerEditor::_animation_new() {
}
void AnimationPlayerEditor::_animation_rename() {
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
return;
}
int selected = animation->get_selected();
@@ -349,84 +354,11 @@ void AnimationPlayerEditor::_animation_rename() {
name_dialog->popup_centered(Size2(300, 90));
name->select_all();
name->grab_focus();
-}
-
-void AnimationPlayerEditor::_animation_load() {
- ERR_FAIL_COND(!player);
- file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILES);
- file->clear_filters();
- List<String> extensions;
-
- ResourceLoader::get_recognized_extensions_for_type("Animation", &extensions);
- for (const String &E : extensions) {
- file->add_filter("*." + E + " ; " + E.to_upper());
- }
-
- file->popup_file_dialog();
-}
-
-void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path) {
- int flg = 0;
- if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) {
- flg |= ResourceSaver::FLAG_COMPRESS;
- }
-
- String path = ProjectSettings::get_singleton()->localize_path(p_path);
- Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
-
- if (err != OK) {
- EditorNode::get_singleton()->show_warning(TTR("Error saving resource!"));
- return;
- }
-
- ((Resource *)p_resource.ptr())->set_path(path);
- EditorNode::get_singleton()->emit_signal(SNAME("resource_saved"), p_resource);
-}
-
-void AnimationPlayerEditor::_animation_save(const Ref<Resource> &p_resource) {
- if (p_resource->get_path().is_resource_file()) {
- _animation_save_in_path(p_resource, p_resource->get_path());
- } else {
- _animation_save_as(p_resource);
- }
-}
-
-void AnimationPlayerEditor::_animation_save_as(const Ref<Resource> &p_resource) {
- file->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
-
- List<String> extensions;
- ResourceSaver::get_recognized_extensions(p_resource, &extensions);
- file->clear_filters();
- for (int i = 0; i < extensions.size(); i++) {
- file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
- }
-
- String path;
- //file->set_current_path(current_path);
- if (!p_resource->get_path().is_empty()) {
- path = p_resource->get_path();
- if (extensions.size()) {
- if (extensions.find(p_resource->get_path().get_extension().to_lower()) == nullptr) {
- path = p_resource->get_path().get_base_dir() + p_resource->get_name() + "." + extensions.front()->get();
- }
- }
- } else {
- if (extensions.size()) {
- if (!p_resource->get_name().is_empty()) {
- path = p_resource->get_name() + "." + extensions.front()->get().to_lower();
- } else {
- String resource_name_snake_case = p_resource->get_class().camelcase_to_underscore();
- path = "new_" + resource_name_snake_case + "." + extensions.front()->get().to_lower();
- }
- }
- }
- file->set_current_path(path);
- file->set_title(TTR("Save Resource As..."));
- file->popup_file_dialog();
+ library->hide();
}
void AnimationPlayerEditor::_animation_remove() {
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
return;
}
@@ -440,6 +372,9 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
+ Ref<AnimationLibrary> al = player->get_animation_library(player->find_animation_library(anim));
+ ERR_FAIL_COND(al.is_null());
+
undo_redo->create_action(TTR("Remove Animation"));
if (player->get_autoplay() == current) {
undo_redo->add_do_method(player, "set_autoplay", "");
@@ -447,11 +382,11 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
// Avoid having the autoplay icon linger around if there is only one animation in the player.
undo_redo->add_do_method(this, "_animation_player_changed", player);
}
- undo_redo->add_do_method(player, "remove_animation", current);
- undo_redo->add_undo_method(player, "add_animation", current, anim);
+ undo_redo->add_do_method(al.ptr(), "remove_animation", current);
+ undo_redo->add_undo_method(al.ptr(), "add_animation", current, anim);
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
- if (animation->get_item_count() == 1) {
+ if (animation->has_selectable_items() && animation->get_selectable_item(false) == animation->get_selectable_item(true)) { // Last item remaining.
undo_redo->add_do_method(this, "_stop_onion_skinning");
undo_redo->add_undo_method(this, "_start_onion_skinning");
}
@@ -498,7 +433,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
return;
}
- if (name_dialog_op == TOOL_RENAME_ANIM && animation->get_item_count() > 0 && animation->get_item_text(animation->get_selected()) == new_name) {
+ if (name_dialog_op == TOOL_RENAME_ANIM && animation->has_selectable_items() && animation->get_item_text(animation->get_selected()) == new_name) {
name_dialog->hide();
return;
}
@@ -514,10 +449,13 @@ void AnimationPlayerEditor::_animation_name_edited() {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
+ Ref<AnimationLibrary> al = player->get_animation_library(player->find_animation_library(anim));
+ ERR_FAIL_COND(al.is_null());
+
undo_redo->create_action(TTR("Rename Animation"));
- undo_redo->add_do_method(player, "rename_animation", current, new_name);
+ undo_redo->add_do_method(al.ptr(), "rename_animation", current, new_name);
undo_redo->add_do_method(anim.ptr(), "set_name", new_name);
- undo_redo->add_undo_method(player, "rename_animation", new_name, current);
+ undo_redo->add_undo_method(al.ptr(), "rename_animation", new_name, current);
undo_redo->add_undo_method(anim.ptr(), "set_name", current);
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
@@ -530,15 +468,35 @@ void AnimationPlayerEditor::_animation_name_edited() {
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
new_anim->set_name(new_name);
+ Ref<AnimationLibrary> al;
+ if (library->is_visible()) {
+ al = player->get_animation_library(library->get_item_metadata(library->get_selected()));
+ } else {
+ if (player->has_animation_library("")) {
+ al = player->get_animation_library("");
+ }
+ }
+
undo_redo->create_action(TTR("Add Animation"));
- undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
- undo_redo->add_undo_method(player, "remove_animation", new_name);
+
+ bool lib_added = false;
+ if (al.is_null()) {
+ al.instantiate();
+ lib_added = true;
+ undo_redo->add_do_method(player, "add_animation_library", "", al);
+ }
+
+ undo_redo->add_do_method(al.ptr(), "add_animation", new_name, new_anim);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", new_name);
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
undo_redo->add_do_method(this, "_start_onion_skinning");
undo_redo->add_undo_method(this, "_stop_onion_skinning");
}
+ if (lib_added) {
+ undo_redo->add_undo_method(player, "remove_animation_library", "");
+ }
undo_redo->commit_action();
_select_anim_by_name(new_name);
@@ -551,9 +509,11 @@ void AnimationPlayerEditor::_animation_name_edited() {
Ref<Animation> new_anim = _animation_clone(anim);
new_anim->set_name(new_name);
+ Ref<AnimationLibrary> library = player->get_animation_library(player->find_animation_library(anim));
+
undo_redo->create_action(TTR("Duplicate Animation"));
- undo_redo->add_do_method(player, "add_animation", new_name, new_anim);
- undo_redo->add_undo_method(player, "remove_animation", new_name);
+ undo_redo->add_do_method(library.ptr(), "add_animation", new_name, new_anim);
+ undo_redo->add_undo_method(library.ptr(), "remove_animation", new_name);
undo_redo->add_do_method(player, "animation_set_next", new_name, player->animation_get_next(current));
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
@@ -567,7 +527,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
}
void AnimationPlayerEditor::_blend_editor_next_changed(const int p_idx) {
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
return;
}
@@ -588,7 +548,7 @@ void AnimationPlayerEditor::_animation_blend() {
blend_editor.tree->clear();
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
return;
}
@@ -643,7 +603,7 @@ void AnimationPlayerEditor::_blend_edited() {
return;
}
- if (animation->get_item_count() == 0) {
+ if (!animation->has_selectable_items()) {
return;
}
@@ -722,16 +682,16 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
}
void AnimationPlayerEditor::_animation_resource_edit() {
- if (animation->get_item_count()) {
- String current = animation->get_item_text(animation->get_selected());
+ String current = _get_current();
+ if (current != String()) {
Ref<Animation> anim = player->get_animation(current);
EditorNode::get_singleton()->edit_resource(anim);
}
}
void AnimationPlayerEditor::_animation_edit() {
- if (animation->get_item_count()) {
- String current = animation->get_item_text(animation->get_selected());
+ String current = _get_current();
+ if (current != String()) {
Ref<Animation> anim = player->get_animation(current);
track_editor->set_animation(anim);
@@ -745,51 +705,6 @@ void AnimationPlayerEditor::_animation_edit() {
}
}
-void AnimationPlayerEditor::_save_animation(String p_file) {
- String current = animation->get_item_text(animation->get_selected());
- if (!current.is_empty()) {
- Ref<Animation> anim = player->get_animation(current);
-
- ERR_FAIL_COND(!Object::cast_to<Resource>(*anim));
-
- RES current_res = RES(Object::cast_to<Resource>(*anim));
-
- _animation_save_in_path(current_res, p_file);
- }
-}
-
-void AnimationPlayerEditor::_load_animations(Vector<String> p_files) {
- ERR_FAIL_COND(!player);
-
- for (int i = 0; i < p_files.size(); i++) {
- String file = p_files[i];
-
- Ref<Resource> res = ResourceLoader::load(file, "Animation");
- ERR_FAIL_COND_MSG(res.is_null(), "Cannot load Animation from file '" + file + "'.");
- ERR_FAIL_COND_MSG(!res->is_class("Animation"), "Loaded resource from file '" + file + "' is not Animation.");
- if (file.rfind("/") != -1) {
- file = file.substr(file.rfind("/") + 1, file.length());
- }
- if (file.rfind("\\") != -1) {
- file = file.substr(file.rfind("\\") + 1, file.length());
- }
-
- if (file.contains(".")) {
- file = file.substr(0, file.find("."));
- }
-
- undo_redo->create_action(TTR("Load Animation"));
- undo_redo->add_do_method(player, "add_animation", file, res);
- undo_redo->add_undo_method(player, "remove_animation", file);
- if (player->has_animation(file)) {
- undo_redo->add_undo_method(player, "add_animation", file, player->get_animation(file));
- }
- undo_redo->add_do_method(this, "_animation_player_changed", player);
- undo_redo->add_undo_method(this, "_animation_player_changed", player);
- undo_redo->commit_action();
- }
-}
-
void AnimationPlayerEditor::_scale_changed(const String &p_scale) {
player->set_speed_scale(p_scale.to_float());
}
@@ -824,49 +739,67 @@ void AnimationPlayerEditor::_update_animation() {
void AnimationPlayerEditor::_update_player() {
updating = true;
- List<StringName> animlist;
- if (player) {
- player->get_animation_list(&animlist);
- }
animation->clear();
-#define ITEM_DISABLED(m_item, m_disabled) tool_anim->get_popup()->set_item_disabled(tool_anim->get_popup()->get_item_index(m_item), m_disabled)
-
- ITEM_DISABLED(TOOL_SAVE_ANIM, animlist.size() == 0);
- ITEM_DISABLED(TOOL_SAVE_AS_ANIM, animlist.size() == 0);
- ITEM_DISABLED(TOOL_DUPLICATE_ANIM, animlist.size() == 0);
- ITEM_DISABLED(TOOL_RENAME_ANIM, animlist.size() == 0);
- ITEM_DISABLED(TOOL_EDIT_TRANSITIONS, animlist.size() == 0);
- ITEM_DISABLED(TOOL_COPY_ANIM, animlist.size() == 0);
- ITEM_DISABLED(TOOL_REMOVE_ANIM, animlist.size() == 0);
-
- stop->set_disabled(animlist.size() == 0);
- play->set_disabled(animlist.size() == 0);
- play_bw->set_disabled(animlist.size() == 0);
- play_bw_from->set_disabled(animlist.size() == 0);
- play_from->set_disabled(animlist.size() == 0);
- frame->set_editable(animlist.size() != 0);
- animation->set_disabled(animlist.size() == 0);
- autoplay->set_disabled(animlist.size() == 0);
- tool_anim->set_disabled(player == nullptr);
- onion_toggle->set_disabled(animlist.size() == 0);
- onion_skinning->set_disabled(animlist.size() == 0);
- pin->set_disabled(player == nullptr);
-
if (!player) {
AnimationPlayerEditor::get_singleton()->get_track_editor()->update_keying();
return;
}
+ List<StringName> libraries;
+ if (player) {
+ player->get_animation_library_list(&libraries);
+ }
+
int active_idx = -1;
- for (const StringName &E : animlist) {
- animation->add_item(E);
+ bool no_anims_found = true;
- if (player->get_assigned_animation() == E) {
- active_idx = animation->get_item_count() - 1;
+ for (const StringName &K : libraries) {
+ if (K != StringName()) {
+ animation->add_separator(K);
+ }
+
+ Ref<AnimationLibrary> library = player->get_animation_library(K);
+ List<StringName> animlist;
+ library->get_animation_list(&animlist);
+
+ for (const StringName &E : animlist) {
+ String path = K;
+ if (path != "") {
+ path += "/";
+ }
+ path += E;
+ animation->add_item(path);
+ if (player->get_assigned_animation() == path) {
+ active_idx = animation->get_selectable_item(true);
+ }
+ no_anims_found = false;
}
}
+#define ITEM_CHECK_DISABLED(m_item) tool_anim->get_popup()->set_item_disabled(tool_anim->get_popup()->get_item_index(m_item), no_anims_found)
+
+ ITEM_CHECK_DISABLED(TOOL_DUPLICATE_ANIM);
+ ITEM_CHECK_DISABLED(TOOL_RENAME_ANIM);
+ ITEM_CHECK_DISABLED(TOOL_EDIT_TRANSITIONS);
+ ITEM_CHECK_DISABLED(TOOL_REMOVE_ANIM);
+ ITEM_CHECK_DISABLED(TOOL_EDIT_RESOURCE);
+
+#undef ITEM_CHECK_DISABLED
+
+ stop->set_disabled(no_anims_found);
+ play->set_disabled(no_anims_found);
+ play_bw->set_disabled(no_anims_found);
+ play_bw_from->set_disabled(no_anims_found);
+ play_from->set_disabled(no_anims_found);
+ frame->set_editable(!no_anims_found);
+ animation->set_disabled(no_anims_found);
+ autoplay->set_disabled(no_anims_found);
+ tool_anim->set_disabled(player == nullptr);
+ onion_toggle->set_disabled(no_anims_found);
+ onion_skinning->set_disabled(no_anims_found);
+ pin->set_disabled(player == nullptr);
+
_update_animation_list_icons();
updating = false;
@@ -874,16 +807,16 @@ void AnimationPlayerEditor::_update_player() {
animation->select(active_idx);
autoplay->set_pressed(animation->get_item_text(active_idx) == player->get_autoplay());
_animation_selected(active_idx);
-
- } else if (animation->get_item_count() > 0) {
- animation->select(0);
- autoplay->set_pressed(animation->get_item_text(0) == player->get_autoplay());
- _animation_selected(0);
+ } else if (animation->has_selectable_items()) {
+ int item = animation->get_selectable_item();
+ animation->select(item);
+ autoplay->set_pressed(animation->get_item_text(item) == player->get_autoplay());
+ _animation_selected(item);
} else {
_animation_selected(0);
}
- if (animation->get_item_count()) {
+ if (!no_anims_found) {
String current = animation->get_item_text(animation->get_selected());
Ref<Animation> anim = player->get_animation(current);
track_editor->set_animation(anim);
@@ -899,6 +832,9 @@ void AnimationPlayerEditor::_update_player() {
void AnimationPlayerEditor::_update_animation_list_icons() {
for (int i = 0; i < animation->get_item_count(); i++) {
String name = animation->get_item_text(i);
+ if (animation->is_item_disabled(i) || animation->is_item_separator(i)) {
+ continue;
+ }
Ref<Texture2D> icon;
if (name == player->get_autoplay()) {
@@ -925,7 +861,7 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
_update_player();
if (onion.enabled) {
- if (animation->get_item_count() > 0) {
+ if (animation->has_selectable_items()) {
_start_onion_skinning();
} else {
_stop_onion_skinning();
@@ -940,6 +876,8 @@ void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
track_editor->show_select_node_warning(true);
}
+
+ library_editor->set_animation_player(player);
}
void AnimationPlayerEditor::forward_force_draw_over_viewport(Control *p_overlay) {
@@ -993,7 +931,7 @@ void AnimationPlayerEditor::forward_force_draw_over_viewport(Control *p_overlay)
}
void AnimationPlayerEditor::_animation_duplicate() {
- if (!animation->get_item_count()) {
+ if (!animation->has_selectable_items()) {
return;
}
@@ -1031,29 +969,6 @@ Ref<Animation> AnimationPlayerEditor::_animation_clone(Ref<Animation> p_anim) {
return new_anim;
}
-void AnimationPlayerEditor::_animation_paste(Ref<Animation> p_anim) {
- String name = p_anim->get_name();
- if (name.is_empty()) {
- name = TTR("Pasted Animation");
- }
-
- int idx = 1;
- String base = name;
- while (player->has_animation(name)) {
- idx++;
- name = base + " " + itos(idx);
- }
-
- undo_redo->create_action(TTR("Paste Animation"));
- undo_redo->add_do_method(player, "add_animation", name, p_anim);
- undo_redo->add_undo_method(player, "remove_animation", name);
- undo_redo->add_do_method(this, "_animation_player_changed", player);
- undo_redo->add_undo_method(this, "_animation_player_changed", player);
- undo_redo->commit_action();
-
- _select_anim_by_name(name);
-}
-
void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set, bool p_timeline_only) {
if (updating || !player || player->is_playing()) {
return;
@@ -1095,6 +1010,9 @@ void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) {
if (blend_editor.dialog->is_visible()) {
_animation_blend(); // Update.
}
+ if (library_editor->is_visible()) {
+ library_editor->update_tree();
+ }
}
}
@@ -1134,10 +1052,7 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag,
}
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
- String current;
- if (animation->get_selected() >= 0 && animation->get_selected() < animation->get_item_count()) {
- current = animation->get_item_text(animation->get_selected());
- }
+ String current = _get_current();
Ref<Animation> anim;
if (!current.is_empty()) {
@@ -1148,18 +1063,9 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
case TOOL_NEW_ANIM: {
_animation_new();
} break;
- case TOOL_LOAD_ANIM: {
- _animation_load();
- } break;
- case TOOL_SAVE_ANIM: {
- if (anim.is_valid()) {
- _animation_save(anim);
- }
- } break;
- case TOOL_SAVE_AS_ANIM: {
- if (anim.is_valid()) {
- _animation_save_as(anim);
- }
+ case TOOL_ANIM_LIBRARY: {
+ library_editor->set_animation_player(player);
+ library_editor->show_dialog();
} break;
case TOOL_DUPLICATE_ANIM: {
_animation_duplicate();
@@ -1173,47 +1079,10 @@ void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
case TOOL_REMOVE_ANIM: {
_animation_remove();
} break;
- case TOOL_COPY_ANIM: {
- if (!animation->get_item_count()) {
- error_dialog->set_text(TTR("No animation to copy!"));
- error_dialog->popup_centered();
- return;
- }
-
- String current2 = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim2 = player->get_animation(current2);
- EditorSettings::get_singleton()->set_resource_clipboard(anim2);
- } break;
- case TOOL_PASTE_ANIM: {
- Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
- if (!anim2.is_valid()) {
- error_dialog->set_text(TTR("No animation resource in clipboard!"));
- error_dialog->popup_centered();
- return;
- }
- Ref<Animation> new_anim = _animation_clone(anim2);
- _animation_paste(new_anim);
- } break;
- case TOOL_PASTE_ANIM_REF: {
- Ref<Animation> anim2 = EditorSettings::get_singleton()->get_resource_clipboard();
- if (!anim2.is_valid()) {
- error_dialog->set_text(TTR("No animation resource in clipboard!"));
- error_dialog->popup_centered();
- return;
- }
-
- _animation_paste(anim2);
- } break;
case TOOL_EDIT_RESOURCE: {
- if (!animation->get_item_count()) {
- error_dialog->set_text(TTR("No animation to edit!"));
- error_dialog->popup_centered();
- return;
+ if (anim.is_valid()) {
+ EditorNode::get_singleton()->edit_resource(anim);
}
-
- String current2 = animation->get_item_text(animation->get_selected());
- Ref<Animation> anim2 = player->get_animation(current2);
- EditorNode::get_singleton()->edit_resource(anim2);
} break;
}
}
@@ -1267,7 +1136,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;
@@ -1300,7 +1169,7 @@ void AnimationPlayerEditor::unhandled_key_input(const Ref<InputEvent> &p_ev) {
}
void AnimationPlayerEditor::_editor_visibility_changed() {
- if (is_visible() && animation->get_item_count() > 0) {
+ if (is_visible() && animation->has_selectable_items()) {
_start_onion_skinning();
}
}
@@ -1536,7 +1405,6 @@ void AnimationPlayerEditor::_pin_pressed() {
void AnimationPlayerEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_animation_new"), &AnimationPlayerEditor::_animation_new);
ClassDB::bind_method(D_METHOD("_animation_rename"), &AnimationPlayerEditor::_animation_rename);
- ClassDB::bind_method(D_METHOD("_animation_load"), &AnimationPlayerEditor::_animation_load);
ClassDB::bind_method(D_METHOD("_animation_remove"), &AnimationPlayerEditor::_animation_remove);
ClassDB::bind_method(D_METHOD("_animation_blend"), &AnimationPlayerEditor::_animation_blend);
ClassDB::bind_method(D_METHOD("_animation_edit"), &AnimationPlayerEditor::_animation_edit);
@@ -1623,13 +1491,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
tool_anim->set_text(TTR("Animation"));
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/new_animation", TTR("New")), TOOL_NEW_ANIM);
tool_anim->get_popup()->add_separator();
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/open_animation", TTR("Load")), TOOL_LOAD_ANIM);
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_animation", TTR("Save")), TOOL_SAVE_ANIM);
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as_animation", TTR("Save As...")), TOOL_SAVE_AS_ANIM);
- tool_anim->get_popup()->add_separator();
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy")), TOOL_COPY_ANIM);
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("Paste")), TOOL_PASTE_ANIM);
- tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation_as_reference", TTR("Paste As Reference")), TOOL_PASTE_ANIM_REF);
+ tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/animation_libraries", TTR("Manage Animations...")), TOOL_ANIM_LIBRARY);
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate...")), TOOL_DUPLICATE_ANIM);
tool_anim->get_popup()->add_separator();
@@ -1638,6 +1500,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/open_animation_in_inspector", TTR("Open in Inspector")), TOOL_EDIT_RESOURCE);
tool_anim->get_popup()->add_separator();
tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove")), TOOL_REMOVE_ANIM);
+ tool_anim->set_disabled(true);
hb->add_child(tool_anim);
animation = memnew(OptionButton);
@@ -1705,8 +1568,14 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
name_title = memnew(Label(TTR("Animation Name:")));
vb->add_child(name_title);
+ HBoxContainer *name_hb = memnew(HBoxContainer);
name = memnew(LineEdit);
- vb->add_child(name);
+ name_hb->add_child(name);
+ name->set_h_size_flags(SIZE_EXPAND_FILL);
+ library = memnew(OptionButton);
+ name_hb->add_child(library);
+ library->hide();
+ vb->add_child(name_hb);
name_dialog->register_text_enter(name);
error_dialog = memnew(ConfirmationDialog);
@@ -1742,15 +1611,13 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
animation->connect("item_selected", callable_mp(this, &AnimationPlayerEditor::_animation_selected));
- file->connect("file_selected", callable_mp(this, &AnimationPlayerEditor::_save_animation));
- file->connect("files_selected", callable_mp(this, &AnimationPlayerEditor::_load_animations));
frame->connect("value_changed", callable_mp(this, &AnimationPlayerEditor::_seek_value_changed), make_binds(true, false));
scale->connect("text_submitted", callable_mp(this, &AnimationPlayerEditor::_scale_changed));
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);
@@ -1759,6 +1626,10 @@ AnimationPlayerEditor::AnimationPlayerEditor(AnimationPlayerEditorPlugin *p_plug
_update_player();
+ library_editor = memnew(AnimationLibraryEditor);
+ add_child(library_editor);
+ library_editor->connect("update_editor", callable_mp(this, &AnimationPlayerEditor::_animation_player_changed));
+
// Onion skinning.
track_editor->connect("visibility_changed", callable_mp(this, &AnimationPlayerEditor::_editor_visibility_changed));
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 5bb32e25e6..0cc04460ca 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -33,6 +33,7 @@
#include "editor/animation_track_editor.h"
#include "editor/editor_plugin.h"
+#include "editor/plugins/animation_library_editor.h"
#include "scene/animation/animation_player.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/slider.h"
@@ -40,27 +41,21 @@
#include "scene/gui/texture_button.h"
#include "scene/gui/tree.h"
-class EditorFileDialog;
class AnimationPlayerEditorPlugin;
class AnimationPlayerEditor : public VBoxContainer {
GDCLASS(AnimationPlayerEditor, VBoxContainer);
- AnimationPlayerEditorPlugin *plugin;
- AnimationPlayer *player;
+ AnimationPlayerEditorPlugin *plugin = nullptr;
+ AnimationPlayer *player = nullptr;
enum {
TOOL_NEW_ANIM,
- TOOL_LOAD_ANIM,
- TOOL_SAVE_ANIM,
- TOOL_SAVE_AS_ANIM,
+ TOOL_ANIM_LIBRARY,
TOOL_DUPLICATE_ANIM,
TOOL_RENAME_ANIM,
TOOL_EDIT_TRANSITIONS,
TOOL_REMOVE_ANIM,
- TOOL_COPY_ANIM,
- TOOL_PASTE_ANIM,
- TOOL_PASTE_ANIM_REF,
TOOL_EDIT_RESOURCE
};
@@ -88,31 +83,35 @@ 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;
+ OptionButton *library = 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;
+
+ AnimationLibraryEditor *library_editor = nullptr;
struct BlendEditor {
AcceptDialog *dialog = nullptr;
@@ -121,14 +120,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.
@@ -173,11 +172,6 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_new();
void _animation_rename();
void _animation_name_edited();
- void _animation_load();
-
- void _animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path);
- void _animation_save(const Ref<Resource> &p_resource);
- void _animation_save_as(const Ref<Resource> &p_resource);
void _animation_remove();
void _animation_remove_confirmed();
@@ -185,11 +179,8 @@ class AnimationPlayerEditor : public VBoxContainer {
void _animation_edit();
void _animation_duplicate();
Ref<Animation> _animation_clone(const Ref<Animation> p_anim);
- void _animation_paste(const Ref<Animation> p_anim);
void _animation_resource_edit();
void _scale_changed(const String &p_scale);
- void _save_animation(String p_file);
- void _load_animations(Vector<String> p_files);
void _seek_value_changed(float p_value, bool p_set = false, bool p_timeline_only = false);
void _blend_editor_next_changed(const int p_idx);
@@ -204,7 +195,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);
@@ -219,6 +210,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _stop_onion_skinning();
void _pin_pressed();
+ String _get_current() const;
~AnimationPlayerEditor();
@@ -250,7 +242,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..157eed02f4 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;
@@ -729,9 +729,8 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
if (use_cache) {
String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
- FileAccess *file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ);
-
- if (file) {
+ Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ);
+ if (file.is_valid()) {
PackedByteArray cached_data;
int len = file->get_32();
cached_data.resize(len);
@@ -740,8 +739,6 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
file->get_buffer(w, len);
image_data = cached_data;
- file->close();
- memdelete(file);
}
}
@@ -808,23 +805,17 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons
if (headers[i].findn("ETag:") == 0) { // Save etag
String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text());
String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges();
- FileAccess *file;
-
- file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE);
- if (file) {
+ Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE);
+ if (file.is_valid()) {
file->store_line(new_etag);
- file->close();
- memdelete(file);
}
int len = p_data.size();
const uint8_t *r = p_data.ptr();
file = FileAccess::open(cache_filename_base + ".data", FileAccess::WRITE);
- if (file) {
+ if (file.is_valid()) {
file->store_32(len);
file->store_buffer(r, len);
- file->close();
- memdelete(file);
}
break;
@@ -858,11 +849,9 @@ void EditorAssetLibrary::_update_image_queue() {
Vector<String> headers;
if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) {
- FileAccess *file = FileAccess::open(cache_filename_base + ".etag", FileAccess::READ);
- if (file) {
+ Ref<FileAccess> file = FileAccess::open(cache_filename_base + ".etag", FileAccess::READ);
+ if (file.is_valid()) {
headers.push_back("If-None-Match: " + file->get_line());
- file->close();
- memdelete(file);
}
}
@@ -1541,7 +1530,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.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.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..906edb006c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1091,13 +1091,13 @@ void ScriptEditor::_file_dialog_action(String p_file) {
switch (file_dialog_option) {
case FILE_NEW_TEXTFILE: {
Error err;
- FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
- if (err) {
- EditorNode::get_singleton()->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!"));
- break;
+ {
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ if (err) {
+ EditorNode::get_singleton()->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!"));
+ break;
+ }
}
- file->close();
- memdelete(file);
if (EditorFileSystem::get_singleton()) {
if (textfile_extensions.has(p_file.get_extension())) {
@@ -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;
@@ -2216,17 +2211,16 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p
String source = sqscr->get_text();
Error err;
- FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
+ {
+ Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err);
- ERR_FAIL_COND_V_MSG(err, err, "Cannot save text file '" + p_path + "'.");
+ ERR_FAIL_COND_V_MSG(err, err, "Cannot save text file '" + p_path + "'.");
- file->store_string(source);
- if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
- memdelete(file);
- return ERR_CANT_CREATE;
+ file->store_string(source);
+ if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
+ return ERR_CANT_CREATE;
+ }
}
- file->close();
- memdelete(file);
if (ResourceSaver::get_timestamp_on_save()) {
p_text_file->set_last_modified_time(FileAccess::get_modified_time(p_path));
@@ -3024,7 +3018,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 +3290,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 +3305,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 +3609,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 +3749,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 +3964,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 6b53ce0660..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;
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..0835d0212f 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());
}
}
}
@@ -93,7 +93,7 @@ void POTGenerator::generate_pot(const String &p_file) {
void POTGenerator::_write_to_pot(const String &p_file) {
Error err;
- FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err);
+ Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err);
if (err != OK) {
ERR_PRINT("Failed to open " + p_file);
return;
@@ -155,11 +155,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
}
}
}
-
- file->close();
}
-void POTGenerator::_write_msgid(FileAccess *r_file, const String &p_id, bool p_plural) {
+void POTGenerator::_write_msgid(Ref<FileAccess> r_file, const String &p_id, bool p_plural) {
// Split \\n and \n.
Vector<String> temp = p_id.split("\\n");
Vector<String> msg_lines;
diff --git a/editor/pot_generator.h b/editor/pot_generator.h
index 2b42c681e5..e7a5f90cee 100644
--- a/editor/pot_generator.h
+++ b/editor/pot_generator.h
@@ -49,7 +49,7 @@ class POTGenerator {
OrderedHashMap<String, Vector<MsgidData>> all_translation_strings;
void _write_to_pot(const String &p_file);
- void _write_msgid(FileAccess *r_file, const String &p_id, bool p_plural);
+ void _write_msgid(Ref<FileAccess> r_file, const String &p_id, bool p_plural);
void _add_new_msgid(const String &p_msgid, const String &p_context, const String &p_plural, const String &p_location);
#ifdef DEBUG_POT
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..2b24c231ea 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -147,7 +147,7 @@ private:
}
String _test_path() {
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
String valid_path, valid_install_path;
if (d->change_dir(project_path->get_text()) == OK) {
valid_path = project_path->get_text();
@@ -186,8 +186,7 @@ private:
if (mode == MODE_IMPORT || mode == MODE_RENAME) {
if (!valid_path.is_empty() && !d->file_exists("project.godot")) {
if (valid_path.ends_with(".zip")) {
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
if (!pkg) {
@@ -202,6 +201,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;
@@ -380,7 +382,7 @@ private:
return;
}
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (d->change_dir(project_path->get_text()) == OK) {
if (!d->dir_exists(project_name_no_edges)) {
if (d->make_dir(project_name_no_edges) == OK) {
@@ -497,8 +499,7 @@ private:
zip_path = project_path->get_text();
}
- FileAccess *src_f = nullptr;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ zlib_filefunc_def io = zipio_create_io();
unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io);
if (!pkg) {
@@ -534,6 +535,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);
@@ -543,7 +547,7 @@ private:
path = path.substr(0, path.length() - 1);
String rel_path = path.substr(zip_root.length());
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir(dir.plus_file(rel_path));
} else {
Vector<uint8_t> data;
@@ -552,14 +556,15 @@ 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);
-
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(dir.plus_file(rel_path), FileAccess::WRITE);
+ if (f.is_valid()) {
f->store_buffer(data.ptr(), data.size());
- memdelete(f);
} else {
failed_files.push_back(rel_path);
}
@@ -606,7 +611,7 @@ private:
void _remove_created_folder() {
if (!created_folder_path.is_empty()) {
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
d->remove(created_folder_path);
create_dir->set_disabled(false);
@@ -710,7 +715,7 @@ public:
project_path->set_text(fav_dir);
fdialog->set_current_dir(fav_dir);
} else {
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
project_path->set_text(d->get_current_dir());
fdialog->set_current_dir(d->get_current_dir());
}
@@ -1903,7 +1908,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 +1967,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;
@@ -2271,7 +2276,7 @@ void ProjectManager::_run_project() {
}
void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) {
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error error = da->change_dir(path);
ERR_FAIL_COND_MSG(error != OK, "Could not scan directory at: " + path);
da->list_dir_begin();
@@ -2393,14 +2398,14 @@ void ProjectManager::_install_project(const String &p_zip_path, const String &p_
npdialog->show_dialog();
}
-void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
+void ProjectManager::_files_dropped(PackedStringArray p_files) {
if (p_files.size() == 1 && p_files[0].ends_with(".zip")) {
const String file = p_files[0].get_file();
_install_project(p_files[0], file.substr(0, file.length() - 4).capitalize());
return;
}
Set<String> folders_set;
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
for (int i = 0; i < p_files.size(); i++) {
String file = p_files[i];
folders_set.insert(da->dir_exists(file) ? file : file.get_base_dir());
@@ -2413,7 +2418,7 @@ void ProjectManager::_files_dropped(PackedStringArray p_files, int p_screen) {
bool confirm = true;
if (folders.size() == 1) {
- DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (dir->change_dir(folders[0]) == OK) {
dir->list_dir_begin();
String file = dir->get_next();
@@ -2840,7 +2845,7 @@ ProjectManager::ProjectManager() {
_load_recent_projects();
- DirAccessRef dir_access = DirAccess::create(DirAccess::AccessType::ACCESS_FILESYSTEM);
+ Ref<DirAccess> dir_access = DirAccess::create(DirAccess::AccessType::ACCESS_FILESYSTEM);
String default_project_path = EditorSettings::get_singleton()->get("filesystem/directories/default_project_path");
if (!dir_access->dir_exists(default_project_path)) {
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 4f053793fd..00f8cfc721 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -126,8 +126,8 @@ 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;
- void _files_dropped(PackedStringArray p_files, int p_screen);
+ virtual void shortcut_input(const Ref<InputEvent> &p_ev) override;
+ void _files_dropped(PackedStringArray p_files);
void _version_button_pressed();
void _on_order_option_changed(int p_idx);
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 551a0ff9c8..03f65cdf52 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;
}
@@ -3149,9 +3149,8 @@ void SceneTreeDock::_update_create_root_dialog() {
favorite_nodes->get_child(i)->queue_delete();
}
- FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ);
-
- if (f) {
+ Ref<FileAccess> f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites.Node"), FileAccess::READ);
+ if (f.is_valid()) {
while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
@@ -3168,8 +3167,6 @@ void SceneTreeDock::_update_create_root_dialog() {
button->connect("pressed", callable_mp(this, &SceneTreeDock::_favorite_root_selected), make_binds(l));
}
}
-
- memdelete(f);
}
if (!favorite_nodes->is_visible_in_tree()) {
@@ -3476,7 +3473,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.cpp b/editor/script_create_dialog.cpp
index 72f77c859b..7d063e13f9 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -246,7 +246,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must
}
{
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->change_dir(p.get_base_dir()) != OK) {
return TTR("Base path is invalid.");
}
@@ -254,7 +254,7 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must
{
// Check if file exists.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->dir_exists(p)) {
return TTR("A directory with the same name exists.");
} else if (p_file_must_exist && !da->file_exists(p)) {
@@ -547,7 +547,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
}
// Check if file exists.
- DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
String p = ProjectSettings::get_singleton()->localize_path(p_path.strip_edges());
if (da->file_exists(p)) {
is_new_script_created = false;
@@ -824,8 +824,8 @@ Vector<ScriptLanguage::ScriptTemplate> ScriptCreateDialog::_get_user_templates(c
String dir_path = p_dir.plus_file(p_object);
- DirAccessRef d = DirAccess::open(dir_path);
- if (d) {
+ Ref<DirAccess> d = DirAccess::open(dir_path);
+ if (d.is_valid()) {
d->list_dir_begin();
String file = d->get_next();
while (file != String()) {
@@ -858,7 +858,7 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL
// Parse file for meta-information and script content
Error err;
- FileAccess *file = FileAccess::open(p_path.plus_file(p_filename), FileAccess::READ, &err);
+ Ref<FileAccess> file = FileAccess::open(p_path.plus_file(p_filename), FileAccess::READ, &err);
if (!err) {
while (!file->eof_reached()) {
String line = file->get_line();
@@ -890,8 +890,6 @@ ScriptLanguage::ScriptTemplate ScriptCreateDialog::_parse_template(const ScriptL
script_template.content += line.replace("\t", "_TS_") + "\n";
}
}
- file->close();
- memdelete(file);
}
script_template.content = script_template.content.lstrip("\n");
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_create_dialog.cpp b/editor/shader_create_dialog.cpp
index dbc78e846c..f07ec161c2 100644
--- a/editor/shader_create_dialog.cpp
+++ b/editor/shader_create_dialog.cpp
@@ -313,7 +313,7 @@ void ShaderCreateDialog::_path_changed(const String &p_path) {
return;
}
- DirAccessRef f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
String p = ProjectSettings::get_singleton()->localize_path(p_path.strip_edges());
if (f->file_exists(p)) {
is_new_shader_created = false;
@@ -371,12 +371,12 @@ String ShaderCreateDialog::_validate_path(const String &p_path) {
return TTR("Path is not local.");
}
- DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (d->change_dir(p.get_base_dir()) != OK) {
return TTR("Invalid base path.");
}
- DirAccessRef f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ Ref<DirAccess> f = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (f->dir_exists(p)) {
return TTR("A directory with the same name exists.");
}
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);