summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp4
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/project_manager.cpp70
-rw-r--r--editor/project_manager.h4
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--editor/scene_tree_dock.cpp1
-rw-r--r--editor/script_create_dialog.cpp48
-rw-r--r--editor/script_create_dialog.h9
8 files changed, 138 insertions, 2 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index d655f52f5d..ec984e480a 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1297,6 +1297,8 @@ void CodeTextEditor::_on_settings_change() {
text_editor->set_callhint_settings(
EDITOR_DEF("text_editor/completion/put_callhint_tooltip_below_current_line", true),
EDITOR_DEF("text_editor/completion/callhint_tooltip_offset", Vector2()));
+
+ idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2.0));
}
void CodeTextEditor::_text_changed_idle_timeout() {
@@ -1411,7 +1413,7 @@ CodeTextEditor::CodeTextEditor() {
idle = memnew(Timer);
add_child(idle);
idle->set_one_shot(true);
- idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2));
+ idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2.0));
code_complete_timer = memnew(Timer);
add_child(code_complete_timer);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bf582ca004..b65a484b16 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -459,7 +459,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/cursor/right_click_moves_caret", true);
// Completion
- _initial_set("text_editor/completion/idle_parse_delay", 2);
+ _initial_set("text_editor/completion/idle_parse_delay", 2.0);
+ hints["text_editor/completion/idle_parse_delay"] = PropertyInfo(Variant::REAL, "text_editor/completion/idle_parse_delay", PROPERTY_HINT_RANGE, "0.1, 10, 0.01");
_initial_set("text_editor/completion/auto_brace_complete", false);
_initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true);
_initial_set("text_editor/completion/callhint_tooltip_offset", Vector2());
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 0a6e4c0607..66766f7ccf 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -987,6 +987,24 @@ void ProjectManager::_update_project_buttons() {
open_btn->set_disabled(empty_selection);
rename_btn->set_disabled(empty_selection);
run_btn->set_disabled(empty_selection);
+
+ bool missing_projects = false;
+ Map<String, String> list_all_projects;
+ for (int i = 0; i < scroll_children->get_child_count(); i++) {
+ HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
+ if (hb) {
+ list_all_projects.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
+ }
+ }
+ for (Map<String, String>::Element *E = list_all_projects.front(); E; E = E->next()) {
+ String project_name = E->key().replace("::", "/") + "/project.godot";
+ if (!FileAccess::exists(project_name)) {
+ missing_projects = true;
+ break;
+ }
+ }
+
+ erase_missing_btn->set_visible(missing_projects);
}
void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) {
@@ -1700,6 +1718,39 @@ void ProjectManager::_erase_project_confirm() {
_load_recent_projects();
}
+void ProjectManager::_erase_missing_projects_confirm() {
+
+ Map<String, String> list_all_projects;
+ for (int i = 0; i < scroll_children->get_child_count(); i++) {
+ HBoxContainer *hb = Object::cast_to<HBoxContainer>(scroll_children->get_child(i));
+ if (hb) {
+ list_all_projects.insert(hb->get_meta("name"), hb->get_meta("main_scene"));
+ }
+ }
+
+ if (list_all_projects.size() == 0) {
+ return;
+ }
+
+ int deleted_projects = 0;
+ int remaining_projects = 0;
+ for (Map<String, String>::Element *E = list_all_projects.front(); E; E = E->next()) {
+ String project_name = E->key().replace("::", "/") + "/project.godot";
+ if (!FileAccess::exists(project_name)) {
+ deleted_projects++;
+ EditorSettings::get_singleton()->erase("projects/" + E->key());
+ EditorSettings::get_singleton()->erase("favorite_projects/" + E->key());
+ } else {
+ remaining_projects++;
+ }
+ }
+ print_line("Deleted " + itos(deleted_projects) + " projects, remaining " + itos(remaining_projects) + " projects");
+ EditorSettings::get_singleton()->save();
+ selected_list.clear();
+ last_clicked = "";
+ _load_recent_projects();
+}
+
void ProjectManager::_erase_project() {
if (selected_list.size() == 0)
@@ -1716,6 +1767,12 @@ void ProjectManager::_erase_project() {
erase_ask->popup_centered_minsize();
}
+void ProjectManager::_erase_missing_projects() {
+
+ erase_missing_ask->set_text(TTR("Remove all missing projects from the list? (Folders contents will not be modified)"));
+ erase_missing_ask->popup_centered_minsize();
+}
+
void ProjectManager::_language_selected(int p_id) {
String lang = language_btn->get_item_metadata(p_id);
@@ -1812,7 +1869,9 @@ void ProjectManager::_bind_methods() {
ClassDB::bind_method("_new_project", &ProjectManager::_new_project);
ClassDB::bind_method("_rename_project", &ProjectManager::_rename_project);
ClassDB::bind_method("_erase_project", &ProjectManager::_erase_project);
+ ClassDB::bind_method("_erase_missing_projects", &ProjectManager::_erase_missing_projects);
ClassDB::bind_method("_erase_project_confirm", &ProjectManager::_erase_project_confirm);
+ ClassDB::bind_method("_erase_missing_projects_confirm", &ProjectManager::_erase_missing_projects_confirm);
ClassDB::bind_method("_language_selected", &ProjectManager::_language_selected);
ClassDB::bind_method("_restart_confirm", &ProjectManager::_restart_confirm);
ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog);
@@ -2050,6 +2109,12 @@ ProjectManager::ProjectManager() {
erase->connect("pressed", this, "_erase_project");
erase_btn = erase;
+ Button *erase_missing = memnew(Button);
+ erase_missing->set_text(TTR("Remove Missing"));
+ tree_vb->add_child(erase_missing);
+ erase_missing->connect("pressed", this, "_erase_missing_projects");
+ erase_missing_btn = erase_missing;
+
tree_vb->add_spacer();
if (StreamPeerSSL::is_available()) {
@@ -2113,6 +2178,11 @@ ProjectManager::ProjectManager() {
language_restart_ask->get_cancel()->set_text(TTR("Continue"));
gui_base->add_child(language_restart_ask);
+ erase_missing_ask = memnew(ConfirmationDialog);
+ erase_missing_ask->get_ok()->set_text(TTR("Remove All"));
+ erase_missing_ask->get_ok()->connect("pressed", this, "_erase_missing_projects_confirm");
+ gui_base->add_child(erase_missing_ask);
+
erase_ask = memnew(ConfirmationDialog);
erase_ask->get_ok()->set_text(TTR("Remove"));
erase_ask->get_ok()->connect("pressed", this, "_erase_project_confirm");
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 1fdd7dbe06..382e9fc8fb 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -45,6 +45,7 @@ class ProjectManager : public Control {
GDCLASS(ProjectManager, Control);
Button *erase_btn;
+ Button *erase_missing_btn;
Button *open_btn;
Button *rename_btn;
Button *run_btn;
@@ -57,6 +58,7 @@ class ProjectManager : public Control {
FileDialog *scan_dir;
ConfirmationDialog *language_restart_ask;
ConfirmationDialog *erase_ask;
+ ConfirmationDialog *erase_missing_ask;
ConfirmationDialog *multi_open_ask;
ConfirmationDialog *multi_run_ask;
ConfirmationDialog *multi_scan_ask;
@@ -89,7 +91,9 @@ class ProjectManager : public Control {
void _new_project();
void _rename_project();
void _erase_project();
+ void _erase_missing_projects();
void _erase_project_confirm();
+ void _erase_missing_projects_confirm();
void _update_project_buttons();
void _language_selected(int p_id);
void _restart_confirm();
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index f8f48d01ad..71bddebcf5 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -1592,6 +1592,7 @@ void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
search_box->select_all();
} else {
+ search_box->clear();
search_bar->hide();
add_prop_bar->show();
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 1dca542138..a41f10607b 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -2625,6 +2625,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
add_child(rename_dialog);
script_create_dialog = memnew(ScriptCreateDialog);
+ script_create_dialog->set_inheritance_base_type("Node");
add_child(script_create_dialog);
script_create_dialog->connect("script_created", this, "_script_created");
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index a7b179753f..292cb8ddc3 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -34,6 +34,7 @@
#include "core/os/file_access.h"
#include "core/project_settings.h"
#include "core/script_language.h"
+#include "editor/create_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor_file_system.h"
@@ -45,11 +46,28 @@ void ScriptCreateDialog::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
path_button->set_icon(get_icon("Folder", "EditorIcons"));
parent_browse_button->set_icon(get_icon("Folder", "EditorIcons"));
+ parent_search_button->set_icon(get_icon("ClassList", "EditorIcons"));
status_panel->add_style_override("panel", get_stylebox("bg", "Tree"));
} break;
}
}
+void ScriptCreateDialog::_path_hbox_sorted() {
+ if (is_visible()) {
+ int filename_start_pos = initial_bp.find_last("/") + 1;
+ int filename_end_pos = initial_bp.length();
+
+ file_path->select(filename_start_pos, filename_end_pos);
+
+ // First set cursor to the end of line to scroll LineEdit view
+ // to the right and then set the actual cursor position.
+ file_path->set_cursor_position(file_path->get_text().length());
+ file_path->set_cursor_position(filename_start_pos);
+
+ file_path->grab_focus();
+ }
+}
+
bool ScriptCreateDialog::_can_be_built_in() {
return (supports_built_in && built_in_enabled);
}
@@ -77,6 +95,11 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
_path_changed(file_path->get_text());
}
+void ScriptCreateDialog::set_inheritance_base_type(const String &p_base) {
+
+ base_type = p_base;
+}
+
bool ScriptCreateDialog::_validate(const String &p_string) {
if (p_string.length() == 0)
@@ -362,6 +385,17 @@ void ScriptCreateDialog::_file_selected(const String &p_file) {
}
}
+void ScriptCreateDialog::_create() {
+
+ parent_name->set_text(select_class->get_selected_type());
+}
+
+void ScriptCreateDialog::_browse_class_in_tree() {
+
+ select_class->set_base_type(base_type);
+ select_class->popup_create(true);
+}
+
void ScriptCreateDialog::_path_changed(const String &p_path) {
is_path_valid = false;
@@ -586,6 +620,7 @@ void ScriptCreateDialog::_update_dialog() {
void ScriptCreateDialog::_bind_methods() {
+ ClassDB::bind_method("_path_hbox_sorted", &ScriptCreateDialog::_path_hbox_sorted);
ClassDB::bind_method("_class_name_changed", &ScriptCreateDialog::_class_name_changed);
ClassDB::bind_method("_parent_name_changed", &ScriptCreateDialog::_parent_name_changed);
ClassDB::bind_method("_lang_changed", &ScriptCreateDialog::_lang_changed);
@@ -595,6 +630,8 @@ void ScriptCreateDialog::_bind_methods() {
ClassDB::bind_method("_path_changed", &ScriptCreateDialog::_path_changed);
ClassDB::bind_method("_path_entered", &ScriptCreateDialog::_path_entered);
ClassDB::bind_method("_template_changed", &ScriptCreateDialog::_template_changed);
+ ClassDB::bind_method("_create", &ScriptCreateDialog::_create);
+ ClassDB::bind_method("_browse_class_in_tree", &ScriptCreateDialog::_browse_class_in_tree);
ClassDB::bind_method(D_METHOD("config", "inherits", "path", "built_in_enabled"), &ScriptCreateDialog::config, DEFVAL(true));
@@ -707,12 +744,18 @@ ScriptCreateDialog::ScriptCreateDialog() {
/* Inherits */
+ base_type = "Object";
+
hb = memnew(HBoxContainer);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
parent_name = memnew(LineEdit);
parent_name->connect("text_changed", this, "_parent_name_changed");
parent_name->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(parent_name);
+ parent_search_button = memnew(Button);
+ parent_search_button->set_flat(true);
+ parent_search_button->connect("pressed", this, "_browse_class_in_tree");
+ hb->add_child(parent_search_button);
parent_browse_button = memnew(Button);
parent_browse_button->set_flat(true);
parent_browse_button->connect("pressed", this, "_browse_path", varray(true, false));
@@ -760,6 +803,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
/* Path */
hb = memnew(HBoxContainer);
+ hb->connect("sort_children", this, "_path_hbox_sorted");
file_path = memnew(LineEdit);
file_path->connect("text_changed", this, "_path_changed");
file_path->connect("text_entered", this, "_path_entered");
@@ -777,6 +821,10 @@ ScriptCreateDialog::ScriptCreateDialog() {
/* Dialog Setup */
+ select_class = memnew(CreateDialog);
+ select_class->connect("create", this, "_create");
+ add_child(select_class);
+
file_browse = memnew(EditorFileDialog);
file_browse->connect("file_selected", this, "_file_selected");
file_browse->set_mode(EditorFileDialog::MODE_OPEN_FILE);
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 15e838d69f..f5c335c00a 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -40,6 +40,8 @@
#include "scene/gui/option_button.h"
#include "scene/gui/panel_container.h"
+class CreateDialog;
+
class ScriptCreateDialog : public ConfirmationDialog {
GDCLASS(ScriptCreateDialog, ConfirmationDialog);
@@ -49,6 +51,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
PanelContainer *status_panel;
LineEdit *parent_name;
Button *parent_browse_button;
+ Button *parent_search_button;
OptionButton *language_menu;
OptionButton *template_menu;
LineEdit *file_path;
@@ -57,6 +60,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
CheckButton *internal;
VBoxContainer *path_vb;
AcceptDialog *alert;
+ CreateDialog *select_class;
bool path_valid;
bool create_new;
bool is_browsing_parent;
@@ -74,7 +78,9 @@ class ScriptCreateDialog : public ConfirmationDialog {
bool re_check_path;
String script_template;
Vector<String> template_list;
+ String base_type;
+ void _path_hbox_sorted();
bool _can_be_built_in();
void _path_changed(const String &p_path = String());
void _path_entered(const String &p_path = String());
@@ -86,6 +92,8 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _template_changed(int p_template = 0);
void _browse_path(bool browse_parent, bool p_save);
void _file_selected(const String &p_file);
+ void _create();
+ void _browse_class_in_tree();
virtual void ok_pressed();
void _create_new();
void _load_exist();
@@ -99,6 +107,7 @@ protected:
public:
void config(const String &p_base_name, const String &p_base_path, bool p_built_in_enabled = true);
+ void set_inheritance_base_type(const String &p_base);
ScriptCreateDialog();
};