summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/dependency_editor.cpp6
-rw-r--r--editor/filesystem_dock.cpp6
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp2
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp177
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h21
-rw-r--r--editor/scene_tree_dock.cpp8
6 files changed, 203 insertions, 17 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 25e155aafe..57d44ca56c 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -86,11 +86,11 @@ void DependencyEditor::_fix_and_find(EditorFileSystemDirectory *efsd, Map<String
String lost = E->key().replace_first("res://", "");
Vector<String> existingv = existing.split("/");
- existingv.invert();
+ existingv.reverse();
Vector<String> currentv = current.split("/");
- currentv.invert();
+ currentv.reverse();
Vector<String> lostv = lost.split("/");
- lostv.invert();
+ lostv.reverse();
int existing_score = 0;
int current_score = 0;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index c9ccd5b0fe..d6ae901ca9 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -680,17 +680,17 @@ void FileSystemDock::_sort_file_info_list(List<FileSystemDock::FileInfo> &r_file
break;
case FILE_SORT_TYPE_REVERSE:
r_file_list.sort_custom<FileInfoTypeComparator>();
- r_file_list.invert();
+ r_file_list.reverse();
break;
case FILE_SORT_MODIFIED_TIME:
r_file_list.sort_custom<FileInfoModifiedTimeComparator>();
break;
case FILE_SORT_MODIFIED_TIME_REVERSE:
r_file_list.sort_custom<FileInfoModifiedTimeComparator>();
- r_file_list.invert();
+ r_file_list.reverse();
break;
case FILE_SORT_NAME_REVERSE:
- r_file_list.invert();
+ r_file_list.reverse();
break;
default: // FILE_SORT_NAME
break;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index cca4f594e9..feaf609557 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -2928,7 +2928,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
}
if (p_total < 0) {
- points.invert();
+ points.reverse();
}
shape->set_points(points);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 69bdc05b3a..b2fa9c540e 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -384,6 +384,20 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
port_offset += 2;
}
+ if (is_resizable) {
+ Ref<VisualShaderNodeComment> comment_node = Object::cast_to<VisualShaderNodeComment>(vsnode.ptr());
+ if (comment_node.is_valid()) {
+ node->set_comment(true);
+
+ Label *comment_label = memnew(Label);
+ node->add_child(comment_label);
+ comment_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ comment_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ comment_label->set_mouse_filter(Control::MouseFilter::MOUSE_FILTER_STOP);
+ comment_label->set_text(comment_node->get_description());
+ }
+ }
+
Ref<VisualShaderNodeUniform> uniform = vsnode;
if (uniform.is_valid()) {
VisualShaderEditor::get_singleton()->graph->add_child(node);
@@ -1624,6 +1638,92 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
undo_redo->commit_action();
}
+void VisualShaderEditor::_comment_title_popup_show(const Point2 &p_position, int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, p_node_id);
+ if (node.is_null()) {
+ return;
+ }
+ comment_title_change_edit->set_text(node->get_title());
+ comment_title_change_popup->set_meta("id", p_node_id);
+ comment_title_change_popup->popup();
+ comment_title_change_popup->set_position(p_position);
+}
+
+void VisualShaderEditor::_comment_title_text_changed(const String &p_new_text) {
+ comment_title_change_edit->set_size(Size2(-1, -1));
+ comment_title_change_popup->set_size(Size2(-1, -1));
+}
+
+void VisualShaderEditor::_comment_title_text_entered(const String &p_new_text) {
+ comment_title_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_title_popup_focus_out() {
+ comment_title_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_title_popup_hide() {
+ ERR_FAIL_COND(!comment_title_change_popup->has_meta("id"));
+ int node_id = (int)comment_title_change_popup->get_meta("id");
+
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, node_id);
+
+ ERR_FAIL_COND(node.is_null());
+
+ if (node->get_title() == comment_title_change_edit->get_text()) {
+ return; // nothing changed - ignored
+ }
+ undo_redo->create_action(TTR("Set Comment Node Title"));
+ undo_redo->add_do_method(node.ptr(), "set_title", comment_title_change_edit->get_text());
+ undo_redo->add_undo_method(node.ptr(), "set_title", node->get_title());
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->commit_action();
+}
+
+void VisualShaderEditor::_comment_desc_popup_show(const Point2 &p_position, int p_node_id) {
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, p_node_id);
+ if (node.is_null()) {
+ return;
+ }
+ comment_desc_change_edit->set_text(node->get_description());
+ comment_desc_change_popup->set_meta("id", p_node_id);
+ comment_desc_change_popup->popup();
+ comment_desc_change_popup->set_position(p_position);
+}
+
+void VisualShaderEditor::_comment_desc_text_changed() {
+ comment_desc_change_edit->set_size(Size2(-1, -1));
+ comment_desc_change_popup->set_size(Size2(-1, -1));
+}
+
+void VisualShaderEditor::_comment_desc_confirm() {
+ comment_desc_change_popup->hide();
+}
+
+void VisualShaderEditor::_comment_desc_popup_hide() {
+ ERR_FAIL_COND(!comment_desc_change_popup->has_meta("id"));
+ int node_id = (int)comment_desc_change_popup->get_meta("id");
+
+ VisualShader::Type type = get_current_shader_type();
+ Ref<VisualShaderNodeComment> node = visual_shader->get_node(type, node_id);
+
+ ERR_FAIL_COND(node.is_null());
+
+ if (node->get_description() == comment_desc_change_edit->get_text()) {
+ return; // nothing changed - ignored
+ }
+ undo_redo->create_action(TTR("Set Comment Node Description"));
+ undo_redo->add_do_method(node.ptr(), "set_description", comment_desc_change_edit->get_text());
+ undo_redo->add_undo_method(node.ptr(), "set_description", node->get_title());
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", (int)type, node_id);
+ undo_redo->commit_action();
+}
+
void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) {
VisualShader::Type type = get_current_shader_type();
@@ -2507,6 +2607,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_RIGHT) {
selected_constants.clear();
selected_uniforms.clear();
+ selected_comment = -1;
List<int> to_change;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -2517,17 +2618,27 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
to_change.push_back(id);
Ref<VisualShaderNode> node = visual_shader->get_node(type, id);
- VisualShaderNodeConstant *cnode = Object::cast_to<VisualShaderNodeConstant>(node.ptr());
- if (cnode != nullptr) {
+
+ VisualShaderNodeComment *comment_node = Object::cast_to<VisualShaderNodeComment>(node.ptr());
+ if (comment_node != nullptr) {
+ selected_comment = id;
+ }
+ VisualShaderNodeConstant *constant_node = Object::cast_to<VisualShaderNodeConstant>(node.ptr());
+ if (constant_node != nullptr) {
selected_constants.insert(id);
}
- VisualShaderNodeUniform *unode = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
- if (unode != nullptr) {
+ VisualShaderNodeUniform *uniform_node = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ if (uniform_node != nullptr && uniform_node->is_convertible_to_constant()) {
selected_uniforms.insert(id);
}
}
}
}
+
+ if (to_change.size() > 1) {
+ selected_comment = -1;
+ }
+
if (to_change.is_empty() && copy_nodes_buffer.is_empty()) {
_show_members_dialog(true);
} else {
@@ -2548,16 +2659,34 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
if (temp != -1) {
popup_menu->remove_item(temp);
}
+ temp = popup_menu->get_item_index(NodeMenuOptions::SEPARATOR3);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::SET_COMMENT_TITLE);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::SET_COMMENT_DESCRIPTION);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
- if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
+ if (selected_comment != -1) {
popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2);
+ popup_menu->add_item(TTR("Set Comment Title"), NodeMenuOptions::SET_COMMENT_TITLE);
+ popup_menu->add_item(TTR("Set Comment Description"), NodeMenuOptions::SET_COMMENT_DESCRIPTION);
+ }
+
+ if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
+ popup_menu->add_separator("", NodeMenuOptions::SEPARATOR3);
if (selected_constants.size() > 0) {
popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
}
if (selected_uniforms.size() > 0) {
- popup_menu->add_item(TTR("Convert Uniforms(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
+ popup_menu->add_item(TTR("Convert Uniform(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
}
}
@@ -3111,6 +3240,12 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
case NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS:
_convert_constants_to_uniforms(true);
break;
+ case NodeMenuOptions::SET_COMMENT_TITLE:
+ _comment_title_popup_show(get_global_mouse_position(), selected_comment);
+ break;
+ case NodeMenuOptions::SET_COMMENT_DESCRIPTION:
+ _comment_desc_popup_show(get_global_mouse_position(), selected_comment);
+ break;
default:
break;
}
@@ -3534,6 +3669,35 @@ VisualShaderEditor::VisualShaderEditor() {
alert->get_label()->set_custom_minimum_size(Size2(400, 60) * EDSCALE);
add_child(alert);
+ comment_title_change_popup = memnew(PopupPanel);
+ comment_title_change_edit = memnew(LineEdit);
+ comment_title_change_edit->set_expand_to_text_length(true);
+ comment_title_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_title_text_changed));
+ comment_title_change_edit->connect("text_entered", callable_mp(this, &VisualShaderEditor::_comment_title_text_entered));
+ comment_title_change_popup->add_child(comment_title_change_edit);
+ comment_title_change_edit->set_size(Size2(-1, -1));
+ comment_title_change_popup->set_size(Size2(-1, -1));
+ comment_title_change_popup->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_comment_title_popup_focus_out));
+ comment_title_change_popup->connect("popup_hide", callable_mp(this, &VisualShaderEditor::_comment_title_popup_hide));
+ add_child(comment_title_change_popup);
+
+ comment_desc_change_popup = memnew(PopupPanel);
+ VBoxContainer *comment_desc_vbox = memnew(VBoxContainer);
+ comment_desc_change_popup->add_child(comment_desc_vbox);
+ comment_desc_change_edit = memnew(TextEdit);
+ comment_desc_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_desc_text_changed));
+ comment_desc_vbox->add_child(comment_desc_change_edit);
+ comment_desc_change_edit->set_custom_minimum_size(Size2(300 * EDSCALE, 150 * EDSCALE));
+ comment_desc_change_edit->set_size(Size2(-1, -1));
+ comment_desc_change_popup->set_size(Size2(-1, -1));
+ comment_desc_change_popup->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_comment_desc_confirm));
+ comment_desc_change_popup->connect("popup_hide", callable_mp(this, &VisualShaderEditor::_comment_desc_popup_hide));
+ Button *comment_desc_confirm_button = memnew(Button);
+ comment_desc_confirm_button->set_text(TTR("OK"));
+ comment_desc_vbox->add_child(comment_desc_confirm_button);
+ comment_desc_confirm_button->connect("pressed", callable_mp(this, &VisualShaderEditor::_comment_desc_confirm));
+ add_child(comment_desc_change_popup);
+
///////////////////////////////////////
// SHADER NODES TREE OPTIONS
///////////////////////////////////////
@@ -3971,6 +4135,7 @@ VisualShaderEditor::VisualShaderEditor() {
// SPECIAL
+ add_options.push_back(AddOption("Comment", "Special", "", "VisualShaderNodeComment", TTR("A rectangular area with a description string for better graph organization.")));
add_options.push_back(AddOption("Expression", "Special", "", "VisualShaderNodeExpression", TTR("Custom Godot Shader Language expression, with custom amount of input and output ports. This is a direct injection of code into the vertex/fragment/light function, do not use it to write the function declarations inside.")));
add_options.push_back(AddOption("Fresnel", "Special", "", "VisualShaderNodeFresnel", TTR("Returns falloff based on the dot product of surface normal and view direction of camera (pass associated inputs to it)."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants.")));
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 182bed6ba6..83b4914b66 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -161,6 +161,12 @@ class VisualShaderEditor : public VBoxContainer {
PopupMenu *popup_menu;
MenuButton *tools;
+ PopupPanel *comment_title_change_popup = nullptr;
+ LineEdit *comment_title_change_edit = nullptr;
+
+ PopupPanel *comment_desc_change_popup = nullptr;
+ TextEdit *comment_desc_change_edit = nullptr;
+
bool preview_first = true;
bool preview_showed = false;
bool particles_mode;
@@ -192,6 +198,9 @@ class VisualShaderEditor : public VBoxContainer {
SEPARATOR2, // ignore
CONVERT_CONSTANTS_TO_UNIFORMS,
CONVERT_UNIFORMS_TO_CONSTANTS,
+ SEPARATOR3, // ignore
+ SET_COMMENT_TITLE,
+ SET_COMMENT_DESCRIPTION,
};
Tree *members;
@@ -325,6 +334,7 @@ class VisualShaderEditor : public VBoxContainer {
Set<int> selected_constants;
Set<int> selected_uniforms;
+ int selected_comment = -1;
void _convert_constants_to_uniforms(bool p_vice_versa);
void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
@@ -334,6 +344,17 @@ class VisualShaderEditor : public VBoxContainer {
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
+ void _comment_title_popup_show(const Point2 &p_position, int p_node_id);
+ void _comment_title_popup_hide();
+ void _comment_title_popup_focus_out();
+ void _comment_title_text_changed(const String &p_new_text);
+ void _comment_title_text_entered(const String &p_new_text);
+
+ void _comment_desc_popup_show(const Point2 &p_position, int p_node_id);
+ void _comment_desc_popup_hide();
+ void _comment_desc_confirm();
+ void _comment_desc_text_changed();
+
void _uniform_line_edit_changed(const String &p_text, int p_node_id);
void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 023019b2aa..57d517b7e9 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -608,7 +608,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
List<Node *> selection = editor_selection->get_selected_node_list();
selection.sort_custom<Node::Comparator>(); // sort by index
if (MOVING_DOWN) {
- selection.invert();
+ selection.reverse();
}
int lowest_id = common_parent->get_child_count() - 1;
@@ -1384,7 +1384,7 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai
base_path.push_back(n->get_name());
n = n->get_parent();
}
- base_path.invert();
+ base_path.reverse();
Vector<StringName> new_base_path;
if (p_new_parent) {
@@ -1394,7 +1394,7 @@ void SceneTreeDock::fill_path_renames(Node *p_node, Node *p_new_parent, List<Pai
n = n->get_parent();
}
- new_base_path.invert();
+ new_base_path.reverse();
}
_fill_path_renames(base_path, new_base_path, p_node, p_renames);
@@ -1580,7 +1580,7 @@ void SceneTreeDock::_node_prerenamed(Node *p_node, const String &p_new_name) {
base_path.push_back(n->get_name());
n = n->get_parent();
}
- base_path.invert();
+ base_path.reverse();
Vector<StringName> new_base_path = base_path;
base_path.push_back(p_node->get_name());