VisualScript-sync-and-improve-variable-and-property

This commit is contained in:
David Cambré 2021-11-06 12:31:50 +01:00
parent 7538c05215
commit d763ee8398
1 changed files with 16 additions and 11 deletions

View File

@ -2195,20 +2195,20 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Ref<VisualScriptNode> vnode; Ref<VisualScriptNode> vnode;
if (use_set) { if (use_set) {
Ref<VisualScriptVariableSet> vnodes; Ref<VisualScriptPropertySet> pset;
vnodes.instantiate(); pset.instantiate();
vnodes->set_variable(d["variable"]); vnode = pset;
vnode = vnodes;
} else { } else {
Ref<VisualScriptVariableGet> vnodeg; Ref<VisualScriptPropertyGet> pget;
vnodeg.instantiate(); pget.instantiate();
vnodeg->set_variable(d["variable"]); vnode = pget;
vnode = vnodeg;
} }
int new_id = script->get_available_id(); int new_id = script->get_available_id();
undo_redo->create_action(TTR("Add Node")); undo_redo->create_action(TTR("Add Node"));
undo_redo->add_do_method(vnode.ptr(), "set_property", d["variable"]);
undo_redo->add_do_method(vnode.ptr(), "set_base_script", script->get_path());
undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos); undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id); undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_do_method(this, "_update_graph");
@ -2451,12 +2451,14 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
pget.instantiate(); pget.instantiate();
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE); pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
pget->set_base_type(obj->get_class()); pget->set_base_type(obj->get_class());
vnode = pget; vnode = pget;
} }
undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos); undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]); undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!obj->get_script().is_null()) {
undo_redo->add_do_method(vnode.ptr(), "set_base_script", Ref<Script>(obj->get_script())->get_path());
}
if (!use_get) { if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]); undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
} }
@ -2487,7 +2489,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH); pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
pset->set_base_path(sn->get_path_to(node)); pset->set_base_path(sn->get_path_to(node));
} }
vnode = pset; vnode = pset;
} else { } else {
Ref<VisualScriptPropertyGet> pget; Ref<VisualScriptPropertyGet> pget;
@ -2502,9 +2503,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos); undo_redo->add_do_method(script.ptr(), "add_node", base_id, vnode, pos);
undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]); undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
if (!obj->get_script().is_null()) {
undo_redo->add_do_method(vnode.ptr(), "set_base_script", Ref<Script>(obj->get_script())->get_path());
}
if (!use_get) { if (!use_get) {
undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]); undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
} }
undo_redo->add_undo_method(script.ptr(), "remove_node", base_id); undo_redo->add_undo_method(script.ptr(), "remove_node", base_id);
undo_redo->add_do_method(this, "_update_graph"); undo_redo->add_do_method(this, "_update_graph");