mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-07 00:25:54 +01:00
Second round of cleanups to MMGraphNode.
This commit is contained in:
parent
0d5514856f
commit
4f6a2df5a5
@ -102,7 +102,7 @@ int MMGraphNode::add_slot_texture(const String &getter, const String &setter) {
|
|||||||
t->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
|
t->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED);
|
||||||
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, getter, setter, t);
|
int slot_idx = add_slot(MMNodeUniversalProperty::SLOT_TYPE_NONE, MMNodeUniversalProperty::SLOT_TYPE_NONE, getter, setter, t);
|
||||||
t->set_texture(_node->call(getter, _material, slot_idx));
|
t->set_texture(_node->call(getter, _material, slot_idx));
|
||||||
properties[slot_idx].append(t->get_texture());
|
properties.write[slot_idx].texture = t->get_texture();
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ int MMGraphNode::add_slot_texture_universal(const Ref<MMNodeUniversalProperty> &
|
|||||||
}
|
}
|
||||||
|
|
||||||
t->set_texture(tex);
|
t->set_texture(tex);
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
property.connect("changed", self, "on_universal_texture_changed", [slot_idx]);
|
property.connect("changed", self, "on_universal_texture_changed", [slot_idx]);
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ int MMGraphNode::add_slot_color_universal(const Ref<MMNodeUniversalProperty> &pr
|
|||||||
ColorPickerButton *cp = memnew(ColorPickerButton);
|
ColorPickerButton *cp = memnew(ColorPickerButton);
|
||||||
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", cp);
|
int slot_idx = add_slot(property.input_slot_type, property.output_slot_type, "", "", cp);
|
||||||
cp->set_color(property->get_default_value());
|
cp->set_color(property->get_default_value());
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
cp->connect("color_changed", this, "on_universal_color_changed", [slot_idx]);
|
cp->connect("color_changed", this, "on_universal_color_changed", [slot_idx]);
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
@ -235,8 +235,9 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
OptionButton *mb = memnew(OptionButton);
|
OptionButton *mb = memnew(OptionButton);
|
||||||
|
|
||||||
for (v in values) {
|
for (int i = 0; i < values.size(); ++i) {
|
||||||
mb.add_item(v);
|
String v = values[i];
|
||||||
|
mb->add_item(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bc->add_child(mb);
|
bc->add_child(mb);
|
||||||
@ -246,7 +247,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MMGraphNode::add_slot_int(const String &getter, const String &setter, const String &slot_name, const Vector2 &prange, const Variant & 1000)) {
|
int MMGraphNode::add_slot_int(const String &getter, const String &setter, const String &slot_name, const Vector2 &prange) {
|
||||||
VBoxContainer *bc = memnew(VBoxContainer);
|
VBoxContainer *bc = memnew(VBoxContainer);
|
||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text(slot_name);
|
l->set_text(slot_name);
|
||||||
@ -275,7 +276,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text(property.slot_name);
|
l->set_text(property.slot_name);
|
||||||
int slot_idx = add_slot(property->input_slot_type, property->output_slot_type, "", "", l);
|
int slot_idx = add_slot(property->input_slot_type, property->output_slot_type, "", "", l);
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,11 +293,11 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
int slot_idx = add_slot(property->input_slot_type, property->output_slot_type, "", "", bc);
|
int slot_idx = add_slot(property->input_slot_type, property->output_slot_type, "", "", bc);
|
||||||
sb->set_value(property->get_default_value());
|
sb->set_value(property->get_default_value());
|
||||||
sb->connect("value_changed", this, "on_int_universal_spinbox_value_changed", [slot_idx]);
|
sb->connect("value_changed", this, "on_int_universal_spinbox_value_changed", [slot_idx]);
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MMGraphNode::add_slot_float(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange, const Variant & 1000)) {
|
int MMGraphNode::add_slot_float(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange) {
|
||||||
VBoxContainer *bc = memnew(VBoxContainer);
|
VBoxContainer *bc = memnew(VBoxContainer);
|
||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text(slot_name);
|
l->set_text(slot_name);
|
||||||
@ -326,7 +327,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
sb->set_min_value(property->value_range.x);
|
sb->set_min_value(property->value_range.x);
|
||||||
sb->set_max_value(property->value_range.y);
|
sb->set_max_value(property->value_range.y);
|
||||||
sb->set_value(property.get_default_value());
|
sb->set_value(property.get_default_value());
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
sb->connect("value_changed", this, "on_float_universal_spinbox_value_changed", [slot_idx]);
|
sb->connect("value_changed", this, "on_float_universal_spinbox_value_changed", [slot_idx]);
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
@ -357,7 +358,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
return slot_idx;
|
return slot_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MMGraphNode::add_slot_vector3(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange, const Variant & 1000)) {
|
int MMGraphNode::add_slot_vector3(const String &getter, const String &setter, const String &slot_name, const float step, const Vector2 &prange) {
|
||||||
VBoxContainer *bc = memnew(VBoxContainer);
|
VBoxContainer *bc = memnew(VBoxContainer);
|
||||||
Label *l = memnew(Label);
|
Label *l = memnew(Label);
|
||||||
l->set_text(slot_name);
|
l->set_text(slot_name);
|
||||||
@ -412,7 +413,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
Vector2 val = property->get_default_value();
|
Vector2 val = property->get_default_value();
|
||||||
sbx.set_value(val.x);
|
sbx.set_value(val.x);
|
||||||
sby.set_value(val.y);
|
sby.set_value(val.y);
|
||||||
properties[slot_idx].append(property);
|
properties.write[slot_idx].universal_property = property;
|
||||||
sbx.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
|
sbx.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
|
||||||
sby.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
|
sby.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ]);
|
||||||
return slot_idx;
|
return slot_idx;
|
||||||
@ -421,6 +422,17 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
int MMGraphNode::add_slot(const int input_type, const int output_type, const String &getter, const String &setter, Control *control) {
|
int MMGraphNode::add_slot(const int input_type, const int output_type, const String &getter, const String &setter, Control *control) {
|
||||||
add_child(control);
|
add_child(control);
|
||||||
int slot_idx = get_child_count() - 1;
|
int slot_idx = get_child_count() - 1;
|
||||||
|
|
||||||
|
MMGraphNodeEntry e;
|
||||||
|
e.slot_idx = slot_idx;
|
||||||
|
e.input_type = input_type;
|
||||||
|
e.output_type = output_type;
|
||||||
|
e.getter = getter;
|
||||||
|
e.setter = setter;
|
||||||
|
e.control = control;
|
||||||
|
properties.push_back(arr);
|
||||||
|
|
||||||
|
/*
|
||||||
Array arr;
|
Array arr;
|
||||||
arr.append(slot_idx);
|
arr.append(slot_idx);
|
||||||
arr.append(input_type);
|
arr.append(input_type);
|
||||||
@ -429,6 +441,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
arr.append(setter);
|
arr.append(setter);
|
||||||
arr.append(control);
|
arr.append(control);
|
||||||
properties.append(arr);
|
properties.append(arr);
|
||||||
|
*/
|
||||||
|
|
||||||
set_slot_enabled_left(slot_idx, input_type != -1);
|
set_slot_enabled_left(slot_idx, input_type != -1);
|
||||||
set_slot_enabled_right(slot_idx, output_type != -1);
|
set_slot_enabled_right(slot_idx, output_type != -1);
|
||||||
|
|
||||||
@ -450,7 +464,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
int to_property_index = -1;
|
int to_property_index = -1;
|
||||||
|
|
||||||
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
||||||
if (properties[i][2] != -1) {
|
if (properties[i].output_type != -1) {
|
||||||
from_property_index += 1;
|
from_property_index += 1;
|
||||||
|
|
||||||
if (from_property_index == slot_idx) {
|
if (from_property_index == slot_idx) {
|
||||||
@ -461,7 +475,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
|
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
|
||||||
if (to_node.properties[i][1] != -1) {
|
if (to_node.properties[i].input_type != -1) {
|
||||||
to_property_index += 1;
|
to_property_index += 1;
|
||||||
|
|
||||||
if (to_property_index == to_slot_idx) {
|
if (to_property_index == to_slot_idx) {
|
||||||
@ -474,8 +488,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
_undo_redo->create_action("MMGD: connect_slot");
|
_undo_redo->create_action("MMGD: connect_slot");
|
||||||
_undo_redo->add_do_method(to_node->properties[to_property_index][6], "set_input_property", properties[from_property_index][6]);
|
_undo_redo->add_do_method(to_node->properties[to_property_index].universal_property, "set_input_property", properties[from_property_index].universal_property);
|
||||||
_undo_redo->add_undo_method(to_node->properties[to_property_index][6], "set_input_property", to_node->properties[to_property_index][6].input_property);
|
_undo_redo->add_undo_method(to_node->properties[to_property_index].universal_property, "set_input_property", to_node->properties[to_property_index].universal_property->input_property);
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -486,7 +500,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
||||||
|
|
||||||
if (properties[i][2] != -1) {
|
if (properties[i].output_type != -1) {
|
||||||
from_property_index += 1;
|
from_property_index += 1;
|
||||||
|
|
||||||
if (from_property_index == slot_idx) {
|
if (from_property_index == slot_idx) {
|
||||||
@ -498,7 +512,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
|
for (int i = 0; i < to_node.properties.size(); ++i) { //i in range(to_node.properties.size())
|
||||||
|
|
||||||
if (to_node.properties[i][1] != -1) {
|
if (to_node.properties[i].input_type != -1) {
|
||||||
to_property_index += 1;
|
to_property_index += 1;
|
||||||
|
|
||||||
if (to_property_index == to_slot_idx) {
|
if (to_property_index == to_slot_idx) {
|
||||||
@ -511,8 +525,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
_undo_redo->create_action("MMGD: disconnect_slot");
|
_undo_redo->create_action("MMGD: disconnect_slot");
|
||||||
_undo_redo->add_do_method(to_node->properties[to_property_index][6], "unset_input_property");
|
_undo_redo->add_do_method(to_node->properties[to_property_index].universal_property, "unset_input_property");
|
||||||
_undo_redo->add_undo_method(to_node->properties[to_property_index][6], "set_input_property", to_node->properties[to_property_index][6].input_property);
|
_undo_redo->add_undo_method(to_node->properties[to_property_index].universal_property, "set_input_property", to_node->properties[to_property_index].universal_property->input_property);
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -522,10 +536,10 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
||||||
|
|
||||||
if (properties[i][1] != -1) {
|
if (properties[i].input_type != -1) {
|
||||||
property_index += 1;
|
property_index += 1;
|
||||||
|
|
||||||
if (properties[i][6] == property) {
|
if (properties[i].universal_property == property) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,10 +553,10 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
for (int i = 0; i < properties.size(); ++i) { //i in range(properties.size())
|
||||||
|
|
||||||
if (properties[i][2] != -1) {
|
if (properties[i].output_type != -1) {
|
||||||
property_index += 1;
|
property_index += 1;
|
||||||
|
|
||||||
if (properties[i][6] == property) {
|
if (properties[i].universal_property == property) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,7 +566,7 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Node MMGraphNode::get_property_control(const int slot_idx) {
|
Node MMGraphNode::get_property_control(const int slot_idx) {
|
||||||
return properties[slot_idx][5];
|
return properties[slot_idx].control;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMGraphNode::set_node(const Ref<MMMaterial> &material, const Ref<MMNode> &node) {
|
void MMGraphNode::set_node(const Ref<MMMaterial> &material, const Ref<MMNode> &node) {
|
||||||
@ -602,8 +616,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], int(val));
|
//_node.call(properties[slot_idx][4], int(val));
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], int(val));
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, int(val));
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx].getter));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -612,8 +626,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], val);
|
//_node.call(properties[slot_idx][4], val);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], val);
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, val);
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx].getter));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -623,8 +637,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], vv);
|
//_node.call(properties[slot_idx][4], vv);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], vv);
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, vv);
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx].getter));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -634,8 +648,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], vv);
|
//_node.call(properties[slot_idx][4], vv);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], vv);
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, vv);
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx][3]));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -644,8 +658,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//properties[slot_idx][6].set_default_value(int(val));
|
//properties[slot_idx][6].set_default_value(int(val));
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(properties[slot_idx][6], "set_default_value", int(val));
|
_undo_redo->add_do_method(properties[slot_idx].universal_property, "set_default_value", int(val));
|
||||||
_undo_redo->add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
|
_undo_redo->add_undo_method(properties[slot_idx].universal_property, "set_default_value", properties[slot_idx].universal_property->get_default_value());
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -654,8 +668,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//properties[slot_idx][6].set_default_value(val);
|
//properties[slot_idx][6].set_default_value(val);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(properties[slot_idx][6], "set_default_value", val);
|
_undo_redo->add_do_method(properties[slot_idx].universal_property, "set_default_value", val);
|
||||||
_undo_redo->add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
|
_undo_redo->add_undo_method(properties[slot_idx].universal_property, "set_default_value", properties[slot_idx].universal_property->get_default_value());
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -665,8 +679,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//properties[slot_idx][6].set_default_value(vv);
|
//properties[slot_idx][6].set_default_value(vv);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(properties[slot_idx][6], "set_default_value", vv);
|
_undo_redo->add_do_method(properties[slot_idx].universal_property, "set_default_value", vv);
|
||||||
_undo_redo->add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
|
_undo_redo->add_undo_method(properties[slot_idx].universal_property, "set_default_value", properties[slot_idx].universal_property->get_default_value());
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -675,21 +689,21 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], val);
|
//_node.call(properties[slot_idx][4], val);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], val);
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, val);
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx].getter));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMGraphNode::on_universal_texture_changed(const int slot_idx) {
|
void MMGraphNode::on_universal_texture_changed(const int slot_idx) {
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
Ref<Image> img = properties[slot_idx][6].get_active_image();
|
Ref<Image> img = properties[slot_idx].universal_property.get_active_image();
|
||||||
Ref<ImageTexture> tex = properties[slot_idx][5].texture;
|
Ref<ImageTexture> tex = properties[slot_idx].control->get_texture();
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
properties[slot_idx][5].texture.create_from_image(img, 0);
|
properties[slot_idx].control->get_texture()->create_from_image(img, 0);
|
||||||
}
|
}
|
||||||
properties[slot_idx][5].texture = ImageTexture.new();
|
properties[slot_idx].control->set_texture(ImageTexture.new());
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
@ -697,11 +711,11 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
|
|
||||||
void MMGraphNode::on_universal_texture_changed_image_picker(const int slot_idx) {
|
void MMGraphNode::on_universal_texture_changed_image_picker(const int slot_idx) {
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
Ref<Image> img = properties[slot_idx][6].get_active_image();
|
Ref<Image> img = properties[slot_idx].universal_property->get_active_image();
|
||||||
Ref<ImageTexture> tex = properties[slot_idx][5].texture_normal;
|
Ref<ImageTexture> tex = properties[slot_idx].control->get_texture_normal();
|
||||||
|
|
||||||
if (img.is_valid()) {
|
if (img.is_valid()) {
|
||||||
properties[slot_idx][5].texture_normal.create_from_image(img, 0);
|
properties[slot_idx].control->get_texture_normal().create_from_image(img, 0);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,8 +726,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//_node.call(properties[slot_idx][4], text);
|
//_node.call(properties[slot_idx][4], text);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(_node, properties[slot_idx][4], text);
|
_undo_redo->add_do_method(_node, properties[slot_idx].setter, text);
|
||||||
_undo_redo->add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]));
|
_undo_redo->add_undo_method(_node, properties[slot_idx].setter, _node.call(properties[slot_idx].getter));
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -722,8 +736,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
//properties[slot_idx][6].set_default_value(c);
|
//properties[slot_idx][6].set_default_value(c);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(properties[slot_idx][6], "set_default_value", c);
|
_undo_redo->add_do_method(properties[slot_idx].universal_property, "set_default_value", c);
|
||||||
_undo_redo->add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
|
_undo_redo->add_undo_method(properties[slot_idx].universal_property, "set_default_value", properties[slot_idx].universal_property->get_default_value());
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
@ -732,8 +746,8 @@ int MMGraphNode::add_slot_enum(const String &getter, const String &setter, const
|
|||||||
_node.call(properties[slot_idx][8], f);
|
_node.call(properties[slot_idx][8], f);
|
||||||
ignore_changes(true);
|
ignore_changes(true);
|
||||||
_undo_redo->create_action("MMGD: value changed");
|
_undo_redo->create_action("MMGD: value changed");
|
||||||
_undo_redo->add_do_method(properties[slot_idx][6], "set_default_value", f);
|
_undo_redo->add_do_method(properties[slot_idx].universal_property, "set_default_value", f);
|
||||||
_undo_redo->add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value());
|
_undo_redo->add_undo_method(properties[slot_idx].universal_property, "set_default_value", properties[slot_idx].universal_property->get_default_value());
|
||||||
_undo_redo->commit_action();
|
_undo_redo->commit_action();
|
||||||
ignore_changes(false);
|
ignore_changes(false);
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,15 @@
|
|||||||
|
|
||||||
#include "core/math/vector2.h"
|
#include "core/math/vector2.h"
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
|
#include "core/undo_redo.h"
|
||||||
#include "core/ustring.h"
|
#include "core/ustring.h"
|
||||||
|
#include "core/vector.h"
|
||||||
|
|
||||||
#include "scene/gui/graph_node.h"
|
#include "scene/gui/graph_node.h"
|
||||||
|
|
||||||
class MMMaterial;
|
class MMMaterial;
|
||||||
class MMNode;
|
class MMNode;
|
||||||
class PackedScene;
|
class PackedScene;
|
||||||
class UndoRedo;
|
|
||||||
class MatMakerGDEditor;
|
class MatMakerGDEditor;
|
||||||
class MMNodeUniversalProperty;
|
class MMNodeUniversalProperty;
|
||||||
|
|
||||||
@ -109,12 +110,30 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
struct MMGraphNodeEntry {
|
||||||
|
int slot_idx;
|
||||||
|
int input_type;
|
||||||
|
int output_type;
|
||||||
|
String getter;
|
||||||
|
String setter;
|
||||||
|
Control *control;
|
||||||
|
Ref<MMGraphNodeEntry> universal_property;
|
||||||
|
Ref<Texture> texture;
|
||||||
|
|
||||||
|
MMGraphNodeEntry() {
|
||||||
|
slot_idx = 0;
|
||||||
|
input_type = 0;
|
||||||
|
output_type = 0;
|
||||||
|
control = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Ref<PackedScene> gradient_editor_scene; // = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn");
|
Ref<PackedScene> gradient_editor_scene; // = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn");
|
||||||
Ref<PackedScene> polygon_edit_scene; // = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
|
Ref<PackedScene> polygon_edit_scene; // = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn");
|
||||||
Ref<PackedScene> curve_edit_scene; // = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn");
|
Ref<PackedScene> curve_edit_scene; // = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn");
|
||||||
Ref<MMMaterial> _material;
|
Ref<MMMaterial> _material;
|
||||||
Ref<MMNode> _node;
|
Ref<MMNode> _node;
|
||||||
Array properties;
|
Vector<MMGraphNodeEntry> properties;
|
||||||
MatMakerGDEditor *_editor_node;
|
MatMakerGDEditor *_editor_node;
|
||||||
UndoRedo *_undo_redo;
|
UndoRedo *_undo_redo;
|
||||||
bool _ignore_change_event;
|
bool _ignore_change_event;
|
||||||
|
Loading…
Reference in New Issue
Block a user