summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_name_dialog.cpp6
-rw-r--r--editor/editor_name_dialog.h1
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_settings.cpp5
-rw-r--r--editor/plugins/script_editor_plugin.cpp14
-rw-r--r--editor/plugins/script_text_editor.cpp15
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/script_create_dialog.cpp48
-rw-r--r--editor/script_create_dialog.h4
9 files changed, 78 insertions, 24 deletions
diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp
index 972857fd88..29d5dda658 100644
--- a/editor/editor_name_dialog.cpp
+++ b/editor/editor_name_dialog.cpp
@@ -79,9 +79,11 @@ void EditorNameDialog::_bind_methods() {
}
EditorNameDialog::EditorNameDialog() {
+ makevb = memnew(VBoxContainer);
+ add_child(makevb);
name = memnew(LineEdit);
- add_child(name);
- move_child(name, get_label()->get_index() + 1);
+ makevb->add_child(name);
+ makevb->move_child(name, get_label()->get_index() + 1);
name->set_margin(MARGIN_TOP, 5);
name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5);
name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 5);
diff --git a/editor/editor_name_dialog.h b/editor/editor_name_dialog.h
index a98db4ffe6..eeeee34d7e 100644
--- a/editor/editor_name_dialog.h
+++ b/editor/editor_name_dialog.h
@@ -38,6 +38,7 @@ class EditorNameDialog : public ConfirmationDialog {
GDCLASS(EditorNameDialog, ConfirmationDialog);
+ VBoxContainer *makevb;
LineEdit *name;
void _line_gui_input(const InputEvent &p_event);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index cc7ee44902..04d369fed4 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -435,7 +435,7 @@ void EditorNode::_sources_changed(bool p_exist) {
if (defer_load_scene != "") {
- print_line("loading scene DEFERED");
+ print_line("loading scene DEFERRED");
load_scene(defer_load_scene);
defer_load_scene = "";
}
@@ -6051,7 +6051,10 @@ EditorNode::EditorNode() {
{
_initializing_addons = true;
- Vector<String> addons = GlobalConfig::get_singleton()->get("editor_plugins/enabled");
+ Vector<String> addons;
+ if (GlobalConfig::get_singleton()->has("editor_plugins/enabled")) {
+ addons = GlobalConfig::get_singleton()->get("editor_plugins/enabled");
+ }
for (int i = 0; i < addons.size(); i++) {
set_addon_plugin_enabled(addons[i], true);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 35373eb815..9beffa3c67 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -407,7 +407,7 @@ void EditorSettings::setup_network() {
IP::get_singleton()->get_local_addresses(&local_ip);
String lip;
String hint;
- String current = get("network/debug_host");
+ String current = has("network/debug_host") ? get("network/debug_host") : "";
for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) {
@@ -557,6 +557,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints["text_editor/theme/font"] = PropertyInfo(Variant::STRING, "text_editor/theme/font", PROPERTY_HINT_GLOBAL_FILE, "*.fnt");
set("text_editor/completion/auto_brace_complete", false);
set("text_editor/files/restore_scripts_on_load", true);
+ set("text_editor/completion/complete_file_paths", true);
//set("docks/scene_tree/display_old_action_buttons",false);
set("docks/scene_tree/start_create_dialog_fully_expanded", false);
@@ -591,9 +592,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
set("editors/2d/bone_color2", Color(0.75, 0.75, 0.75, 0.9));
set("editors/2d/bone_selected_color", Color(0.9, 0.45, 0.45, 0.9));
set("editors/2d/bone_ik_color", Color(0.9, 0.9, 0.45, 0.9));
-
set("editors/2d/keep_margins_when_changing_anchors", false);
-
set("editors/2d/warped_mouse_panning", true);
set("run/window_placement/rect", 0);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index a99cd7a2d6..cdcc0a0855 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1534,13 +1534,6 @@ void ScriptEditor::save_all_scripts() {
if (!se)
continue;
- if (!se->is_unsaved())
- continue;
-
- if (trim_trailing_whitespace_on_save) {
- se->trim_trailing_whitespace();
- }
-
if (convert_indent_on_save) {
if (use_space_indentation) {
se->convert_indent_to_spaces();
@@ -1549,6 +1542,13 @@ void ScriptEditor::save_all_scripts() {
}
}
+ if (trim_trailing_whitespace_on_save) {
+ se->trim_trailing_whitespace();
+ }
+
+ if (!se->is_unsaved())
+ continue;
+
Ref<Script> script = se->get_edited_script();
if (script.is_valid())
se->apply_code();
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 052c19f34e..e942d6cebd 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -285,6 +285,9 @@ void ScriptTextEditor::convert_indent_to_spaces() {
indent += " ";
}
+ int cursor_line = tx->cursor_get_line();
+ int cursor_column = tx->cursor_get_column();
+
bool changed_indentation = false;
for (int i = 0; i < tx->get_line_count(); i++) {
String line = tx->get_line(i);
@@ -300,6 +303,9 @@ void ScriptTextEditor::convert_indent_to_spaces() {
tx->begin_complex_operation();
changed_indentation = true;
}
+ if (cursor_line == i && cursor_column > j) {
+ cursor_column += indent_size - 1;
+ }
line = line.left(j) + indent + line.right(j + 1);
}
j++;
@@ -307,6 +313,7 @@ void ScriptTextEditor::convert_indent_to_spaces() {
tx->set_line(i, line);
}
if (changed_indentation) {
+ tx->cursor_set_column(cursor_column);
tx->end_complex_operation();
tx->update();
}
@@ -323,6 +330,9 @@ void ScriptTextEditor::convert_indent_to_tabs() {
int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
indent_size -= 1;
+ int cursor_line = tx->cursor_get_line();
+ int cursor_column = tx->cursor_get_column();
+
bool changed_indentation = false;
for (int i = 0; i < tx->get_line_count(); i++) {
String line = tx->get_line(i);
@@ -342,7 +352,9 @@ void ScriptTextEditor::convert_indent_to_tabs() {
tx->begin_complex_operation();
changed_indentation = true;
}
-
+ if (cursor_line == i && cursor_column > j) {
+ cursor_column -= indent_size;
+ }
line = line.left(j - indent_size) + "\t" + line.right(j + 1);
j = 0;
space_count = -1;
@@ -355,6 +367,7 @@ void ScriptTextEditor::convert_indent_to_tabs() {
tx->set_line(i, line);
}
if (changed_indentation) {
+ tx->cursor_set_column(cursor_column);
tx->end_complex_operation();
tx->update();
}
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 3bdc742354..1a4a36fa18 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1211,7 +1211,7 @@ ProjectManager::ProjectManager() {
}
}
- FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesytem/file_dialog/show_hidden_files"));
+ FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"));
set_area_as_parent_rect();
set_theme(create_editor_theme());
diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp
index 7808cae0cd..15c540e132 100644
--- a/editor/script_create_dialog.cpp
+++ b/editor/script_create_dialog.cpp
@@ -55,6 +55,8 @@ bool ScriptCreateDialog::_validate(const String &p_string) {
if (p_string.length() == 0)
return false;
+ String path_chars = "\"res://";
+ bool is_val_path = ScriptServer::get_language(language_menu->get_selected())->can_inherit_from_file();
for (int i = 0; i < p_string.length(); i++) {
if (i == 0) {
@@ -62,7 +64,17 @@ bool ScriptCreateDialog::_validate(const String &p_string) {
return false; // no start with number plz
}
- bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_';
+ if (i == p_string.length() - 1 && is_val_path)
+ return p_string[i] == '\"';
+
+ if (is_val_path && i < path_chars.length()) {
+ if (p_string[i] != path_chars[i])
+ is_val_path = false;
+ else
+ continue;
+ }
+
+ bool valid_char = (p_string[i] >= '0' && p_string[i] <= '9') || (p_string[i] >= 'a' && p_string[i] <= 'z') || (p_string[i] >= 'A' && p_string[i] <= 'Z') || p_string[i] == '_' || (is_val_path && (p_string[i] == '/' || p_string[i] == '.'));
if (!valid_char)
return false;
@@ -74,7 +86,7 @@ bool ScriptCreateDialog::_validate(const String &p_string) {
void ScriptCreateDialog::_class_name_changed(const String &p_name) {
if (!_validate(parent_name->get_text())) {
- error_label->set_text(TTR("Invalid parent class name"));
+ error_label->set_text(TTR("Invalid parent class name or path"));
error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
} else if (class_name->is_editable()) {
if (class_name->get_text() == "") {
@@ -175,6 +187,12 @@ void ScriptCreateDialog::_lang_changed(int l) {
class_name->set_editable(false);
}
+ if (ScriptServer::get_language(l)->can_inherit_from_file()) {
+ parent_browse_button->show();
+ } else {
+ parent_browse_button->hide();
+ }
+
String selected_ext = "." + ScriptServer::get_language(l)->get_extension();
String path = file_path->get_text();
String extension = "";
@@ -215,7 +233,9 @@ void ScriptCreateDialog::_built_in_pressed() {
}
}
-void ScriptCreateDialog::_browse_path() {
+void ScriptCreateDialog::_browse_path(bool browse_parent) {
+
+ is_browsing_parent = browse_parent;
file_browse->set_mode(EditorFileDialog::MODE_SAVE_FILE);
file_browse->set_disable_overwrite_warning(true);
@@ -238,8 +258,13 @@ void ScriptCreateDialog::_browse_path() {
void ScriptCreateDialog::_file_selected(const String &p_file) {
String p = GlobalConfig::get_singleton()->localize_path(p_file);
- file_path->set_text(p);
- _path_changed(p);
+ if (is_browsing_parent) {
+ parent_name->set_text("\"" + p + "\"");
+ _class_name_changed("\"" + p + "\"");
+ } else {
+ file_path->set_text(p);
+ _path_changed(p);
+ }
}
void ScriptCreateDialog::_path_changed(const String &p_path) {
@@ -353,9 +378,18 @@ ScriptCreateDialog::ScriptCreateDialog() {
vb2->add_child(error_label);
vb->add_margin_child(TTR("Class Name:"), vb2);
+ HBoxContainer *hb1 = memnew(HBoxContainer);
parent_name = memnew(LineEdit);
- vb->add_margin_child(TTR("Inherits:"), parent_name);
parent_name->connect("text_changed", this, "_class_name_changed");
+ parent_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb1->add_child(parent_name);
+ parent_browse_button = memnew(Button);
+ parent_browse_button->set_text(" .. ");
+ parent_browse_button->connect("pressed", this, "_browse_path", varray(true));
+ hb1->add_child(parent_browse_button);
+ parent_browse_button->hide();
+ vb->add_margin_child(TTR("Inherits:"), hb1);
+ is_browsing_parent = false;
language_menu = memnew(OptionButton);
vb->add_margin_child(TTR("Language"), language_menu);
@@ -398,7 +432,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
file_path->set_h_size_flags(SIZE_EXPAND_FILL);
Button *b = memnew(Button);
b->set_text(" .. ");
- b->connect("pressed", this, "_browse_path");
+ b->connect("pressed", this, "_browse_path", varray(false));
hbc->add_child(b);
path_vb->add_child(hbc);
path_error_label = memnew(Label);
diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h
index 499886facd..113d4a468c 100644
--- a/editor/script_create_dialog.h
+++ b/editor/script_create_dialog.h
@@ -44,6 +44,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
Label *error_label;
Label *path_error_label;
LineEdit *parent_name;
+ Button *parent_browse_button;
OptionButton *language_menu;
LineEdit *file_path;
EditorFileDialog *file_browse;
@@ -52,6 +53,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
AcceptDialog *alert;
bool path_valid;
bool create_new;
+ bool is_browsing_parent;
String initial_bp;
EditorSettings *editor_settings;
@@ -60,7 +62,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
void _built_in_pressed();
bool _validate(const String &p_strin);
void _class_name_changed(const String &p_name);
- void _browse_path();
+ void _browse_path(bool browse_parent);
void _file_selected(const String &p_file);
virtual void ok_pressed();
void _create_new();