You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
This commit is contained in:
@@ -48,7 +48,6 @@
|
||||
#include "servers/rendering/shader_types.h"
|
||||
|
||||
Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
|
||||
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("create_editor", p_parent_resource, p_node);
|
||||
}
|
||||
@@ -56,14 +55,12 @@ Control *VisualShaderNodePlugin::create_editor(const Ref<Resource> &p_parent_res
|
||||
}
|
||||
|
||||
void VisualShaderNodePlugin::_bind_methods() {
|
||||
|
||||
BIND_VMETHOD(MethodInfo(Variant::OBJECT, "create_editor", PropertyInfo(Variant::OBJECT, "parent_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"), PropertyInfo(Variant::OBJECT, "for_node", PROPERTY_HINT_RESOURCE_TYPE, "VisualShaderNode")));
|
||||
}
|
||||
|
||||
///////////////////
|
||||
|
||||
void VisualShaderEditor::edit(VisualShader *p_visual_shader) {
|
||||
|
||||
bool changed = false;
|
||||
if (p_visual_shader) {
|
||||
if (visual_shader.is_null()) {
|
||||
@@ -125,7 +122,6 @@ void VisualShaderEditor::clear_custom_types() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, bool p_highend) {
|
||||
|
||||
ERR_FAIL_COND(!p_name.is_valid_identifier());
|
||||
ERR_FAIL_COND(!p_script.is_valid());
|
||||
|
||||
@@ -166,11 +162,9 @@ void VisualShaderEditor::add_custom_type(const String &p_name, const Ref<Script>
|
||||
}
|
||||
|
||||
bool VisualShaderEditor::_is_available(int p_mode) {
|
||||
|
||||
int current_mode = edit_type->get_selected();
|
||||
|
||||
if (p_mode != -1) {
|
||||
|
||||
switch (current_mode) {
|
||||
case VisualShader::TYPE_VERTEX:
|
||||
current_mode = 1;
|
||||
@@ -215,7 +209,6 @@ void VisualShaderEditor::update_custom_nodes() {
|
||||
Dictionary added;
|
||||
for (int i = 0; i < class_list.size(); i++) {
|
||||
if (ScriptServer::get_global_class_native_base(class_list[i]) == "VisualShaderNodeCustom") {
|
||||
|
||||
String script_path = ScriptServer::get_global_class_path(class_list[i]);
|
||||
Ref<Resource> res = ResourceLoader::load(script_path);
|
||||
ERR_FAIL_COND(res.is_null());
|
||||
@@ -285,7 +278,6 @@ void VisualShaderEditor::update_custom_nodes() {
|
||||
keys.sort();
|
||||
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
|
||||
const Variant &key = keys.get(i);
|
||||
|
||||
const Dictionary &value = (Dictionary)added[key];
|
||||
@@ -301,7 +293,6 @@ String VisualShaderEditor::_get_description(int p_idx) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_options_menu() {
|
||||
|
||||
node_desc->set_text("");
|
||||
members_dialog->get_ok()->set_disabled(true);
|
||||
|
||||
@@ -411,12 +402,10 @@ void VisualShaderEditor::_update_options_menu() {
|
||||
}
|
||||
|
||||
Size2 VisualShaderEditor::get_minimum_size() const {
|
||||
|
||||
return Size2(10, 200);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_draw_color_over_button(Object *obj, Color p_color) {
|
||||
|
||||
Button *button = Object::cast_to<Button>(obj);
|
||||
if (!button)
|
||||
return;
|
||||
@@ -435,7 +424,6 @@ static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_created_node(GraphNode *node) {
|
||||
|
||||
if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
|
||||
Ref<StyleBoxFlat> sb = node->get_theme_stylebox("frame", "GraphNode");
|
||||
Color c = sb->get_border_color();
|
||||
@@ -459,7 +447,6 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_graph() {
|
||||
|
||||
if (updating)
|
||||
return;
|
||||
|
||||
@@ -472,7 +459,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
graph->clear_connections();
|
||||
//erase all nodes
|
||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||
|
||||
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
|
||||
Node *node = graph->get_child(i);
|
||||
graph->remove_child(node);
|
||||
@@ -500,7 +486,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
Control *offset;
|
||||
|
||||
for (int n_i = 0; n_i < nodes.size(); n_i++) {
|
||||
|
||||
Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
|
||||
Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);
|
||||
|
||||
@@ -592,7 +577,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
if (custom_editor && !float_uniform.is_valid() && !int_uniform.is_valid() && !vec3_uniform.is_valid() && !bool_uniform.is_valid() && !transform_uniform.is_valid() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
|
||||
//will be embedded in first port
|
||||
} else if (custom_editor) {
|
||||
|
||||
port_offset++;
|
||||
node->add_child(custom_editor);
|
||||
if (color_uniform.is_valid()) {
|
||||
@@ -606,7 +590,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
}
|
||||
|
||||
if (is_group) {
|
||||
|
||||
offset = memnew(Control);
|
||||
offset->set_custom_minimum_size(Size2(0, 6 * EDSCALE));
|
||||
node->add_child(offset);
|
||||
@@ -631,7 +614,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
|
||||
|
||||
if (vsnode->is_port_separator(i)) {
|
||||
node->add_child(memnew(HSeparator));
|
||||
port_offset++;
|
||||
@@ -674,7 +656,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
button->connect("pressed", callable_mp(this, &VisualShaderEditor::_edit_port_default_input), varray(button, nodes[n_i], i));
|
||||
|
||||
switch (default_value.get_type()) {
|
||||
|
||||
case Variant::COLOR: {
|
||||
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
|
||||
button->connect("draw", callable_mp(this, &VisualShaderEditor::_draw_color_over_button), varray(button, default_value));
|
||||
@@ -699,9 +680,7 @@ void VisualShaderEditor::_update_graph() {
|
||||
hb->add_child(custom_editor);
|
||||
custom_editor->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
} else {
|
||||
|
||||
if (valid_left) {
|
||||
|
||||
if (is_group) {
|
||||
OptionButton *type_box = memnew(OptionButton);
|
||||
hb->add_child(type_box);
|
||||
@@ -729,14 +708,12 @@ void VisualShaderEditor::_update_graph() {
|
||||
remove_btn->connect("pressed", callable_mp(this, &VisualShaderEditor::_remove_input_port), varray(nodes[n_i], i), CONNECT_DEFERRED);
|
||||
hb->add_child(remove_btn);
|
||||
} else {
|
||||
|
||||
Label *label = memnew(Label);
|
||||
label->set_text(name_left);
|
||||
label->add_theme_style_override("normal", label_style); //more compact
|
||||
hb->add_child(label);
|
||||
|
||||
if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
|
||||
|
||||
Label *hint_label = memnew(Label);
|
||||
hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
|
||||
hint_label->add_theme_color_override("font_color", get_theme_color("font_color_readonly", "TextEdit"));
|
||||
@@ -840,7 +817,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
}
|
||||
|
||||
if (is_expression) {
|
||||
|
||||
TextEdit *expression_box = memnew(TextEdit);
|
||||
expression_node->set_control(expression_box, 0);
|
||||
node->add_child(expression_box);
|
||||
@@ -855,7 +831,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
expression_box->add_theme_color_override("background_color", background_color);
|
||||
|
||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||
|
||||
expression_box->add_keyword_color(E->get(), keyword_color);
|
||||
}
|
||||
|
||||
@@ -881,7 +856,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
}
|
||||
|
||||
for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
|
||||
|
||||
int from = E->get().from_node;
|
||||
int from_idx = E->get().from_port;
|
||||
int to = E->get().to_node;
|
||||
@@ -892,7 +866,6 @@ void VisualShaderEditor::_update_graph() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type, const String &p_name) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -910,7 +883,6 @@ void VisualShaderEditor::_add_input_port(int p_node, int p_port, int p_port_type
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_type, const String &p_name) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -928,7 +900,6 @@ void VisualShaderEditor::_add_output_port(int p_node, int p_port, int p_port_typ
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -946,7 +917,6 @@ void VisualShaderEditor::_change_input_port_type(int p_type, int p_node, int p_p
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -964,7 +934,6 @@ void VisualShaderEditor::_change_output_port_type(int p_type, int p_node, int p_
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
|
||||
@@ -979,7 +948,6 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *l
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *line_edit, int p_node_id, int p_port_id) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
|
||||
@@ -994,7 +962,6 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1006,7 +973,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
|
||||
List<VisualShader::Connection> conns;
|
||||
visual_shader->get_node_connections(type, &conns);
|
||||
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
|
||||
|
||||
int from_node = E->get().from_node;
|
||||
int from_port = E->get().from_port;
|
||||
int to_node = E->get().to_node;
|
||||
@@ -1039,7 +1005,6 @@ void VisualShaderEditor::_remove_input_port(int p_node, int p_port) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1051,7 +1016,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
|
||||
List<VisualShader::Connection> conns;
|
||||
visual_shader->get_node_connections(type, &conns);
|
||||
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
|
||||
|
||||
int from_node = E->get().from_node;
|
||||
int from_port = E->get().from_port;
|
||||
int to_node = E->get().to_node;
|
||||
@@ -1084,7 +1048,6 @@ void VisualShaderEditor::_remove_output_port(int p_node, int p_port) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_expression_focus_out(Object *text_edit, int p_node) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNodeExpression> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1112,7 +1075,6 @@ void VisualShaderEditor::_rebuild() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p_size) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(p_type);
|
||||
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1159,7 +1121,6 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, int p_node) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(p_type);
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1173,7 +1134,6 @@ void VisualShaderEditor::_node_resized(const Vector2 &p_new_size, int p_type, in
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNode> node = visual_shader->get_node(type, p_node);
|
||||
if (node.is_null()) {
|
||||
@@ -1192,7 +1152,6 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_edit, int p_node_id) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id);
|
||||
@@ -1213,13 +1172,11 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_line_edit_focus_out(Object *line_edit, int p_node_id) {
|
||||
|
||||
String text = Object::cast_to<LineEdit>(line_edit)->get_text();
|
||||
_line_edit_changed(text, line_edit, p_node_id);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Ref<VisualShaderNodeGroupBase> node = visual_shader->get_node(type, p_node_id);
|
||||
@@ -1267,7 +1224,6 @@ void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id,
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_port_edited() {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Variant value = property_editor->get_variant();
|
||||
@@ -1285,7 +1241,6 @@ void VisualShaderEditor::_port_edited() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, int p_port) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
Ref<VisualShaderNode> vsn = visual_shader->get_node(type, p_node);
|
||||
@@ -1301,7 +1256,6 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node,
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_add_custom_node(const String &p_path) {
|
||||
|
||||
int idx = -1;
|
||||
|
||||
for (int i = custom_node_option_idx; i < add_options.size(); i++) {
|
||||
@@ -1323,7 +1277,6 @@ void VisualShaderEditor::_add_texture_node(const String &p_path) {
|
||||
}
|
||||
|
||||
VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr);
|
||||
|
||||
Ref<VisualShaderNode> vsnode;
|
||||
@@ -1342,7 +1295,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
|
||||
}
|
||||
|
||||
if (p_op_idx != -1) {
|
||||
|
||||
VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsn);
|
||||
|
||||
if (input) {
|
||||
@@ -1463,7 +1415,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
|
||||
|
||||
if (to_node != -1 && to_slot != -1) {
|
||||
if (vsnode->get_output_port_count() > 0) {
|
||||
|
||||
int _from_node = id_to_use;
|
||||
int _from_slot = 0;
|
||||
|
||||
@@ -1474,7 +1425,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
|
||||
}
|
||||
} else if (from_node != -1 && from_slot != -1) {
|
||||
if (vsnode->get_input_port_count() > 0) {
|
||||
|
||||
int _to_node = id_to_use;
|
||||
int _to_slot = 0;
|
||||
|
||||
@@ -1492,7 +1442,6 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
updating = true;
|
||||
@@ -1506,7 +1455,6 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
int from = p_from.to_int();
|
||||
@@ -1536,7 +1484,6 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index) {
|
||||
|
||||
graph->disconnect_node(p_from, p_from_index, p_to, p_to_index);
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
@@ -1567,7 +1514,6 @@ void VisualShaderEditor::_connection_from_empty(const String &p_to, int p_to_slo
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_delete_request(int which) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
Ref<VisualShaderNode> node = Ref<VisualShaderNode>(visual_shader->get_node(type, which));
|
||||
|
||||
@@ -1607,7 +1553,6 @@ void VisualShaderEditor::_delete_request(int which) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_node_selected(Object *p_node) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(p_node);
|
||||
@@ -1623,7 +1568,6 @@ void VisualShaderEditor::_node_selected(Object *p_node) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
||||
|
||||
Ref<InputEventMouseButton> mb = p_event;
|
||||
|
||||
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
|
||||
@@ -1652,7 +1596,6 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos) {
|
||||
|
||||
if (at_mouse_pos) {
|
||||
saved_node_pos_dirty = true;
|
||||
saved_node_pos = graph->get_local_mouse_position();
|
||||
@@ -1688,7 +1631,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
|
||||
ie->get_keycode() == KEY_DOWN ||
|
||||
ie->get_keycode() == KEY_ENTER ||
|
||||
ie->get_keycode() == KEY_KP_ENTER)) {
|
||||
|
||||
members->call("_gui_input", ie);
|
||||
node_filter->accept_event();
|
||||
}
|
||||
@@ -1696,7 +1638,6 @@ void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) {
|
||||
|
||||
void VisualShaderEditor::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
node_filter->set_clear_button_enabled(true);
|
||||
|
||||
// collapse tree by default
|
||||
@@ -1723,7 +1664,6 @@ void VisualShaderEditor::_notification(int p_what) {
|
||||
}
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
||||
|
||||
highend_label->set_modulate(get_theme_color("vulkan_color", "Editor"));
|
||||
|
||||
error_panel->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
|
||||
@@ -1743,7 +1683,6 @@ void VisualShaderEditor::_notification(int p_what) {
|
||||
preview_text->add_theme_color_override("background_color", background_color);
|
||||
|
||||
for (List<String>::Element *E = keyword_list.front(); E; E = E->next()) {
|
||||
|
||||
preview_text->add_keyword_color(E->get(), keyword_color);
|
||||
}
|
||||
|
||||
@@ -1786,7 +1725,6 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded)
|
||||
VisualShader::Type type = (VisualShader::Type)p_type;
|
||||
|
||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
||||
if (gn) {
|
||||
int id = String(gn->get_name()).to_int();
|
||||
@@ -1802,14 +1740,12 @@ void VisualShaderEditor::_dup_update_excluded(int p_type, Set<int> &r_excluded)
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int> &r_excluded) {
|
||||
|
||||
VisualShader::Type type = (VisualShader::Type)p_type;
|
||||
|
||||
selection_center.x = 0.0f;
|
||||
selection_center.y = 0.0f;
|
||||
|
||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
||||
if (gn) {
|
||||
int id = String(gn->get_name()).to_int();
|
||||
@@ -1832,7 +1768,6 @@ void VisualShaderEditor::_dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<int> &r_nodes, Set<int> &r_excluded, const Vector2 &p_offset, bool p_select) {
|
||||
|
||||
VisualShader::Type type = (VisualShader::Type)p_type;
|
||||
VisualShader::Type pasted_type = (VisualShader::Type)p_pasted_type;
|
||||
|
||||
@@ -1842,7 +1777,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
|
||||
Set<int> unsupported_set;
|
||||
|
||||
for (List<int>::Element *E = r_nodes.front(); E; E = E->next()) {
|
||||
|
||||
connection_remap[E->get()] = id_from;
|
||||
Ref<VisualShaderNode> node = visual_shader->get_node(pasted_type, E->get());
|
||||
|
||||
@@ -1900,7 +1834,6 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
|
||||
if (p_select) {
|
||||
// reselect duplicated nodes by excluding the other ones
|
||||
for (int i = 0; i < graph->get_child_count(); i++) {
|
||||
|
||||
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
|
||||
if (gn) {
|
||||
int id = String(gn->get_name()).to_int();
|
||||
@@ -1915,13 +1848,11 @@ void VisualShaderEditor::_dup_paste_nodes(int p_type, int p_pasted_type, List<in
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_clear_buffer() {
|
||||
|
||||
copy_nodes_buffer.clear();
|
||||
copy_nodes_excluded_buffer.clear();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_duplicate_nodes() {
|
||||
|
||||
int type = edit_type->get_selected();
|
||||
|
||||
List<int> nodes;
|
||||
@@ -1938,7 +1869,6 @@ void VisualShaderEditor::_duplicate_nodes() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_copy_nodes() {
|
||||
|
||||
copy_type = edit_type->get_selected();
|
||||
|
||||
_clear_buffer();
|
||||
@@ -1947,7 +1877,6 @@ void VisualShaderEditor::_copy_nodes() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {
|
||||
|
||||
if (copy_nodes_buffer.empty())
|
||||
return;
|
||||
|
||||
@@ -1970,7 +1899,6 @@ void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_delete_nodes() {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
|
||||
List<int> to_erase;
|
||||
|
||||
@@ -1989,7 +1917,6 @@ void VisualShaderEditor::_delete_nodes() {
|
||||
undo_redo->create_action(TTR("Delete Nodes"));
|
||||
|
||||
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
|
||||
|
||||
Ref<VisualShaderNode> node = visual_shader->get_node(type, F->get());
|
||||
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, F->get());
|
||||
@@ -2020,7 +1947,6 @@ void VisualShaderEditor::_delete_nodes() {
|
||||
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
|
||||
for (List<VisualShader::Connection>::Element *E = conns.front(); E; E = E->next()) {
|
||||
if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
|
||||
|
||||
bool cancel = false;
|
||||
for (List<VisualShader::Connection>::Element *R = used_conns.front(); R; R = R->next()) {
|
||||
if (R->get().from_node == E->get().from_node && R->get().from_port == E->get().from_port && R->get().to_node == E->get().to_node && R->get().to_port == E->get().to_port) {
|
||||
@@ -2042,13 +1968,11 @@ void VisualShaderEditor::_delete_nodes() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_mode_selected(int p_id) {
|
||||
|
||||
_update_options_menu();
|
||||
_update_graph();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> input, String name) {
|
||||
|
||||
String prev_name = input->get_input_name();
|
||||
|
||||
if (name == prev_name)
|
||||
@@ -2119,7 +2043,6 @@ void VisualShaderEditor::_member_cancel() {
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_tools_menu_option(int p_idx) {
|
||||
|
||||
TreeItem *category = members->get_root()->get_children();
|
||||
|
||||
switch (p_idx) {
|
||||
@@ -2176,7 +2099,6 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
|
||||
}
|
||||
|
||||
Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
||||
|
||||
if (p_from == members) {
|
||||
TreeItem *it = members->get_item_at_position(p_point);
|
||||
if (!it)
|
||||
@@ -2204,9 +2126,7 @@ Variant VisualShaderEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
|
||||
}
|
||||
|
||||
bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
|
||||
if (p_from == graph) {
|
||||
|
||||
Dictionary d = p_data;
|
||||
|
||||
if (d.has("id")) {
|
||||
@@ -2221,9 +2141,7 @@ bool VisualShaderEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
||||
}
|
||||
|
||||
void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
|
||||
if (p_from == graph) {
|
||||
|
||||
Dictionary d = p_data;
|
||||
|
||||
if (d.has("id")) {
|
||||
@@ -2233,11 +2151,9 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
||||
_add_node(idx, add_options[idx].sub_func);
|
||||
} else if (d.has("files")) {
|
||||
if (d["files"].get_type() == Variant::PACKED_STRING_ARRAY) {
|
||||
|
||||
int j = 0;
|
||||
PackedStringArray arr = d["files"];
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
|
||||
String type = ResourceLoader::get_resource_type(arr[i]);
|
||||
if (type == "GDScript") {
|
||||
Ref<Script> script = ResourceLoader::load(arr[i]);
|
||||
@@ -2271,13 +2187,11 @@ void VisualShaderEditor::_show_preview_text() {
|
||||
}
|
||||
|
||||
static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
|
||||
|
||||
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
|
||||
return RS::global_variable_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_preview() {
|
||||
|
||||
if (!preview_showed) {
|
||||
pending_update_preview = true;
|
||||
return;
|
||||
@@ -2327,7 +2241,6 @@ void VisualShaderEditor::_bind_methods() {
|
||||
VisualShaderEditor *VisualShaderEditor::singleton = nullptr;
|
||||
|
||||
VisualShaderEditor::VisualShaderEditor() {
|
||||
|
||||
singleton = this;
|
||||
updating = false;
|
||||
saved_node_pos_dirty = false;
|
||||
@@ -2945,17 +2858,14 @@ VisualShaderEditor::VisualShaderEditor() {
|
||||
}
|
||||
|
||||
void VisualShaderEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
visual_shader_editor->edit(Object::cast_to<VisualShader>(p_object));
|
||||
}
|
||||
|
||||
bool VisualShaderEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("VisualShader");
|
||||
}
|
||||
|
||||
void VisualShaderEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
//editor->hide_animation_player_editors();
|
||||
//editor->animation_panel_make_visible(true);
|
||||
@@ -2965,7 +2875,6 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) {
|
||||
visual_shader_editor->set_process_input(true);
|
||||
//visual_shader_editor->set_process(true);
|
||||
} else {
|
||||
|
||||
if (visual_shader_editor->is_visible_in_tree())
|
||||
editor->hide_bottom_panel();
|
||||
button->hide();
|
||||
@@ -2975,7 +2884,6 @@ void VisualShaderEditorPlugin::make_visible(bool p_visible) {
|
||||
}
|
||||
|
||||
VisualShaderEditorPlugin::VisualShaderEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
editor = p_node;
|
||||
visual_shader_editor = memnew(VisualShaderEditor);
|
||||
visual_shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
|
||||
@@ -3037,7 +2945,6 @@ class VisualShaderNodePluginDefaultEditor : public VBoxContainer {
|
||||
|
||||
public:
|
||||
void _property_changed(const String &p_property, const Variant &p_value, const String &p_field = "", bool p_changing = false) {
|
||||
|
||||
if (p_changing)
|
||||
return;
|
||||
|
||||
@@ -3049,7 +2956,6 @@ public:
|
||||
undo_redo->add_undo_property(node.ptr(), p_property, node->get(p_property));
|
||||
|
||||
if (p_value.get_type() == Variant::OBJECT) {
|
||||
|
||||
RES prev_res = node->get(p_property);
|
||||
RES curr_res = p_value;
|
||||
|
||||
@@ -3109,7 +3015,6 @@ public:
|
||||
properties = p_properties;
|
||||
|
||||
for (int i = 0; i < p_properties.size(); i++) {
|
||||
|
||||
HBoxContainer *hbox = memnew(HBoxContainer);
|
||||
hbox->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
add_child(hbox);
|
||||
@@ -3147,7 +3052,6 @@ public:
|
||||
};
|
||||
|
||||
Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) {
|
||||
|
||||
if (p_node->is_class("VisualShaderNodeInput")) {
|
||||
//create input
|
||||
VisualShaderNodePluginInputEditor *input_editor = memnew(VisualShaderNodePluginInputEditor);
|
||||
@@ -3166,7 +3070,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
|
||||
Vector<PropertyInfo> pinfo;
|
||||
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
|
||||
for (int i = 0; i < properties.size(); i++) {
|
||||
if (E->get().name == String(properties[i])) {
|
||||
pinfo.push_back(E->get());
|
||||
@@ -3183,7 +3086,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
|
||||
Vector<EditorProperty *> editors;
|
||||
|
||||
for (int i = 0; i < pinfo.size(); i++) {
|
||||
|
||||
EditorProperty *prop = EditorInspector::instantiate_property_editor(node.ptr(), pinfo[i].type, pinfo[i].name, pinfo[i].hint, pinfo[i].hint_string, pinfo[i].usage);
|
||||
if (!prop)
|
||||
return nullptr;
|
||||
@@ -3209,7 +3111,6 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
|
||||
}
|
||||
|
||||
void EditorPropertyShaderMode::_option_selected(int p_which) {
|
||||
|
||||
//will not use this, instead will do all the logic setting manually
|
||||
//emit_signal("property_changed", get_edited_property(), p_which);
|
||||
|
||||
@@ -3227,7 +3128,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
|
||||
|
||||
//1. restore connections to output
|
||||
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(i);
|
||||
List<VisualShader::Connection> conns;
|
||||
visual_shader->get_node_connections(type, &conns);
|
||||
@@ -3239,7 +3139,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
|
||||
}
|
||||
//2. restore input indices
|
||||
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
|
||||
|
||||
VisualShader::Type type = VisualShader::Type(i);
|
||||
Vector<int> nodes = visual_shader->get_node_list(type);
|
||||
for (int j = 0; j < nodes.size(); j++) {
|
||||
@@ -3257,7 +3156,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
|
||||
visual_shader->get_property_list(&props);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
|
||||
if (E->get().name.begins_with("flags/") || E->get().name.begins_with("modes/")) {
|
||||
undo_redo->add_undo_property(visual_shader.ptr(), E->get().name, visual_shader->get(E->get().name));
|
||||
}
|
||||
@@ -3274,7 +3172,6 @@ void EditorPropertyShaderMode::_option_selected(int p_which) {
|
||||
}
|
||||
|
||||
void EditorPropertyShaderMode::update_property() {
|
||||
|
||||
int which = get_edited_object()->get(get_edited_property());
|
||||
options->select(which);
|
||||
}
|
||||
@@ -3309,9 +3206,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) {
|
||||
}
|
||||
|
||||
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
|
||||
|
||||
if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) {
|
||||
|
||||
EditorPropertyShaderMode *editor = memnew(EditorPropertyShaderMode);
|
||||
Vector<String> options = p_hint_text.split(",");
|
||||
editor->setup(options);
|
||||
@@ -3355,7 +3250,6 @@ void VisualShaderNodePortPreview::_shader_changed() {
|
||||
continue;
|
||||
ShaderMaterial *src_mat = Object::cast_to<ShaderMaterial>(object);
|
||||
if (src_mat && src_mat->get_shader().is_valid()) {
|
||||
|
||||
List<PropertyInfo> params;
|
||||
src_mat->get_shader()->get_param_list(¶ms);
|
||||
for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) {
|
||||
@@ -3368,7 +3262,6 @@ void VisualShaderNodePortPreview::_shader_changed() {
|
||||
}
|
||||
|
||||
void VisualShaderNodePortPreview::setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port) {
|
||||
|
||||
shader = p_shader;
|
||||
shader->connect("changed", callable_mp(this, &VisualShaderNodePortPreview::_shader_changed));
|
||||
type = p_type;
|
||||
@@ -3413,18 +3306,15 @@ VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
|
||||
//////////////////////////////////
|
||||
|
||||
String VisualShaderConversionPlugin::converts_to() const {
|
||||
|
||||
return "Shader";
|
||||
}
|
||||
|
||||
bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {
|
||||
|
||||
Ref<VisualShader> vshader = p_resource;
|
||||
return vshader.is_valid();
|
||||
}
|
||||
|
||||
Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
|
||||
Ref<VisualShader> vshader = p_resource;
|
||||
ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user