summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp339
-rw-r--r--editor/code_editor.h23
-rw-r--r--editor/connections_dialog.cpp4
-rw-r--r--editor/editor_help.cpp3
-rw-r--r--editor/editor_help.h5
-rw-r--r--editor/editor_inspector.cpp87
-rw-r--r--editor/editor_inspector.h21
-rw-r--r--editor/editor_node.cpp104
-rw-r--r--editor/editor_node.h11
-rw-r--r--editor/editor_sectioned_inspector.cpp306
-rw-r--r--editor/editor_sectioned_inspector.h42
-rw-r--r--editor/editor_settings.cpp41
-rw-r--r--editor/editor_settings.h7
-rw-r--r--editor/editor_spin_slider.cpp3
-rw-r--r--editor/editor_themes.cpp5
-rw-r--r--editor/filesystem_dock.cpp26
-rw-r--r--editor/filesystem_dock.h7
-rw-r--r--editor/icons/icon_g_l_e_s_2.svg69
-rw-r--r--editor/icons/icon_g_l_e_s_3.svg67
-rw-r--r--editor/icons/icon_soft_body.svg56
-rw-r--r--editor/icons/icon_vulkan.svg127
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp32
-rw-r--r--editor/import/editor_scene_importer_gltf.h2
-rw-r--r--editor/inspector_dock.cpp1
-rw-r--r--editor/plugins/particles_editor_plugin.cpp5
-rw-r--r--editor/plugins/script_editor_plugin.cpp373
-rw-r--r--editor/plugins/script_editor_plugin.h20
-rw-r--r--editor/plugins/script_text_editor.cpp438
-rw-r--r--editor/plugins/script_text_editor.h12
-rw-r--r--editor/plugins/shader_editor_plugin.cpp127
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp4
-rw-r--r--editor/plugins/spatial_editor_plugin.h1
-rw-r--r--editor/plugins/text_editor.cpp607
-rw-r--r--editor/plugins/text_editor.h146
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp10
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp207
-rw-r--r--editor/project_settings_editor.cpp73
-rw-r--r--editor/project_settings_editor.h15
-rw-r--r--editor/property_editor.cpp2
-rw-r--r--editor/scene_tree_dock.cpp6
-rw-r--r--editor/scene_tree_dock.h2
-rw-r--r--editor/script_editor_debugger.cpp3
-rw-r--r--editor/settings_config_dialog.cpp70
-rw-r--r--editor/settings_config_dialog.h18
-rw-r--r--editor/spatial_editor_gizmos.cpp108
-rw-r--r--editor/spatial_editor_gizmos.h17
47 files changed, 2949 insertions, 705 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 6aec6135f1..925f97de8e 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -784,6 +784,345 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));
}
+void CodeTextEditor::trim_trailing_whitespace() {
+ bool trimed_whitespace = false;
+ for (int i = 0; i < text_editor->get_line_count(); i++) {
+ String line = text_editor->get_line(i);
+ if (line.ends_with(" ") || line.ends_with("\t")) {
+
+ if (!trimed_whitespace) {
+ text_editor->begin_complex_operation();
+ trimed_whitespace = true;
+ }
+
+ int end = 0;
+ for (int j = line.length() - 1; j > -1; j--) {
+ if (line[j] != ' ' && line[j] != '\t') {
+ end = j + 1;
+ break;
+ }
+ }
+ text_editor->set_line(i, line.substr(0, end));
+ }
+ }
+
+ if (trimed_whitespace) {
+ text_editor->end_complex_operation();
+ text_editor->update();
+ }
+}
+
+void CodeTextEditor::convert_indent_to_spaces() {
+ int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
+ String indent = "";
+
+ for (int i = 0; i < indent_size; i++) {
+ indent += " ";
+ }
+
+ int cursor_line = text_editor->cursor_get_line();
+ int cursor_column = text_editor->cursor_get_column();
+
+ bool changed_indentation = false;
+ for (int i = 0; i < text_editor->get_line_count(); i++) {
+ String line = text_editor->get_line(i);
+
+ if (line.length() <= 0) {
+ continue;
+ }
+
+ int j = 0;
+ while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
+ if (line[j] == '\t') {
+ if (!changed_indentation) {
+ text_editor->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++;
+ }
+ if (changed_indentation) {
+ text_editor->set_line(i, line);
+ }
+ }
+ if (changed_indentation) {
+ text_editor->cursor_set_column(cursor_column);
+ text_editor->end_complex_operation();
+ text_editor->update();
+ }
+}
+
+void CodeTextEditor::convert_indent_to_tabs() {
+ int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
+ indent_size -= 1;
+
+ int cursor_line = text_editor->cursor_get_line();
+ int cursor_column = text_editor->cursor_get_column();
+
+ bool changed_indentation = false;
+ for (int i = 0; i < text_editor->get_line_count(); i++) {
+ String line = text_editor->get_line(i);
+
+ if (line.length() <= 0) {
+ continue;
+ }
+
+ int j = 0;
+ int space_count = -1;
+ while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
+ if (line[j] != '\t') {
+ space_count++;
+
+ if (space_count == indent_size) {
+ if (!changed_indentation) {
+ text_editor->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;
+ }
+ } else {
+ space_count = -1;
+ }
+ j++;
+ }
+ if (changed_indentation) {
+ text_editor->set_line(i, line);
+ }
+ }
+ if (changed_indentation) {
+ text_editor->cursor_set_column(cursor_column);
+ text_editor->end_complex_operation();
+ text_editor->update();
+ }
+}
+
+void CodeTextEditor::convert_case(CaseStyle p_case) {
+ if (!text_editor->is_selection_active()) {
+ return;
+ }
+
+ text_editor->begin_complex_operation();
+
+ int begin = text_editor->get_selection_from_line();
+ int end = text_editor->get_selection_to_line();
+ int begin_col = text_editor->get_selection_from_column();
+ int end_col = text_editor->get_selection_to_column();
+
+ for (int i = begin; i <= end; i++) {
+ int len = text_editor->get_line(i).length();
+ if (i == end)
+ len -= len - end_col;
+ if (i == begin)
+ len -= begin_col;
+ String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len);
+
+ switch (p_case) {
+ case UPPER: {
+ new_line = new_line.to_upper();
+ } break;
+ case LOWER: {
+ new_line = new_line.to_lower();
+ } break;
+ case CAPITALIZE: {
+ new_line = new_line.capitalize();
+ } break;
+ }
+
+ if (i == begin) {
+ new_line = text_editor->get_line(i).left(begin_col) + new_line;
+ }
+ if (i == end) {
+ new_line = new_line + text_editor->get_line(i).right(end_col);
+ }
+ text_editor->set_line(i, new_line);
+ }
+ text_editor->end_complex_operation();
+}
+
+void CodeTextEditor::move_lines_up() {
+ text_editor->begin_complex_operation();
+ if (text_editor->is_selection_active()) {
+ int from_line = text_editor->get_selection_from_line();
+ int from_col = text_editor->get_selection_from_column();
+ int to_line = text_editor->get_selection_to_line();
+ int to_column = text_editor->get_selection_to_column();
+
+ for (int i = from_line; i <= to_line; i++) {
+ int line_id = i;
+ int next_id = i - 1;
+
+ if (line_id == 0 || next_id < 0)
+ return;
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->cursor_set_line(next_id);
+ }
+ int from_line_up = from_line > 0 ? from_line - 1 : from_line;
+ int to_line_up = to_line > 0 ? to_line - 1 : to_line;
+ text_editor->select(from_line_up, from_col, to_line_up, to_column);
+ } else {
+ int line_id = text_editor->cursor_get_line();
+ int next_id = line_id - 1;
+
+ if (line_id == 0 || next_id < 0)
+ return;
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->cursor_set_line(next_id);
+ }
+ text_editor->end_complex_operation();
+ text_editor->update();
+}
+
+void CodeTextEditor::move_lines_down() {
+ text_editor->begin_complex_operation();
+ if (text_editor->is_selection_active()) {
+ int from_line = text_editor->get_selection_from_line();
+ int from_col = text_editor->get_selection_from_column();
+ int to_line = text_editor->get_selection_to_line();
+ int to_column = text_editor->get_selection_to_column();
+
+ for (int i = to_line; i >= from_line; i--) {
+ int line_id = i;
+ int next_id = i + 1;
+
+ if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count())
+ return;
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->cursor_set_line(next_id);
+ }
+ int from_line_down = from_line < text_editor->get_line_count() ? from_line + 1 : from_line;
+ int to_line_down = to_line < text_editor->get_line_count() ? to_line + 1 : to_line;
+ text_editor->select(from_line_down, from_col, to_line_down, to_column);
+ } else {
+ int line_id = text_editor->cursor_get_line();
+ int next_id = line_id + 1;
+
+ if (line_id == text_editor->get_line_count() - 1 || next_id > text_editor->get_line_count())
+ return;
+
+ text_editor->unfold_line(line_id);
+ text_editor->unfold_line(next_id);
+
+ text_editor->swap_lines(line_id, next_id);
+ text_editor->cursor_set_line(next_id);
+ }
+ text_editor->end_complex_operation();
+ text_editor->update();
+}
+
+void CodeTextEditor::delete_lines() {
+ text_editor->begin_complex_operation();
+ if (text_editor->is_selection_active()) {
+ int to_line = text_editor->get_selection_to_line();
+ int from_line = text_editor->get_selection_from_line();
+ int count = Math::abs(to_line - from_line) + 1;
+ while (count) {
+ text_editor->set_line(text_editor->cursor_get_line(), "");
+ text_editor->backspace_at_cursor();
+ count--;
+ if (count)
+ text_editor->unfold_line(from_line);
+ }
+ text_editor->cursor_set_line(from_line - 1);
+ text_editor->deselect();
+ } else {
+ int line = text_editor->cursor_get_line();
+ text_editor->set_line(text_editor->cursor_get_line(), "");
+ text_editor->backspace_at_cursor();
+ text_editor->unfold_line(line);
+ text_editor->cursor_set_line(line);
+ }
+ text_editor->end_complex_operation();
+}
+
+void CodeTextEditor::code_lines_down() {
+ int from_line = text_editor->cursor_get_line();
+ int to_line = text_editor->cursor_get_line();
+ int column = text_editor->cursor_get_column();
+
+ if (text_editor->is_selection_active()) {
+ from_line = text_editor->get_selection_from_line();
+ to_line = text_editor->get_selection_to_line();
+ column = text_editor->cursor_get_column();
+ }
+ int next_line = to_line + 1;
+
+ if (to_line >= text_editor->get_line_count() - 1) {
+ text_editor->set_line(to_line, text_editor->get_line(to_line) + "\n");
+ }
+
+ text_editor->begin_complex_operation();
+ for (int i = from_line; i <= to_line; i++) {
+
+ text_editor->unfold_line(i);
+ if (i >= text_editor->get_line_count() - 1) {
+ text_editor->set_line(i, text_editor->get_line(i) + "\n");
+ }
+ String line_clone = text_editor->get_line(i);
+ text_editor->insert_at(line_clone, next_line);
+ next_line++;
+ }
+
+ text_editor->cursor_set_column(column);
+ if (text_editor->is_selection_active()) {
+ text_editor->select(to_line + 1, text_editor->get_selection_from_column(), next_line - 1, text_editor->get_selection_to_column());
+ }
+
+ text_editor->end_complex_operation();
+ text_editor->update();
+}
+
+void CodeTextEditor::goto_line(int p_line) {
+ text_editor->deselect();
+ text_editor->unfold_line(p_line);
+ text_editor->call_deferred("cursor_set_line", p_line);
+}
+
+void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
+ text_editor->unfold_line(p_line);
+ text_editor->call_deferred("cursor_set_line", p_line);
+ text_editor->call_deferred("cursor_set_column", p_begin);
+ text_editor->select(p_line, p_begin, p_line, p_end);
+}
+
+Variant CodeTextEditor::get_edit_state() {
+ Dictionary state;
+
+ state["scroll_position"] = text_editor->get_v_scroll();
+ state["column"] = text_editor->cursor_get_column();
+ state["row"] = text_editor->cursor_get_line();
+
+ return state;
+}
+
+void CodeTextEditor::set_edit_state(const Variant &p_state) {
+ Dictionary state = p_state;
+ text_editor->cursor_set_column(state["column"]);
+ text_editor->cursor_set_line(state["row"]);
+ text_editor->set_v_scroll(state["scroll_position"]);
+ text_editor->grab_focus();
+}
+
void CodeTextEditor::set_error(const String &p_error) {
error->set_text(p_error);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index 2a3bb1ba76..903f61d87d 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -186,6 +186,29 @@ protected:
static void _bind_methods();
public:
+ void trim_trailing_whitespace();
+
+ void convert_indent_to_spaces();
+ void convert_indent_to_tabs();
+
+ enum CaseStyle {
+ UPPER,
+ LOWER,
+ CAPITALIZE,
+ };
+ void convert_case(CaseStyle p_case);
+
+ void move_lines_up();
+ void move_lines_down();
+ void delete_lines();
+ void code_lines_down();
+
+ void goto_line(int p_line);
+ void goto_line_selection(int p_line, int p_begin, int p_end);
+
+ Variant get_edit_state();
+ void set_edit_state(const Variant &p_state);
+
void update_editor_settings();
void set_error(const String &p_error);
void update_line_and_column() { _line_col_changed(); }
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 8933fd7fe8..c4f4e28fec 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -820,7 +820,9 @@ void ConnectionsDock::update_tree() {
if (i > 0)
signaldesc += ", ";
String tname = "var";
- if (pi.type != Variant::NIL) {
+ if (pi.type == Variant::OBJECT && pi.class_name != StringName()) {
+ tname = pi.class_name.operator String();
+ } else if (pi.type != Variant::NIL) {
tname = Variant::get_type_name(pi.type);
}
signaldesc += tname + " " + (pi.name == "" ? String("arg " + itos(i)) : pi.name);
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 65e50560bc..727383b960 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1900,6 +1900,7 @@ void EditorHelpBit::_meta_clicked(String p_select) {
void EditorHelpBit::_bind_methods() {
ClassDB::bind_method("_meta_clicked", &EditorHelpBit::_meta_clicked);
+ ClassDB::bind_method(D_METHOD("set_text", "text"), &EditorHelpBit::set_text);
ADD_SIGNAL(MethodInfo("request_hide"));
}
@@ -1925,7 +1926,7 @@ EditorHelpBit::EditorHelpBit() {
rich_text = memnew(RichTextLabel);
add_child(rich_text);
- rich_text->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ //rich_text->set_anchors_and_margins_preset(Control::PRESET_WIDE);
rich_text->connect("meta_clicked", this, "_meta_clicked");
rich_text->add_color_override("selection_color", get_color("text_editor/theme/selection_color", "Editor"));
rich_text->set_override_selected_font_color(false);
diff --git a/editor/editor_help.h b/editor/editor_help.h
index 514169dc19..dbea97e98b 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -272,9 +272,9 @@ public:
~EditorHelp();
};
-class EditorHelpBit : public Panel {
+class EditorHelpBit : public PanelContainer {
- GDCLASS(EditorHelpBit, Panel);
+ GDCLASS(EditorHelpBit, PanelContainer);
RichTextLabel *rich_text;
void _go_to_help(String p_what);
@@ -285,6 +285,7 @@ protected:
void _notification(int p_what);
public:
+ RichTextLabel *get_rich_text() { return rich_text; }
void set_text(const String &p_text);
EditorHelpBit();
};
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 482b0dec35..488980db07 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -719,6 +719,24 @@ void EditorProperty::set_object_and_property(Object *p_object, const StringName
property = p_property;
}
+Control *EditorProperty::make_custom_tooltip(const String &p_text) const {
+
+ tooltip_text = p_text;
+ EditorHelpBit *help_bit = memnew(EditorHelpBit);
+ help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
+ help_bit->get_rich_text()->set_fixed_size_to_width(300);
+
+ String text = TTR("Property: ") + "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n";
+ text += p_text.get_slice("::", 1).strip_edges();
+ help_bit->set_text(text);
+ help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ return help_bit;
+}
+
+String EditorProperty::get_tooltip_text() const {
+ return tooltip_text;
+}
+
void EditorProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_label", "text"), &EditorProperty::set_label);
@@ -745,6 +763,8 @@ void EditorProperty::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &EditorProperty::_gui_input);
ClassDB::bind_method(D_METHOD("_focusable_focused"), &EditorProperty::_focusable_focused);
+ ClassDB::bind_method(D_METHOD("get_tooltip_text"), &EditorProperty::get_tooltip_text);
+
ADD_PROPERTY(PropertyInfo(Variant::STRING, "label"), "set_label", "get_label");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "read_only"), "set_read_only", "is_read_only");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "checkable"), "set_checkable", "is_checkable");
@@ -919,6 +939,20 @@ void EditorInspectorCategory::_notification(int p_what) {
}
}
+Control *EditorInspectorCategory::make_custom_tooltip(const String &p_text) const {
+
+ tooltip_text = p_text;
+ EditorHelpBit *help_bit = memnew(EditorHelpBit);
+ help_bit->add_style_override("panel", get_stylebox("panel", "TooltipPanel"));
+ help_bit->get_rich_text()->set_fixed_size_to_width(300);
+
+ String text = "[u][b]" + p_text.get_slice("::", 0) + "[/b][/u]\n";
+ text += p_text.get_slice("::", 1).strip_edges();
+ help_bit->set_text(text);
+ help_bit->call_deferred("set_text", text); //hack so it uses proper theme once inside scene
+ return help_bit;
+}
+
Size2 EditorInspectorCategory::get_minimum_size() const {
Ref<Font> font = get_font("font", "Tree");
@@ -934,6 +968,15 @@ Size2 EditorInspectorCategory::get_minimum_size() const {
return ms;
}
+void EditorInspectorCategory::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_tooltip_text"), &EditorInspectorCategory::get_tooltip_text);
+}
+
+String EditorInspectorCategory::get_tooltip_text() const {
+
+ return tooltip_text;
+}
+
EditorInspectorCategory::EditorInspectorCategory() {
}
@@ -1395,7 +1438,7 @@ void EditorInspector::update_tree() {
class_descr_cache[type] = descr.word_wrap(80);
}
- category->set_tooltip(TTR("Class:") + " " + p.name + (class_descr_cache[type] == "" ? "" : "\n\n" + class_descr_cache[type]));
+ category->set_tooltip(p.name + "::" + (class_descr_cache[type] == "" ? "" : class_descr_cache[type]));
}
for (List<Ref<EditorInspectorPlugin> >::Element *E = valid_plugins.front(); E; E = E->next()) {
@@ -1507,12 +1550,19 @@ void EditorInspector::update_tree() {
checked = p.usage & PROPERTY_USAGE_CHECKED;
}
+ if (p.usage & PROPERTY_USAGE_RESTART_IF_CHANGED) {
+ restart_request_props.insert(p.name);
+ }
+
String doc_hint;
if (use_doc_hints) {
StringName classname = object->get_class_name();
- StringName propname = p.name;
+ if (object_class != String()) {
+ classname = object_class;
+ }
+ StringName propname = property_prefix + p.name;
String descr;
bool found = false;
@@ -1580,9 +1630,9 @@ void EditorInspector::update_tree() {
ep->connect("resource_selected", this, "_resource_selected", varray(), CONNECT_DEFERRED);
ep->connect("object_id_selected", this, "_object_id_selected", varray(), CONNECT_DEFERRED);
if (doc_hint != String()) {
- ep->set_tooltip(TTR("Property: ") + p.name + "\n\n" + doc_hint);
+ ep->set_tooltip(property_prefix + p.name + "::" + doc_hint);
} else {
- ep->set_tooltip(TTR("Property: ") + p.name);
+ ep->set_tooltip(property_prefix + p.name);
}
ep->set_draw_red(draw_red);
ep->set_use_folding(use_folding);
@@ -1659,6 +1709,7 @@ void EditorInspector::_clear() {
editor_property_map.clear();
sections.clear();
pending.clear();
+ restart_request_props.clear();
}
void EditorInspector::refresh() {
@@ -1902,6 +1953,10 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v
if (changing)
this->changing--;
+
+ if (restart_request_props.has(p_path)) {
+ emit_signal("restart_requested");
+ }
}
void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) {
@@ -1921,6 +1976,9 @@ void EditorInspector::_multiple_properties_changed(Vector<String> p_paths, Array
undo_redo->create_action(TTR("Set Multiple:") + " " + names, UndoRedo::MERGE_ENDS);
for (int i = 0; i < p_paths.size(); i++) {
_edit_set(p_paths[i], p_values[i], false, "");
+ if (restart_request_props.has(p_paths[i])) {
+ emit_signal("restart_requested");
+ }
}
changing++;
undo_redo->commit_action();
@@ -1993,6 +2051,8 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable)
E->get()->deselect();
}
}
+
+ emit_signal("property_selected", p_path);
}
void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) {
@@ -2091,6 +2151,22 @@ void EditorInspector::_vscroll_changed(double p_offset) {
}
}
+void EditorInspector::set_property_prefix(const String &p_prefix) {
+ property_prefix = p_prefix;
+}
+
+String EditorInspector::get_property_prefix() const {
+ return property_prefix;
+}
+
+void EditorInspector::set_object_class(const String &p_class) {
+ object_class = p_class;
+}
+
+String EditorInspector::get_object_class() const {
+ return object_class;
+}
+
void EditorInspector::_bind_methods() {
ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed, DEFVAL(false));
@@ -2110,9 +2186,12 @@ void EditorInspector::_bind_methods() {
ClassDB::bind_method("refresh", &EditorInspector::refresh);
+ ADD_SIGNAL(MethodInfo("property_selected", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property")));
ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop")));
ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property")));
+ ADD_SIGNAL(MethodInfo("restart_requested"));
}
EditorInspector::EditorInspector() {
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index 320641c693..454622d662 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -85,6 +85,8 @@ private:
Control *label_reference;
Control *bottom_editor;
+ mutable String tooltip_text;
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -143,6 +145,10 @@ public:
float get_name_split_ratio() const;
void set_object_and_property(Object *p_object, const StringName &p_property);
+ virtual Control *make_custom_tooltip(const String &p_text) const;
+
+ String get_tooltip_text() const;
+
EditorProperty();
};
@@ -180,12 +186,17 @@ class EditorInspectorCategory : public Control {
Ref<Texture> icon;
String label;
Color bg_color;
+ mutable String tooltip_text;
protected:
void _notification(int p_what);
+ static void _bind_methods();
public:
virtual Size2 get_minimum_size() const;
+ virtual Control *make_custom_tooltip(const String &p_text) const;
+
+ String get_tooltip_text() const;
EditorInspectorCategory();
};
@@ -267,9 +278,13 @@ class EditorInspector : public ScrollContainer {
Map<StringName, Map<StringName, String> > descr_cache;
Map<StringName, String> class_descr_cache;
+ Set<StringName> restart_request_props;
Map<ObjectID, int> scroll_cache;
+ String property_prefix; //used for sectioned inspector
+ String object_class;
+
void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field);
void _property_changed(const String &p_path, const Variant &p_value, bool changing = false);
@@ -343,6 +358,12 @@ public:
void set_scroll_offset(int p_offset);
int get_scroll_offset() const;
+ void set_property_prefix(const String &p_prefix);
+ String get_property_prefix() const;
+
+ void set_object_class(const String &p_class);
+ String get_object_class() const;
+
void set_use_sub_inspector_bg(bool p_enable);
EditorInspector();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 52f6f1ed0e..b366ebd911 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -112,6 +112,7 @@
#include "editor/plugins/sprite_editor_plugin.h"
#include "editor/plugins/sprite_frames_editor_plugin.h"
#include "editor/plugins/style_box_editor_plugin.h"
+#include "editor/plugins/text_editor.h"
#include "editor/plugins/texture_editor_plugin.h"
#include "editor/plugins/texture_region_editor_plugin.h"
#include "editor/plugins/theme_editor_plugin.h"
@@ -156,7 +157,6 @@ void EditorNode::_update_scene_tabs() {
scene_tabs->set_current_tab(editor_data.get_edited_scene());
- int current = editor_data.get_edited_scene();
if (scene_tabs->get_offset_buttons_visible()) {
// move add button to fixed position on the tabbar
if (scene_tab_add->get_parent() == scene_tabs) {
@@ -1068,6 +1068,32 @@ void EditorNode::_save_scene(String p_file, int idx) {
}
}
+void EditorNode::save_all_scenes_and_restart() {
+
+ _menu_option_confirm(RUN_STOP, true);
+ exiting = true;
+
+ _save_all_scenes();
+
+ String to_reopen;
+ if (get_tree()->get_edited_scene_root()) {
+ to_reopen = get_tree()->get_edited_scene_root()->get_filename();
+ }
+
+ get_tree()->quit();
+ String exec = OS::get_singleton()->get_executable_path();
+
+ List<String> args;
+ args.push_back("--path");
+ args.push_back(ProjectSettings::get_singleton()->get_resource_path());
+ args.push_back("-e");
+ if (to_reopen != String()) {
+ args.push_back(to_reopen);
+ }
+
+ OS::get_singleton()->set_restart_on_exit(true, args);
+}
+
void EditorNode::_save_all_scenes() {
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
@@ -2204,6 +2230,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
about->popup_centered_minsize(Size2(780, 500) * EDSCALE);
} break;
+ case SET_VIDEO_DRIVER_SAVE_AND_RESTART: {
+
+ ProjectSettings::get_singleton()->set("rendering/quality/driver/driver_name", video_driver_request);
+ ProjectSettings::get_singleton()->save();
+
+ save_all_scenes_and_restart();
+ } break;
default: {
if (p_option >= IMPORT_PLUGIN_BASE) {
}
@@ -4390,6 +4423,21 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) {
}
}
+void EditorNode::_video_driver_selected(int p_which) {
+
+ String driver = video_driver->get_item_metadata(p_which);
+
+ String current = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
+
+ if (driver == current) {
+ return;
+ }
+
+ video_driver_request = driver;
+ video_restart_dialog->popup_centered_minsize();
+ video_driver->select(video_driver_current);
+}
+
void EditorNode::_bind_methods() {
ClassDB::bind_method("_menu_option", &EditorNode::_menu_option);
@@ -4460,6 +4508,8 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported);
ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled);
+ ClassDB::bind_method(D_METHOD("_video_driver_selected"), &EditorNode::_video_driver_selected);
+
ADD_SIGNAL(MethodInfo("play_pressed"));
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
@@ -4656,19 +4706,19 @@ EditorNode::EditorNode() {
ClassDB::set_class_enabled("RootMotionView", true);
//defs here, use EDITOR_GET in logic
- EDITOR_DEF("interface/scene_tabs/always_show_close_button", false);
- EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true);
- EDITOR_DEF("interface/scene_tabs/minimum_width", 50);
+ EDITOR_DEF_RST("interface/scene_tabs/always_show_close_button", false);
+ EDITOR_DEF_RST("interface/scene_tabs/resize_if_many_tabs", true);
+ EDITOR_DEF_RST("interface/scene_tabs/minimum_width", 50);
EDITOR_DEF("run/output/always_clear_output_on_play", true);
EDITOR_DEF("run/output/always_open_output_on_play", true);
EDITOR_DEF("run/output/always_close_output_on_stop", true);
EDITOR_DEF("run/auto_save/save_before_running", true);
- EDITOR_DEF("interface/editor/save_each_scene_on_quit", true);
+ EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF("interface/editor/quit_confirmation", true);
- EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false);
- EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true);
- EDITOR_DEF("interface/inspector/capitalize_properties", true);
- EDITOR_DEF("interface/inspector/disable_folding", false);
+ EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", false);
+ EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true);
+ EDITOR_DEF_RST("interface/inspector/capitalize_properties", true);
+ EDITOR_DEF_RST("interface/inspector/disable_folding", false);
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
EDITOR_DEF("interface/inspector/resources_types_to_open_in_new_inspector", "SpatialMaterial");
EDITOR_DEF("run/auto_save/save_before_running", true);
@@ -5191,6 +5241,37 @@ EditorNode::EditorNode() {
play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5));
#endif
+ video_driver = memnew(OptionButton);
+ video_driver->set_flat(true);
+ video_driver->set_focus_mode(Control::FOCUS_NONE);
+ video_driver->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
+ String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string;
+ String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver());
+ menu_hb->add_child(video_driver);
+ video_driver_current = 0;
+ for (int i = 0; i < video_drivers.get_slice_count(","); i++) {
+ String driver = video_drivers.get_slice(",", i);
+ if (gui_base->has_icon(driver, "EditorIcons")) {
+ video_driver->add_icon_item(gui_base->get_icon(driver, "EditorIcons"), "");
+ } else {
+ video_driver->add_item(driver);
+ }
+
+ video_driver->set_item_metadata(i, driver);
+
+ if (current_video_driver == driver) {
+ video_driver->select(i);
+ video_driver_current = i;
+ }
+ }
+
+ video_driver->connect("item_selected", this, "_video_driver_selected");
+ video_restart_dialog = memnew(ConfirmationDialog);
+ video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor."));
+ video_restart_dialog->get_ok()->set_text(TTR("Save & Restart"));
+ video_restart_dialog->connect("confirmed", this, "_menu_option", varray(SET_VIDEO_DRIVER_SAVE_AND_RESTART));
+ gui_base->add_child(video_restart_dialog);
+
progress_hb = memnew(BackgroundProgress);
HBoxContainer *right_menu_hb = memnew(HBoxContainer);
@@ -5208,8 +5289,8 @@ EditorNode::EditorNode() {
update_menu->set_icon(gui_base->get_icon("Progress1", "EditorIcons"));
update_menu->get_popup()->connect("id_pressed", this, "_menu_option");
p = update_menu->get_popup();
- p->add_check_item(TTR("Update Always"), SETTINGS_UPDATE_ALWAYS);
- p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES);
+ p->add_radio_check_item(TTR("Update Always"), SETTINGS_UPDATE_ALWAYS);
+ p->add_radio_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES);
p->add_separator();
p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE);
int update_always = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_always", false);
@@ -5388,6 +5469,7 @@ EditorNode::EditorNode() {
EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();
ScriptTextEditor::register_editor(); //register one for text scripts
+ TextEditor::register_editor();
if (StreamPeerSSL::is_available()) {
add_editor_plugin(memnew(AssetLibraryEditorPlugin(this)));
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 88fe008b34..38e68b2e09 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -182,6 +182,8 @@ private:
HELP_COMMUNITY,
HELP_ABOUT,
+ SET_VIDEO_DRIVER_SAVE_AND_RESTART,
+
IMPORT_PLUGIN_BASE = 100,
TOOL_MENU_BASE = 1000
@@ -194,6 +196,13 @@ private:
Control *gui_base;
VBoxContainer *main_vbox;
PanelContainer *play_button_panel;
+ OptionButton *video_driver;
+
+ ConfirmationDialog *video_restart_dialog;
+
+ int video_driver_current;
+ String video_driver_request;
+ void _video_driver_selected(int);
//split
@@ -745,6 +754,8 @@ public:
void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
void remove_tool_menu_item(const String &p_name);
+ void save_all_scenes_and_restart();
+
void dim_editor(bool p_dimming);
void edit_current() { _edit_current(); };
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
new file mode 100644
index 0000000000..72050cd79b
--- /dev/null
+++ b/editor/editor_sectioned_inspector.cpp
@@ -0,0 +1,306 @@
+#include "editor_sectioned_inspector.h"
+#include "editor_scale.h"
+class SectionedInspectorFilter : public Object {
+
+ GDCLASS(SectionedInspectorFilter, Object);
+
+ Object *edited;
+ String section;
+ bool allow_sub;
+
+ bool _set(const StringName &p_name, const Variant &p_value) {
+
+ if (!edited)
+ return false;
+
+ String name = p_name;
+ if (section != "") {
+ name = section + "/" + name;
+ }
+
+ bool valid;
+ edited->set(name, p_value, &valid);
+ return valid;
+ }
+
+ bool _get(const StringName &p_name, Variant &r_ret) const {
+
+ if (!edited)
+ return false;
+
+ String name = p_name;
+ if (section != "") {
+ name = section + "/" + name;
+ }
+
+ bool valid = false;
+
+ r_ret = edited->get(name, &valid);
+ return valid;
+ }
+ void _get_property_list(List<PropertyInfo> *p_list) const {
+
+ if (!edited)
+ return;
+
+ List<PropertyInfo> pinfo;
+ edited->get_property_list(&pinfo);
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+
+ PropertyInfo pi = E->get();
+ int sp = pi.name.find("/");
+
+ if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff
+ continue;
+
+ if (sp == -1) {
+ pi.name = "global/" + pi.name;
+ }
+
+ if (pi.name.begins_with(section + "/")) {
+ pi.name = pi.name.replace_first(section + "/", "");
+ if (!allow_sub && pi.name.find("/") != -1)
+ continue;
+ p_list->push_back(pi);
+ }
+ }
+ }
+
+ bool property_can_revert(const String &p_name) {
+
+ return edited->call("property_can_revert", section + "/" + p_name);
+ }
+
+ Variant property_get_revert(const String &p_name) {
+
+ return edited->call("property_get_revert", section + "/" + p_name);
+ }
+
+protected:
+ static void _bind_methods() {
+
+ ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert);
+ ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert);
+ }
+
+public:
+ void set_section(const String &p_section, bool p_allow_sub) {
+
+ section = p_section;
+ allow_sub = p_allow_sub;
+ _change_notify();
+ }
+
+ void set_edited(Object *p_edited) {
+ edited = p_edited;
+ _change_notify();
+ }
+
+ SectionedInspectorFilter() {
+ edited = NULL;
+ }
+};
+
+void SectionedInspector::_bind_methods() {
+
+ ClassDB::bind_method("_section_selected", &SectionedInspector::_section_selected);
+ ClassDB::bind_method("_search_changed", &SectionedInspector::_search_changed);
+
+ ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list);
+}
+
+void SectionedInspector::_section_selected() {
+
+ if (!sections->get_selected())
+ return;
+
+ filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL);
+ inspector->set_property_prefix(String(sections->get_selected()->get_metadata(0)) + "/");
+}
+
+void SectionedInspector::set_current_section(const String &p_section) {
+
+ if (section_map.has(p_section)) {
+ section_map[p_section]->select(0);
+ }
+}
+
+String SectionedInspector::get_current_section() const {
+
+ if (sections->get_selected())
+ return sections->get_selected()->get_metadata(0);
+ else
+ return "";
+}
+
+String SectionedInspector::get_full_item_path(const String &p_item) {
+
+ String base = get_current_section();
+
+ if (base != "")
+ return base + "/" + p_item;
+ else
+ return p_item;
+}
+
+void SectionedInspector::edit(Object *p_object) {
+
+ if (!p_object) {
+ obj = -1;
+ sections->clear();
+
+ filter->set_edited(NULL);
+ inspector->edit(NULL);
+
+ return;
+ }
+
+ ObjectID id = p_object->get_instance_id();
+
+ inspector->set_object_class(p_object->get_class());
+
+ if (obj != id) {
+
+ obj = id;
+ update_category_list();
+
+ filter->set_edited(p_object);
+ inspector->edit(filter);
+
+ if (sections->get_root()->get_children()) {
+ sections->get_root()->get_children()->select(0);
+ }
+ } else {
+
+ update_category_list();
+ }
+}
+
+void SectionedInspector::update_category_list() {
+
+ String selected_category = get_current_section();
+ sections->clear();
+
+ Object *o = ObjectDB::get_instance(obj);
+
+ if (!o)
+ return;
+
+ List<PropertyInfo> pinfo;
+ o->get_property_list(&pinfo);
+
+ section_map.clear();
+
+ TreeItem *root = sections->create_item();
+ section_map[""] = root;
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+
+ PropertyInfo pi = E->get();
+
+ if (pi.usage & PROPERTY_USAGE_CATEGORY)
+ continue;
+ else if (!(pi.usage & PROPERTY_USAGE_EDITOR))
+ continue;
+
+ if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene")
+ continue;
+
+ if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1)
+ continue;
+
+ int sp = pi.name.find("/");
+ if (sp == -1)
+ pi.name = "Global/" + pi.name;
+
+ Vector<String> sectionarr = pi.name.split("/");
+ String metasection;
+
+ int sc = MIN(2, sectionarr.size() - 1);
+
+ for (int i = 0; i < sc; i++) {
+
+ TreeItem *parent = section_map[metasection];
+ parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
+
+ if (i > 0) {
+ metasection += "/" + sectionarr[i];
+ } else {
+ metasection = sectionarr[i];
+ }
+
+ if (!section_map.has(metasection)) {
+ TreeItem *ms = sections->create_item(parent);
+ section_map[metasection] = ms;
+ ms->set_text(0, sectionarr[i].capitalize());
+ ms->set_metadata(0, metasection);
+ ms->set_selectable(0, false);
+ }
+
+ if (i == sc - 1) {
+ //if it has children, make selectable
+ section_map[metasection]->set_selectable(0, true);
+ }
+ }
+ }
+
+ if (section_map.has(selected_category)) {
+ section_map[selected_category]->select(0);
+ }
+
+ inspector->update_tree();
+}
+
+void SectionedInspector::register_search_box(LineEdit *p_box) {
+
+ search_box = p_box;
+ inspector->register_text_enter(p_box);
+ search_box->connect("text_changed", this, "_search_changed");
+}
+
+void SectionedInspector::_search_changed(const String &p_what) {
+
+ update_category_list();
+}
+
+EditorInspector *SectionedInspector::get_inspector() {
+
+ return inspector;
+}
+
+SectionedInspector::SectionedInspector() {
+
+ obj = -1;
+
+ search_box = NULL;
+
+ add_constant_override("autohide", 1); // Fixes the dragger always showing up
+
+ VBoxContainer *left_vb = memnew(VBoxContainer);
+ left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE);
+ add_child(left_vb);
+
+ sections = memnew(Tree);
+ sections->set_v_size_flags(SIZE_EXPAND_FILL);
+ sections->set_hide_root(true);
+
+ left_vb->add_child(sections, true);
+
+ VBoxContainer *right_vb = memnew(VBoxContainer);
+ right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE);
+ right_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ add_child(right_vb);
+
+ filter = memnew(SectionedInspectorFilter);
+ inspector = memnew(EditorInspector);
+ inspector->set_v_size_flags(SIZE_EXPAND_FILL);
+ right_vb->add_child(inspector, true);
+ inspector->set_use_doc_hints(true);
+
+ sections->connect("cell_selected", this, "_section_selected");
+}
+
+SectionedInspector::~SectionedInspector() {
+
+ memdelete(filter);
+}
diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h
new file mode 100644
index 0000000000..75b51a1581
--- /dev/null
+++ b/editor/editor_sectioned_inspector.h
@@ -0,0 +1,42 @@
+#ifndef EDITOR_SECTIONED_INSPECTOR_H
+#define EDITOR_SECTIONED_INSPECTOR_H
+
+#include "editor/editor_inspector.h"
+#include "scene/gui/split_container.h"
+#include "scene/gui/tree.h"
+
+class SectionedInspectorFilter;
+
+class SectionedInspector : public HSplitContainer {
+
+ GDCLASS(SectionedInspector, HSplitContainer);
+
+ ObjectID obj;
+
+ Tree *sections;
+ SectionedInspectorFilter *filter;
+
+ Map<String, TreeItem *> section_map;
+ EditorInspector *inspector;
+ LineEdit *search_box;
+
+ static void _bind_methods();
+ void _section_selected();
+
+ void _search_changed(const String &p_what);
+
+public:
+ void register_search_box(LineEdit *p_box);
+ EditorInspector *get_inspector();
+ void edit(Object *p_object);
+ String get_full_item_path(const String &p_item);
+
+ void set_current_section(const String &p_section);
+ String get_current_section() const;
+
+ void update_category_list();
+
+ SectionedInspector();
+ ~SectionedInspector();
+};
+#endif // EDITOR_SECTIONED_INSPECTOR_H
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 4045d6c3d3..c8e97b071f 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -165,6 +165,7 @@ struct _EVCSort {
Variant::Type type;
int order;
bool save;
+ bool restart_if_changed;
bool operator<(const _EVCSort &p_vcs) const { return order < p_vcs.order; }
};
@@ -188,6 +189,7 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
vc.order = v->order;
vc.type = v->variant.get_type();
vc.save = v->save;
+ vc.restart_if_changed = v->restart_if_changed;
vclist.insert(vc);
}
@@ -210,6 +212,10 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const {
if (hints.has(E->get().name))
pi = hints[E->get().name];
+ if (E->get().restart_if_changed) {
+ pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED;
+ }
+
p_list->push_back(pi);
}
@@ -280,6 +286,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
}
_initial_set("interface/editor/editor_language", best);
+ set_restart_if_changed("interface/editor/editor_language", true);
hints["interface/editor/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
}
@@ -291,17 +298,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/main_font_size", 14);
hints["interface/editor/main_font_size"] = PropertyInfo(Variant::INT, "interface/editor/main_font_size", PROPERTY_HINT_RANGE, "10,40,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/code_font_size", 14);
- hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/code_font_size"] = PropertyInfo(Variant::INT, "interface/editor/code_font_size", PROPERTY_HINT_RANGE, "8,96,1", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/main_font_hinting", 2);
- hints["interface/editor/main_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/main_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/main_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/main_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/code_font_hinting", 2);
- hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/code_font_hinting"] = PropertyInfo(Variant::INT, "interface/editor/code_font_hinting", PROPERTY_HINT_ENUM, "None,Light,Normal", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/main_font", "");
- hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/main_font"] = PropertyInfo(Variant::STRING, "interface/editor/main_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/main_font_bold", "");
- hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_font_bold", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/main_font_bold"] = PropertyInfo(Variant::STRING, "interface/editor/main_font_bold", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/code_font", "");
- hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
+ hints["interface/editor/code_font"] = PropertyInfo(Variant::STRING, "interface/editor/code_font", PROPERTY_HINT_GLOBAL_FILE, "*.ttf,*.otf", PROPERTY_USAGE_DEFAULT);
_initial_set("interface/editor/dim_editor_on_dialog_popup", true);
_initial_set("interface/editor/dim_amount", 0.6f);
hints["interface/editor/dim_amount"] = PropertyInfo(Variant::REAL, "interface/editor/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT);
@@ -357,6 +364,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/highlighting/highlight_all_occurrences", true);
_initial_set("text_editor/highlighting/highlight_current_line", true);
+ _initial_set("text_editor/highlighting/highlight_type_safe_lines", true);
_initial_set("text_editor/cursor/scroll_past_end_of_file", false);
_initial_set("text_editor/indent/type", 0);
@@ -397,6 +405,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/completion/callhint_tooltip_offset", Vector2());
_initial_set("text_editor/files/restore_scripts_on_load", true);
_initial_set("text_editor/completion/complete_file_paths", true);
+ _initial_set("text_editor/completion/add_type_hints", false);
_initial_set("docks/scene_tree/start_create_dialog_fully_expanded", false);
_initial_set("docks/scene_tree/draw_relationship_lines", false);
@@ -585,6 +594,7 @@ void EditorSettings::_load_default_text_editor_theme() {
_initial_set("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"));
_initial_set("text_editor/highlighting/text_color", Color::html("aaaaaa"));
_initial_set("text_editor/highlighting/line_number_color", Color::html("66aaaaaa"));
+ _initial_set("text_editor/highlighting/safe_line_number_color", Color::html("99aac8aa"));
_initial_set("text_editor/highlighting/caret_color", Color::html("aaaaaa"));
_initial_set("text_editor/highlighting/caret_background_color", Color::html("000000"));
_initial_set("text_editor/highlighting/text_selected_color", Color::html("000000"));
@@ -1017,6 +1027,14 @@ void EditorSettings::raise_order(const String &p_setting) {
props[p_setting].order = ++last_order;
}
+void EditorSettings::set_restart_if_changed(const StringName &p_setting, bool p_restart) {
+ _THREAD_SAFE_METHOD_
+
+ if (!props.has(p_setting))
+ return;
+ props[p_setting].restart_if_changed = p_restart;
+}
+
void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) {
_THREAD_SAFE_METHOD_
@@ -1030,16 +1048,19 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian
}
}
-Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) {
+Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed) {
Variant ret = p_default;
- if (EditorSettings::get_singleton()->has_setting(p_setting))
+ if (EditorSettings::get_singleton()->has_setting(p_setting)) {
ret = EditorSettings::get_singleton()->get(p_setting);
- else
+ } else {
EditorSettings::get_singleton()->set_manually(p_setting, p_default);
+ EditorSettings::get_singleton()->set_restart_if_changed(p_setting, p_restart_if_changed);
+ }
- if (!EditorSettings::get_singleton()->has_default_value(p_setting))
+ if (!EditorSettings::get_singleton()->has_default_value(p_setting)) {
EditorSettings::get_singleton()->set_initial_value(p_setting, p_default);
+ }
return ret;
}
diff --git a/editor/editor_settings.h b/editor/editor_settings.h
index 420e067cad..e5b61abf54 100644
--- a/editor/editor_settings.h
+++ b/editor/editor_settings.h
@@ -70,6 +70,7 @@ private:
bool has_default_value;
bool hide_from_editor;
bool save;
+ bool restart_if_changed;
VariantContainer() {
variant = Variant();
initial = Variant();
@@ -77,6 +78,7 @@ private:
hide_from_editor = false;
has_default_value = false;
save = false;
+ restart_if_changed = false;
}
VariantContainer(const Variant &p_variant, int p_order) {
variant = p_variant;
@@ -85,6 +87,7 @@ private:
hide_from_editor = false;
has_default_value = false;
save = false;
+ restart_if_changed = false;
}
};
@@ -145,6 +148,7 @@ public:
void erase(const String &p_setting);
void raise_order(const String &p_setting);
void set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current = false);
+ void set_restart_if_changed(const StringName &p_setting, bool p_restart);
void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) {
if (p_emit_signal)
_set(p_setting, p_value);
@@ -200,7 +204,8 @@ public:
//not a macro any longer
#define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val))
-Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default);
+#define EDITOR_DEF_RST(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val), true)
+Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed = false);
#define EDITOR_GET(m_var) _EDITOR_GET(m_var)
Variant _EDITOR_GET(const String &p_setting);
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index 79023a1f28..0e6d81d13b 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -268,7 +268,8 @@ void EditorSpinSlider::_notification(int p_what) {
update();
}
if (p_what == NOTIFICATION_FOCUS_ENTER) {
- /* Sorry, I dont like this, it makes navigating the different fields with arrows more difficult
+ /* Sorry, I dont like this, it makes navigating the different fields with arrows more difficult.
+ * Just press enter to edit.
* if (!Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) {
_focus_entered();
}*/
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 084caff083..18cc52a5c6 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -237,8 +237,6 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme =
ImageLoaderSVG::set_convert_colors(NULL);
clock_t end_time = clock();
-
- double time_d = (double)(end_time - begin_time) / CLOCKS_PER_SEC;
#else
print_line("Sorry no icons for you");
#endif
@@ -257,7 +255,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
String preset = EDITOR_DEF("interface/theme/preset", "Default");
- int icon_font_color_setting = EDITOR_DEF("interface/theme/icon_and_font_color", 0);
bool highlight_tabs = EDITOR_DEF("interface/theme/highlight_tabs", false);
int border_size = EDITOR_DEF("interface/theme/border_size", 1);
@@ -1089,6 +1086,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color completion_font_color = font_color;
const Color text_color = font_color;
const Color line_number_color = dim_color;
+ const Color safe_line_number_color = dim_color * Color(1, 1.2, 1, 1.5);
const Color caret_color = mono_color;
const Color caret_background_color = mono_color.inverted();
const Color text_selected_color = dark_color_3;
@@ -1123,6 +1121,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
setting->set_initial_value("text_editor/highlighting/completion_font_color", completion_font_color, true);
setting->set_initial_value("text_editor/highlighting/text_color", text_color, true);
setting->set_initial_value("text_editor/highlighting/line_number_color", line_number_color, true);
+ setting->set_initial_value("text_editor/highlighting/safe_line_number_color", safe_line_number_color, true);
setting->set_initial_value("text_editor/highlighting/caret_color", caret_color, true);
setting->set_initial_value("text_editor/highlighting/caret_background_color", caret_background_color, true);
setting->set_initial_value("text_editor/highlighting/text_selected_color", text_selected_color, true);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index f65fb5365b..37f86cc912 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1319,6 +1319,9 @@ void FileSystemDock::_file_option(int p_option) {
String fpath = files->get_item_metadata(idx);
OS::get_singleton()->set_clipboard(fpath);
} break;
+ case FILE_NEW_RESOURCE: {
+ new_resource_dialog->popup_create(true);
+ } break;
}
}
@@ -1393,6 +1396,21 @@ void FileSystemDock::_folder_option(int p_option) {
}
}
+void FileSystemDock::_resource_created() const {
+ Object *c = new_resource_dialog->instance_selected();
+
+ ERR_FAIL_COND(!c);
+ Resource *r = Object::cast_to<Resource>(c);
+ ERR_FAIL_COND(!r);
+
+ REF res(r);
+ editor->push_item(c);
+
+ RES current_res = RES(r);
+
+ editor->save_resource_as(current_res);
+}
+
void FileSystemDock::_go_to_file_list() {
if (low_height_mode) {
@@ -1738,6 +1756,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) {
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
+ file_options->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE);
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
file_options->set_position(files->get_global_position() + p_pos);
@@ -1750,6 +1769,7 @@ void FileSystemDock::_rmb_pressed(const Vector2 &p_pos) {
file_options->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
file_options->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
+ file_options->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE);
file_options->add_item(TTR("Show In File Manager"), FILE_SHOW_IN_EXPLORER);
file_options->set_position(files->get_global_position() + p_pos);
file_options->popup();
@@ -1862,6 +1882,7 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_file_option"), &FileSystemDock::_file_option);
ClassDB::bind_method(D_METHOD("_folder_option"), &FileSystemDock::_folder_option);
ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &FileSystemDock::_make_dir_confirm);
+ ClassDB::bind_method(D_METHOD("_resource_created"), &FileSystemDock::_resource_created);
ClassDB::bind_method(D_METHOD("_move_operation_confirm", "to_path", "overwrite"), &FileSystemDock::_move_operation_confirm, DEFVAL(false));
ClassDB::bind_method(D_METHOD("_move_with_overwrite"), &FileSystemDock::_move_with_overwrite);
ClassDB::bind_method(D_METHOD("_rename_operation_confirm"), &FileSystemDock::_rename_operation_confirm);
@@ -2087,6 +2108,11 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
make_script_dialog_text->set_title(TTR("Create Script"));
add_child(make_script_dialog_text);
+ new_resource_dialog = memnew(CreateDialog);
+ add_child(new_resource_dialog);
+ new_resource_dialog->set_base_type("Resource");
+ new_resource_dialog->connect("create", this, "_resource_created");
+
updating_tree = false;
initialized = false;
import_dock_needs_update = false;
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index e8ab803cca..6a0c73d52e 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -47,6 +47,8 @@
#include "os/dir_access.h"
#include "os/thread.h"
+#include "create_dialog.h"
+
#include "dependency_editor.h"
#include "editor_dir_dialog.h"
#include "editor_file_system.h"
@@ -78,7 +80,8 @@ private:
FILE_NEW_FOLDER,
FILE_NEW_SCRIPT,
FILE_SHOW_IN_EXPLORER,
- FILE_COPY_PATH
+ FILE_COPY_PATH,
+ FILE_NEW_RESOURCE
};
enum FolderMenu {
@@ -131,6 +134,7 @@ private:
LineEdit *make_dir_dialog_text;
ConfirmationDialog *overwrite_dialog;
ScriptCreateDialog *make_script_dialog_text;
+ CreateDialog *new_resource_dialog;
class FileOrFolder {
public:
@@ -191,6 +195,7 @@ private:
void _update_favorite_dirs_list_after_move(const Map<String, String> &p_renames) const;
void _update_project_settings_after_move(const Map<String, String> &p_renames) const;
+ void _resource_created() const;
void _make_dir_confirm();
void _rename_operation_confirm();
void _duplicate_operation_confirm();
diff --git a/editor/icons/icon_g_l_e_s_2.svg b/editor/icons/icon_g_l_e_s_2.svg
new file mode 100644
index 0000000000..efc4f01e4f
--- /dev/null
+++ b/editor/icons/icon_g_l_e_s_2.svg
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="svg2"
+ width="48"
+ height="16"
+ viewBox="0 0 47.999999 16"
+ sodipodi:docname="icon_g_l_e_s_2.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs6" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1484"
+ inkscape:window-height="697"
+ id="namedview4"
+ showgrid="false"
+ inkscape:zoom="13.520979"
+ inkscape:cx="20.549976"
+ inkscape:cy="7.9399684"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg2" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path835"
+ d="m 19.839879,15.499154 c -0.0652,-0.0268 -0.141743,-0.1098 -0.170113,-0.184417 -0.03304,-0.08688 -0.05158,-0.95731 -0.05158,-5.912028 V 3.1830459 l 0.108486,-0.1379162 c 0.150269,-0.1910365 0.41814,-0.1907342 0.568677,6.436e-4 l 0.10899,0.1385579 -0.01358,6.2990785 c -0.01194,6.8660953 -0.0921,5.3381383 -0.0921,5.9327083 -0.106573,0.104434 -0.315006,0.142158 -0.458762,0.08303 z M 5.3808767,14.575188 C 4.5309456,14.518738 3.6260357,14.196602 2.9750499,13.718734 2.5767564,13.42636 2.0035795,12.787236 1.747789,12.350269 1.2385669,11.480363 1.0170768,10.580508 1.0213778,9.399057 1.0293972,7.2009406 1.9726797,5.5285643 3.6891526,4.6693537 4.7813316,4.1226444 6.2246017,4.0371807 7.4330177,4.4476602 8.1309525,4.6847376 8.4685433,4.8972607 9.0207129,5.4471587 9.4063328,5.8311907 9.5338898,6.0004852 9.7108978,6.3631718 9.8335428,6.6144683 9.9681328,6.9987435 10.020175,7.2461971 10.145759,7.8433551 10.170431,7.8289765 9.0218356,7.828057 8.5307356,7.8276009 8.0769363,7.8134035 8.0133918,7.7963663 7.9392662,7.7764919 7.8757344,7.6970176 7.8361313,7.5746239 7.5012661,6.5397183 6.6297764,6.0267536 5.4889128,6.193037 4.244092,6.3744711 3.4980921,7.3344965 3.343357,8.9541432 3.2260083,10.182472 3.5434132,11.329338 4.1781352,11.97041 c 0.46237,0.466997 0.9869175,0.673904 1.7084683,0.673904 1.2025378,0 1.9439704,-0.533034 2.1862936,-1.57178 0.055989,-0.240028 0.059178,-0.324448 0.012859,-0.341503 -0.033838,-0.01246 -0.5090516,-0.02871 -1.0560342,-0.03612 L 6.0352096,10.681458 V 9.8178001 8.9541431 l 1.9890278,-0.014575 c 1.0939663,-0.00802 2.0422396,-0.00163 2.1072756,0.014201 l 0.118246,0.028779 -0.01356,2.6814549 -0.01356,2.681455 -0.7170922,0.01455 c -0.8295927,0.01682 -0.7753286,0.05076 -0.8815155,-0.55106 -0.036825,-0.208719 -0.077853,-0.379487 -0.091164,-0.379487 -0.013311,0 -0.16916,0.135437 -0.3463303,0.300972 -0.3894417,0.363866 -0.8188673,0.600316 -1.3418506,0.738852 -0.4725114,0.125166 -0.8081647,0.149449 -1.4638111,0.10591 z M 32.49721,14.469781 c -0.928547,-0.194854 -1.630354,-0.56605 -2.174913,-1.150343 -0.515384,-0.552992 -0.832054,-1.344249 -0.800629,-2.000518 l 0.01549,-0.323408 1.060826,-0.01418 1.060825,-0.01418 0.05146,0.135352 c 0.0283,0.07444 0.0517,0.198593 0.05197,0.275887 8.54e-4,0.230559 0.229434,0.649361 0.479979,0.879354 0.347226,0.318744 0.735307,0.44853 1.431019,0.478576 1.267096,0.05472 2.007349,-0.393206 1.947849,-1.178652 -0.0456,-0.601928 -0.471503,-0.860841 -2.12876,-1.294103 C 32.881626,10.103917 32.242852,9.9264243 32.07283,9.8691486 30.95902,9.4939337 30.283515,8.9537559 29.97948,8.195172 29.836139,7.8375288 29.784025,7.0484225 29.874852,6.6109088 30.100606,5.5234588 31.071976,4.6456053 32.416011,4.314394 33.01697,4.1662997 34.128873,4.156633 34.77144,4.293917 c 1.67335,0.3575071 2.584333,1.270761 2.774448,2.7813655 0.0543,0.4314615 0.0347,0.4394334 -1.080484,0.4394334 -0.521251,0 -0.9851,-0.023133 -1.038665,-0.051802 C 35.367672,7.4313026 35.307808,7.3078793 35.273143,7.1462409 35.195527,6.7843357 35.099156,6.6147944 34.849667,6.4012402 34.543832,6.1394568 34.14764,6.029069 33.515213,6.0294329 c -0.428465,2.111e-4 -0.570793,0.021517 -0.784491,0.1172346 -0.47592,0.2131691 -0.654939,0.4628549 -0.654939,0.9134748 0,0.5904894 0.225799,0.7059322 2.58195,1.3200619 1.350552,0.3520209 1.903346,0.598685 2.415601,1.0778741 0.591219,0.5530567 0.852295,1.2543747 0.796412,2.1393787 -0.07929,1.255762 -0.891416,2.255747 -2.192274,2.699402 -0.885807,0.302103 -2.21918,0.374602 -3.180262,0.172924 z M 11.476954,14.306572 c -0.0138,-0.03619 -0.019,-2.268126 -0.01158,-4.9598581 l 0.0135,-4.8940567 1.066335,-0.01419 c 0.742348,-0.00988 1.088249,0.00399 1.138458,0.045665 0.06009,0.049873 0.07211,0.7135739 0.07211,3.9791612 v 3.9193056 h 2.293081 c 1.756352,0 2.314103,0.01538 2.382892,0.06567 0.07993,0.05845 0.08822,0.166396 0.07543,0.981428 l -0.01437,0.915757 -3.495384,0.01345 c -2.768549,0.0107 -3.500605,-1.69e-4 -3.520473,-0.05234 z m 10.193414,0.0026 c -0.04842,-0.04842 -0.06297,-1.193838 -0.06236,-4.9074882 4.61e-4,-2.6643823 0.01959,-4.8739347 0.04256,-4.9101166 0.03301,-0.05201 0.813774,-0.062971 3.728627,-0.052342 l 3.686862,0.013441 V 5.3948518 6.337024 l -2.5648,0.026171 -2.5648,0.026172 v 0.9421438 0.9421716 l 2.313597,0.026171 c 1.548367,0.017515 2.332217,0.044804 2.36989,0.082507 0.03673,0.036745 0.05127,0.3461819 0.04183,0.889829 l -0.01446,0.8334926 -2.355428,0.02617 -2.355429,0.02617 v 1.0992 1.099199 l 2.617143,0.0274 c 1.439428,0.01507 2.623562,0.03274 2.63141,0.03926 0.0078,0.0065 0.0078,0.441727 0,0.967118 l -0.01427,0.955257 -3.718613,0.01343 c -2.848812,0.01027 -3.733388,-0.0013 -3.781773,-0.04973 z m 17.753791,-0.378679 c -0.04061,-0.105824 0.0759,-0.828141 0.198829,-1.232689 0.288088,-0.948035 0.88431,-1.590368 2.319422,-2.498804 1.100465,-0.6965999 1.86374,-1.2293374 2.17747,-1.5198007 0.515251,-0.477031 0.731074,-1.0868265 0.620161,-1.7522036 -0.126353,-0.7579473 -0.607483,-1.1395723 -1.436711,-1.1395723 -0.930964,0 -1.401324,0.4507271 -1.481617,1.4197789 l -0.03634,0.4383927 h -1.099202 -1.099196 l -0.01524,-0.3725124 c -0.03408,-0.8332648 0.288934,-1.6827799 0.855164,-2.2490093 0.399774,-0.3997734 1.09283,-0.7574546 1.70958,-0.8822975 0.580047,-0.1174131 1.71432,-0.1077309 2.332892,0.019914 1.258364,0.2596698 2.203978,1.0560413 2.520675,2.1228587 0.104477,0.3519131 0.117355,0.4871812 0.09657,1.0144101 -0.01959,0.4962935 -0.04847,0.667451 -0.157022,0.9292002 -0.313508,0.7560998 -0.900391,1.3802206 -1.888823,2.0086882 -1.507571,0.958543 -1.915442,1.243322 -2.230808,1.557578 -0.26352,0.262604 -0.32016,0.345357 -0.261709,0.382352 0.04123,0.0261 1.061246,0.04757 2.280484,0.04802 1.96272,7.11e-4 2.209393,0.0099 2.237659,0.0836 0.01749,0.04554 0.03178,0.408703 0.03178,0.807033 0,0.398331 -0.0143,0.761495 -0.03178,0.807033 -0.0286,0.07445 -0.414152,0.0828 -3.822672,0.0828 -3.236429,0 -3.795092,-0.01093 -3.819578,-0.07475 z"
+ style="fill:#5586a4;fill-opacity:1;stroke-width:0.05234285"
+ sodipodi:nodetypes="ccscccccccccsscsscccccscccsccsccccccccccssscccccccccccccccscsccsccccsssscscccccccscscscccccccscccccccscccccccscccccccccccscccccsssccccccccscscc" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path819"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path817"
+ inkscape:connector-curvature="0" />
+</svg>
diff --git a/editor/icons/icon_g_l_e_s_3.svg b/editor/icons/icon_g_l_e_s_3.svg
new file mode 100644
index 0000000000..dfa3c26b38
--- /dev/null
+++ b/editor/icons/icon_g_l_e_s_3.svg
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="svg2"
+ width="48"
+ height="16"
+ viewBox="0 0 47.999999 16"
+ sodipodi:docname="icon_g_l_e_s_3.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs6" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1484"
+ inkscape:window-height="697"
+ id="namedview4"
+ showgrid="false"
+ inkscape:zoom="13.520979"
+ inkscape:cx="20.549976"
+ inkscape:cy="7.9399684"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg2" />
+ <path
+ style="fill:#6aa455;fill-opacity:1;stroke-width:0.05234285"
+ d="M 20.011719 2.9023438 C 19.90715 2.9022255 19.801697 2.9494036 19.726562 3.0449219 L 19.619141 3.1835938 L 19.619141 9.4023438 C 19.619141 14.357062 19.636882 15.227573 19.669922 15.314453 C 19.698292 15.38907 19.774644 15.4732 19.839844 15.5 C 19.9836 15.559128 20.192255 15.52045 20.298828 15.416016 C 20.298828 14.821446 20.378685 16.35047 20.390625 9.484375 L 20.404297 3.1835938 L 20.294922 3.0449219 C 20.219653 2.949233 20.116287 2.902462 20.011719 2.9023438 z M 33.578125 4.1972656 C 33.144709 4.2010336 32.716495 4.240406 32.416016 4.3144531 C 31.071981 4.6456644 30.100754 5.5238781 29.875 6.6113281 C 29.784173 7.0488418 29.835175 7.8376693 29.978516 8.1953125 C 30.282551 8.9538964 30.958456 9.4939257 32.072266 9.8691406 C 32.242288 9.9264163 32.881487 10.104023 33.492188 10.263672 C 35.149445 10.696934 35.575494 10.956666 35.621094 11.558594 C 35.680594 12.34404 34.940924 12.791048 33.673828 12.736328 C 32.978116 12.706282 32.589413 12.576557 32.242188 12.257812 C 31.991643 12.02782 31.762573 11.609465 31.761719 11.378906 C 31.761449 11.301612 31.739238 11.176002 31.710938 11.101562 L 31.658203 10.966797 L 30.597656 10.980469 L 29.537109 10.996094 L 29.521484 11.318359 C 29.490059 11.974628 29.806882 12.767321 30.322266 13.320312 C 30.866825 13.904606 31.5695 14.275849 32.498047 14.470703 C 33.459129 14.672381 34.791927 14.598978 35.677734 14.296875 C 36.978592 13.85322 37.789851 12.853418 37.869141 11.597656 C 37.925024 10.712652 37.665438 10.012041 37.074219 9.4589844 C 36.561964 8.9797953 36.008755 8.7328803 34.658203 8.3808594 C 32.302052 7.7667297 32.076172 7.6510363 32.076172 7.0605469 C 32.076172 6.609927 32.254549 6.3596535 32.730469 6.1464844 C 32.944167 6.0507668 33.08716 6.029508 33.515625 6.0292969 C 34.148052 6.028933 34.543774 6.1386072 34.849609 6.4003906 C 35.099098 6.6139448 35.195822 6.7845792 35.273438 7.1464844 C 35.308103 7.3081228 35.366714 7.4312793 35.425781 7.4628906 C 35.479346 7.4915596 35.943593 7.515625 36.464844 7.515625 C 37.580028 7.515625 37.599222 7.5076334 37.544922 7.0761719 C 37.354807 5.5655674 36.444834 4.6504759 34.771484 4.2929688 C 34.450201 4.2243268 34.011541 4.1934977 33.578125 4.1972656 z M 5.5175781 4.1992188 C 4.8691862 4.2376134 4.2355426 4.3965672 3.6894531 4.6699219 C 1.9729802 5.5291325 1.0295038 7.2003211 1.0214844 9.3984375 C 1.0171834 10.579889 1.2388248 11.479703 1.7480469 12.349609 C 2.0038374 12.786576 2.5763159 13.426376 2.9746094 13.71875 C 3.6255952 14.196618 4.5309283 14.517769 5.3808594 14.574219 C 6.0365058 14.617758 6.3712386 14.593916 6.84375 14.46875 C 7.3667333 14.330214 7.7980583 14.094335 8.1875 13.730469 C 8.3646703 13.564934 8.5198921 13.429688 8.5332031 13.429688 C 8.5465141 13.429688 8.588175 13.599875 8.625 13.808594 C 8.7311869 14.410414 8.6762667 14.376195 9.5058594 14.359375 L 10.222656 14.345703 L 10.236328 11.664062 L 10.25 8.9824219 L 10.130859 8.953125 C 10.065823 8.937294 9.1174038 8.9314331 8.0234375 8.9394531 L 6.0351562 8.9550781 L 6.0351562 9.8183594 L 6.0351562 10.681641 L 7.0292969 10.695312 C 7.5762795 10.702722 8.0520995 10.718009 8.0859375 10.730469 C 8.1322565 10.747524 8.1282546 10.832238 8.0722656 11.072266 C 7.8299424 12.111012 7.0892565 12.644531 5.8867188 12.644531 C 5.1651679 12.644531 4.6401044 12.4377 4.1777344 11.970703 C 3.5430124 11.329631 3.2264013 10.183407 3.34375 8.9550781 C 3.4984851 7.3354314 4.2434605 6.3747935 5.4882812 6.1933594 C 6.6291449 6.027076 7.5010723 6.5393131 7.8359375 7.5742188 C 7.8755406 7.6966124 7.9395463 7.7770006 8.0136719 7.796875 C 8.0772164 7.8139122 8.5303844 7.8276689 9.0214844 7.828125 C 10.17008 7.8290445 10.145115 7.8432518 10.019531 7.2460938 C 9.967489 6.9986401 9.8335825 6.6145778 9.7109375 6.3632812 C 9.5339295 6.0005947 9.4071043 5.8312976 9.0214844 5.4472656 C 8.4693148 4.8973676 8.1315285 4.684343 7.4335938 4.4472656 C 6.8293858 4.2420259 6.16597 4.1608241 5.5175781 4.1992188 z M 42.03125 4.2617188 L 41.537109 4.4335938 C 40.933232 4.6433398 40.657695 4.8014669 40.300781 5.1386719 C 39.969225 5.4519119 39.761404 5.8046136 39.621094 6.2910156 C 39.502474 6.7023596 39.433137 7.3494687 39.498047 7.4492188 C 39.531044 7.4999487 39.783863 7.5127831 40.576172 7.5019531 L 41.611328 7.4863281 L 41.691406 7.0703125 C 41.808812 6.4678105 41.927622 6.2685471 42.265625 6.0957031 C 42.510424 5.9705181 42.604184 5.953125 43.019531 5.953125 C 43.426321 5.953125 43.533311 5.9721266 43.765625 6.0878906 C 44.253715 6.3311276 44.455638 6.904517 44.273438 7.53125 C 44.105442 8.109131 43.697334 8.363965 42.791016 8.453125 C 42.521874 8.479605 42.288464 8.51424 42.271484 8.53125 C 42.225224 8.577174 42.232777 9.7874244 42.279297 9.8339844 C 42.301291 9.8559744 42.598053 9.8907794 42.939453 9.9121094 C 43.836652 9.9681724 44.239534 10.166191 44.525391 10.691406 C 44.916028 11.409137 44.561069 12.318315 43.787109 12.582031 C 43.476088 12.688024 42.767292 12.688624 42.470703 12.583984 C 42.00204 12.418633 41.795632 12.174325 41.642578 11.597656 L 41.560547 11.285156 L 40.46875 11.285156 L 39.376953 11.285156 L 39.361328 11.527344 C 39.352678 11.660649 39.384791 11.918152 39.431641 12.099609 C 39.739925 13.294376 40.783209 14.156157 42.212891 14.396484 C 42.284425 14.408514 42.682741 14.422181 43.097656 14.425781 C 44.074936 14.434074 44.653306 14.320796 45.308594 13.996094 C 46.07786 13.61492 46.610204 13.058412 46.847656 12.382812 C 47.087412 11.700564 47.08166 10.999125 46.833984 10.333984 C 46.695621 9.962377 46.130198 9.3782416 45.6875 9.1503906 C 45.523031 9.0657476 45.386773 8.9810006 45.386719 8.9628906 C 45.386654 8.9447846 45.539488 8.8195027 45.724609 8.6835938 C 46.129744 8.3861558 46.390215 8.064434 46.53125 7.6875 C 46.963216 6.532963 46.370297 5.2063894 45.166016 4.6308594 C 44.482944 4.3044164 44.23589 4.2611938 43.072266 4.2617188 L 42.03125 4.2617188 z M 12.544922 4.4375 L 11.478516 4.453125 L 11.464844 9.3476562 C 11.457424 12.039388 11.462763 14.270451 11.476562 14.306641 C 11.49643 14.358812 12.229498 14.370075 14.998047 14.359375 L 18.492188 14.345703 L 18.507812 13.429688 C 18.520602 12.614656 18.511571 12.507669 18.431641 12.449219 C 18.362852 12.398929 17.80518 12.382812 16.048828 12.382812 L 13.755859 12.382812 L 13.755859 8.4628906 C 13.755859 5.1973033 13.743684 4.534248 13.683594 4.484375 C 13.633385 4.4427 13.28727 4.42762 12.544922 4.4375 z M 25.378906 4.4394531 C 22.464053 4.4288241 21.683401 4.4401775 21.650391 4.4921875 C 21.627421 4.5283694 21.607883 6.7379615 21.607422 9.4023438 C 21.606812 13.115994 21.621502 14.260174 21.669922 14.308594 C 21.718307 14.357024 22.60236 14.369645 25.451172 14.359375 L 29.169922 14.345703 L 29.185547 13.390625 C 29.193347 12.865234 29.193347 12.430328 29.185547 12.423828 C 29.177699 12.417308 27.992162 12.399836 26.552734 12.384766 L 23.935547 12.355469 L 23.935547 11.257812 L 23.935547 10.158203 L 26.291016 10.132812 L 28.646484 10.105469 L 28.662109 9.2714844 C 28.671549 8.7278373 28.655871 8.4195575 28.619141 8.3828125 C 28.581468 8.3451095 27.798367 8.3182962 26.25 8.3007812 L 23.935547 8.2734375 L 23.935547 7.3320312 L 23.935547 6.3886719 L 26.501953 6.3632812 L 29.066406 6.3378906 L 29.066406 5.3945312 L 29.066406 4.453125 L 25.378906 4.4394531 z "
+ id="path3424" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path819"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path817"
+ inkscape:connector-curvature="0" />
+</svg>
diff --git a/editor/icons/icon_soft_body.svg b/editor/icons/icon_soft_body.svg
new file mode 100644
index 0000000000..9930026b61
--- /dev/null
+++ b/editor/icons/icon_soft_body.svg
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ version="1.1"
+ viewBox="0 0 16 16"
+ id="svg2"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="icon_soft_body.svg">
+ <metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs12" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1920"
+ inkscape:window-height="1027"
+ id="namedview10"
+ showgrid="false"
+ inkscape:zoom="18.792233"
+ inkscape:cx="2.8961304"
+ inkscape:cy="4.3816933"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg2" />
+ <path
+ style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;fill-rule:nonzero;stroke:none;stroke-width:1.42799997;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="m 2.3447105,1.6091897 c -0.011911,1.9816766 -1.4168958,3.9344766 0,5.9495986 1.4168957,2.0151221 0,6.6693597 0,6.6693597 l 10.9510055,0 c 0,0 1.780829,-4.4523824 0,-6.489075 -1.780829,-2.0366925 -0.183458,-4.119112 0,-6.1298833 z m 1.8894067,0.7549031 7.4390658,0 c -0.431995,1.5996085 -1.62289,4.0426807 0,5.3749802 1.622888,1.3322996 0,5.887932 0,5.887932 l -7.4390658,0 c 0,0 1.3903413,-4.3680495 0,-5.9780743 -1.3903412,-1.6100247 -0.3951213,-3.7149271 0,-5.2848379 z"
+ id="rect4142"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="czcczcccczcczc" />
+</svg>
diff --git a/editor/icons/icon_vulkan.svg b/editor/icons/icon_vulkan.svg
new file mode 100644
index 0000000000..1d5fed0305
--- /dev/null
+++ b/editor/icons/icon_vulkan.svg
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ id="svg2"
+ width="48"
+ height="16"
+ viewBox="0 0 47.999999 16"
+ sodipodi:docname="icon_vulkan.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)">
+ <metadata
+ id="metadata8">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs6" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1853"
+ inkscape:window-height="1016"
+ id="namedview4"
+ showgrid="false"
+ inkscape:zoom="10.24"
+ inkscape:cx="9.4970674"
+ inkscape:cy="11.192118"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g8" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path819"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:#000000;stroke-width:1.06666672"
+ d=""
+ id="path817"
+ inkscape:connector-curvature="0" />
+ <g
+ transform="matrix(0.04333868,0,0,0.04333868,-4.0493236,-3.7704963)"
+ id="g8">
+ <path
+ inkscape:connector-curvature="0"
+ d="m 724.1,432.41989 h -40.6 c 0,0 0,-99 0,-129.7 13,7.2 30.1,20.5 40.6,33.3 z"
+ id="path10"
+ style="fill:#e6555a;fill-opacity:1" />
+ <g
+ id="g12"
+ style="fill:#e6555a;fill-opacity:1"
+ transform="translate(0,47.319882)">
+ <path
+ inkscape:connector-curvature="0"
+ d="m 381.8,385.1 h -50.6 l -66,-204 h 46 l 45.4,143.5 h 0.6 l 46,-143.5 h 46.3 z"
+ id="path14"
+ style="fill:#e6555a;fill-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ d="M 585.5,385.1 H 546.9 V 364.5 H 546 c -5.1,8.6 -11.8,14.8 -20,18.6 -8.2,3.8 -16.6,5.7 -25.1,5.7 -10.9,0 -19.8,-1.4 -26.7,-4.3 -7,-2.9 -12.4,-6.9 -16.4,-12.1 -4,-5.2 -6.8,-11.6 -8.4,-19.1 -1.6,-7.5 -2.4,-15.9 -2.4,-25 v -90.9 h 40.6 v 83.4 c 0,12.2 1.9,21.3 5.7,27.3 3.8,6 10.6,9 20.3,9 11,0 19.1,-3.3 24,-9.9 5,-6.6 7.4,-17.4 7.4,-32.4 v -77.4 h 40.6 v 147.7 z"
+ id="path16"
+ style="fill:#e6555a;fill-opacity:1" />
+ </g>
+ <polygon
+ points="730.8,296.2 730.7,290.5 781.9,237.3 829.9,237.3 774.2,291.6 836.2,385.1 787,385.1 "
+ id="polygon18"
+ style="fill:#e6555a;fill-opacity:1"
+ transform="translate(0,47.319882)" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 843.6,330.11989 c 0.6,-9.5 3,-17.4 7.2,-23.7 4.2,-6.3 9.5,-11.3 16,-15.1 6.5,-3.8 13.8,-6.5 21.9,-8.1 8.1,-1.6 16.2,-2.4 24.4,-2.4 7.4,0 15,0.5 22.6,1.6 7.6,1.1 14.6,3.1 20.9,6.1 6.3,3.1 11.4,7.3 15.4,12.7 4,5.4 6,12.6 6,21.6 v 76.9 c 0,6.7 0.4,13.1 1.1,19.1 0.8,6.1 2.1,10.7 4,13.7 h -41.2 c -0.8,-2.3 -1.4,-4.6 -1.9,-7 -0.5,-2.4 -0.8,-4.8 -1,-7.3 -6.5,6.7 -14.1,11.3 -22.9,14 -8.8,2.7 -17.7,4 -26.9,4 -7,0 -13.6,-0.9 -19.7,-2.6 -6.1,-1.7 -11.4,-4.4 -16,-8 -4.6,-3.6 -8.2,-8.2 -10.7,-13.7 -2.6,-5.5 -3.9,-12.1 -3.9,-19.7 0,-8.4 1.5,-15.3 4.4,-20.7 3,-5.4 6.8,-9.8 11.4,-13 4.7,-3.2 10,-5.7 16,-7.3 6,-1.6 12,-2.9 18.1,-3.9 6.1,-0.9 12.1,-1.7 18,-2.3 5.9,-0.6 11.1,-1.4 15.7,-2.6 4.6,-1.1 8.2,-2.8 10.9,-5 2.7,-2.2 3.9,-5.4 3.7,-9.6 0,-4.4 -0.7,-7.9 -2.2,-10.4 -1.4,-2.6 -3.3,-4.6 -5.7,-6 -2.4,-1.4 -5.1,-2.4 -8.3,-2.9 -3.1,-0.5 -6.5,-0.7 -10.1,-0.7 -8,0 -14.3,1.7 -18.9,5.1 -4.6,3.4 -7.2,9.1 -8,17.1 h -40.3 z m 93.8,30 c -1.7,1.5 -3.9,2.7 -6.4,3.6 -2.6,0.9 -5.3,1.6 -8.3,2.2 -2.9,0.6 -6,1 -9.3,1.4 -3.2,0.4 -6.5,0.9 -9.7,1.4 -3,0.6 -6,1.3 -9,2.3 -3,1 -5.5,2.2 -7.7,3.9 -2.2,1.6 -4,3.7 -5.3,6.1 -1.3,2.5 -2,5.6 -2,9.4 0,3.6 0.7,6.7 2,9.1 1.3,2.5 3.1,4.4 5.4,5.9 2.3,1.4 5,2.4 8,3 3.1,0.6 6.2,0.9 9.4,0.9 8,0 14.2,-1.3 18.6,-4 4.4,-2.7 7.6,-5.9 9.7,-9.6 2.1,-3.7 3.4,-7.5 3.9,-11.3 0.5,-3.8 0.7,-6.9 0.7,-9.1 z"
+ id="path20"
+ style="fill:#e6555a;fill-opacity:1" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 1004.2,284.61989 h 38.6 v 20.6 h 0.9 c 5.1,-8.6 11.8,-14.8 20,-18.7 8.2,-3.9 16.6,-5.9 25.1,-5.9 10.9,0 19.8,1.5 26.7,4.4 7,3 12.4,7.1 16.4,12.3 4,5.2 6.8,11.6 8.4,19.1 1.6,7.5 2.4,15.9 2.4,25 v 90.9 h -40.6 v -83.4 c 0,-12.2 -1.9,-21.3 -5.7,-27.3 -3.8,-6 -10.6,-9 -20.3,-9 -11,0 -19,3.3 -24,9.9 -5,6.6 -7.4,17.4 -7.4,32.4 v 77.4 h -40.6 v -147.7 z"
+ id="path22"
+ style="fill:#e6555a;fill-opacity:1" />
+ <g
+ id="g24"
+ style="fill:#e6555a;fill-opacity:1"
+ transform="translate(0,47.319882)">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 612.4,211.8 V 385 H 653 V 234.2 c -13.1,-8 -26.6,-15.5 -40.6,-22.4 z"
+ id="path26"
+ style="fill:#e6555a;fill-opacity:1" />
+ </g>
+ <path
+ inkscape:connector-curvature="0"
+ d="m 198.4,266.51989 c 23.5,-68.9 164.2,-94.2 314.1,-56.4 90,22.6 163.5,66.5 211.5,109.9 -21.7,-57.6 -127.3,-139.6 -272.8,-167.7 -164.5,-31.8 -326.7,-3.9 -346.8,69.1 -14.5,52.7 49.2,114.5 147.7,156.7 -44.3,-35.8 -65.8,-76 -53.7,-111.6 z"
+ id="path28"
+ style="fill:#e6555a;fill-opacity:1" />
+ <g
+ id="g30"
+ style="fill:#e6555a;fill-opacity:1"
+ transform="translate(0,47.319882)">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 724.2,247.6 V 181 h -40.6 v 20.2 c 17.3,15.5 31,31.2 40.6,46.4 z"
+ id="path32"
+ style="fill:#e6555a;fill-opacity:1" />
+ </g>
+ </g>
+</svg>
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index eb0bc0f782..f2f4328cd2 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1711,14 +1711,14 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
#endif
for (int i = 0; i < n->children.size(); i++) {
if (state.nodes[n->children[i]]->joints.size()) {
- _generate_bone(state, n->children[i], skeletons, Vector<int>(), node);
+ _generate_bone(state, n->children[i], skeletons, node);
} else {
_generate_node(state, n->children[i], node, p_owner, skeletons);
}
}
}
-void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, const Vector<int> &p_parent_bones, Node *p_parent_node) {
+void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node) {
ERR_FAIL_INDEX(p_node, state.nodes.size());
if (state.skeleton_nodes.has(p_node)) {
@@ -1733,30 +1733,28 @@ void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vecto
}
GLTFNode *n = state.nodes[p_node];
- Vector<int> parent_bones;
for (int i = 0; i < n->joints.size(); i++) {
- ERR_FAIL_COND(n->joints[i].skin < 0);
+ const int skin = n->joints[i].skin;
+ ERR_FAIL_COND(skin < 0);
- int bone_index = n->joints[i].bone;
+ Skeleton *s = skeletons[skin];
+ const GLTFNode *gltf_bone_node = state.nodes[state.skins[skin].bones[n->joints[i].bone].node];
+ const String bone_name = gltf_bone_node->name;
+ const int parent = gltf_bone_node->parent;
+ const int parent_index = s->find_bone(state.nodes[parent]->name);
- Skeleton *s = skeletons[n->joints[i].skin];
- while (s->get_bone_count() <= bone_index) {
- s->add_bone("Bone " + itos(s->get_bone_count()));
- }
-
- if (p_parent_bones.size()) {
- s->set_bone_parent(bone_index, p_parent_bones[i]);
- }
- s->set_bone_rest(bone_index, state.skins[n->joints[i].skin].bones[n->joints[i].bone].inverse_bind.affine_inverse());
+ s->add_bone(bone_name);
+ const int bone_index = s->find_bone(bone_name);
+ s->set_bone_parent(bone_index, parent_index);
+ s->set_bone_rest(bone_index, state.skins[skin].bones[n->joints[i].bone].inverse_bind.affine_inverse());
n->godot_nodes.push_back(s);
n->joints[i].godot_bone_index = bone_index;
- parent_bones.push_back(bone_index);
}
for (int i = 0; i < n->children.size(); i++) {
- _generate_bone(state, n->children[i], skeletons, parent_bones, p_parent_node);
+ _generate_bone(state, n->children[i], skeletons, p_parent_node);
}
}
@@ -2070,7 +2068,7 @@ Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_f
}
for (int i = 0; i < state.root_nodes.size(); i++) {
if (state.nodes[state.root_nodes[i]]->joints.size()) {
- _generate_bone(state, state.root_nodes[i], skeletons, Vector<int>(), root);
+ _generate_bone(state, state.root_nodes[i], skeletons, root);
} else {
_generate_node(state, state.root_nodes[i], root, root, skeletons);
}
diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h
index 088036ce75..e8f3bdff62 100644
--- a/editor/import/editor_scene_importer_gltf.h
+++ b/editor/import/editor_scene_importer_gltf.h
@@ -311,7 +311,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<Basis> _decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex);
Vector<Transform> _decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex);
- void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, const Vector<int> &p_parent_bones, Node *p_parent_node);
+ void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node);
void _generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons);
void _import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons);
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 0d0b12c911..43baabe2f5 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -140,6 +140,7 @@ void InspectorDock::_load_resource(const String &p_type) {
void InspectorDock::_resource_file_selected(String p_file) {
RES res = ResourceLoader::load(p_file);
+
if (res.is_null()) {
warning_dialog->get_ok()->set_text("Ugh");
warning_dialog->set_text(TTR("Failed to load resource."));
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index e0325702a8..1f5a4a8a36 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -40,7 +40,6 @@ bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vect
float area_accum = 0;
Map<float, int> triangle_area_map;
- print_line("geometry size: " + itos(geometry.size()));
for (int i = 0; i < geometry.size(); i++) {
@@ -300,6 +299,10 @@ void ParticlesEditor::_menu_option(int p_option) {
CPUParticles *cpu_particles = memnew(CPUParticles);
cpu_particles->convert_from_particles(node);
+ cpu_particles->set_name(node->get_name());
+ cpu_particles->set_transform(node->get_transform());
+ cpu_particles->set_visible(node->is_visible());
+ cpu_particles->set_pause_mode(node->get_pause_mode());
undo_redo->create_action("Replace Particles by CPUParticles");
undo_redo->add_do_method(node, "replace_by", cpu_particles);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 876da7f61a..a1dc746702 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -31,7 +31,6 @@
#include "script_editor_plugin.h"
#include "core/io/resource_loader.h"
-#include "core/io/resource_saver.h"
#include "core/os/file_access.h"
#include "core/os/input.h"
#include "core/os/keyboard.h"
@@ -283,7 +282,6 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
-
continue;
}
@@ -402,7 +400,10 @@ void ScriptEditor::_go_to_tab(int p_idx) {
if (is_visible_in_tree())
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
- notify_script_changed(Object::cast_to<ScriptEditorBase>(c)->get_edited_script());
+ Ref<Script> script = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
+ if (script != NULL) {
+ notify_script_changed(script);
+ }
}
if (Object::cast_to<EditorHelp>(c)) {
@@ -482,12 +483,23 @@ void ScriptEditor::_open_recent_script(int p_idx) {
String path = rc[p_idx];
// if its not on disk its a help file or deleted
if (FileAccess::exists(path)) {
- Ref<Script> script = ResourceLoader::load(path);
- if (script.is_valid()) {
- edit(script, true);
- return;
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+
+ if (extensions.find(path.get_extension())) {
+ Ref<Script> script = ResourceLoader::load(path);
+ if (script.is_valid()) {
+ edit(script, true);
+ return;
+ }
}
+ Error err;
+ Ref<TextFile> text_file = _load_text_file(path, &err);
+ if (text_file.is_valid()) {
+ edit(text_file, true);
+ return;
+ }
// if it's a path then its most likely a deleted file not help
} else if (!path.is_resource_file()) {
_help_class_open(path);
@@ -513,12 +525,17 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
return;
Node *tselected = tab_container->get_child(selected);
+
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
if (p_save) {
apply_scripts();
}
- notify_script_close(current->get_edited_script());
+
+ Ref<Script> script = current->get_edited_resource();
+ if (script != NULL) {
+ notify_script_close(script);
+ }
}
// roll back to previous tab
@@ -589,7 +606,7 @@ void ScriptEditor::_close_docs_tab() {
void ScriptEditor::_copy_script_path() {
ScriptEditorBase *se = _get_current_editor();
- Ref<Script> script = se->get_edited_script();
+ RES script = se->get_edited_resource();
OS::get_singleton()->set_clipboard(script->get_path());
}
@@ -655,7 +672,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
if (!se)
continue;
- Ref<Script> script = se->get_edited_script();
+ RES script = se->get_edited_resource();
if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)
continue; //internal script, who cares
@@ -672,7 +689,14 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
}
}
- editor->save_resource(script);
+ Ref<TextFile> text_file = script;
+ if (text_file != NULL) {
+ se->apply_code();
+ _save_text_file(text_file, text_file->get_path());
+ break;
+ } else {
+ editor->save_resource(script);
+ }
se->tag_saved_version();
}
@@ -689,25 +713,37 @@ void ScriptEditor::_reload_scripts() {
continue;
}
- Ref<Script> script = se->get_edited_script();
+ RES edited_res = se->get_edited_resource();
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
+ if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1) {
continue; //internal script, who cares
}
- uint64_t last_date = script->get_last_modified_time();
- uint64_t date = FileAccess::get_modified_time(script->get_path());
+ uint64_t last_date = edited_res->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(edited_res->get_path());
if (last_date == date) {
continue;
}
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
- ERR_CONTINUE(!rel_script.is_valid());
- script->set_source_code(rel_script->get_source_code());
- script->set_last_modified_time(rel_script->get_last_modified_time());
- script->reload();
+ Ref<Script> script = edited_res;
+ if (script != NULL) {
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
+ ERR_CONTINUE(!rel_script.is_valid());
+ script->set_source_code(rel_script->get_source_code());
+ script->set_last_modified_time(rel_script->get_last_modified_time());
+ script->reload();
+ }
+
+ Ref<TextFile> text_file = edited_res;
+ if (text_file != NULL) {
+ Error err;
+ Ref<TextFile> rel_text_file = _load_text_file(text_file->get_path(), &err);
+ ERR_CONTINUE(!rel_text_file.is_valid());
+ text_file->set_text(rel_text_file->get_text());
+ text_file->set_last_modified_time(rel_text_file->get_last_modified_time());
+ }
se->reload_text();
}
@@ -725,7 +761,7 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource> &p_res) {
continue;
}
- Ref<Script> script = se->get_edited_script();
+ RES script = se->get_edited_resource();
if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1) {
continue; //internal script, who cares
@@ -750,7 +786,7 @@ void ScriptEditor::_live_auto_reload_running_scripts() {
debugger->reload_scripts();
}
-bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
+bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
disk_changed_list->clear();
TreeItem *r = disk_changed_list->create_item();
@@ -765,21 +801,20 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
- Ref<Script> script = se->get_edited_script();
-
- if (p_for_script.is_valid() && p_for_script != script)
+ RES edited_res = se->get_edited_resource();
+ if (edited_res.is_valid() && p_for_script != edited_res)
continue;
- if (script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)
+ if (edited_res->get_path() == "" || edited_res->get_path().find("local://") != -1 || edited_res->get_path().find("::") != -1)
continue; //internal script, who cares
- uint64_t last_date = script->get_last_modified_time();
- uint64_t date = FileAccess::get_modified_time(script->get_path());
+ uint64_t last_date = edited_res->get_last_modified_time();
+ uint64_t date = FileAccess::get_modified_time(edited_res->get_path());
if (last_date != date) {
TreeItem *ti = disk_changed_list->create_item(r);
- ti->set_text(0, script->get_path().get_file());
+ ti->set_text(0, edited_res->get_path().get_file());
if (!use_autoreload || se->is_unsaved()) {
need_ask = true;
@@ -804,6 +839,49 @@ bool ScriptEditor::_test_script_times_on_disk(Ref<Script> p_for_script) {
void ScriptEditor::_file_dialog_action(String p_file) {
switch (file_dialog_option) {
+ case FILE_OPEN: {
+
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ if (extensions.find(p_file.get_extension())) {
+ Ref<Script> scr = ResourceLoader::load(p_file);
+ if (!scr.is_valid()) {
+ editor->show_warning(TTR("Error could not load file."), TTR("Error!"));
+ file_dialog_option = -1;
+ return;
+ }
+
+ edit(scr);
+ file_dialog_option = -1;
+ return;
+ }
+
+ Error error;
+ Ref<TextFile> text_file = _load_text_file(p_file, &error);
+ if (error != OK) {
+ editor->show_warning(TTR("Error could not load file."), TTR("Error!"));
+ }
+
+ if (text_file.is_valid()) {
+ edit(text_file);
+ file_dialog_option = -1;
+ return;
+ }
+ }
+ case FILE_SAVE_AS: {
+ ScriptEditorBase *current = _get_current_editor();
+
+ String path = ProjectSettings::get_singleton()->localize_path(p_file);
+ Error err = _save_text_file(current->get_edited_resource(), path);
+
+ if (err != OK) {
+ editor->show_accept(TTR("Error saving file!"), TTR("OK"));
+ return;
+ }
+
+ ((Resource *)current->get_edited_resource().ptr())->set_path(path);
+ _update_script_names();
+ } break;
case THEME_SAVE_AS: {
if (!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) {
editor->show_warning(TTR("Error while saving theme"), TTR("Error saving"));
@@ -823,7 +901,8 @@ Ref<Script> ScriptEditor::_get_current_script() {
ScriptEditorBase *current = _get_current_editor();
if (current) {
- return current->get_edited_script();
+ Ref<Script> script = current->get_edited_resource();
+ return script != NULL ? script : NULL;
} else {
return NULL;
}
@@ -848,8 +927,19 @@ void ScriptEditor::_menu_option(int p_option) {
script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
} break;
case FILE_OPEN: {
+ file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+ file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ file_dialog_option = FILE_OPEN;
- editor->open_resource("Script");
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ file_dialog->clear_filters();
+ for (int i = 0; i < extensions.size(); i++) {
+ file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
+ }
+
+ file_dialog->popup_centered_ratio();
+ file_dialog->set_title(TTR("Open File"));
return;
} break;
case FILE_SAVE_ALL: {
@@ -929,7 +1019,14 @@ void ScriptEditor::_menu_option(int p_option) {
current->convert_indent_to_tabs();
}
}
- editor->save_resource(current->get_edited_script());
+
+ Ref<TextFile> text_file = current->get_edited_resource();
+ if (text_file != NULL) {
+ current->apply_code();
+ _save_text_file(text_file, text_file->get_path());
+ break;
+ }
+ editor->save_resource(current->get_edited_resource());
} break;
case FILE_SAVE_AS: {
@@ -943,8 +1040,25 @@ void ScriptEditor::_menu_option(int p_option) {
current->convert_indent_to_tabs();
}
}
- editor->push_item(Object::cast_to<Object>(current->get_edited_script().ptr()));
- editor->save_resource_as(current->get_edited_script());
+
+ Ref<TextFile> text_file = current->get_edited_resource();
+ if (text_file != NULL) {
+ file_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE);
+ file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
+ file_dialog_option = FILE_SAVE_AS;
+
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+ file_dialog->clear_filters();
+ file_dialog->set_current_dir(text_file->get_path().get_base_dir());
+ file_dialog->set_current_file(text_file->get_path().get_file());
+ file_dialog->popup_centered_ratio();
+ file_dialog->set_title(TTR("Save File As..."));
+ break;
+ }
+
+ editor->push_item(Object::cast_to<Object>(current->get_edited_resource().ptr()));
+ editor->save_resource_as(current->get_edited_resource());
} break;
@@ -956,8 +1070,8 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case FILE_RUN: {
- Ref<Script> scr = current->get_edited_script();
- if (scr.is_null()) {
+ Ref<Script> scr = current->get_edited_resource();
+ if (scr == NULL || scr.is_null()) {
EditorNode::get_singleton()->show_warning("Can't obtain the script for running");
break;
}
@@ -1000,8 +1114,7 @@ void ScriptEditor::_menu_option(int p_option) {
_copy_script_path();
} break;
case SHOW_IN_FILE_SYSTEM: {
- ScriptEditorBase *se = _get_current_editor();
- Ref<Script> script = se->get_edited_script();
+ RES script = current->get_edited_resource();
FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock();
file_system_dock->navigate_to_path(script->get_path());
// Ensure that the FileSystem dock is visible.
@@ -1259,8 +1372,8 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
if (se) {
- Ref<Script> script = se->get_edited_script();
- if (!script.is_valid())
+ Ref<Script> script = se->get_edited_resource();
+ if (script == NULL || !script.is_valid())
continue;
if (script->get_path().find("::") != -1 && script->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
@@ -1307,9 +1420,13 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
if (!se)
continue;
+ Ref<Script> script = se->get_edited_resource();
+ if (script == NULL) {
+ continue;
+ }
+
List<int> bpoints;
se->get_breakpoints(&bpoints);
- Ref<Script> script = se->get_edited_script();
String base = script->get_path();
ERR_CONTINUE(base.begins_with("local://") || base == "");
@@ -1452,7 +1569,7 @@ void ScriptEditor::_update_members_overview() {
members_overview->set_item_metadata(i, functions[i].get_slice(":", 1).to_int() - 1);
}
- String path = se->get_edited_script()->get_path();
+ String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name = built_in ? path.get_file() : se->get_name();
filename->set_text(name);
@@ -1570,7 +1687,7 @@ void ScriptEditor::_update_script_names() {
if (se) {
Ref<Texture> icon = se->get_icon();
- String path = se->get_edited_script()->get_path();
+ String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name = built_in ? path.get_file() : se->get_name();
@@ -1579,7 +1696,7 @@ void ScriptEditor::_update_script_names() {
sd.name = name;
sd.tooltip = path;
sd.index = i;
- sd.used = used.has(se->get_edited_script());
+ sd.used = used.has(se->get_edited_resource());
sd.category = 0;
sd.ref = se;
@@ -1681,11 +1798,65 @@ void ScriptEditor::_update_script_names() {
_update_script_colors();
}
-bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus) {
+Ref<TextFile> ScriptEditor::_load_text_file(const String &p_path, Error *r_error) {
+ if (r_error) {
+ *r_error = ERR_FILE_CANT_OPEN;
+ }
+
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ String path = ResourceLoader::path_remap(local_path);
+
+ TextFile *text_file = memnew(TextFile);
+ Ref<TextFile> text_res(text_file);
+ Error err = text_file->load_text(path);
+
+ if (err != OK) {
+ ERR_FAIL_COND_V(err != OK, RES());
+ }
+
+ text_file->set_file_path(local_path);
+ text_file->set_path(local_path, true);
+
+ if (r_error) {
+ *r_error = OK;
+ }
+
+ return text_res;
+}
+
+Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_path) {
+ Ref<TextFile> sqscr = p_text_file;
+ ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
+
+ String source = sqscr->get_text();
+
+ Error err;
+ FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
+
+ if (err) {
+
+ ERR_FAIL_COND_V(err, err);
+ }
+
+ file->store_string(source);
+ if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
+ memdelete(file);
+ return ERR_CANT_CREATE;
+ }
+ file->close();
+ memdelete(file);
+
+ _res_saved_callback(sqscr);
+ return OK;
+}
+
+bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus) {
- if (p_script.is_null())
+ if (p_resource.is_null())
return false;
+ Ref<Script> script = p_resource;
+
// refuse to open built-in if scene is not loaded
// see if already has it
@@ -1694,17 +1865,17 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
const bool should_open = open_dominant || !EditorNode::get_singleton()->is_changing_scene();
- if (p_script->get_language()->overrides_external_editor()) {
+ if (script != NULL && script->get_language()->overrides_external_editor()) {
if (should_open) {
- Error err = p_script->get_language()->open_in_external_editor(p_script, p_line >= 0 ? p_line : 0, p_col);
+ Error err = script->get_language()->open_in_external_editor(script, p_line >= 0 ? p_line : 0, p_col);
if (err != OK)
ERR_PRINT("Couldn't open script in the overridden external text editor");
}
return false;
}
- if ((debugger->get_dump_stack_script() != p_script || debugger->get_debug_with_external_editor()) &&
- p_script->get_path().is_resource_file() &&
+ if ((debugger->get_dump_stack_script() != p_resource || debugger->get_debug_with_external_editor()) &&
+ p_resource->get_path().is_resource_file() &&
bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor"))) {
String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path");
@@ -1714,7 +1885,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
if (flags.size()) {
String project_path = ProjectSettings::get_singleton()->get_resource_path();
- String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
+ String script_path = ProjectSettings::get_singleton()->globalize_path(p_resource->get_path());
flags = flags.replacen("{line}", itos(p_line > 0 ? p_line : 0));
flags = flags.replacen("{col}", itos(p_col));
@@ -1762,7 +1933,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
if (!se)
continue;
- if (se->get_edited_script() == p_script) {
+ if (se->get_edited_resource() == p_resource) {
if (should_open) {
if (tab_container->get_current_tab() != i) {
@@ -1784,7 +1955,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
ScriptEditorBase *se;
for (int i = script_editor_func_count - 1; i >= 0; i--) {
- se = script_editor_funcs[i](p_script);
+ se = script_editor_funcs[i](p_resource);
if (se)
break;
}
@@ -1795,9 +1966,9 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i]();
se->add_syntax_highlighter(highlighter);
- if (!highlighter_set) {
+ if (script != NULL && !highlighter_set) {
List<String> languages = highlighter->get_supported_languages();
- if (languages.find(p_script->get_language()->get_name())) {
+ if (languages.find(script->get_language()->get_name())) {
se->set_syntax_highlighter(highlighter);
highlighter_set = true;
}
@@ -1805,7 +1976,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
}
tab_container->add_child(se);
- se->set_edited_script(p_script);
+ se->set_edited_resource(p_resource);
se->set_tooltip_request_func("_get_debug_tooltip", this);
if (se->get_edit_menu()) {
se->get_edit_menu()->hide();
@@ -1829,14 +2000,14 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
//test for modification, maybe the script was not edited but was loaded
- _test_script_times_on_disk(p_script);
- _update_modified_scripts_for_external_editor(p_script);
+ _test_script_times_on_disk(p_resource);
+ _update_modified_scripts_for_external_editor(p_resource);
if (p_line >= 0)
se->goto_line(p_line - 1);
- notify_script_changed(p_script);
- _add_recent_script(p_script->get_path());
+ notify_script_changed(p_resource);
+ _add_recent_script(p_resource->get_path());
return true;
}
@@ -1863,12 +2034,19 @@ void ScriptEditor::save_all_scripts() {
if (!se->is_unsaved())
continue;
- Ref<Script> script = se->get_edited_script();
- if (script.is_valid())
+ RES edited_res = se->get_edited_resource();
+ if (edited_res.is_valid()) {
se->apply_code();
+ }
- if (script->get_path() != "" && script->get_path().find("local://") == -1 && script->get_path().find("::") == -1)
- editor->save_resource(script); //external script, save it
+ if (edited_res->get_path() != "" && edited_res->get_path().find("local://") == -1 && edited_res->get_path().find("::") == -1) {
+ Ref<TextFile> text_file = edited_res;
+ if (text_file != NULL) {
+ _save_text_file(text_file, text_file->get_path());
+ continue;
+ }
+ editor->save_resource(edited_res); //external script, save it
+ }
}
_update_script_names();
@@ -1938,7 +2116,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
- if (se->get_edited_script() != script)
+ if (se->get_edited_resource() != script)
continue;
se->add_callback(p_function, p_args);
@@ -2228,9 +2406,12 @@ void ScriptEditor::_make_script_list_context_menu() {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_other_tabs"), CLOSE_OTHER_TABS);
context_menu->add_separator();
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_path"), FILE_COPY_PATH);
- context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/show_in_file_system"), SHOW_IN_FILE_SYSTEM);
- Ref<Script> scr = se->get_edited_script();
+ }
+
+ Ref<Script> scr = se->get_edited_resource();
+ if (scr != NULL) {
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT);
if (!scr.is_null() && scr->is_tool()) {
context_menu->add_separator();
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_RUN);
@@ -2239,8 +2420,6 @@ void ScriptEditor::_make_script_list_context_menu() {
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_CLOSE);
}
- EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(selected));
-
context_menu->add_separator();
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/window_move_up"), WINDOW_MOVE_UP);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/window_move_down"), WINDOW_MOVE_DOWN);
@@ -2268,14 +2447,28 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
restoring_layout = true;
+ List<String> extensions;
+ ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
+
for (int i = 0; i < scripts.size(); i++) {
String path = scripts[i];
if (!FileAccess::exists(path))
continue;
- Ref<Script> scr = ResourceLoader::load(path);
- if (scr.is_valid()) {
- edit(scr);
+
+ if (extensions.find(path.get_extension())) {
+ Ref<Script> scr = ResourceLoader::load(path);
+ if (scr.is_valid()) {
+ edit(scr);
+ continue;
+ }
+ }
+
+ Error error;
+ Ref<TextFile> text_file = _load_text_file(path, &error);
+ if (error == OK && text_file.is_valid()) {
+ edit(text_file);
+ continue;
}
}
@@ -2311,7 +2504,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (se) {
- String path = se->get_edited_script()->get_path();
+ String path = se->get_edited_resource()->get_path();
if (!path.is_resource_file())
continue;
@@ -2436,7 +2629,10 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
Object::cast_to<ScriptEditorBase>(n)->set_edit_state(history[history_pos].state);
Object::cast_to<ScriptEditorBase>(n)->ensure_focus();
- notify_script_changed(Object::cast_to<ScriptEditorBase>(n)->get_edited_script());
+ Ref<Script> script = Object::cast_to<ScriptEditorBase>(n)->get_edited_resource();
+ if (script != NULL) {
+ notify_script_changed(script);
+ }
}
if (Object::cast_to<EditorHelp>(n)) {
@@ -2473,7 +2669,11 @@ Vector<Ref<Script> > ScriptEditor::get_open_scripts() const {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se)
continue;
- out_scripts.push_back(se->get_edited_script());
+
+ Ref<Script> script = se->get_edited_resource();
+ if (script != NULL) {
+ out_scripts.push_back(script);
+ }
}
return out_scripts;
@@ -2519,6 +2719,14 @@ void ScriptEditor::_open_script_request(const String &p_path) {
Ref<Script> script = ResourceLoader::load(p_path);
if (script.is_valid()) {
script_editor->edit(script, false);
+ return;
+ }
+
+ Error err;
+ Ref<TextFile> text_file = script_editor->_load_text_file(p_path, &err);
+ if (text_file.is_valid()) {
+ script_editor->edit(text_file, false);
+ return;
}
}
@@ -2552,7 +2760,7 @@ void ScriptEditor::_on_find_in_files_requested(String text) {
void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_number, int begin, int end) {
- Ref<Resource> res = ResourceLoader::load(fpath);
+ RES res = ResourceLoader::load(fpath);
edit(res);
ScriptEditorBase *seb = _get_current_editor();
@@ -2968,14 +3176,21 @@ ScriptEditor::~ScriptEditor() {
void ScriptEditorPlugin::edit(Object *p_object) {
- if (!Object::cast_to<Script>(p_object))
- return;
+ if (Object::cast_to<Script>(p_object)) {
+ script_editor->edit(Object::cast_to<Script>(p_object));
+ }
- script_editor->edit(Object::cast_to<Script>(p_object));
+ if (Object::cast_to<TextFile>(p_object)) {
+ script_editor->edit(Object::cast_to<TextFile>(p_object));
+ }
}
bool ScriptEditorPlugin::handles(Object *p_object) const {
+ if (Object::cast_to<TextFile>(p_object)) {
+ return true;
+ }
+
if (Object::cast_to<Script>(p_object)) {
bool valid = _can_open_in_editor(Object::cast_to<Script>(p_object));
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index ad12add53f..186c80a5f9 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -43,6 +43,7 @@
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
#include "scene/main/timer.h"
+#include "scene/resources/text_file.h"
#include "script_language.h"
class ScriptEditorQuickOpen : public ConfirmationDialog {
@@ -74,7 +75,7 @@ class ScriptEditorDebugger;
class ScriptEditorBase : public VBoxContainer {
- GDCLASS(ScriptEditorBase, VBoxContainer);
+ GDCLASS(ScriptEditorBase, VBoxContainer)
protected:
static void _bind_methods();
@@ -84,9 +85,9 @@ public:
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter) = 0;
virtual void apply_code() = 0;
- virtual Ref<Script> get_edited_script() const = 0;
+ virtual RES get_edited_resource() const = 0;
virtual Vector<String> get_functions() = 0;
- virtual void set_edited_script(const Ref<Script> &p_script) = 0;
+ virtual void set_edited_resource(const RES &p_res) = 0;
virtual void reload_text() = 0;
virtual String get_name() = 0;
virtual Ref<Texture> get_icon() = 0;
@@ -99,7 +100,7 @@ public:
virtual void convert_indent_to_tabs() = 0;
virtual void ensure_focus() = 0;
virtual void tag_saved_version() = 0;
- virtual void reload(bool p_soft) = 0;
+ virtual void reload(bool p_soft) {}
virtual void get_breakpoints(List<int> *p_breakpoints) = 0;
virtual void add_callback(const String &p_function, PoolStringArray p_args) = 0;
virtual void update_settings() = 0;
@@ -116,7 +117,7 @@ public:
};
typedef SyntaxHighlighter *(*CreateSyntaxHighlighterFunc)();
-typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Script> &p_script);
+typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const RES &p_resource);
class EditorScriptCodeCompletionCache;
class FindInFilesDialog;
@@ -268,7 +269,7 @@ class ScriptEditor : public PanelContainer {
void _resave_scripts(const String &p_str);
void _reload_scripts();
- bool _test_script_times_on_disk(Ref<Script> p_for_script = Ref<Script>());
+ bool _test_script_times_on_disk(RES p_for_script = Ref<Resource>());
void _add_recent_script(String p_path);
void _update_recent_scripts();
@@ -378,6 +379,9 @@ class ScriptEditor : public PanelContainer {
Ref<Script> _get_current_script();
Array _get_open_scripts() const;
+ Ref<TextFile> _load_text_file(const String &p_path, Error *r_error);
+ Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
+
void _on_find_in_files_requested(String text);
void _on_find_in_files_result_selected(String fpath, int line_number, int begin, int end);
void _start_find_in_files(bool with_replace);
@@ -400,8 +404,8 @@ public:
void ensure_select_current();
- _FORCE_INLINE_ bool edit(const Ref<Script> &p_script, bool p_grab_focus = true) { return edit(p_script, -1, 0, p_grab_focus); }
- bool edit(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus = true);
+ _FORCE_INLINE_ bool edit(const RES &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
+ bool edit(const RES &p_resource, int p_line, int p_col, bool p_grab_focus = true);
void get_breakpoints(List<String> *p_breakpoints);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index ffc2203475..165d7e32b9 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -66,11 +66,24 @@ void ScriptTextEditor::apply_code() {
_update_member_keywords();
}
-Ref<Script> ScriptTextEditor::get_edited_script() const {
-
+RES ScriptTextEditor::get_edited_resource() const {
return script;
}
+void ScriptTextEditor::set_edited_resource(const RES &p_res) {
+ ERR_FAIL_COND(!script.is_null());
+
+ script = p_res;
+ _set_theme_for_script();
+
+ code_editor->get_text_edit()->set_text(script->get_source_code());
+ code_editor->get_text_edit()->clear_undo_history();
+ code_editor->get_text_edit()->tag_saved_version();
+
+ emit_signal("name_changed");
+ code_editor->update_line_and_column();
+}
+
void ScriptTextEditor::_update_member_keywords() {
member_keywords.clear();
code_editor->get_text_edit()->clear_member_keywords();
@@ -116,6 +129,7 @@ void ScriptTextEditor::_load_theme_settings() {
Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
+ Color safe_line_number_color = EDITOR_GET("text_editor/highlighting/safe_line_number_color");
Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
@@ -147,6 +161,7 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_color_override("completion_font_color", completion_font_color);
text_edit->add_color_override("font_color", text_color);
text_edit->add_color_override("line_number_color", line_number_color);
+ text_edit->add_color_override("safe_line_number_color", safe_line_number_color);
text_edit->add_color_override("caret_color", caret_color);
text_edit->add_color_override("caret_background_color", caret_background_color);
text_edit->add_color_override("font_selected_color", text_selected_color);
@@ -188,6 +203,7 @@ void ScriptTextEditor::_set_theme_for_script() {
List<String> keywords;
script->get_language()->get_reserved_words(&keywords);
+
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
text_edit->add_keyword_color(E->get(), colors_cache.keyword_color);
@@ -249,7 +265,6 @@ void ScriptTextEditor::_set_theme_for_script() {
//colorize strings
List<String> strings;
script->get_language()->get_string_delimiters(&strings);
-
for (List<String>::Element *E = strings.front(); E; E = E->next()) {
String string = E->get();
@@ -324,197 +339,32 @@ bool ScriptTextEditor::is_unsaved() {
Variant ScriptTextEditor::get_edit_state() {
- Dictionary state;
+ return code_editor->get_edit_state();
+}
- state["scroll_position"] = code_editor->get_text_edit()->get_v_scroll();
- state["column"] = code_editor->get_text_edit()->cursor_get_column();
- state["row"] = code_editor->get_text_edit()->cursor_get_line();
+void ScriptTextEditor::set_edit_state(const Variant &p_state) {
- return state;
+ code_editor->set_edit_state(p_state);
}
-void ScriptTextEditor::_convert_case(CaseStyle p_case) {
- TextEdit *te = code_editor->get_text_edit();
- Ref<Script> scr = get_edited_script();
- if (scr.is_null()) {
- return;
- }
-
- if (te->is_selection_active()) {
- te->begin_complex_operation();
-
- int begin = te->get_selection_from_line();
- int end = te->get_selection_to_line();
- int begin_col = te->get_selection_from_column();
- int end_col = te->get_selection_to_column();
-
- for (int i = begin; i <= end; i++) {
- int len = te->get_line(i).length();
- if (i == end)
- len -= len - end_col;
- if (i == begin)
- len -= begin_col;
- String new_line = te->get_line(i).substr(i == begin ? begin_col : 0, len);
-
- switch (p_case) {
- case UPPER: {
- new_line = new_line.to_upper();
- } break;
- case LOWER: {
- new_line = new_line.to_lower();
- } break;
- case CAPITALIZE: {
- new_line = new_line.capitalize();
- } break;
- }
+void ScriptTextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
- if (i == begin) {
- new_line = te->get_line(i).left(begin_col) + new_line;
- }
- if (i == end) {
- new_line = new_line + te->get_line(i).right(end_col);
- }
- te->set_line(i, new_line);
- }
- te->end_complex_operation();
- }
+ code_editor->convert_case(p_case);
}
void ScriptTextEditor::trim_trailing_whitespace() {
- TextEdit *tx = code_editor->get_text_edit();
-
- bool trimed_whitespace = false;
- for (int i = 0; i < tx->get_line_count(); i++) {
- String line = tx->get_line(i);
- if (line.ends_with(" ") || line.ends_with("\t")) {
-
- if (!trimed_whitespace) {
- tx->begin_complex_operation();
- trimed_whitespace = true;
- }
-
- int end = 0;
- for (int j = line.length() - 1; j > -1; j--) {
- if (line[j] != ' ' && line[j] != '\t') {
- end = j + 1;
- break;
- }
- }
- tx->set_line(i, line.substr(0, end));
- }
- }
- if (trimed_whitespace) {
- tx->end_complex_operation();
- tx->update();
- }
+ code_editor->trim_trailing_whitespace();
}
void ScriptTextEditor::convert_indent_to_spaces() {
- TextEdit *tx = code_editor->get_text_edit();
- Ref<Script> scr = get_edited_script();
-
- if (scr.is_null()) {
- return;
- }
-
- int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
- String indent = "";
-
- for (int i = 0; i < indent_size; i++) {
- 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);
-
- if (line.length() <= 0) {
- continue;
- }
-
- int j = 0;
- while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
- if (line[j] == '\t') {
- if (!changed_indentation) {
- 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++;
- }
- if (changed_indentation) {
- tx->set_line(i, line);
- }
- }
- if (changed_indentation) {
- tx->cursor_set_column(cursor_column);
- tx->end_complex_operation();
- tx->update();
- }
+ code_editor->convert_indent_to_spaces();
}
void ScriptTextEditor::convert_indent_to_tabs() {
- TextEdit *tx = code_editor->get_text_edit();
- Ref<Script> scr = get_edited_script();
-
- if (scr.is_null()) {
- return;
- }
-
- 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);
-
- if (line.length() <= 0) {
- continue;
- }
- int j = 0;
- int space_count = -1;
- while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) {
- if (line[j] != '\t') {
- space_count++;
-
- if (space_count == indent_size) {
- if (!changed_indentation) {
- 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;
- }
- } else {
- space_count = -1;
- }
- j++;
- }
- if (changed_indentation) {
- tx->set_line(i, line);
- }
- }
- if (changed_indentation) {
- tx->cursor_set_column(cursor_column);
- tx->end_complex_operation();
- tx->update();
- }
+ code_editor->convert_indent_to_tabs();
}
void ScriptTextEditor::tag_saved_version() {
@@ -523,31 +373,17 @@ void ScriptTextEditor::tag_saved_version() {
}
void ScriptTextEditor::goto_line(int p_line, bool p_with_error) {
- TextEdit *tx = code_editor->get_text_edit();
- tx->deselect();
- tx->unfold_line(p_line);
- tx->call_deferred("cursor_set_line", p_line);
-}
-void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
- TextEdit *tx = code_editor->get_text_edit();
- tx->unfold_line(p_line);
- tx->call_deferred("cursor_set_line", p_line);
- tx->call_deferred("cursor_set_column", p_begin);
- tx->select(p_line, p_begin, p_line, p_end);
+ code_editor->goto_line(p_line);
}
-void ScriptTextEditor::ensure_focus() {
+void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
- code_editor->get_text_edit()->grab_focus();
+ code_editor->goto_line_selection(p_line, p_begin, p_end);
}
-void ScriptTextEditor::set_edit_state(const Variant &p_state) {
+void ScriptTextEditor::ensure_focus() {
- Dictionary state = p_state;
- code_editor->get_text_edit()->cursor_set_column(state["column"]);
- code_editor->get_text_edit()->cursor_set_line(state["row"]);
- code_editor->get_text_edit()->set_v_scroll(state["scroll_position"]);
code_editor->get_text_edit()->grab_focus();
}
@@ -576,21 +412,6 @@ Ref<Texture> ScriptTextEditor::get_icon() {
return Ref<Texture>();
}
-void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) {
-
- ERR_FAIL_COND(!script.is_null());
-
- script = p_script;
- _set_theme_for_script();
-
- code_editor->get_text_edit()->set_text(script->get_source_code());
- code_editor->get_text_edit()->clear_undo_history();
- code_editor->get_text_edit()->tag_saved_version();
-
- emit_signal("name_changed");
- code_editor->update_line_and_column();
-}
-
void ScriptTextEditor::_validate_script() {
String errortxt;
@@ -599,8 +420,9 @@ void ScriptTextEditor::_validate_script() {
String text = te->get_text();
List<String> fnc;
+ Set<int> safe_lines;
- if (!script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc)) {
+ if (!script->get_language()->validate(text, line, col, errortxt, script->get_path(), &fnc, &safe_lines)) {
String error_text = "error(" + itos(line) + "," + itos(col) + "): " + errortxt;
code_editor->set_error(error_text);
} else {
@@ -621,8 +443,23 @@ void ScriptTextEditor::_validate_script() {
}
line--;
+ bool highlight_safe = EDITOR_DEF("text_editor/highlighting/highlight_type_safe_lines", true);
+ bool last_is_safe = false;
for (int i = 0; i < te->get_line_count(); i++) {
te->set_line_as_marked(i, line == i);
+ if (highlight_safe) {
+ if (safe_lines.has(i + 1)) {
+ te->set_line_as_safe(i, true);
+ last_is_safe = true;
+ } else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().empty())) {
+ te->set_line_as_safe(i, true);
+ } else {
+ te->set_line_as_safe(i, false);
+ last_is_safe = false;
+ }
+ } else {
+ te->set_line_as_safe(i, false);
+ }
}
emit_signal("name_changed");
@@ -859,98 +696,15 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_MOVE_LINE_UP: {
- Ref<Script> scr = script;
- if (scr.is_null())
- return;
-
- tx->begin_complex_operation();
- if (tx->is_selection_active()) {
- int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
- int to_column = tx->get_selection_to_column();
-
- for (int i = from_line; i <= to_line; i++) {
- int line_id = i;
- int next_id = i - 1;
-
- if (line_id == 0 || next_id < 0)
- return;
-
- tx->unfold_line(line_id);
- tx->unfold_line(next_id);
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- int from_line_up = from_line > 0 ? from_line - 1 : from_line;
- int to_line_up = to_line > 0 ? to_line - 1 : to_line;
- tx->select(from_line_up, from_col, to_line_up, to_column);
- } else {
- int line_id = tx->cursor_get_line();
- int next_id = line_id - 1;
-
- if (line_id == 0 || next_id < 0)
- return;
-
- tx->unfold_line(line_id);
- tx->unfold_line(next_id);
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- tx->end_complex_operation();
- tx->update();
+ code_editor->move_lines_up();
} break;
case EDIT_MOVE_LINE_DOWN: {
- Ref<Script> scr = get_edited_script();
- if (scr.is_null())
- return;
-
- tx->begin_complex_operation();
- if (tx->is_selection_active()) {
- int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
- int to_column = tx->get_selection_to_column();
-
- for (int i = to_line; i >= from_line; i--) {
- int line_id = i;
- int next_id = i + 1;
-
- if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
- return;
-
- tx->unfold_line(line_id);
- tx->unfold_line(next_id);
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- int from_line_down = from_line < tx->get_line_count() ? from_line + 1 : from_line;
- int to_line_down = to_line < tx->get_line_count() ? to_line + 1 : to_line;
- tx->select(from_line_down, from_col, to_line_down, to_column);
- } else {
- int line_id = tx->cursor_get_line();
- int next_id = line_id + 1;
-
- if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
- return;
-
- tx->unfold_line(line_id);
- tx->unfold_line(next_id);
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- tx->end_complex_operation();
- tx->update();
-
+ code_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
- Ref<Script> scr = get_edited_script();
+ Ref<Script> scr = script;
if (scr.is_null())
return;
@@ -958,7 +712,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_INDENT_RIGHT: {
- Ref<Script> scr = get_edited_script();
+ Ref<Script> scr = script;
if (scr.is_null())
return;
@@ -966,72 +720,11 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_DELETE_LINE: {
- Ref<Script> scr = get_edited_script();
- if (scr.is_null())
- return;
- tx->begin_complex_operation();
- if (tx->is_selection_active()) {
- int to_line = tx->get_selection_to_line();
- int from_line = tx->get_selection_from_line();
- int count = Math::abs(to_line - from_line) + 1;
- while (count) {
- tx->set_line(tx->cursor_get_line(), "");
- tx->backspace_at_cursor();
- count--;
- if (count)
- tx->unfold_line(from_line);
- }
- tx->cursor_set_line(from_line - 1);
- tx->deselect();
- } else {
- int line = tx->cursor_get_line();
- tx->set_line(tx->cursor_get_line(), "");
- tx->backspace_at_cursor();
- tx->unfold_line(line);
- tx->cursor_set_line(line);
- }
- tx->end_complex_operation();
+ code_editor->delete_lines();
} break;
case EDIT_CLONE_DOWN: {
- Ref<Script> scr = get_edited_script();
- if (scr.is_null())
- return;
-
- int from_line = tx->cursor_get_line();
- int to_line = tx->cursor_get_line();
- int column = tx->cursor_get_column();
-
- if (tx->is_selection_active()) {
- from_line = tx->get_selection_from_line();
- to_line = tx->get_selection_to_line();
- column = tx->cursor_get_column();
- }
- int next_line = to_line + 1;
-
- if (to_line >= tx->get_line_count() - 1) {
- tx->set_line(to_line, tx->get_line(to_line) + "\n");
- }
-
- tx->begin_complex_operation();
- for (int i = from_line; i <= to_line; i++) {
-
- tx->unfold_line(i);
- if (i >= tx->get_line_count() - 1) {
- tx->set_line(i, tx->get_line(i) + "\n");
- }
- String line_clone = tx->get_line(i);
- tx->insert_at(line_clone, next_line);
- next_line++;
- }
-
- tx->cursor_set_column(column);
- if (tx->is_selection_active()) {
- tx->select(to_line + 1, tx->get_selection_from_column(), next_line - 1, tx->get_selection_to_column());
- }
-
- tx->end_complex_operation();
- tx->update();
+ code_editor->code_lines_down();
} break;
case EDIT_TOGGLE_FOLD_LINE: {
@@ -1050,7 +743,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_TOGGLE_COMMENT: {
- Ref<Script> scr = get_edited_script();
+ Ref<Script> scr = script;
if (scr.is_null())
return;
@@ -1118,7 +811,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
case EDIT_AUTO_INDENT: {
String text = tx->get_text();
- Ref<Script> scr = get_edited_script();
+ Ref<Script> scr = script;
if (scr.is_null())
return;
@@ -1161,15 +854,15 @@ void ScriptTextEditor::_edit_option(int p_op) {
} break;
case EDIT_TO_UPPERCASE: {
- _convert_case(UPPER);
+ _convert_case(CodeTextEditor::UPPER);
} break;
case EDIT_TO_LOWERCASE: {
- _convert_case(LOWER);
+ _convert_case(CodeTextEditor::LOWER);
} break;
case EDIT_CAPITALIZE: {
- _convert_case(CAPITALIZE);
+ _convert_case(CodeTextEditor::CAPITALIZE);
} break;
case SEARCH_FIND: {
@@ -1209,7 +902,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
int line = tx->cursor_get_line();
bool dobreak = !tx->is_line_set_as_breakpoint(line);
tx->set_line_as_breakpoint(line, dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak);
+ ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), line + 1, dobreak);
} break;
case DEBUG_REMOVE_ALL_BREAKPOINTS: {
@@ -1220,7 +913,7 @@ void ScriptTextEditor::_edit_option(int p_op) {
int line = E->get();
bool dobreak = !tx->is_line_set_as_breakpoint(line);
tx->set_line_as_breakpoint(line, dobreak);
- ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak);
+ ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), line + 1, dobreak);
}
}
case DEBUG_GOTO_NEXT_BREAKPOINT: {
@@ -1340,7 +1033,7 @@ void ScriptTextEditor::clear_edit_menu() {
void ScriptTextEditor::reload(bool p_soft) {
TextEdit *te = code_editor->get_text_edit();
- Ref<Script> scr = get_edited_script();
+ Ref<Script> scr = script;
if (scr.is_null())
return;
scr->set_source_code(te->get_text());
@@ -1724,9 +1417,12 @@ ScriptTextEditor::ScriptTextEditor() {
code_editor->get_text_edit()->set_drag_forwarding(this);
}
-static ScriptEditorBase *create_editor(const Ref<Script> &p_script) {
+static ScriptEditorBase *create_editor(const RES &p_resource) {
- return memnew(ScriptTextEditor);
+ if (Object::cast_to<Script>(*p_resource)) {
+ return memnew(ScriptTextEditor);
+ }
+ return NULL;
}
void ScriptTextEditor::register_editor() {
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index a415f478e8..f0b00a9117 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -138,12 +138,7 @@ protected:
void _goto_line(int p_line) { goto_line(p_line); }
void _lookup_symbol(const String &p_symbol, int p_row, int p_column);
- enum CaseStyle {
- UPPER,
- LOWER,
- CAPITALIZE,
- };
- void _convert_case(CaseStyle p_case);
+ void _convert_case(CodeTextEditor::CaseStyle p_case);
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
@@ -154,14 +149,13 @@ public:
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual void apply_code();
- virtual Ref<Script> get_edited_script() const;
+ virtual RES get_edited_resource() const;
+ virtual void set_edited_resource(const RES &p_res);
virtual Vector<String> get_functions();
- virtual void set_edited_script(const Ref<Script> &p_script);
virtual void reload_text();
virtual String get_name();
virtual Ref<Texture> get_icon();
virtual bool is_unsaved();
-
virtual Variant get_edit_state();
virtual void set_edit_state(const Variant &p_state);
virtual void ensure_focus();
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 4b7f27c0c1..7650cd6ae7 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -258,84 +258,10 @@ void ShaderEditor::_menu_option(int p_option) {
shader_editor->get_text_edit()->select_all();
} break;
case EDIT_MOVE_LINE_UP: {
-
- TextEdit *tx = shader_editor->get_text_edit();
- if (shader.is_null())
- return;
-
- tx->begin_complex_operation();
- if (tx->is_selection_active()) {
- int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
- int to_column = tx->get_selection_to_column();
-
- for (int i = from_line; i <= to_line; i++) {
- int line_id = i;
- int next_id = i - 1;
-
- if (line_id == 0 || next_id < 0)
- return;
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- int from_line_up = from_line > 0 ? from_line - 1 : from_line;
- int to_line_up = to_line > 0 ? to_line - 1 : to_line;
- tx->select(from_line_up, from_col, to_line_up, to_column);
- } else {
- int line_id = tx->cursor_get_line();
- int next_id = line_id - 1;
-
- if (line_id == 0 || next_id < 0)
- return;
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- tx->end_complex_operation();
- tx->update();
-
+ shader_editor->move_lines_up();
} break;
case EDIT_MOVE_LINE_DOWN: {
-
- TextEdit *tx = shader_editor->get_text_edit();
- if (shader.is_null())
- return;
-
- tx->begin_complex_operation();
- if (tx->is_selection_active()) {
- int from_line = tx->get_selection_from_line();
- int from_col = tx->get_selection_from_column();
- int to_line = tx->get_selection_to_line();
- int to_column = tx->get_selection_to_column();
-
- for (int i = to_line; i >= from_line; i--) {
- int line_id = i;
- int next_id = i + 1;
-
- if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
- return;
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- int from_line_down = from_line < tx->get_line_count() ? from_line + 1 : from_line;
- int to_line_down = to_line < tx->get_line_count() ? to_line + 1 : to_line;
- tx->select(from_line_down, from_col, to_line_down, to_column);
- } else {
- int line_id = tx->cursor_get_line();
- int next_id = line_id + 1;
-
- if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count())
- return;
-
- tx->swap_lines(line_id, next_id);
- tx->cursor_set_line(next_id);
- }
- tx->end_complex_operation();
- tx->update();
-
+ shader_editor->move_lines_down();
} break;
case EDIT_INDENT_LEFT: {
@@ -356,55 +282,10 @@ void ShaderEditor::_menu_option(int p_option) {
} break;
case EDIT_DELETE_LINE: {
-
- TextEdit *tx = shader_editor->get_text_edit();
- if (shader.is_null())
- return;
-
- tx->begin_complex_operation();
- int line = tx->cursor_get_line();
- tx->set_line(tx->cursor_get_line(), "");
- tx->backspace_at_cursor();
- tx->cursor_set_line(line);
- tx->end_complex_operation();
-
+ shader_editor->delete_lines();
} break;
case EDIT_CLONE_DOWN: {
-
- TextEdit *tx = shader_editor->get_text_edit();
- if (shader.is_null())
- return;
-
- int from_line = tx->cursor_get_line();
- int to_line = tx->cursor_get_line();
- int column = tx->cursor_get_column();
-
- if (tx->is_selection_active()) {
- from_line = tx->get_selection_from_line();
- to_line = tx->get_selection_to_line();
- column = tx->cursor_get_column();
- }
- int next_line = to_line + 1;
-
- tx->begin_complex_operation();
- for (int i = from_line; i <= to_line; i++) {
-
- if (i >= tx->get_line_count() - 1) {
- tx->set_line(i, tx->get_line(i) + "\n");
- }
- String line_clone = tx->get_line(i);
- tx->insert_at(line_clone, next_line);
- next_line++;
- }
-
- tx->cursor_set_column(column);
- if (tx->is_selection_active()) {
- tx->select(to_line + 1, tx->get_selection_from_column(), next_line - 1, tx->get_selection_to_column());
- }
-
- tx->end_complex_operation();
- tx->update();
-
+ shader_editor->code_lines_down();
} break;
case EDIT_TOGGLE_COMMENT: {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 37b8562e96..f0c874a150 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -4641,9 +4641,7 @@ void SpatialEditor::_init_grid() {
Vector3 p2_dest = p2 * (-axis_n1 + axis_n2);
Color line_color = secondary_grid_color;
- if (j == 0) {
- continue;
- } else if (j % primary_grid_steps == 0) {
+ if (j % primary_grid_steps == 0) {
line_color = primary_grid_color;
}
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 637926a913..af882f6e05 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -60,6 +60,7 @@ public:
virtual Variant get_handle_value(int p_idx) const;
virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
+ virtual bool is_gizmo_handle_highlighted(int idx) const { return false; }
virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
virtual bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
new file mode 100644
index 0000000000..16c25f3074
--- /dev/null
+++ b/editor/plugins/text_editor.cpp
@@ -0,0 +1,607 @@
+/*************************************************************************/
+/* text_editor.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "text_editor.h"
+
+void TextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
+ highlighters[p_highlighter->get_name()] = p_highlighter;
+ highlighter_menu->add_radio_check_item(p_highlighter->get_name());
+}
+
+void TextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) {
+ TextEdit *te = code_editor->get_text_edit();
+ te->_set_syntax_highlighting(p_highlighter);
+ if (p_highlighter != NULL) {
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(p_highlighter->get_name()), true);
+ } else {
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text("Standard"), true);
+ }
+
+ // little work around. GDScript highlighter goes through text_edit for colours,
+ // so to remove all colours we need to set and unset them here.
+ if (p_highlighter == NULL) { // standard
+ TextEdit *text_edit = code_editor->get_text_edit();
+ text_edit->add_color_override("number_color", colors_cache.font_color);
+ text_edit->add_color_override("function_color", colors_cache.font_color);
+ text_edit->add_color_override("number_color", colors_cache.font_color);
+ text_edit->add_color_override("member_variable_color", colors_cache.font_color);
+ } else {
+ _load_theme_settings();
+ }
+}
+
+void TextEditor::_change_syntax_highlighter(int p_idx) {
+ Map<String, SyntaxHighlighter *>::Element *el = highlighters.front();
+ while (el != NULL) {
+ highlighter_menu->set_item_checked(highlighter_menu->get_item_idx_from_text(el->key()), false);
+ el = el->next();
+ }
+ set_syntax_highlighter(highlighters[highlighter_menu->get_item_text(p_idx)]);
+}
+
+void TextEditor::_load_theme_settings() {
+
+ TextEdit *text_edit = code_editor->get_text_edit();
+ text_edit->clear_colors();
+
+ Color background_color = EDITOR_GET("text_editor/highlighting/background_color");
+ Color completion_background_color = EDITOR_GET("text_editor/highlighting/completion_background_color");
+ Color completion_selected_color = EDITOR_GET("text_editor/highlighting/completion_selected_color");
+ Color completion_existing_color = EDITOR_GET("text_editor/highlighting/completion_existing_color");
+ Color completion_scroll_color = EDITOR_GET("text_editor/highlighting/completion_scroll_color");
+ Color completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
+ Color text_color = EDITOR_GET("text_editor/highlighting/text_color");
+ Color line_number_color = EDITOR_GET("text_editor/highlighting/line_number_color");
+ Color caret_color = EDITOR_GET("text_editor/highlighting/caret_color");
+ Color caret_background_color = EDITOR_GET("text_editor/highlighting/caret_background_color");
+ Color text_selected_color = EDITOR_GET("text_editor/highlighting/text_selected_color");
+ Color selection_color = EDITOR_GET("text_editor/highlighting/selection_color");
+ Color brace_mismatch_color = EDITOR_GET("text_editor/highlighting/brace_mismatch_color");
+ Color current_line_color = EDITOR_GET("text_editor/highlighting/current_line_color");
+ Color line_length_guideline_color = EDITOR_GET("text_editor/highlighting/line_length_guideline_color");
+ Color word_highlighted_color = EDITOR_GET("text_editor/highlighting/word_highlighted_color");
+ Color number_color = EDITOR_GET("text_editor/highlighting/number_color");
+ Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
+ Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
+ Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
+ Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
+ Color search_result_color = EDITOR_GET("text_editor/highlighting/search_result_color");
+ Color search_result_border_color = EDITOR_GET("text_editor/highlighting/search_result_border_color");
+ Color symbol_color = EDITOR_GET("text_editor/highlighting/symbol_color");
+ Color keyword_color = EDITOR_GET("text_editor/highlighting/keyword_color");
+ Color basetype_color = EDITOR_GET("text_editor/highlighting/base_type_color");
+ Color type_color = EDITOR_GET("text_editor/highlighting/engine_type_color");
+ Color comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
+ Color string_color = EDITOR_GET("text_editor/highlighting/string_color");
+
+ text_edit->add_color_override("background_color", background_color);
+ text_edit->add_color_override("completion_background_color", completion_background_color);
+ text_edit->add_color_override("completion_selected_color", completion_selected_color);
+ text_edit->add_color_override("completion_existing_color", completion_existing_color);
+ text_edit->add_color_override("completion_scroll_color", completion_scroll_color);
+ text_edit->add_color_override("completion_font_color", completion_font_color);
+ text_edit->add_color_override("font_color", text_color);
+ text_edit->add_color_override("line_number_color", line_number_color);
+ text_edit->add_color_override("caret_color", caret_color);
+ text_edit->add_color_override("caret_background_color", caret_background_color);
+ text_edit->add_color_override("font_selected_color", text_selected_color);
+ text_edit->add_color_override("selection_color", selection_color);
+ text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color);
+ text_edit->add_color_override("current_line_color", current_line_color);
+ text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color);
+ text_edit->add_color_override("word_highlighted_color", word_highlighted_color);
+ text_edit->add_color_override("number_color", number_color);
+ text_edit->add_color_override("function_color", function_color);
+ text_edit->add_color_override("member_variable_color", member_variable_color);
+ text_edit->add_color_override("breakpoint_color", breakpoint_color);
+ text_edit->add_color_override("mark_color", mark_color);
+ text_edit->add_color_override("code_folding_color", code_folding_color);
+ text_edit->add_color_override("search_result_color", search_result_color);
+ text_edit->add_color_override("search_result_border_color", search_result_border_color);
+ text_edit->add_color_override("symbol_color", symbol_color);
+
+ text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4));
+
+ colors_cache.font_color = text_color;
+ colors_cache.symbol_color = symbol_color;
+ colors_cache.keyword_color = keyword_color;
+ colors_cache.basetype_color = basetype_color;
+ colors_cache.type_color = type_color;
+ colors_cache.comment_color = comment_color;
+ colors_cache.string_color = string_color;
+}
+
+String TextEditor::get_name() {
+ String name;
+
+ if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) {
+ name = text_file->get_path().get_file();
+ if (is_unsaved()) {
+ name += "(*)";
+ }
+ } else if (text_file->get_name() != "") {
+ name = text_file->get_name();
+ } else {
+ name = text_file->get_class() + "(" + itos(text_file->get_instance_id()) + ")";
+ }
+
+ return name;
+}
+
+Ref<Texture> TextEditor::get_icon() {
+
+ if (get_parent_control() && get_parent_control()->has_icon(text_file->get_class(), "EditorIcons")) {
+ return get_parent_control()->get_icon(text_file->get_class(), "EditorIcons");
+ }
+ return Ref<Texture>();
+}
+
+RES TextEditor::get_edited_resource() const {
+ return text_file;
+}
+
+void TextEditor::set_edited_resource(const RES &p_res) {
+ ERR_FAIL_COND(!text_file.is_null());
+
+ text_file = p_res;
+
+ code_editor->get_text_edit()->set_text(text_file->get_text());
+ code_editor->get_text_edit()->clear_undo_history();
+ code_editor->get_text_edit()->tag_saved_version();
+
+ emit_signal("name_changed");
+ code_editor->update_line_and_column();
+}
+
+void TextEditor::add_callback(const String &p_function, PoolStringArray p_args) {
+}
+
+void TextEditor::set_debugger_active(bool p_active) {
+}
+
+void TextEditor::get_breakpoints(List<int> *p_breakpoints) {
+}
+
+void TextEditor::reload_text() {
+
+ ERR_FAIL_COND(text_file.is_null());
+
+ TextEdit *te = code_editor->get_text_edit();
+ int column = te->cursor_get_column();
+ int row = te->cursor_get_line();
+ int h = te->get_h_scroll();
+ int v = te->get_v_scroll();
+
+ te->set_text(text_file->get_text());
+ te->clear_undo_history();
+ te->cursor_set_line(row);
+ te->cursor_set_column(column);
+ te->set_h_scroll(h);
+ te->set_v_scroll(v);
+
+ te->tag_saved_version();
+
+ code_editor->update_line_and_column();
+}
+
+void TextEditor::_validate_script() {
+ emit_signal("name_changed");
+ emit_signal("edited_script_changed");
+}
+
+void TextEditor::apply_code() {
+ text_file->set_text(code_editor->get_text_edit()->get_text());
+}
+
+bool TextEditor::is_unsaved() {
+
+ return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version();
+}
+
+Variant TextEditor::get_edit_state() {
+
+ return code_editor->get_edit_state();
+}
+
+void TextEditor::set_edit_state(const Variant &p_state) {
+
+ code_editor->set_edit_state(p_state);
+}
+
+void TextEditor::trim_trailing_whitespace() {
+
+ code_editor->trim_trailing_whitespace();
+}
+
+void TextEditor::convert_indent_to_spaces() {
+
+ code_editor->convert_indent_to_spaces();
+}
+
+void TextEditor::convert_indent_to_tabs() {
+
+ code_editor->convert_indent_to_tabs();
+}
+
+void TextEditor::tag_saved_version() {
+
+ code_editor->get_text_edit()->tag_saved_version();
+}
+
+void TextEditor::goto_line(int p_line, bool p_with_error) {
+
+ code_editor->goto_line(p_line);
+}
+
+void TextEditor::ensure_focus() {
+
+ code_editor->get_text_edit()->grab_focus();
+}
+
+Vector<String> TextEditor::get_functions() {
+
+ return Vector<String>();
+}
+
+bool TextEditor::show_members_overview() {
+ return true;
+}
+
+void TextEditor::update_settings() {
+
+ code_editor->update_editor_settings();
+}
+
+void TextEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
+
+ code_editor->get_text_edit()->set_tooltip_request_func(p_obj, p_method, this);
+}
+
+Control *TextEditor::get_edit_menu() {
+
+ return edit_hb;
+}
+
+void TextEditor::clear_edit_menu() {
+ memdelete(edit_hb);
+}
+
+void TextEditor::_notification(int p_what) {
+
+ switch (p_what) {
+ case NOTIFICATION_READY:
+ _load_theme_settings();
+ set_syntax_highlighter(NULL);
+ break;
+ }
+}
+
+void TextEditor::_edit_option(int p_op) {
+ TextEdit *tx = code_editor->get_text_edit();
+
+ switch (p_op) {
+ case EDIT_UNDO: {
+
+ tx->undo();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_REDO: {
+
+ tx->redo();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_CUT: {
+
+ tx->cut();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_COPY: {
+
+ tx->copy();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_PASTE: {
+
+ tx->paste();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_SELECT_ALL: {
+
+ tx->select_all();
+ tx->call_deferred("grab_focus");
+ } break;
+ case EDIT_MOVE_LINE_UP: {
+
+ code_editor->move_lines_up();
+ } break;
+ case EDIT_MOVE_LINE_DOWN: {
+
+ code_editor->move_lines_down();
+ } break;
+ case EDIT_INDENT_LEFT: {
+
+ tx->indent_left();
+ } break;
+ case EDIT_INDENT_RIGHT: {
+
+ tx->indent_right();
+ } break;
+ case EDIT_DELETE_LINE: {
+
+ code_editor->delete_lines();
+ } break;
+ case EDIT_CLONE_DOWN: {
+
+ code_editor->code_lines_down();
+ } break;
+ case EDIT_TOGGLE_FOLD_LINE: {
+
+ tx->toggle_fold_line(tx->cursor_get_line());
+ tx->update();
+ } break;
+ case EDIT_FOLD_ALL_LINES: {
+
+ tx->fold_all_lines();
+ tx->update();
+ } break;
+ case EDIT_UNFOLD_ALL_LINES: {
+
+ tx->unhide_all_lines();
+ tx->update();
+ } break;
+ case EDIT_TRIM_TRAILING_WHITESAPCE: {
+
+ trim_trailing_whitespace();
+ } break;
+ case EDIT_CONVERT_INDENT_TO_SPACES: {
+
+ convert_indent_to_spaces();
+ } break;
+ case EDIT_CONVERT_INDENT_TO_TABS: {
+
+ convert_indent_to_tabs();
+ } break;
+ case EDIT_TO_UPPERCASE: {
+
+ _convert_case(CodeTextEditor::UPPER);
+ } break;
+ case EDIT_TO_LOWERCASE: {
+
+ _convert_case(CodeTextEditor::LOWER);
+ } break;
+ case EDIT_CAPITALIZE: {
+
+ _convert_case(CodeTextEditor::CAPITALIZE);
+ } break;
+ case SEARCH_FIND: {
+
+ code_editor->get_find_replace_bar()->popup_search();
+ } break;
+ case SEARCH_FIND_NEXT: {
+
+ code_editor->get_find_replace_bar()->search_next();
+ } break;
+ case SEARCH_FIND_PREV: {
+
+ code_editor->get_find_replace_bar()->search_prev();
+ } break;
+ case SEARCH_REPLACE: {
+
+ code_editor->get_find_replace_bar()->popup_replace();
+ } break;
+ case SEARCH_GOTO_LINE: {
+
+ goto_line_dialog->popup_find_line(tx);
+ } break;
+ }
+}
+
+void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) {
+
+ code_editor->convert_case(p_case);
+}
+
+void TextEditor::_bind_methods() {
+
+ ClassDB::bind_method("_validate_script", &TextEditor::_validate_script);
+ ClassDB::bind_method("_load_theme_settings", &TextEditor::_load_theme_settings);
+ ClassDB::bind_method("_edit_option", &TextEditor::_edit_option);
+ ClassDB::bind_method("_change_syntax_highlighter", &TextEditor::_change_syntax_highlighter);
+ ClassDB::bind_method("_text_edit_gui_input", &TextEditor::_text_edit_gui_input);
+}
+
+static ScriptEditorBase *create_editor(const RES &p_resource) {
+
+ if (Object::cast_to<TextFile>(*p_resource)) {
+ return memnew(TextEditor);
+ }
+ return NULL;
+}
+
+void TextEditor::register_editor() {
+
+ ScriptEditor::register_create_script_editor_function(create_editor);
+}
+
+void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
+
+ Ref<InputEventMouseButton> mb = ev;
+
+ if (mb.is_valid()) {
+ if (mb->get_button_index() == BUTTON_RIGHT) {
+
+ int col, row;
+ TextEdit *tx = code_editor->get_text_edit();
+ tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col);
+
+ tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret"));
+ bool can_fold = tx->can_fold(row);
+ bool is_folded = tx->is_folded(row);
+
+ if (tx->is_right_click_moving_caret()) {
+ if (tx->is_selection_active()) {
+
+ int from_line = tx->get_selection_from_line();
+ int to_line = tx->get_selection_to_line();
+ int from_column = tx->get_selection_from_column();
+ int to_column = tx->get_selection_to_column();
+
+ if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
+ // Right click is outside the seleted text
+ tx->deselect();
+ }
+ }
+ if (!tx->is_selection_active()) {
+ tx->cursor_set_line(row, true, false);
+ tx->cursor_set_column(col);
+ }
+ }
+
+ if (!mb->is_pressed()) {
+ _make_context_menu(tx->is_selection_active(), can_fold, is_folded);
+ }
+ }
+ }
+}
+
+void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded) {
+
+ context_menu->clear();
+ if (p_selection) {
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY);
+ }
+
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE);
+ context_menu->add_separator();
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
+ context_menu->add_separator();
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT);
+
+ if (p_selection) {
+ context_menu->add_separator();
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_uppercase"), EDIT_TO_UPPERCASE);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE);
+ }
+ if (p_can_fold || p_is_folded)
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE);
+
+ context_menu->set_position(get_global_transform().xform(get_local_mouse_position()));
+ context_menu->set_size(Vector2(1, 1));
+ context_menu->popup();
+}
+
+TextEditor::TextEditor() {
+ code_editor = memnew(CodeTextEditor);
+ add_child(code_editor);
+ code_editor->add_constant_override("separation", 0);
+ code_editor->connect("load_theme_settings", this, "_load_theme_settings");
+ code_editor->connect("validate_script", this, "_validate_script");
+ code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+
+ update_settings();
+
+ code_editor->get_text_edit()->set_context_menu_enabled(false);
+ code_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input");
+
+ context_menu = memnew(PopupMenu);
+ add_child(context_menu);
+ context_menu->connect("id_pressed", this, "_edit_option");
+
+ edit_hb = memnew(HBoxContainer);
+
+ search_menu = memnew(MenuButton);
+ edit_hb->add_child(search_menu);
+ search_menu->set_text(TTR("Search"));
+ search_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND);
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV);
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE);
+ search_menu->get_popup()->add_separator();
+ search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
+
+ goto_line_dialog = memnew(GotoLineDialog);
+ add_child(goto_line_dialog);
+
+ edit_menu = memnew(MenuButton);
+ edit_menu->set_text(TTR("Edit"));
+ edit_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+
+ edit_hb->add_child(edit_menu);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
+ edit_menu->get_popup()->add_separator();
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE);
+ edit_menu->get_popup()->add_separator();
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL);
+ edit_menu->get_popup()->add_separator();
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES);
+ edit_menu->get_popup()->add_separator();
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
+ edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
+
+ edit_menu->get_popup()->add_separator();
+ PopupMenu *convert_case = memnew(PopupMenu);
+ convert_case->set_name("convert_case");
+ edit_menu->get_popup()->add_child(convert_case);
+ edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case");
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE);
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE);
+ convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE);
+ convert_case->connect("id_pressed", this, "_edit_option");
+
+ highlighters["Standard"] = NULL;
+ highlighter_menu = memnew(PopupMenu);
+ highlighter_menu->set_name("highlighter_menu");
+ edit_menu->get_popup()->add_child(highlighter_menu);
+ edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu");
+ highlighter_menu->add_radio_check_item(TTR("Standard"));
+ highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
+
+ code_editor->get_text_edit()->set_drag_forwarding(this);
+}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
new file mode 100644
index 0000000000..8b1983d891
--- /dev/null
+++ b/editor/plugins/text_editor.h
@@ -0,0 +1,146 @@
+/*************************************************************************/
+/* text_editor.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef TEXT_EDITOR_H
+#define TEXT_EDITOR_H
+
+#include "script_editor_plugin.h"
+
+class TextEditor : public ScriptEditorBase {
+
+ GDCLASS(TextEditor, ScriptEditorBase)
+
+private:
+ CodeTextEditor *code_editor;
+
+ Ref<TextFile> text_file;
+
+ HBoxContainer *edit_hb;
+ MenuButton *edit_menu;
+ PopupMenu *highlighter_menu;
+ MenuButton *search_menu;
+ PopupMenu *context_menu;
+
+ GotoLineDialog *goto_line_dialog;
+
+ struct ColorsCache {
+ Color font_color;
+ Color symbol_color;
+ Color keyword_color;
+ Color basetype_color;
+ Color type_color;
+ Color comment_color;
+ Color string_color;
+ } colors_cache;
+
+ enum {
+ EDIT_UNDO,
+ EDIT_REDO,
+ EDIT_CUT,
+ EDIT_COPY,
+ EDIT_PASTE,
+ EDIT_SELECT_ALL,
+ EDIT_TRIM_TRAILING_WHITESAPCE,
+ EDIT_CONVERT_INDENT_TO_SPACES,
+ EDIT_CONVERT_INDENT_TO_TABS,
+ EDIT_MOVE_LINE_UP,
+ EDIT_MOVE_LINE_DOWN,
+ EDIT_INDENT_RIGHT,
+ EDIT_INDENT_LEFT,
+ EDIT_DELETE_LINE,
+ EDIT_CLONE_DOWN,
+ EDIT_TO_UPPERCASE,
+ EDIT_TO_LOWERCASE,
+ EDIT_CAPITALIZE,
+ EDIT_TOGGLE_FOLD_LINE,
+ EDIT_FOLD_ALL_LINES,
+ EDIT_UNFOLD_ALL_LINES,
+ SEARCH_FIND,
+ SEARCH_FIND_NEXT,
+ SEARCH_FIND_PREV,
+ SEARCH_REPLACE,
+ SEARCH_GOTO_LINE,
+ };
+
+protected:
+ static void _bind_methods();
+
+ void _notification(int p_what);
+
+ void _edit_option(int p_op);
+ void _make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded);
+ void _text_edit_gui_input(const Ref<InputEvent> &ev);
+
+ Map<String, SyntaxHighlighter *> highlighters;
+ void _change_syntax_highlighter(int p_idx);
+ void _load_theme_settings();
+
+ void _convert_case(CodeTextEditor::CaseStyle p_case);
+
+ void _validate_script();
+
+public:
+ virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter);
+ virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
+
+ virtual String get_name();
+ virtual Ref<Texture> get_icon();
+ virtual RES get_edited_resource() const;
+ virtual void set_edited_resource(const RES &p_res);
+ void set_edited_file(const Ref<TextFile> &p_file);
+ virtual void reload_text();
+ virtual void apply_code();
+ virtual bool is_unsaved();
+ virtual Variant get_edit_state();
+ virtual void set_edit_state(const Variant &p_state);
+ virtual Vector<String> get_functions();
+ virtual void get_breakpoints(List<int> *p_breakpoints);
+ virtual void goto_line(int p_line, bool p_with_error = false);
+ virtual void trim_trailing_whitespace();
+ virtual void convert_indent_to_spaces();
+ virtual void convert_indent_to_tabs();
+ virtual void ensure_focus();
+ virtual void tag_saved_version();
+ virtual void update_settings();
+ virtual bool show_members_overview();
+ virtual bool can_lose_focus_on_node_selection() { return true; }
+ virtual void set_debugger_active(bool p_active);
+ virtual void set_tooltip_request_func(String p_method, Object *p_obj);
+ virtual void add_callback(const String &p_function, PoolStringArray p_args);
+
+ virtual Control *get_edit_menu();
+ virtual void clear_edit_menu();
+
+ static void register_editor();
+
+ TextEditor();
+};
+
+#endif // TEXT_EDITOR_H
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 19646f37b5..484da3b4f3 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -526,7 +526,7 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
if (!erase) {
ids = get_selected_tiles();
- if (ids.size() == 0 && ids[0] == TileMap::INVALID_CELL)
+ if (ids.size() == 0 || ids[0] == TileMap::INVALID_CELL)
return PoolVector<Vector2>();
} else if (prev_id == TileMap::INVALID_CELL) {
return PoolVector<Vector2>();
@@ -538,9 +538,7 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era
}
}
- Rect2i r = node->_edit_get_rect();
- r.position = r.position / node->get_cell_size();
- r.size = r.size / node->get_cell_size();
+ Rect2i r = node->get_used_rect();
int area = r.get_area();
if (preview) {
@@ -1029,7 +1027,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
if (points.size() == 0)
return false;
- undo_redo->create_action(TTR("Bucket Fill"));
+ _start_undo(TTR("Bucket Fill"));
Dictionary op;
op["id"] = get_selected_tiles();
@@ -1039,7 +1037,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
_fill_points(points, op);
- undo_redo->commit_action();
+ _finish_undo();
// We want to keep the bucket-tool active
return true;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 682ca744ff..b9b8b07a2e 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -735,7 +735,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->connect("duplicate_nodes_request", this, "_duplicate_nodes");
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR);
- //graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_SCALAR);
+ graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 0d06b71420..af7c4bb379 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -72,16 +72,26 @@ private:
MESSAGE_SUCCESS
};
+ enum InputType {
+ PROJECT_PATH,
+ INSTALL_PATH
+ };
+
Mode mode;
Button *browse;
+ Button *install_browse;
Button *create_dir;
Container *name_container;
Container *path_container;
+ Container *install_path_container;
Label *msg;
LineEdit *project_path;
LineEdit *project_name;
+ LineEdit *install_path;
TextureRect *status_rect;
+ TextureRect *install_status_rect;
FileDialog *fdialog;
+ FileDialog *fdialog_install;
String zip_path;
String zip_title;
AcceptDialog *dialog_error;
@@ -89,10 +99,11 @@ private:
String created_folder_path;
- void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS) {
+ void set_message(const String &p_msg, MessageType p_type = MESSAGE_SUCCESS, InputType input_type = PROJECT_PATH) {
msg->set_text(p_msg);
- Ref<Texture> current_icon = status_rect->get_texture();
+ Ref<Texture> current_path_icon = status_rect->get_texture();
+ Ref<Texture> current_install_icon = install_status_rect->get_texture();
Ref<Texture> new_icon;
switch (p_type) {
@@ -119,8 +130,11 @@ private:
} break;
}
- if (current_icon != new_icon)
+ if (current_path_icon != new_icon && input_type == PROJECT_PATH) {
status_rect->set_texture(new_icon);
+ } else if (current_install_icon != new_icon && input_type == INSTALL_PATH) {
+ install_status_rect->set_texture(new_icon);
+ }
set_size(Size2(500, 0) * EDSCALE);
}
@@ -128,11 +142,19 @@ private:
String _test_path() {
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- String valid_path;
+ String valid_path, valid_install_path;
if (d->change_dir(project_path->get_text()) == OK) {
valid_path = project_path->get_text();
} else if (d->change_dir(project_path->get_text().strip_edges()) == OK) {
valid_path = project_path->get_text().strip_edges();
+ } else if (project_path->get_text().ends_with(".zip")) {
+ if (d->file_exists(project_path->get_text())) {
+ valid_path = project_path->get_text();
+ }
+ } else if (project_path->get_text().strip_edges().ends_with(".zip")) {
+ if (d->file_exists(project_path->get_text().strip_edges())) {
+ valid_path = project_path->get_text().strip_edges();
+ }
}
if (valid_path == "") {
@@ -142,11 +164,94 @@ private:
return "";
}
+ if (mode == MODE_IMPORT && valid_path.ends_with(".zip")) {
+ if (d->change_dir(install_path->get_text()) == OK) {
+ valid_install_path = install_path->get_text();
+ } else if (d->change_dir(install_path->get_text().strip_edges()) == OK) {
+ valid_install_path = install_path->get_text().strip_edges();
+ }
+
+ if (valid_install_path == "") {
+ set_message(TTR("The path does not exist."), MESSAGE_ERROR, INSTALL_PATH);
+ memdelete(d);
+ get_ok()->set_disabled(true);
+ return "";
+ }
+ }
+
if (mode == MODE_IMPORT || mode == MODE_RENAME) {
if (valid_path != "" && !d->file_exists("project.godot")) {
- set_message(TTR("Please choose a 'project.godot' file."), MESSAGE_ERROR);
+ if (valid_path.ends_with(".zip")) {
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ unzFile pkg = unzOpen2(valid_path.utf8().get_data(), &io);
+ if (!pkg) {
+
+ set_message(TTR("Error opening package file, not in zip format."), MESSAGE_ERROR);
+ memdelete(d);
+ get_ok()->set_disabled(true);
+ unzClose(pkg);
+ return "";
+ }
+
+ int ret = unzGoToFirstFile(pkg);
+ while (ret == UNZ_OK) {
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
+
+ if (String(fname).ends_with("project.godot")) {
+ break;
+ }
+
+ ret = unzGoToNextFile(pkg);
+ }
+
+ if (ret == UNZ_END_OF_LIST_OF_FILE) {
+ set_message(TTR("Invalid '.zip' project file, does not contain a 'project.godot' file."), MESSAGE_ERROR);
+ memdelete(d);
+ get_ok()->set_disabled(true);
+ unzClose(pkg);
+ return "";
+ }
+
+ unzClose(pkg);
+
+ // check if the specified install folder is empty, even though this is not an error, it is good to check here
+ d->list_dir_begin();
+ bool is_empty = true;
+ String n = d->get_next();
+ while (n != String()) {
+ if (n != "." && n != "..") {
+ is_empty = false;
+ break;
+ }
+ n = d->get_next();
+ }
+ d->list_dir_end();
+
+ if (!is_empty) {
+
+ set_message(TTR("Please choose an empty folder."), MESSAGE_WARNING, INSTALL_PATH);
+ memdelete(d);
+ get_ok()->set_disabled(true);
+ return "";
+ }
+
+ } else {
+ set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR);
+ memdelete(d);
+ install_path_container->hide();
+ get_ok()->set_disabled(true);
+ return "";
+ }
+
+ } else if (valid_path.ends_with("zip")) {
+
+ set_message(TTR("Directory already contains a Godot project."), MESSAGE_ERROR, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(true);
return "";
@@ -159,7 +264,7 @@ private:
bool is_empty = true;
String n = d->get_next();
while (n != String()) {
- if (!n.begins_with(".")) { // i don't know if this is enough to guarantee an empty dir
+ if (n != "." && n != "..") { // i don't know if this is enough to guarantee an empty dir
is_empty = false;
break;
}
@@ -177,6 +282,7 @@ private:
}
set_message("");
+ set_message("", MESSAGE_SUCCESS, INSTALL_PATH);
memdelete(d);
get_ok()->set_disabled(false);
return valid_path;
@@ -214,9 +320,14 @@ private:
if (mode == MODE_IMPORT) {
if (p.ends_with("project.godot")) {
p = p.get_base_dir();
+ install_path_container->hide();
+ get_ok()->set_disabled(false);
+ } else if (p.ends_with(".zip")) {
+ install_path->set_text(p.get_base_dir());
+ install_path_container->show();
get_ok()->set_disabled(false);
} else {
- set_message(TTR("Please choose a 'project.godot' file."), MESSAGE_ERROR);
+ set_message(TTR("Please choose a 'project.godot' or '.zip' file."), MESSAGE_ERROR);
get_ok()->set_disabled(true);
return;
}
@@ -224,7 +335,11 @@ private:
String sp = p.simplify_path();
project_path->set_text(sp);
_path_text_changed(sp);
- get_ok()->call_deferred("grab_focus");
+ if (p.ends_with(".zip")) {
+ install_path->call_deferred("grab_focus");
+ } else {
+ get_ok()->call_deferred("grab_focus");
+ }
}
void _path_selected(const String &p_path) {
@@ -236,6 +351,14 @@ private:
get_ok()->call_deferred("grab_focus");
}
+ void _install_path_selected(const String &p_path) {
+ String p = p_path;
+ String sp = p.simplify_path();
+ install_path->set_text(sp);
+ _path_text_changed(sp);
+ get_ok()->call_deferred("grab_focus");
+ }
+
void _browse_path() {
fdialog->set_current_dir(project_path->get_text());
@@ -245,12 +368,19 @@ private:
fdialog->set_mode(FileDialog::MODE_OPEN_FILE);
fdialog->clear_filters();
fdialog->add_filter("project.godot ; " VERSION_NAME " Project");
+ fdialog->add_filter("*.zip ; Zip File");
} else {
fdialog->set_mode(FileDialog::MODE_OPEN_DIR);
}
fdialog->popup_centered_ratio();
}
+ void _browse_install_path() {
+ fdialog_install->set_current_dir(install_path->get_text());
+ fdialog_install->set_mode(FileDialog::MODE_OPEN_DIR);
+ fdialog_install->popup_centered_ratio();
+ }
+
void _create_folder() {
if (project_name->get_text() == "" || created_folder_path != "" || project_name->get_text().ends_with(".") || project_name->get_text().ends_with(" ")) {
@@ -328,7 +458,15 @@ private:
} else {
if (mode == MODE_IMPORT) {
- // nothing to do
+
+ if (project_path->get_text().ends_with(".zip")) {
+
+ mode = MODE_INSTALL;
+ ok_pressed();
+
+ return;
+ }
+
} else {
if (mode == MODE_NEW) {
@@ -357,6 +495,11 @@ private:
} else if (mode == MODE_INSTALL) {
+ if (project_path->get_text().ends_with(".zip")) {
+ dir = install_path->get_text();
+ zip_path = project_path->get_text();
+ }
+
FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
@@ -444,7 +587,7 @@ private:
dialog_error->set_text(msg);
dialog_error->popup_centered_minsize();
- } else {
+ } else if (!project_path->get_text().ends_with(".zip")) {
dialog_error->set_text(TTR("Package Installed Successfully!"));
dialog_error->popup_centered_minsize();
}
@@ -486,6 +629,9 @@ private:
if (status_rect->get_texture() == get_icon("StatusError", "EditorIcons"))
msg->show();
+
+ if (install_status_rect->get_texture() == get_icon("StatusError", "EditorIcons"))
+ msg->show();
}
void _notification(int p_what) {
@@ -503,6 +649,8 @@ protected:
ClassDB::bind_method("_path_text_changed", &ProjectDialog::_path_text_changed);
ClassDB::bind_method("_path_selected", &ProjectDialog::_path_selected);
ClassDB::bind_method("_file_selected", &ProjectDialog::_file_selected);
+ ClassDB::bind_method("_install_path_selected", &ProjectDialog::_install_path_selected);
+ ClassDB::bind_method("_browse_install_path", &ProjectDialog::_browse_install_path);
ADD_SIGNAL(MethodInfo("project_created"));
ADD_SIGNAL(MethodInfo("project_renamed"));
}
@@ -530,12 +678,15 @@ public:
project_path->set_editable(false);
browse->hide();
+ install_browse->hide();
set_title(TTR("Rename Project"));
get_ok()->set_text(TTR("Rename"));
name_container->show();
status_rect->hide();
msg->hide();
+ install_path_container->hide();
+ install_status_rect->hide();
get_ok()->set_disabled(false);
ProjectSettings *current = memnew(ProjectSettings);
@@ -575,14 +726,18 @@ public:
project_path->set_editable(true);
browse->set_disabled(false);
browse->show();
+ install_browse->set_disabled(false);
+ install_browse->show();
create_dir->show();
status_rect->show();
+ install_status_rect->show();
msg->show();
if (mode == MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
get_ok()->set_text(TTR("Import & Edit"));
name_container->hide();
+ install_path_container->hide();
project_path->grab_focus();
} else if (mode == MODE_NEW) {
@@ -590,6 +745,7 @@ public:
set_title(TTR("Create New Project"));
get_ok()->set_text(TTR("Create & Edit"));
name_container->show();
+ install_path_container->hide();
project_name->grab_focus();
} else if (mode == MODE_INSTALL) {
@@ -597,6 +753,7 @@ public:
set_title(TTR("Install Project:") + " " + zip_title);
get_ok()->set_text(TTR("Install & Edit"));
name_container->hide();
+ install_path_container->hide();
project_path->grab_focus();
}
@@ -644,6 +801,20 @@ public:
project_path->set_h_size_flags(SIZE_EXPAND_FILL);
pphb->add_child(project_path);
+ install_path_container = memnew(VBoxContainer);
+ vb->add_child(install_path_container);
+
+ l = memnew(Label);
+ l->set_text(TTR("Project Installation Path:"));
+ install_path_container->add_child(l);
+
+ HBoxContainer *iphb = memnew(HBoxContainer);
+ install_path_container->add_child(iphb);
+
+ install_path = memnew(LineEdit);
+ install_path->set_h_size_flags(SIZE_EXPAND_FILL);
+ iphb->add_child(install_path);
+
// status icon
status_rect = memnew(TextureRect);
status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
@@ -654,17 +825,33 @@ public:
browse->connect("pressed", this, "_browse_path");
pphb->add_child(browse);
+ // install status icon
+ install_status_rect = memnew(TextureRect);
+ install_status_rect->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED);
+ iphb->add_child(install_status_rect);
+
+ install_browse = memnew(Button);
+ install_browse->set_text(TTR("Browse"));
+ install_browse->connect("pressed", this, "_browse_install_path");
+ iphb->add_child(install_browse);
+
msg = memnew(Label);
msg->set_align(Label::ALIGN_CENTER);
vb->add_child(msg);
fdialog = memnew(FileDialog);
fdialog->set_access(FileDialog::ACCESS_FILESYSTEM);
+ fdialog_install = memnew(FileDialog);
+ fdialog_install->set_access(FileDialog::ACCESS_FILESYSTEM);
add_child(fdialog);
+ add_child(fdialog_install);
project_name->connect("text_changed", this, "_text_changed");
project_path->connect("text_changed", this, "_path_text_changed");
+ install_path->connect("text_changed", this, "_path_text_changed");
fdialog->connect("dir_selected", this, "_path_selected");
fdialog->connect("file_selected", this, "_file_selected");
+ fdialog_install->connect("dir_selected", this, "_install_path_selected");
+ fdialog_install->connect("file_selected", this, "_install_path_selected");
set_hide_on_ok(false);
mode = MODE_NEW;
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 7e4e589bb4..e6ae2d64e7 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -106,6 +106,12 @@ void ProjectSettingsEditor::_notification(int p_what) {
translation_res_file_open->add_filter("*." + E->get());
translation_res_option_file_open->add_filter("*." + E->get());
}
+
+ restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
+ restart_container->add_style_override("panel", get_stylebox("bg", "Tree"));
+ restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons"));
+ restart_label->add_color_override("font_color", get_color("error_color", "Editor"));
+
} break;
case NOTIFICATION_POPUP_HIDE: {
EditorSettings::get_singleton()->set("interface/dialogs/project_settings_bounds", get_rect());
@@ -800,15 +806,13 @@ void ProjectSettingsEditor::popup_project_settings() {
plugin_settings->update_plugins();
}
-void ProjectSettingsEditor::_item_selected() {
+void ProjectSettingsEditor::_item_selected(const String &p_path) {
- TreeItem *ti = globals_editor->get_property_editor()->get_property_tree()->get_selected();
- if (!ti)
- return;
- if (!ti->get_parent())
+ String selected_path = p_path;
+ if (selected_path == String())
return;
category->set_text(globals_editor->get_current_section());
- property->set_text(ti->get_text(0));
+ property->set_text(selected_path);
popup_copy_to_feature->set_disabled(false);
}
@@ -865,7 +869,7 @@ void ProjectSettingsEditor::_item_add() {
void ProjectSettingsEditor::_item_del() {
- String path = globals_editor->get_property_editor()->get_selected_path();
+ String path = globals_editor->get_inspector()->get_selected_path();
if (path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
return;
@@ -1043,7 +1047,7 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
void ProjectSettingsEditor::_copy_to_platform(int p_which) {
- String path = globals_editor->get_property_editor()->get_selected_path();
+ String path = globals_editor->get_inspector()->get_selected_path();
if (path == String()) {
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
return;
@@ -1572,7 +1576,7 @@ void ProjectSettingsEditor::_update_translations() {
void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
- globals_editor->get_property_editor()->set_use_filter(p_pressed);
+ globals_editor->get_inspector()->set_use_filter(p_pressed);
if (p_pressed) {
@@ -1593,7 +1597,7 @@ void ProjectSettingsEditor::_clear_search_box() {
return;
search_box->clear();
- globals_editor->get_property_editor()->update_tree();
+ globals_editor->get_inspector()->update_tree();
}
void ProjectSettingsEditor::set_plugins_page() {
@@ -1606,6 +1610,18 @@ TabContainer *ProjectSettingsEditor::get_tabs() {
return tab_container;
}
+void ProjectSettingsEditor::_editor_restart() {
+ EditorNode::get_singleton()->save_all_scenes_and_restart();
+}
+
+void ProjectSettingsEditor::_editor_restart_request() {
+ restart_container->show();
+}
+
+void ProjectSettingsEditor::_editor_restart_close() {
+ restart_container->hide();
+}
+
void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected);
@@ -1651,6 +1667,10 @@ void ProjectSettingsEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show);
+ ClassDB::bind_method(D_METHOD("_editor_restart_request"), &ProjectSettingsEditor::_editor_restart_request);
+ ClassDB::bind_method(D_METHOD("_editor_restart"), &ProjectSettingsEditor::_editor_restart);
+ ClassDB::bind_method(D_METHOD("_editor_restart_close"), &ProjectSettingsEditor::_editor_restart_close);
+
ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs);
}
@@ -1737,16 +1757,17 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
search_bar->add_child(clear_button);
clear_button->connect("pressed", this, "_clear_search_box");
- globals_editor = memnew(SectionedPropertyEditor);
+ globals_editor = memnew(SectionedInspector);
props_base->add_child(globals_editor);
- globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
- globals_editor->get_property_editor()->set_property_selectable(true);
+ globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
+ globals_editor->get_inspector()->set_property_selectable(true);
//globals_editor->hide_top_label();
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
globals_editor->register_search_box(search_box);
- globals_editor->get_property_editor()->get_property_tree()->connect("cell_selected", this, "_item_selected");
- globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
- globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited");
+ globals_editor->get_inspector()->connect("property_selected", this, "_item_selected");
+ //globals_editor->get_inspector()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED);
+ globals_editor->get_inspector()->connect("property_edited", this, "_settings_prop_edited");
+ globals_editor->get_inspector()->connect("restart_requested", this, "_editor_restart_request");
Button *del = memnew(Button);
hbc->add_child(del);
@@ -1766,6 +1787,26 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
+ restart_container = memnew(PanelContainer);
+ props_base->add_child(restart_container);
+ HBoxContainer *restart_hb = memnew(HBoxContainer);
+ restart_container->add_child(restart_hb);
+ restart_icon = memnew(TextureRect);
+ restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
+ restart_hb->add_child(restart_icon);
+ restart_label = memnew(Label);
+ restart_label->set_text(TTR("Editor must be restarted for changes to take effect"));
+ restart_hb->add_child(restart_label);
+ restart_hb->add_spacer();
+ Button *restart_button = memnew(Button);
+ restart_button->connect("pressed", this, "_editor_restart");
+ restart_hb->add_child(restart_button);
+ restart_button->set_text(TTR("Save & Restart"));
+ restart_close_button = memnew(ToolButton);
+ restart_close_button->connect("pressed", this, "_editor_restart_close");
+ restart_hb->add_child(restart_close_button);
+ restart_container->hide();
+
message = memnew(AcceptDialog);
add_child(message);
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 0ced88d7f6..3b74ae1909 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -35,7 +35,7 @@
#include "editor/editor_autoload_settings.h"
#include "editor/editor_data.h"
#include "editor/editor_plugin_settings.h"
-#include "editor/property_editor.h"
+#include "editor/editor_sectioned_inspector.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/tab_container.h"
@@ -64,7 +64,7 @@ class ProjectSettingsEditor : public AcceptDialog {
EditorData *data;
UndoRedo *undo_redo;
- SectionedPropertyEditor *globals_editor;
+ SectionedInspector *globals_editor;
HBoxContainer *search_bar;
Button *search_button;
@@ -112,7 +112,7 @@ class ProjectSettingsEditor : public AcceptDialog {
EditorPluginSettings *plugin_settings;
- void _item_selected();
+ void _item_selected(const String &);
void _item_adds(String);
void _item_add();
void _item_del();
@@ -166,6 +166,15 @@ class ProjectSettingsEditor : public AcceptDialog {
static ProjectSettingsEditor *singleton;
+ Label *restart_label;
+ TextureRect *restart_icon;
+ PanelContainer *restart_container;
+ ToolButton *restart_close_button;
+
+ void _editor_restart_request();
+ void _editor_restart();
+ void _editor_restart_close();
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 7f46844f6c..576227344b 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -4394,7 +4394,7 @@ PropertyEditor::PropertyEditor() {
use_filter = false;
subsection_selectable = false;
property_selectable = false;
- show_type_icons = EDITOR_DEF("interface/editor/show_type_icons", false);
+ show_type_icons = false; // TODO: need to reimplement it to work with the new inspector
}
PropertyEditor::~PropertyEditor() {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 2ffaa0ca12..8d38bf39b5 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -724,7 +724,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
}
}
} break;
- case TOOL_SCENE_CLEAR_INSTANCING: {
+ case TOOL_SCENE_MAKE_LOCAL: {
List<Node *> selection = editor_selection->get_selected_node_list();
List<Node *>::Element *e = selection.front();
if (e) {
@@ -736,7 +736,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
break;
ERR_FAIL_COND(node->get_filename() == String());
- undo_redo->create_action(TTR("Discard Instancing"));
+ undo_redo->create_action(TTR("Make Local"));
undo_redo->add_do_method(node, "set_filename", "");
undo_redo->add_undo_method(node, "set_filename", node->get_filename());
_node_replace_owner(node, node, root);
@@ -2028,7 +2028,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
bool placeholder = selection[0]->get_scene_instance_load_placeholder();
menu->add_check_item(TTR("Editable Children"), TOOL_SCENE_EDITABLE_CHILDREN);
menu->add_check_item(TTR("Load As Placeholder"), TOOL_SCENE_USE_PLACEHOLDER);
- menu->add_item(TTR("Discard Instancing"), TOOL_SCENE_CLEAR_INSTANCING);
+ menu->add_item(TTR("Make Local"), TOOL_SCENE_MAKE_LOCAL);
menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Open in Editor"), TOOL_SCENE_OPEN);
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Editable Children")), editable);
menu->set_item_checked(menu->get_item_idx_from_text(TTR("Load As Placeholder")), placeholder);
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index fd74611bde..57f4759747 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -77,7 +77,7 @@ class SceneTreeDock : public VBoxContainer {
TOOL_BUTTON_MAX,
TOOL_SCENE_EDITABLE_CHILDREN,
TOOL_SCENE_USE_PLACEHOLDER,
- TOOL_SCENE_CLEAR_INSTANCING,
+ TOOL_SCENE_MAKE_LOCAL,
TOOL_SCENE_OPEN,
TOOL_SCENE_CLEAR_INHERITANCE,
TOOL_SCENE_CLEAR_INHERITANCE_CONFIRM,
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 62848a6035..9ce0e973f7 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1249,6 +1249,9 @@ void ScriptEditorDebugger::stop() {
EditorNode::get_singleton()->get_scene_tree_dock()->hide_remote_tree();
EditorNode::get_singleton()->get_scene_tree_dock()->hide_tab_buttons();
+ Node *node = editor->get_scene_tree_dock()->get_tree_editor()->get_selected();
+ editor->push_item(node);
+
if (hide_on_stop) {
if (is_visible_in_tree())
EditorNode::get_singleton()->hide_bottom_panel();
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index ae88b3a035..fe379703e5 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -54,12 +54,12 @@ void EditorSettingsDialog::_settings_changed() {
void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
- String full_name = property_editor->get_full_item_path(p_name);
+ String full_name = inspector->get_full_item_path(p_name);
// Small usability workaround to update the text color settings when the
// color theme is changed
if (full_name == "text_editor/theme/color_theme") {
- property_editor->get_property_editor()->update_tree();
+ inspector->get_inspector()->update_tree();
} else if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") {
EditorSettings::get_singleton()->set_manually("interface/theme/preset", "Custom"); // set preset to Custom
} else if (full_name.begins_with("text_editor/highlighting")) {
@@ -88,8 +88,8 @@ void EditorSettingsDialog::popup_edit_settings() {
EditorSettings::get_singleton()->list_text_editor_themes(); // make sure we have an up to date list of themes
- property_editor->edit(EditorSettings::get_singleton());
- property_editor->get_property_editor()->update_tree();
+ inspector->edit(EditorSettings::get_singleton());
+ inspector->get_inspector()->update_tree();
search_box->select_all();
search_box->grab_focus();
@@ -120,7 +120,7 @@ void EditorSettingsDialog::_clear_search_box() {
return;
search_box->clear();
- property_editor->get_property_editor()->update_tree();
+ inspector->get_inspector()->update_tree();
}
void EditorSettingsDialog::_clear_shortcut_search_box() {
@@ -158,7 +158,7 @@ void EditorSettingsDialog::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_icons();
// Update theme colors.
- property_editor->update_category_list();
+ inspector->update_category_list();
_update_shortcuts();
} break;
}
@@ -202,6 +202,11 @@ void EditorSettingsDialog::_update_icons() {
shortcut_search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
clear_button->set_icon(get_icon("Close", "EditorIcons"));
shortcut_clear_button->set_icon(get_icon("Close", "EditorIcons"));
+
+ restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
+ restart_container->add_style_override("panel", get_stylebox("bg", "Tree"));
+ restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons"));
+ restart_label->add_color_override("font_color", get_color("error_color", "Editor"));
}
void EditorSettingsDialog::_update_shortcuts() {
@@ -388,6 +393,18 @@ void EditorSettingsDialog::_focus_current_search_box() {
}
}
+void EditorSettingsDialog::_editor_restart() {
+ EditorNode::get_singleton()->save_all_scenes_and_restart();
+}
+
+void EditorSettingsDialog::_editor_restart_request() {
+ restart_container->show();
+}
+
+void EditorSettingsDialog::_editor_restart_close() {
+ restart_container->hide();
+}
+
void EditorSettingsDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorSettingsDialog::_unhandled_input);
@@ -402,6 +419,10 @@ void EditorSettingsDialog::_bind_methods() {
ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &EditorSettingsDialog::_press_a_key_confirm);
ClassDB::bind_method(D_METHOD("_wait_for_key"), &EditorSettingsDialog::_wait_for_key);
ClassDB::bind_method(D_METHOD("_tabs_tab_changed"), &EditorSettingsDialog::_tabs_tab_changed);
+
+ ClassDB::bind_method(D_METHOD("_editor_restart_request"), &EditorSettingsDialog::_editor_restart_request);
+ ClassDB::bind_method(D_METHOD("_editor_restart"), &EditorSettingsDialog::_editor_restart);
+ ClassDB::bind_method(D_METHOD("_editor_restart_close"), &EditorSettingsDialog::_editor_restart_close);
}
EditorSettingsDialog::EditorSettingsDialog() {
@@ -434,14 +455,35 @@ EditorSettingsDialog::EditorSettingsDialog() {
hbc->add_child(clear_button);
clear_button->connect("pressed", this, "_clear_search_box");
- property_editor = memnew(SectionedPropertyEditor);
- //property_editor->hide_top_label();
- property_editor->get_property_editor()->set_use_filter(true);
- property_editor->register_search_box(search_box);
- property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- property_editor->get_property_editor()->set_undo_redo(undo_redo);
- tab_general->add_child(property_editor);
- property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited");
+ inspector = memnew(SectionedInspector);
+ //inspector->hide_top_label();
+ inspector->get_inspector()->set_use_filter(true);
+ inspector->register_search_box(search_box);
+ inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ inspector->get_inspector()->set_undo_redo(undo_redo);
+ tab_general->add_child(inspector);
+ inspector->get_inspector()->connect("property_edited", this, "_settings_property_edited");
+ inspector->get_inspector()->connect("restart_requested", this, "_editor_restart_request");
+
+ restart_container = memnew(PanelContainer);
+ tab_general->add_child(restart_container);
+ HBoxContainer *restart_hb = memnew(HBoxContainer);
+ restart_container->add_child(restart_hb);
+ restart_icon = memnew(TextureRect);
+ restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER);
+ restart_hb->add_child(restart_icon);
+ restart_label = memnew(Label);
+ restart_label->set_text(TTR("Editor must be restarted for changes to take effect"));
+ restart_hb->add_child(restart_label);
+ restart_hb->add_spacer();
+ Button *restart_button = memnew(Button);
+ restart_button->connect("pressed", this, "_editor_restart");
+ restart_hb->add_child(restart_button);
+ restart_button->set_text(TTR("Save & Restart"));
+ restart_close_button = memnew(ToolButton);
+ restart_close_button->connect("pressed", this, "_editor_restart_close");
+ restart_hb->add_child(restart_close_button);
+ restart_container->hide();
// Shortcuts Tab
diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h
index 6676e870d0..6cf2eb6bdf 100644
--- a/editor/settings_config_dialog.h
+++ b/editor/settings_config_dialog.h
@@ -31,9 +31,14 @@
#ifndef SETTINGS_CONFIG_DIALOG_H
#define SETTINGS_CONFIG_DIALOG_H
-#include "property_editor.h"
+#include "editor/editor_sectioned_inspector.h"
+#include "editor_inspector.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/panel_container.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/tab_container.h"
+#include "scene/gui/texture_rect.h"
+#include "scene/gui/tool_button.h"
class EditorSettingsDialog : public AcceptDialog {
@@ -49,7 +54,7 @@ class EditorSettingsDialog : public AcceptDialog {
LineEdit *shortcut_search_box;
ToolButton *clear_button;
ToolButton *shortcut_clear_button;
- SectionedPropertyEditor *property_editor;
+ SectionedInspector *inspector;
Timer *timer;
@@ -89,6 +94,15 @@ class EditorSettingsDialog : public AcceptDialog {
static void _undo_redo_callback(void *p_self, const String &p_name);
+ Label *restart_label;
+ TextureRect *restart_icon;
+ PanelContainer *restart_container;
+ ToolButton *restart_close_button;
+
+ void _editor_restart_request();
+ void _editor_restart();
+ void _editor_restart_close();
+
protected:
static void _bind_methods();
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index c45dea0df7..35544f711b 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -33,6 +33,7 @@
#include "geometry.h"
#include "quick_hull.h"
#include "scene/3d/camera.h"
+#include "scene/3d/soft_body.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
#include "scene/resources/convex_polygon_shape.h"
@@ -256,8 +257,12 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
for (int i = 0; i < p_handles.size(); i++) {
Color col(1, 1, 1, 1);
+ if (is_gizmo_handle_highlighted(i))
+ col = Color(0, 0, 1, 0.9);
+
if (SpatialEditor::get_singleton()->get_over_gizmo_handle() != i)
- col = Color(0.9, 0.9, 0.9, 0.9);
+ col.a = 0.8;
+
w[i] = col;
}
}
@@ -1914,6 +1919,100 @@ VehicleWheelSpatialGizmo::VehicleWheelSpatialGizmo(VehicleWheel *p_car_wheel) {
///////////
+void SoftBodySpatialGizmo::redraw() {
+ clear();
+
+ if (!soft_body || soft_body->get_mesh().is_null()) {
+ return;
+ }
+
+ // find mesh
+
+ Vector<Vector3> lines;
+
+ soft_body->get_mesh()->generate_debug_mesh_lines(lines);
+
+ if (!lines.size()) {
+ return;
+ }
+
+ Vector<Vector3> points;
+ soft_body->get_mesh()->generate_debug_mesh_indices(points);
+
+ soft_body->get_mesh()->clear_cache();
+
+ Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
+ Ref<Material> material = create_material("shape_material", gizmo_color);
+
+ add_lines(lines, material);
+ add_collision_segments(lines);
+ add_handles(points);
+}
+
+bool SoftBodySpatialGizmo::intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle, bool p_sec_first) {
+ return EditorSpatialGizmo::intersect_ray(p_camera, p_point, r_pos, r_normal, r_gizmo_handle, p_sec_first);
+
+ /* Perform a shape cast but doesn't work with softbody
+ PhysicsDirectSpaceState *space_state = PhysicsServer::get_singleton()->space_get_direct_state(SceneTree::get_singleton()->get_root()->get_world()->get_space());
+ if (!physics_sphere_shape.is_valid()) {
+ physics_sphere_shape = PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE);
+ real_t radius = 0.02;
+ PhysicsServer::get_singleton()->shape_set_data(physics_sphere_shape, radius);
+ }
+
+ Vector3 sphere_motion(p_camera->project_ray_normal(p_point));
+ real_t closest_safe;
+ real_t closest_unsafe;
+ PhysicsDirectSpaceState::ShapeRestInfo result;
+ bool collided = space_state->cast_motion(
+ physics_sphere_shape,
+ p_camera->get_transform(),
+ sphere_motion * Vector3(1000, 1000, 1000),
+ 0.f,
+ closest_safe,
+ closest_unsafe,
+ Set<RID>(),
+ 0xFFFFFFFF,
+ 0xFFFFFFFF,
+ &result);
+
+ if (collided) {
+
+ if (result.collider_id == soft_body->get_instance_id()) {
+ print_line("Collided");
+ } else {
+ print_line("Collided but with wrong object: " + itos(result.collider_id));
+ }
+ } else {
+ print_line("Not collided, motion: x: " + rtos(sphere_motion[0]) + " y: " + rtos(sphere_motion[1]) + " z: " + rtos(sphere_motion[2]));
+ }
+ return false;
+ */
+}
+
+void SoftBodySpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
+ soft_body->pin_point_toggle(p_idx);
+ redraw();
+}
+
+bool SoftBodySpatialGizmo::is_gizmo_handle_highlighted(int idx) const {
+ return soft_body->is_point_pinned(idx);
+}
+
+SoftBodySpatialGizmo::SoftBodySpatialGizmo(SoftBody *p_soft_physics_body) :
+ EditorSpatialGizmo(),
+ soft_body(p_soft_physics_body) {
+ set_spatial_node(p_soft_physics_body);
+}
+
+SoftBodySpatialGizmo::~SoftBodySpatialGizmo() {
+ //if (!physics_sphere_shape.is_valid()) {
+ // PhysicsServer::get_singleton()->free(physics_sphere_shape);
+ //}
+}
+
+///////////
+
String CollisionShapeSpatialGizmo::get_handle_name(int p_idx) const {
Ref<Shape> s = cs->get_shape();
@@ -4051,6 +4150,12 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return lsg;
}
+ if (Object::cast_to<SoftBody>(p_spatial)) {
+
+ Ref<SoftBodySpatialGizmo> misg = memnew(SoftBodySpatialGizmo(Object::cast_to<SoftBody>(p_spatial)));
+ return misg;
+ }
+
if (Object::cast_to<MeshInstance>(p_spatial)) {
Ref<MeshInstanceSpatialGizmo> misg = memnew(MeshInstanceSpatialGizmo(Object::cast_to<MeshInstance>(p_spatial)));
@@ -4081,6 +4186,7 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
return misg;
}
*/
+
if (Object::cast_to<CollisionShape>(p_spatial)) {
Ref<CollisionShapeSpatialGizmo> misg = memnew(CollisionShapeSpatialGizmo(Object::cast_to<CollisionShape>(p_spatial)));
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index 924f82dc16..198d028516 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -331,6 +331,23 @@ public:
BakedIndirectLightGizmo(BakedLightmap *p_baker = NULL);
};
+class SoftBodySpatialGizmo : public EditorSpatialGizmo {
+ GDCLASS(SoftBodySpatialGizmo, EditorSpatialGizmo);
+
+ class SoftBody *soft_body;
+ //RID physics_sphere_shape; // Used for raycast that doesn't work, in this moment, with softbody
+
+public:
+ void redraw();
+ virtual bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
+ virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel);
+
+ virtual bool is_gizmo_handle_highlighted(int idx) const;
+
+ SoftBodySpatialGizmo(SoftBody *p_soft_physics_body = NULL);
+ ~SoftBodySpatialGizmo();
+};
+
class CollisionShapeSpatialGizmo : public EditorSpatialGizmo {
GDCLASS(CollisionShapeSpatialGizmo, EditorSpatialGizmo);