summaryrefslogtreecommitdiff
path: root/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
authorsteincodes <swarnimarun11@gmail.com>2018-07-22 21:23:40 +0530
committersteincodes <swarnimarun11@gmail.com>2018-07-22 21:23:40 +0530
commita1dee44e21c3b9c61a77d4ba51806c743c5d0cb4 (patch)
tree1fbfd67eeb48b466998b2acdf8070ec593cd19aa /editor/filesystem_dock.cpp
parent89e1b302b504feb1cea218adcc6fac77c8ae0052 (diff)
Ability to add Resource from FileSystem Dock
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r--editor/filesystem_dock.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index f65fb5365b..37f86cc912 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1319,6 +1319,9 @@ void FileSystemDock::_file_option(int p_option) {
String fpath = files->get_item_metadata(idx);
OS::get_singleton()->set_clipboard(fpath);
} break;
+ case FILE_NEW_RESOURCE: {
+ new_resource_dialog->popup_create(true);
+ } break;
}
}
@@ -1393,6 +1396,21 @@ void FileSystemDock::_folder_option(int p_option) {
}
}
+void FileSystemDock::_resource_created() const {
+ Object *c = new_resource_dialog->instance_selected();
+
+ ERR_FAIL_COND(!c);
+ Resource *r = Object::cast_to<Resource>(c);
+ ERR_FAIL_COND(!r);
+
+ REF res(r);
+ editor->push_item(c);
+
+ RES current_res = RES(r);
+
+ editor->save_resource_as(current_res);
+}
+
void FileSystemDock::_go_to_file_list() {
if (low_height_mode) {
@@ -1738,6 +1756,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
+ file_options->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE);
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
file_options->set_position(files->get_global_position() + p_pos);
@@ -1750,6 +1769,7 @@ void FileSystemDock::_rmb_pressed(const Vector2 &p_pos) {
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
+ file_options->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE);
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
file_options->set_position(files->get_global_position() + p_pos);
file_options->popup();
@@ -1862,6 +1882,7 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_file_option"), &FileSystemDock::_file_option);
ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option);
ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &FileSystemDock::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("_resource_created"), &FileSystemDock::_resource_created);
ClassDB::bind_method(D_METHOD("_move_operation_confirm", "to_path", "overwrite"), &FileSystemDock::_move_operation_confirm, DEFVAL(false));
ClassDB::bind_method(D_METHOD("_move_with_overwrite"), &FileSystemDock::_move_with_overwrite);
ClassDB::bind_method(D_METHOD("_rename_operation_confirm"), &FileSystemDock::_rename_operation_confirm);
@@ -2087,6 +2108,11 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
make_script_dialog_text->set_title(TTR("Create Script"));
add_child(make_script_dialog_text);
+ new_resource_dialog = memnew(CreateDialog);
+ add_child(new_resource_dialog);
+ new_resource_dialog->set_base_type("Resource");
+ new_resource_dialog->connect("create", this, "_resource_created");
+
updating_tree = false;
initialized = false;
import_dock_needs_update = false;