Added an "Edit Now" option to project dialog.

This commit is contained in:
Zi Ye 2024-08-15 18:28:25 -05:00
parent ee363af0ed
commit 3669eb0b69
4 changed files with 25 additions and 7 deletions

View File

@ -711,14 +711,17 @@ void ProjectManager::_on_projects_updated() {
project_list->update_dock_menu();
}
void ProjectManager::_on_project_created(const String &dir) {
void ProjectManager::_on_project_created(const String &dir, bool edit) {
project_list->add_project(dir, false);
project_list->save_config();
search_box->clear();
int i = project_list->refresh_project(dir);
project_list->select_project(i);
project_list->ensure_project_visible(i);
if (edit) {
_open_selected_projects_ask();
}
project_list->update_dock_menu();
}

View File

@ -187,7 +187,7 @@ class ProjectManager : public Control {
void _erase_missing_projects_confirm();
void _update_project_buttons();
void _on_project_created(const String &dir);
void _on_project_created(const String &dir, bool edit);
void _on_projects_updated();
void _on_order_option_changed(int p_idx);

View File

@ -671,7 +671,7 @@ void ProjectDialog::ok_pressed() {
hide();
if (mode == MODE_NEW || mode == MODE_IMPORT || mode == MODE_INSTALL) {
emit_signal(SNAME("project_created"), path);
emit_signal(SNAME("project_created"), path, edit_check_box->is_pressed());
} else if (mode == MODE_RENAME) {
emit_signal(SNAME("projects_updated"));
}
@ -713,6 +713,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
create_dir->hide();
project_status_rect->hide();
project_browse->hide();
edit_check_box->hide();
name_container->show();
install_path_container->hide();
@ -742,10 +743,11 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
create_dir->show();
project_status_rect->show();
project_browse->show();
edit_check_box->show();
if (mode == MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
set_ok_button_text(TTR("Import & Edit"));
set_ok_button_text(TTR("Import"));
name_container->hide();
install_path_container->hide();
@ -755,7 +757,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
// Project path dialog is also opened; no need to change focus.
} else if (mode == MODE_NEW) {
set_title(TTR("Create New Project"));
set_ok_button_text(TTR("Create & Edit"));
set_ok_button_text(TTR("Create"));
name_container->show();
install_path_container->hide();
@ -766,7 +768,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
callable_mp(project_name, &LineEdit::select_all).call_deferred();
} else if (mode == MODE_INSTALL) {
set_title(TTR("Install Project:") + " " + zip_title);
set_ok_button_text(TTR("Install & Edit"));
set_ok_button_text(TTR("Install"));
project_name->set_text(zip_title);
@ -993,6 +995,16 @@ ProjectDialog::ProjectDialog() {
fdialog_install->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
add_child(fdialog_install);
Control *spacer2 = memnew(Control);
spacer2->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_child(spacer2);
edit_check_box = memnew(CheckBox);
edit_check_box->set_text(TTR("Edit Now"));
edit_check_box->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
edit_check_box->set_pressed(true);
vb->add_child(edit_check_box);
project_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_project_name_changed).unbind(1));
project_path->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_project_path_changed).unbind(1));
install_path->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_install_path_changed).unbind(1));

View File

@ -34,6 +34,7 @@
#include "scene/gui/dialogs.h"
class Button;
class CheckBox;
class CheckButton;
class EditorFileDialog;
class LineEdit;
@ -87,6 +88,8 @@ private:
OptionButton *vcs_metadata_selection = nullptr;
CheckBox *edit_check_box = nullptr;
EditorFileDialog *fdialog_project = nullptr;
EditorFileDialog *fdialog_install = nullptr;
AcceptDialog *dialog_error = nullptr;