|
43 | 43 | #include "editor/editor_node.h" |
44 | 44 | #include "editor/editor_string_names.h" |
45 | 45 | #include "editor/editor_undo_redo_manager.h" |
| 46 | +#include "editor/extension/extension_source_code_manager.h" |
46 | 47 | #include "editor/gui/create_dialog.h" |
47 | 48 | #include "editor/gui/directory_create_dialog.h" |
48 | 49 | #include "editor/gui/editor_dir_dialog.h" |
@@ -2572,6 +2573,15 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected |
2572 | 2573 | make_script_dialog->popup_centered(); |
2573 | 2574 | } break; |
2574 | 2575 |
|
| 2576 | + case FILE_MENU_NEW_EXTENSION_CLASS: { |
| 2577 | + String fpath = current_path; |
| 2578 | + if (!fpath.ends_with("/")) { |
| 2579 | + fpath = fpath.get_base_dir(); |
| 2580 | + } |
| 2581 | + make_extension_class_dialog->config("Node", fpath); |
| 2582 | + make_extension_class_dialog->popup_centered(); |
| 2583 | + } break; |
| 2584 | + |
2575 | 2585 | case FILE_MENU_COPY_PATH: { |
2576 | 2586 | if (!p_selected.is_empty()) { |
2577 | 2587 | const String &fpath = p_selected[0]; |
@@ -3336,6 +3346,12 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect |
3336 | 3346 | new_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("Folder..."), FILE_MENU_NEW_FOLDER); |
3337 | 3347 | new_menu->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("Scene..."), FILE_MENU_NEW_SCENE); |
3338 | 3348 | new_menu->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("Script..."), FILE_MENU_NEW_SCRIPT); |
| 3349 | + new_menu->add_icon_item(get_editor_theme_icon(SNAME("ExtensionClass")), TTRC("Extension class..."), FILE_MENU_NEW_EXTENSION_CLASS); |
| 3350 | + if (!ExtensionSourceCodeManager::get_singleton()->has_plugins_that_can_create_class_source()) { |
| 3351 | + int item_idx = new_menu->get_item_count() - 1; |
| 3352 | + new_menu->set_item_disabled(item_idx, true); |
| 3353 | + new_menu->set_item_tooltip(item_idx, "No extension source code plugins available."); |
| 3354 | + } |
3339 | 3355 | new_menu->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("Resource..."), FILE_MENU_NEW_RESOURCE); |
3340 | 3356 | new_menu->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("TextFile..."), FILE_MENU_NEW_TEXTFILE); |
3341 | 3357 |
|
@@ -3560,6 +3576,12 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto |
3560 | 3576 | tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER); |
3561 | 3577 | tree_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE); |
3562 | 3578 | tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT); |
| 3579 | + tree_popup->add_icon_item(get_editor_theme_icon(SNAME("ExtensionClass")), TTRC("Extension class..."), FILE_MENU_NEW_EXTENSION_CLASS); |
| 3580 | + if (!ExtensionSourceCodeManager::get_singleton()->has_plugins_that_can_create_class_source()) { |
| 3581 | + int item_idx = tree_popup->get_item_count() - 1; |
| 3582 | + tree_popup->set_item_disabled(item_idx, true); |
| 3583 | + tree_popup->set_item_tooltip(item_idx, "No extension source code plugins available."); |
| 3584 | + } |
3563 | 3585 | tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE); |
3564 | 3586 | tree_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE); |
3565 | 3587 | // To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE). |
@@ -3637,6 +3659,12 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton |
3637 | 3659 | file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER); |
3638 | 3660 | file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE); |
3639 | 3661 | file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT); |
| 3662 | + file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("ExtensionClass")), TTRC("Extension class..."), FILE_MENU_NEW_EXTENSION_CLASS); |
| 3663 | + if (!ExtensionSourceCodeManager::get_singleton()->has_plugins_that_can_create_class_source()) { |
| 3664 | + int item_idx = file_list_popup->get_item_count() - 1; |
| 3665 | + file_list_popup->set_item_disabled(item_idx, true); |
| 3666 | + file_list_popup->set_item_tooltip(item_idx, "No extension source code plugins available."); |
| 3667 | + } |
3640 | 3668 | file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE); |
3641 | 3669 | file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE); |
3642 | 3670 | // To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE). |
@@ -4371,6 +4399,10 @@ FileSystemDock::FileSystemDock() { |
4371 | 4399 | make_script_dialog->set_title(TTRC("Create Script")); |
4372 | 4400 | add_child(make_script_dialog); |
4373 | 4401 |
|
| 4402 | + make_extension_class_dialog = memnew(ExtensionClassCreateDialog); |
| 4403 | + make_extension_class_dialog->set_title(TTRC("Create Extension Class")); |
| 4404 | + add_child(make_extension_class_dialog); |
| 4405 | + |
4374 | 4406 | make_shader_dialog = memnew(ShaderCreateDialog); |
4375 | 4407 | add_child(make_shader_dialog); |
4376 | 4408 |
|
|
0 commit comments