summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp30
-rw-r--r--modules/gdscript/gdscript_parser.cpp14
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp39
-rw-r--r--scene/resources/visual_shader_nodes.cpp2
4 files changed, 61 insertions, 24 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 48f64e041c..0a067dfc17 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -491,6 +491,35 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
bool is_curve = curve.is_valid() || curve_xyz.is_valid();
if (is_curve) {
+ // a default value handling
+ {
+ Variant default_value;
+ bool port_left_used = false;
+
+ for (const VisualShader::Connection &E : connections) {
+ if (E.to_node == p_id && E.to_port == 0) {
+ port_left_used = true;
+ break;
+ }
+ }
+
+ if (!port_left_used) {
+ default_value = vsnode->get_input_port_default_value(0);
+ }
+
+ Button *button = memnew(Button);
+ custom_editor->add_child(button);
+ register_default_input_button(p_id, 0, button);
+ custom_editor->move_child(button, 0);
+
+ button->connect("pressed", callable_mp(VisualShaderEditor::get_singleton(), &VisualShaderEditor::_edit_port_default_input), varray(button, p_id, 0));
+ if (default_value.get_type() != Variant::NIL) {
+ set_input_port_default_value(p_type, p_id, 0, default_value);
+ } else {
+ button->hide();
+ }
+ }
+
VisualShaderEditor::get_singleton()->graph->add_child(node);
VisualShaderEditor::get_singleton()->_update_created_node(node);
@@ -643,6 +672,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
for (const VisualShader::Connection &E : connections) {
if (E.to_node == p_id && E.to_port == j) {
port_left_used = true;
+ break;
}
}
}
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 40be5cb324..7ddb9b93b4 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -967,15 +967,17 @@ void GDScriptParser::parse_property_setter(VariableNode *p_variable) {
ParameterNode *parameter = alloc_node<ParameterNode>();
parameter->identifier = p_variable->setter_parameter;
- function->parameters_indices[parameter->identifier->name] = 0;
- function->parameters.push_back(parameter);
+ if (parameter->identifier != nullptr) {
+ function->parameters_indices[parameter->identifier->name] = 0;
+ function->parameters.push_back(parameter);
- SuiteNode *body = alloc_node<SuiteNode>();
- body->add_local(parameter, function);
+ SuiteNode *body = alloc_node<SuiteNode>();
+ body->add_local(parameter, function);
- function->body = parse_suite("setter declaration", body);
+ function->body = parse_suite("setter declaration", body);
+ p_variable->setter = function;
+ }
- p_variable->setter = function;
current_function = previous_function;
break;
}
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 12d6ceb9be..f8736dd043 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -139,61 +139,65 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type, bool *r_nil_is_
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
- MonoArrayType *array_type = mono_type_get_array_type(p_type.type_class->get_mono_type());
+ MonoClass *elem_class = mono_class_get_element_class(p_type.type_class->get_mono_ptr());
- if (array_type->eklass == CACHED_CLASS_RAW(MonoObject)) {
+ if (elem_class == CACHED_CLASS_RAW(MonoObject)) {
return Variant::ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(uint8_t)) {
+ if (elem_class == CACHED_CLASS_RAW(uint8_t)) {
return Variant::PACKED_BYTE_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(int32_t)) {
+ if (elem_class == CACHED_CLASS_RAW(int32_t)) {
return Variant::PACKED_INT32_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(int64_t)) {
+ if (elem_class == CACHED_CLASS_RAW(int64_t)) {
return Variant::PACKED_INT64_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(float)) {
+ if (elem_class == CACHED_CLASS_RAW(float)) {
return Variant::PACKED_FLOAT32_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(double)) {
+ if (elem_class == CACHED_CLASS_RAW(double)) {
return Variant::PACKED_FLOAT64_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(String)) {
+ if (elem_class == CACHED_CLASS_RAW(String)) {
return Variant::PACKED_STRING_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(Vector2)) {
+ if (elem_class == CACHED_CLASS_RAW(Vector2)) {
return Variant::PACKED_VECTOR2_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(Vector3)) {
+ if (elem_class == CACHED_CLASS_RAW(Vector3)) {
return Variant::PACKED_VECTOR3_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(Color)) {
+ if (elem_class == CACHED_CLASS_RAW(Color)) {
return Variant::PACKED_COLOR_ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(StringName)) {
+ if (elem_class == CACHED_CLASS_RAW(StringName)) {
return Variant::ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(NodePath)) {
+ if (elem_class == CACHED_CLASS_RAW(NodePath)) {
return Variant::ARRAY;
}
- if (array_type->eklass == CACHED_CLASS_RAW(RID)) {
+ if (elem_class == CACHED_CLASS_RAW(RID)) {
return Variant::ARRAY;
}
- GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
+ if (mono_class_is_enum(elem_class)) {
+ return Variant::ARRAY;
+ }
+
+ GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(elem_class);
if (CACHED_CLASS(GodotObject)->is_assignable_from(array_type_class)) {
return Variant::ARRAY;
}
@@ -302,9 +306,8 @@ bool try_get_array_element_type(const ManagedType &p_array_type, ManagedType &r_
switch (p_array_type.type_encoding) {
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {
- MonoArrayType *array_type = mono_type_get_array_type(p_array_type.type_class->get_mono_type());
- GDMonoClass *array_type_class = GDMono::get_singleton()->get_class(array_type->eklass);
- r_elem_type = ManagedType::from_class(array_type_class);
+ MonoClass *elem_class = mono_class_get_element_class(p_array_type.type_class->get_mono_ptr());
+ r_elem_type = ManagedType::from_class(elem_class);
return true;
} break;
case MONO_TYPE_GENERICINST: {
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index e45dfdcb1b..c3d9ef7b04 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -918,6 +918,7 @@ bool VisualShaderNodeCurveTexture::is_use_prop_slots() const {
}
VisualShaderNodeCurveTexture::VisualShaderNodeCurveTexture() {
+ set_input_port_default_value(0, 0.0);
simple_decl = true;
allow_v_resize = false;
}
@@ -1002,6 +1003,7 @@ bool VisualShaderNodeCurveXYZTexture::is_use_prop_slots() const {
}
VisualShaderNodeCurveXYZTexture::VisualShaderNodeCurveXYZTexture() {
+ set_input_port_default_value(0, 0.0);
simple_decl = true;
allow_v_resize = false;
}