Skip to content

Commit fd4ad29

Browse files
committed
Merge pull request godotengine#110641 from DallasHuff/new-resource-hotkey
Add Create Resource Hotkey
2 parents 6e76eb3 + 3d16ea8 commit fd4ad29

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

editor/docks/filesystem_dock.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,16 @@ int FileSystemDock::_get_menu_option_from_key(const Ref<InputEventKey> &p_key) {
26742674
return FILE_MENU_COPY_UID;
26752675
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_key)) {
26762676
return FILE_MENU_REMOVE;
2677+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_folder", p_key)) {
2678+
return FILE_MENU_NEW_FOLDER;
2679+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_scene", p_key)) {
2680+
return FILE_MENU_NEW_SCENE;
2681+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_script", p_key)) {
2682+
return FILE_MENU_NEW_SCRIPT;
2683+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_resource", p_key)) {
2684+
return FILE_MENU_NEW_RESOURCE;
2685+
} else if (ED_IS_SHORTCUT("filesystem_dock/new_textfile", p_key)) {
2686+
return FILE_MENU_NEW_TEXTFILE;
26772687
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_key)) {
26782688
return FILE_MENU_RENAME;
26792689
} else if (ED_IS_SHORTCUT("filesystem_dock/show_in_explorer", p_key)) {
@@ -3339,10 +3349,15 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
33393349
p_popup->set_item_icon(p_popup->get_item_index(FILE_MENU_NEW), get_editor_theme_icon(SNAME("Add")));
33403350

33413351
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("Folder..."), FILE_MENU_NEW_FOLDER);
3352+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
33423353
new_menu->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("Scene..."), FILE_MENU_NEW_SCENE);
3354+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
33433355
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("Script..."), FILE_MENU_NEW_SCRIPT);
3356+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
33443357
new_menu->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("Resource..."), FILE_MENU_NEW_RESOURCE);
3358+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
33453359
new_menu->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("TextFile..."), FILE_MENU_NEW_TEXTFILE);
3360+
new_menu->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
33463361

33473362
const PackedStringArray folder_path = { p_paths[0].get_base_dir() };
33483363
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(new_menu, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, folder_path);
@@ -3563,10 +3578,16 @@ void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_butto
35633578
tree_popup->clear();
35643579
tree_popup->reset_size();
35653580
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER);
3581+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
35663582
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE);
3583+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
35673584
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT);
3585+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
35683586
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE);
3587+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
35693588
tree_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE);
3589+
tree_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
3590+
35703591
// To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE).
35713592
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(tree_popup, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, Vector<String>());
35723593
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)
@@ -3640,10 +3661,16 @@ void FileSystemDock::_file_list_empty_clicked(const Vector2 &p_pos, MouseButton
36403661
file_list_popup->reset_size();
36413662

36423663
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Folder")), TTRC("New Folder..."), FILE_MENU_NEW_FOLDER);
3664+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_folder"));
36433665
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("PackedScene")), TTRC("New Scene..."), FILE_MENU_NEW_SCENE);
3666+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_scene"));
36443667
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Script")), TTRC("New Script..."), FILE_MENU_NEW_SCRIPT);
3668+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_script"));
36453669
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("Object")), TTRC("New Resource..."), FILE_MENU_NEW_RESOURCE);
3670+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_resource"));
36463671
file_list_popup->add_icon_item(get_editor_theme_icon(SNAME("TextFile")), TTRC("New TextFile..."), FILE_MENU_NEW_TEXTFILE);
3672+
file_list_popup->set_item_shortcut(-1, ED_GET_SHORTCUT("filesystem_dock/new_textfile"));
3673+
36473674
// To keep consistency with options added to "Create New..." menu (for plugin which has slot as CONTEXT_SLOT_FILESYSTEM_CREATE).
36483675
EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(file_list_popup, EditorContextMenuPlugin::CONTEXT_SLOT_FILESYSTEM_CREATE, Vector<String>());
36493676
file_list_popup->add_separator();
@@ -4158,6 +4185,11 @@ FileSystemDock::FileSystemDock() {
41584185
ED_SHORTCUT("filesystem_dock/copy_uid", TTRC("Copy UID"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | KeyModifierMask::SHIFT | Key::C);
41594186
ED_SHORTCUT("filesystem_dock/duplicate", TTRC("Duplicate..."), KeyModifierMask::CMD_OR_CTRL | Key::D);
41604187
ED_SHORTCUT("filesystem_dock/delete", TTRC("Delete"), Key::KEY_DELETE);
4188+
ED_SHORTCUT("filesystem_dock/new_folder", TTRC("New Folder..."), Key::NONE);
4189+
ED_SHORTCUT("filesystem_dock/new_scene", TTRC("New Scene..."), Key::NONE);
4190+
ED_SHORTCUT("filesystem_dock/new_script", TTRC("New Script..."), Key::NONE);
4191+
ED_SHORTCUT("filesystem_dock/new_resource", TTRC("New Resource..."), Key::NONE);
4192+
ED_SHORTCUT("filesystem_dock/new_textfile", TTRC("New TextFile..."), Key::NONE);
41614193
ED_SHORTCUT("filesystem_dock/rename", TTRC("Rename..."), Key::F2);
41624194
ED_SHORTCUT_OVERRIDE("filesystem_dock/rename", "macos", Key::ENTER);
41634195
#if !defined(ANDROID_ENABLED) && !defined(WEB_ENABLED)

0 commit comments

Comments
 (0)