You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Streamline the project import workflow
This commit is contained in:
@@ -264,6 +264,8 @@ void EditorFileDialog::update_dir() {
|
|||||||
}
|
}
|
||||||
dir->set_text(dir_access->get_current_dir(false));
|
dir->set_text(dir_access->get_current_dir(false));
|
||||||
|
|
||||||
|
file->set_text("");
|
||||||
|
|
||||||
// Disable "Open" button only when selecting file(s) mode.
|
// Disable "Open" button only when selecting file(s) mode.
|
||||||
get_ok_button()->set_disabled(_is_open_should_be_disabled());
|
get_ok_button()->set_disabled(_is_open_should_be_disabled());
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
@@ -271,10 +273,10 @@ void EditorFileDialog::update_dir() {
|
|||||||
case FILE_MODE_OPEN_FILES:
|
case FILE_MODE_OPEN_FILES:
|
||||||
set_ok_button_text(TTR("Open"));
|
set_ok_button_text(TTR("Open"));
|
||||||
break;
|
break;
|
||||||
|
case FILE_MODE_OPEN_ANY:
|
||||||
case FILE_MODE_OPEN_DIR:
|
case FILE_MODE_OPEN_DIR:
|
||||||
set_ok_button_text(TTR("Select Current Folder"));
|
set_ok_button_text(TTR("Select Current Folder"));
|
||||||
break;
|
break;
|
||||||
case FILE_MODE_OPEN_ANY:
|
|
||||||
case FILE_MODE_SAVE_FILE:
|
case FILE_MODE_SAVE_FILE:
|
||||||
// FIXME: Implement, or refactor to avoid duplication with set_mode
|
// FIXME: Implement, or refactor to avoid duplication with set_mode
|
||||||
break;
|
break;
|
||||||
@@ -522,7 +524,11 @@ void EditorFileDialog::_item_selected(int p_item) {
|
|||||||
if (!d["dir"]) {
|
if (!d["dir"]) {
|
||||||
file->set_text(d["name"]);
|
file->set_text(d["name"]);
|
||||||
_request_single_thumbnail(get_current_dir().path_join(get_current_file()));
|
_request_single_thumbnail(get_current_dir().path_join(get_current_file()));
|
||||||
} else if (mode == FILE_MODE_OPEN_DIR) {
|
|
||||||
|
// FILE_MODE_OPEN_ANY can alternate this text depending on what's selected.
|
||||||
|
set_ok_button_text(TTR("Open"));
|
||||||
|
} else if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
|
||||||
|
file->set_text("");
|
||||||
set_ok_button_text(TTR("Select This Folder"));
|
set_ok_button_text(TTR("Select This Folder"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,12 +566,13 @@ void EditorFileDialog::_items_clear_selection(const Vector2 &p_pos, MouseButton
|
|||||||
get_ok_button()->set_disabled(!item_list->is_anything_selected());
|
get_ok_button()->set_disabled(!item_list->is_anything_selected());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FILE_MODE_OPEN_ANY:
|
||||||
case FILE_MODE_OPEN_DIR:
|
case FILE_MODE_OPEN_DIR:
|
||||||
|
file->set_text("");
|
||||||
get_ok_button()->set_disabled(false);
|
get_ok_button()->set_disabled(false);
|
||||||
set_ok_button_text(TTR("Select Current Folder"));
|
set_ok_button_text(TTR("Select Current Folder"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_MODE_OPEN_ANY:
|
|
||||||
case FILE_MODE_SAVE_FILE:
|
case FILE_MODE_SAVE_FILE:
|
||||||
// FIXME: Implement, or refactor to avoid duplication with set_mode
|
// FIXME: Implement, or refactor to avoid duplication with set_mode
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ String ProjectDialog::_test_path() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
|
_set_message(TTR("Please choose a \"project.godot\", a directory with it, or a \".zip\" file."), MESSAGE_ERROR);
|
||||||
install_path_container->hide();
|
install_path_container->hide();
|
||||||
get_ok_button()->set_disabled(true);
|
get_ok_button()->set_disabled(true);
|
||||||
return "";
|
return "";
|
||||||
@@ -283,6 +283,9 @@ void ProjectDialog::_path_text_changed(const String &p_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectDialog::_file_selected(const String &p_path) {
|
void ProjectDialog::_file_selected(const String &p_path) {
|
||||||
|
// If not already shown.
|
||||||
|
show_dialog();
|
||||||
|
|
||||||
String p = p_path;
|
String p = p_path;
|
||||||
if (mode == MODE_IMPORT) {
|
if (mode == MODE_IMPORT) {
|
||||||
if (p.ends_with("project.godot")) {
|
if (p.ends_with("project.godot")) {
|
||||||
@@ -311,6 +314,9 @@ void ProjectDialog::_file_selected(const String &p_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProjectDialog::_path_selected(const String &p_path) {
|
void ProjectDialog::_path_selected(const String &p_path) {
|
||||||
|
// If not already shown.
|
||||||
|
show_dialog();
|
||||||
|
|
||||||
String sp = p_path.simplify_path();
|
String sp = p_path.simplify_path();
|
||||||
project_path->set_text(sp);
|
project_path->set_text(sp);
|
||||||
_path_text_changed(sp);
|
_path_text_changed(sp);
|
||||||
@@ -328,7 +334,7 @@ void ProjectDialog::_browse_path() {
|
|||||||
fdialog->set_current_dir(project_path->get_text());
|
fdialog->set_current_dir(project_path->get_text());
|
||||||
|
|
||||||
if (mode == MODE_IMPORT) {
|
if (mode == MODE_IMPORT) {
|
||||||
fdialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
|
fdialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_ANY);
|
||||||
fdialog->clear_filters();
|
fdialog->clear_filters();
|
||||||
fdialog->add_filter("project.godot", vformat("%s %s", VERSION_NAME, TTR("Project")));
|
fdialog->add_filter("project.godot", vformat("%s %s", VERSION_NAME, TTR("Project")));
|
||||||
fdialog->add_filter("*.zip", TTR("ZIP File"));
|
fdialog->add_filter("*.zip", TTR("ZIP File"));
|
||||||
@@ -666,6 +672,14 @@ void ProjectDialog::set_project_path(const String &p_path) {
|
|||||||
project_path->set_text(p_path);
|
project_path->set_text(p_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectDialog::ask_for_path_and_show() {
|
||||||
|
// Workaround: for the file selection dialog content to be rendered we need to show its parent dialog.
|
||||||
|
show_dialog();
|
||||||
|
_set_message("");
|
||||||
|
|
||||||
|
_browse_path();
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectDialog::show_dialog() {
|
void ProjectDialog::show_dialog() {
|
||||||
if (mode == MODE_RENAME) {
|
if (mode == MODE_RENAME) {
|
||||||
project_path->set_editable(false);
|
project_path->set_editable(false);
|
||||||
@@ -2448,7 +2462,7 @@ void ProjectManager::_new_project() {
|
|||||||
|
|
||||||
void ProjectManager::_import_project() {
|
void ProjectManager::_import_project() {
|
||||||
npdialog->set_mode(ProjectDialog::MODE_IMPORT);
|
npdialog->set_mode(ProjectDialog::MODE_IMPORT);
|
||||||
npdialog->show_dialog();
|
npdialog->ask_for_path_and_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::_rename_project() {
|
void ProjectManager::_rename_project() {
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ public:
|
|||||||
void set_mode(Mode p_mode);
|
void set_mode(Mode p_mode);
|
||||||
void set_project_path(const String &p_path);
|
void set_project_path(const String &p_path);
|
||||||
|
|
||||||
|
void ask_for_path_and_show();
|
||||||
void show_dialog();
|
void show_dialog();
|
||||||
|
|
||||||
ProjectDialog();
|
ProjectDialog();
|
||||||
|
|||||||
Reference in New Issue
Block a user