summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp59
-rw-r--r--modules/visual_script/visual_script_editor.cpp597
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp20
-rw-r--r--modules/visual_script/visual_script_nodes.cpp17
4 files changed, 398 insertions, 295 deletions
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 2c8796820e..972be5f5a4 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -1175,6 +1175,65 @@ void VisualScriptBuiltinFunc::_bind_methods() {
cc += func_name[i];
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, cc), "set_func", "get_func");
+
+ BIND_ENUM_CONSTANT(MATH_SIN);
+ BIND_ENUM_CONSTANT(MATH_COS);
+ BIND_ENUM_CONSTANT(MATH_TAN);
+ BIND_ENUM_CONSTANT(MATH_SINH);
+ BIND_ENUM_CONSTANT(MATH_COSH);
+ BIND_ENUM_CONSTANT(MATH_TANH);
+ BIND_ENUM_CONSTANT(MATH_ASIN);
+ BIND_ENUM_CONSTANT(MATH_ACOS);
+ BIND_ENUM_CONSTANT(MATH_ATAN);
+ BIND_ENUM_CONSTANT(MATH_ATAN2);
+ BIND_ENUM_CONSTANT(MATH_SQRT);
+ BIND_ENUM_CONSTANT(MATH_FMOD);
+ BIND_ENUM_CONSTANT(MATH_FPOSMOD);
+ BIND_ENUM_CONSTANT(MATH_FLOOR);
+ BIND_ENUM_CONSTANT(MATH_CEIL);
+ BIND_ENUM_CONSTANT(MATH_ROUND);
+ BIND_ENUM_CONSTANT(MATH_ABS);
+ BIND_ENUM_CONSTANT(MATH_SIGN);
+ BIND_ENUM_CONSTANT(MATH_POW);
+ BIND_ENUM_CONSTANT(MATH_LOG);
+ BIND_ENUM_CONSTANT(MATH_EXP);
+ BIND_ENUM_CONSTANT(MATH_ISNAN);
+ BIND_ENUM_CONSTANT(MATH_ISINF);
+ BIND_ENUM_CONSTANT(MATH_EASE);
+ BIND_ENUM_CONSTANT(MATH_DECIMALS);
+ BIND_ENUM_CONSTANT(MATH_STEPIFY);
+ BIND_ENUM_CONSTANT(MATH_LERP);
+ BIND_ENUM_CONSTANT(MATH_DECTIME);
+ BIND_ENUM_CONSTANT(MATH_RANDOMIZE);
+ BIND_ENUM_CONSTANT(MATH_RAND);
+ BIND_ENUM_CONSTANT(MATH_RANDF);
+ BIND_ENUM_CONSTANT(MATH_RANDOM);
+ BIND_ENUM_CONSTANT(MATH_SEED);
+ BIND_ENUM_CONSTANT(MATH_RANDSEED);
+ BIND_ENUM_CONSTANT(MATH_DEG2RAD);
+ BIND_ENUM_CONSTANT(MATH_RAD2DEG);
+ BIND_ENUM_CONSTANT(MATH_LINEAR2DB);
+ BIND_ENUM_CONSTANT(MATH_DB2LINEAR);
+ BIND_ENUM_CONSTANT(LOGIC_MAX);
+ BIND_ENUM_CONSTANT(LOGIC_MIN);
+ BIND_ENUM_CONSTANT(LOGIC_CLAMP);
+ BIND_ENUM_CONSTANT(LOGIC_NEAREST_PO2);
+ BIND_ENUM_CONSTANT(OBJ_WEAKREF);
+ BIND_ENUM_CONSTANT(FUNC_FUNCREF);
+ BIND_ENUM_CONSTANT(TYPE_CONVERT);
+ BIND_ENUM_CONSTANT(TYPE_OF);
+ BIND_ENUM_CONSTANT(TYPE_EXISTS);
+ BIND_ENUM_CONSTANT(TEXT_CHAR);
+ BIND_ENUM_CONSTANT(TEXT_STR);
+ BIND_ENUM_CONSTANT(TEXT_PRINT);
+ BIND_ENUM_CONSTANT(TEXT_PRINTERR);
+ BIND_ENUM_CONSTANT(TEXT_PRINTRAW);
+ BIND_ENUM_CONSTANT(VAR_TO_STR);
+ BIND_ENUM_CONSTANT(STR_TO_VAR);
+ BIND_ENUM_CONSTANT(VAR_TO_BYTES);
+ BIND_ENUM_CONSTANT(BYTES_TO_VAR);
+ BIND_ENUM_CONSTANT(COLORN);
+ BIND_ENUM_CONSTANT(FUNC_MAX);
}
VisualScriptBuiltinFunc::VisualScriptBuiltinFunc() {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index d415618383..671a507377 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -1397,415 +1397,424 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
- if (p_from == graph) {
+ if (p_from != graph) {
+ return;
+ }
- Dictionary d = p_data;
- if (d.has("type") && String(d["type"]) == "visual_script_node_drag") {
+ Dictionary d = p_data;
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (!d.has("type")) {
+ return;
+ }
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ if (String(d["type"]) == "visual_script_node_drag") {
+ if (!d.has("node_type") || String(d["node_type"]) == "Null") {
+ return;
+ }
- ofs /= EDSCALE;
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
- Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(d["node_type"]);
- int new_id = script->get_available_id();
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ ofs /= EDSCALE;
- Node *node = graph->get_node(itos(new_id));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(d["node_type"]);
+ int new_id = script->get_available_id();
+
+ undo_redo->create_action(TTR("Add Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
+
+ Node *node = graph->get_node(itos(new_id));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
+ }
- if (d.has("type") && String(d["type"]) == "visual_script_variable_drag") {
+ if (String(d["type"]) == "visual_script_variable_drag") {
#ifdef OSX_ENABLED
- bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_set = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_set = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- ofs /= EDSCALE;
+ ofs /= EDSCALE;
- Ref<VisualScriptNode> vnode;
- if (use_set) {
- Ref<VisualScriptVariableSet> vnodes;
- vnodes.instance();
- vnodes->set_variable(d["variable"]);
- vnode = vnodes;
- } else {
+ Ref<VisualScriptNode> vnode;
+ if (use_set) {
+ Ref<VisualScriptVariableSet> vnodes;
+ vnodes.instance();
+ vnodes->set_variable(d["variable"]);
+ vnode = vnodes;
+ } else {
- Ref<VisualScriptVariableGet> vnodeg;
- vnodeg.instance();
- vnodeg->set_variable(d["variable"]);
- vnode = vnodeg;
- }
+ Ref<VisualScriptVariableGet> vnodeg;
+ vnodeg.instance();
+ vnodeg->set_variable(d["variable"]);
+ 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->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->create_action(TTR("Add Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
- Node *node = graph->get_node(itos(new_id));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Node *node = graph->get_node(itos(new_id));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
+ }
- if (d.has("type") && String(d["type"]) == "visual_script_function_drag") {
+ if (String(d["type"]) == "visual_script_function_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- ofs /= EDSCALE;
+ ofs /= EDSCALE;
- Ref<VisualScriptFunctionCall> vnode;
- vnode.instance();
- vnode->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF);
+ Ref<VisualScriptFunctionCall> vnode;
+ vnode.instance();
+ vnode->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF);
- int new_id = script->get_available_id();
+ int new_id = script->get_available_id();
- undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
- undo_redo->add_do_method(vnode.ptr(), "set_base_type", script->get_instance_base_type());
- undo_redo->add_do_method(vnode.ptr(), "set_function", d["function"]);
+ undo_redo->create_action(TTR("Add Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
+ undo_redo->add_do_method(vnode.ptr(), "set_base_type", script->get_instance_base_type());
+ undo_redo->add_do_method(vnode.ptr(), "set_function", d["function"]);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
- Node *node = graph->get_node(itos(new_id));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Node *node = graph->get_node(itos(new_id));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
+ }
- if (d.has("type") && String(d["type"]) == "visual_script_signal_drag") {
+ if (String(d["type"]) == "visual_script_signal_drag") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- ofs /= EDSCALE;
+ ofs /= EDSCALE;
- Ref<VisualScriptEmitSignal> vnode;
- vnode.instance();
- vnode->set_signal(d["signal"]);
+ Ref<VisualScriptEmitSignal> vnode;
+ vnode.instance();
+ vnode->set_signal(d["signal"]);
- int new_id = script->get_available_id();
+ int new_id = script->get_available_id();
- undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->create_action(TTR("Add Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, vnode, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
- Node *node = graph->get_node(itos(new_id));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Node *node = graph->get_node(itos(new_id));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
+ }
- if (d.has("type") && String(d["type"]) == "resource") {
+ if (String(d["type"]) == "resource") {
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- ofs /= EDSCALE;
+ ofs /= EDSCALE;
- Ref<VisualScriptPreload> prnode;
- prnode.instance();
- prnode->set_preload(d["resource"]);
+ Ref<VisualScriptPreload> prnode;
+ prnode.instance();
+ prnode->set_preload(d["resource"]);
- int new_id = script->get_available_id();
+ int new_id = script->get_available_id();
- undo_redo->create_action(TTR("Add Preload Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, prnode, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->create_action(TTR("Add Preload Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, prnode, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
- Node *node = graph->get_node(itos(new_id));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Node *node = graph->get_node(itos(new_id));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
+ }
- if (d.has("type") && String(d["type"]) == "files") {
-
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ if (String(d["type"]) == "files") {
- ofs /= EDSCALE;
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- Array files = d["files"];
+ ofs /= EDSCALE;
- List<int> new_ids;
- int new_id = script->get_available_id();
+ Array files = d["files"];
- if (files.size()) {
- undo_redo->create_action(TTR("Add Preload Node"));
+ List<int> new_ids;
+ int new_id = script->get_available_id();
- for (int i = 0; i < files.size(); i++) {
+ if (files.size()) {
+ undo_redo->create_action(TTR("Add Preload Node"));
- Ref<Resource> res = ResourceLoader::load(files[i]);
- if (!res.is_valid())
- continue;
+ for (int i = 0; i < files.size(); i++) {
- Ref<VisualScriptPreload> prnode;
- prnode.instance();
- prnode->set_preload(res);
+ Ref<Resource> res = ResourceLoader::load(files[i]);
+ if (!res.is_valid())
+ continue;
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, prnode, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
- new_ids.push_back(new_id);
- new_id++;
- ofs += Vector2(20, 20) * EDSCALE;
- }
+ Ref<VisualScriptPreload> prnode;
+ prnode.instance();
+ prnode->set_preload(res);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, new_id, prnode, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, new_id);
+ new_ids.push_back(new_id);
+ new_id++;
+ ofs += Vector2(20, 20) * EDSCALE;
}
- for (List<int>::Element *E = new_ids.front(); E; E = E->next()) {
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
+ }
+
+ for (List<int>::Element *E = new_ids.front(); E; E = E->next()) {
- Node *node = graph->get_node(itos(E->get()));
- if (node) {
- graph->set_selected(node);
- _node_selected(node);
- }
+ Node *node = graph->get_node(itos(E->get()));
+ if (node) {
+ graph->set_selected(node);
+ _node_selected(node);
}
}
+ }
- if (d.has("type") && String(d["type"]) == "nodes") {
+ if (String(d["type"]) == "nodes") {
- Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
+ Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
- if (!sn) {
- EditorNode::get_singleton()->show_warning("Can't drop nodes because script '" + get_name() + "' is not used in this scene.");
- return;
- }
+ if (!sn) {
+ EditorNode::get_singleton()->show_warning("Can't drop nodes because script '" + get_name() + "' is not used in this scene.");
+ return;
+ }
#ifdef OSX_ENABLED
- bool use_node = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_node = Input::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_node = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_node = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
- Array nodes = d["nodes"];
+ Array nodes = d["nodes"];
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
- ofs /= EDSCALE;
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
+ ofs /= EDSCALE;
- undo_redo->create_action(TTR("Add Node(s) From Tree"));
- int base_id = script->get_available_id();
+ undo_redo->create_action(TTR("Add Node(s) From Tree"));
+ int base_id = script->get_available_id();
- if (nodes.size() > 1) {
- use_node = true;
- }
+ if (nodes.size() > 1) {
+ use_node = true;
+ }
- for (int i = 0; i < nodes.size(); i++) {
+ for (int i = 0; i < nodes.size(); i++) {
- NodePath np = nodes[i];
- Node *node = get_node(np);
- if (!node) {
- continue;
- }
-
- Ref<VisualScriptNode> n;
+ NodePath np = nodes[i];
+ Node *node = get_node(np);
+ if (!node) {
+ continue;
+ }
- if (use_node) {
- Ref<VisualScriptSceneNode> scene_node;
- scene_node.instance();
- scene_node->set_node_path(sn->get_path_to(node));
- n = scene_node;
+ Ref<VisualScriptNode> n;
- } else {
- Ref<VisualScriptFunctionCall> call;
- call.instance();
- call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
- call->set_base_path(sn->get_path_to(node));
- call->set_base_type(node->get_class());
- n = call;
-
- method_select->select_method_from_instance(node);
- selecting_method_id = base_id;
- }
+ if (use_node) {
+ Ref<VisualScriptSceneNode> scene_node;
+ scene_node.instance();
+ scene_node->set_node_path(sn->get_path_to(node));
+ n = scene_node;
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, n, ofs);
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
+ } else {
+ Ref<VisualScriptFunctionCall> call;
+ call.instance();
+ call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
+ call->set_base_path(sn->get_path_to(node));
+ call->set_base_type(node->get_class());
+ n = call;
- base_id++;
- ofs += Vector2(25, 25);
+ method_select->select_method_from_instance(node);
+ selecting_method_id = base_id;
}
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, n, ofs);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
+
+ base_id++;
+ ofs += Vector2(25, 25);
}
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
+ }
- if (d.has("type") && String(d["type"]) == "obj_property") {
+ if (String(d["type"]) == "obj_property") {
- Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
+ Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
- if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
- EditorNode::get_singleton()->show_warning("Can't drop properties because script '" + get_name() + "' is not used in this scene.\nDrop holding 'Shift' to just copy the signature.");
- return;
- }
+ if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ EditorNode::get_singleton()->show_warning("Can't drop properties because script '" + get_name() + "' is not used in this scene.\nDrop holding 'Shift' to just copy the signature.");
+ return;
+ }
- Object *obj = d["object"];
+ Object *obj = d["object"];
- if (!obj)
- return;
+ if (!obj)
+ return;
- Node *node = Object::cast_to<Node>(obj);
- Vector2 ofs = graph->get_scroll_ofs() + p_point;
+ Node *node = Object::cast_to<Node>(obj);
+ Vector2 ofs = graph->get_scroll_ofs() + p_point;
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
- ofs = ofs.snapped(Vector2(snap, snap));
- }
+ if (graph->is_using_snap()) {
+ int snap = graph->get_snap();
+ ofs = ofs.snapped(Vector2(snap, snap));
+ }
- ofs /= EDSCALE;
+ ofs /= EDSCALE;
#ifdef OSX_ENABLED
- bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
+ bool use_get = Input::get_singleton()->is_key_pressed(KEY_META);
#else
- bool use_get = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
+ bool use_get = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
#endif
- if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
- if (use_get)
- undo_redo->create_action(TTR("Add Getter Property"));
- else
- undo_redo->create_action(TTR("Add Setter Property"));
+ if (use_get)
+ undo_redo->create_action(TTR("Add Getter Property"));
+ else
+ undo_redo->create_action(TTR("Add Setter Property"));
- int base_id = script->get_available_id();
+ int base_id = script->get_available_id();
- Ref<VisualScriptNode> vnode;
+ Ref<VisualScriptNode> vnode;
- if (!use_get) {
+ if (!use_get) {
- Ref<VisualScriptPropertySet> pset;
- pset.instance();
- pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
- pset->set_base_type(obj->get_class());
- /*if (use_value) {
+ Ref<VisualScriptPropertySet> pset;
+ pset.instance();
+ pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
+ pset->set_base_type(obj->get_class());
+ /*if (use_value) {
pset->set_use_builtin_value(true);
pset->set_builtin_value(d["value"]);
}*/
- vnode = pset;
- } else {
-
- Ref<VisualScriptPropertyGet> pget;
- pget.instance();
- pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
- pget->set_base_type(obj->get_class());
+ vnode = pset;
+ } else {
- vnode = pget;
- }
+ Ref<VisualScriptPropertyGet> pget;
+ pget.instance();
+ pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
+ pget->set_base_type(obj->get_class());
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, vnode, ofs);
- undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
- if (!use_get) {
- undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
- }
+ vnode = pget;
+ }
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, vnode, ofs);
+ undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
+ if (!use_get) {
+ undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
+ }
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
- } else {
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
- if (use_get)
- undo_redo->create_action(TTR("Add Getter Property"));
- else
- undo_redo->create_action(TTR("Add Setter Property"));
+ } else {
- int base_id = script->get_available_id();
+ if (use_get)
+ undo_redo->create_action(TTR("Add Getter Property"));
+ else
+ undo_redo->create_action(TTR("Add Setter Property"));
- Ref<VisualScriptNode> vnode;
+ int base_id = script->get_available_id();
- if (!use_get) {
+ Ref<VisualScriptNode> vnode;
- Ref<VisualScriptPropertySet> pset;
- pset.instance();
- if (sn == node) {
- pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
- } else {
- pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
- pset->set_base_path(sn->get_path_to(node));
- }
+ if (!use_get) {
- vnode = pset;
+ Ref<VisualScriptPropertySet> pset;
+ pset.instance();
+ if (sn == node) {
+ pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
} else {
-
- Ref<VisualScriptPropertyGet> pget;
- pget.instance();
- if (sn == node) {
- pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
- } else {
- pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH);
- pget->set_base_path(sn->get_path_to(node));
- }
- vnode = pget;
+ pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
+ pset->set_base_path(sn->get_path_to(node));
}
- undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, vnode, ofs);
- undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
- if (!use_get) {
- undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
- }
- undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
+ vnode = pset;
+ } else {
+
+ Ref<VisualScriptPropertyGet> pget;
+ pget.instance();
+ if (sn == node) {
+ pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
+ } else {
+ pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH);
+ pget->set_base_path(sn->get_path_to(node));
+ }
+ vnode = pget;
}
+ undo_redo->add_do_method(script.ptr(), "add_node", edited_func, base_id, vnode, ofs);
+ undo_redo->add_do_method(vnode.ptr(), "set_property", d["property"]);
+ if (!use_get) {
+ undo_redo->add_do_method(vnode.ptr(), "set_default_input_value", 0, d["value"]);
+ }
+ undo_redo->add_undo_method(script.ptr(), "remove_node", edited_func, base_id);
+
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->commit_action();
}
}
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 5fcc5b0ad9..267946750f 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -748,6 +748,13 @@ void VisualScriptFunctionCall::_bind_methods() {
BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SINGLETON);
+
+ BIND_ENUM_CONSTANT(RPC_DISABLED);
+ BIND_ENUM_CONSTANT(RPC_RELIABLE);
+ BIND_ENUM_CONSTANT(RPC_UNRELIABLE);
+ BIND_ENUM_CONSTANT(RPC_RELIABLE_TO_ID);
+ BIND_ENUM_CONSTANT(RPC_UNRELIABLE_TO_ID);
}
class VisualScriptNodeInstanceFunctionCall : public VisualScriptNodeInstance {
@@ -1487,6 +1494,19 @@ void VisualScriptPropertySet::_bind_methods() {
BIND_ENUM_CONSTANT(CALL_MODE_SELF);
BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE);
+
+ BIND_ENUM_CONSTANT(ASSIGN_OP_NONE);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_ADD);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_SUB);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_MUL);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_DIV);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_MOD);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_SHIFT_LEFT);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_SHIFT_RIGHT);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_AND);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_OR);
+ BIND_ENUM_CONSTANT(ASSIGN_OP_BIT_XOR);
}
class VisualScriptNodeInstancePropertySet : public VisualScriptNodeInstance {
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 093f01c49f..b617c11bab 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -1882,6 +1882,16 @@ void VisualScriptMathConstant::_bind_methods() {
cc += const_name[i];
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant");
+
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_ONE);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_PI);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_2PI);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_HALF_PI);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_E);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_SQRT2);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_INF);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_NAN);
+ BIND_ENUM_CONSTANT(MATH_CONSTANT_MAX);
}
VisualScriptMathConstant::VisualScriptMathConstant() {
@@ -2002,7 +2012,7 @@ void VisualScriptEngineSingleton::_bind_methods() {
cc += E->get().name;
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton");
}
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
@@ -3535,6 +3545,11 @@ void VisualScriptInputAction::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action_name", "get_action_name");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Pressed,Released,JustPressed,JustReleased"), "set_action_mode", "get_action_mode");
+
+ BIND_ENUM_CONSTANT(MODE_PRESSED);
+ BIND_ENUM_CONSTANT(MODE_RELEASED);
+ BIND_ENUM_CONSTANT(MODE_JUST_PRESSED);
+ BIND_ENUM_CONSTANT(MODE_JUST_RELEASED);
}
VisualScriptInputAction::VisualScriptInputAction() {