diff options
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r-- | editor/filesystem_dock.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index f40a048b75..39452b7192 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -46,6 +46,7 @@ #include "scene/main/window.h" #include "scene/resources/packed_scene.h" #include "servers/display_server.h" +#include "shader_create_dialog.h" Ref<Texture2D> FileSystemDock::_get_tree_item_icon(bool p_is_valid, String p_file_type) { Ref<Texture2D> file_icon; @@ -1967,6 +1968,22 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected } void FileSystemDock::_resource_created() { + String fpath = path; + if (!fpath.ends_with("/")) { + fpath = fpath.get_base_dir(); + } + + String type_name = new_resource_dialog->get_selected_type(); + if (type_name == "Shader") { + make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 0); + make_shader_dialog->popup_centered(); + return; + } else if (type_name == "VisualShader") { + make_shader_dialog->config(fpath.plus_file("new_shader"), false, false, 1); + make_shader_dialog->popup_centered(); + return; + } + Variant c = new_resource_dialog->instance_selected(); ERR_FAIL_COND(!c); @@ -1982,12 +1999,6 @@ void FileSystemDock::_resource_created() { } editor->push_item(r); - - String fpath = path; - if (!fpath.ends_with("/")) { - fpath = fpath.get_base_dir(); - } - editor->save_resource_as(RES(r), fpath); } @@ -2510,6 +2521,7 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { tree_popup->reset_size(); _file_and_folders_fill_popup(tree_popup, paths); tree_popup->set_position(tree->get_screen_position() + p_pos); + tree_popup->reset_size(); tree_popup->popup(); } } @@ -2524,7 +2536,8 @@ void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) { tree_popup->add_icon_item(get_theme_icon(SNAME("Script"), SNAME("EditorIcons")), TTR("New Script..."), FILE_NEW_SCRIPT); tree_popup->add_icon_item(get_theme_icon(SNAME("Object"), SNAME("EditorIcons")), TTR("New Resource..."), FILE_NEW_RESOURCE); tree_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); - tree_popup->set_position(tree->get_global_position() + p_pos); + tree_popup->set_position(tree->get_screen_position() + p_pos); + tree_popup->reset_size(); tree_popup->popup(); } @@ -2549,9 +2562,9 @@ void FileSystemDock::_file_list_rmb_select(int p_item, const Vector2 &p_pos) { // Popup. if (!paths.is_empty()) { file_list_popup->clear(); - file_list_popup->reset_size(); _file_and_folders_fill_popup(file_list_popup, paths, searched_string.length() == 0); - file_list_popup->set_position(files->get_global_position() + p_pos); + file_list_popup->set_position(files->get_screen_position() + p_pos); + file_list_popup->reset_size(); file_list_popup->popup(); } } @@ -2572,7 +2585,8 @@ void FileSystemDock::_file_list_rmb_pressed(const Vector2 &p_pos) { file_list_popup->add_icon_item(get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons")), TTR("New TextFile..."), FILE_NEW_TEXTFILE); file_list_popup->add_separator(); file_list_popup->add_icon_item(get_theme_icon(SNAME("Filesystem"), SNAME("EditorIcons")), TTR("Open in File Manager"), FILE_SHOW_IN_EXPLORER); - file_list_popup->set_position(files->get_global_position() + p_pos); + file_list_popup->set_position(files->get_screen_position() + p_pos); + file_list_popup->reset_size(); file_list_popup->popup(); } @@ -2922,7 +2936,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { Label *slabel = memnew(Label); slabel->set_text(TTR("Scanning Files,\nPlease Wait...")); - slabel->set_align(Label::ALIGN_CENTER); + slabel->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); scanning_vb->add_child(slabel); scanning_progress = memnew(ProgressBar); @@ -2997,6 +3011,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { make_script_dialog->set_title(TTR("Create Script")); add_child(make_script_dialog); + make_shader_dialog = memnew(ShaderCreateDialog); + add_child(make_shader_dialog); + new_resource_dialog = memnew(CreateDialog); add_child(new_resource_dialog); new_resource_dialog->set_base_type("Resource"); |