From 241e2594f1ea9e051876dea0e4217890359dc50b Mon Sep 17 00:00:00 2001 From: "Ying-Ruei Liang(KK)" Date: Mon, 19 Sep 2016 11:27:53 +0800 Subject: [PATCH 1/3] Show '.' in the tree of file_dialog --- scene/gui/file_dialog.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 6b43425edc8..f942f15ed0b 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -186,15 +186,17 @@ void FileDialog::_action_pressed() { hide(); }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) { - String path=dir_access->get_current_dir(); - /*if (tree->get_selected()) { - Dictionary d = tree->get_selected()->get_metadata(0); - if (d["dir"]) { - path=path+"/"+String(d["name"]); - } - }*/ + path=path.replace("\\","/"); + + if (TreeItem* item = tree->get_selected()) { + Dictionary d = item->get_metadata(0); + if (d["dir"]) { + path=path.plus_file(d["name"]); + } + } + emit_signal("dir_selected",path); hide(); } @@ -348,18 +350,18 @@ void FileDialog::update_file_list() { files.sort_custom(); while(!dirs.empty()) { + String& dir_name = dirs.front()->get(); + TreeItem *ti=tree->create_item(root); + ti->set_text(0,dir_name+"/"); + ti->set_icon(0,folder); + + Dictionary d; + d["name"]=dir_name; + d["dir"]=true; + + ti->set_metadata(0,d); - if (dirs.front()->get()!=".") { - TreeItem *ti=tree->create_item(root); - ti->set_text(0,dirs.front()->get()+"/"); - ti->set_icon(0,folder); - Dictionary d; - d["name"]=dirs.front()->get(); - d["dir"]=true; - ti->set_metadata(0,d); - } dirs.pop_front(); - } dirs.clear(); From ef1bfd3f2e2a5ee071c1c8a7f474629ac98d9c74 Mon Sep 17 00:00:00 2001 From: "Ying-Ruei Liang(KK)" Date: Mon, 26 Sep 2016 15:38:15 +0800 Subject: [PATCH 2/3] Show "." in item_list of EditorFiledialog --- tools/editor/editor_file_dialog.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index b8abd1d32c8..cbf678d6bb2 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -571,25 +571,26 @@ void EditorFileDialog::update_file_list() { files.sort_custom(); while(!dirs.empty()) { + const String& dir_name=dirs.front()->get(); - if (dirs.front()->get()!=".") { - item_list->add_item(dirs.front()->get()+"/"); - if (display_mode==DISPLAY_THUMBNAILS) { + item_list->add_item(dir_name+"/"); - item_list->set_item_icon(item_list->get_item_count()-1,folder_thumbnail); - } else { + if (display_mode==DISPLAY_THUMBNAILS) { - item_list->set_item_icon(item_list->get_item_count()-1,folder); - } + item_list->set_item_icon(item_list->get_item_count()-1,folder_thumbnail); + } else { - Dictionary d; - d["name"]=dirs.front()->get(); - d["path"]=String(); - d["dir"]=true; - item_list->set_item_metadata( item_list->get_item_count() -1, d); + item_list->set_item_icon(item_list->get_item_count()-1,folder); } - dirs.pop_front(); + Dictionary d; + d["name"]=dir_name; + d["path"]=String(); + d["dir"]=true; + + item_list->set_item_metadata( item_list->get_item_count() -1, d); + + dirs.pop_front(); } dirs.clear(); From b40265492cccb9ee11067e328bd6e7f828fd8b6c Mon Sep 17 00:00:00 2001 From: "Ying-Ruei Liang(KK)" Date: Mon, 26 Sep 2016 15:43:10 +0800 Subject: [PATCH 3/3] Append selected dir when openning dir with Editorfiledialog --- tools/editor/editor_file_dialog.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index cbf678d6bb2..90289a275e6 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -336,15 +336,21 @@ void EditorFileDialog::_action_pressed() { hide(); }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) { - String path=dir_access->get_current_dir(); - /*if (tree->get_selected()) { - Dictionary d = tree->get_selected()->get_metadata(0); - if (d["dir"]) { - path=path+"/"+String(d["name"]); - } - }*/ + path=path.replace("\\","/"); + + for(int i=0;iget_item_count();i++) { + if (item_list->is_selected(i)) { + Dictionary d=item_list->get_item_metadata(i); + if (d["dir"]) { + path=path.plus_file(d["name"]); + + break; + } + } + } + _save_to_recent(); emit_signal("dir_selected",path); hide();