More progress on visual script editing
This commit is contained in:
parent
01ac237ab7
commit
d8af6330e5
15 changed files with 1019 additions and 109 deletions
|
@ -395,6 +395,10 @@ public:
|
|||
|
||||
void get_method_list(List<MethodInfo> *p_list) const;
|
||||
bool has_method(const StringName& p_method) const;
|
||||
static Vector<Variant::Type> get_method_argument_types(Variant::Type p_type,const StringName& p_method);
|
||||
static Vector<Variant> get_method_default_arguments(Variant::Type p_type,const StringName& p_method);
|
||||
static Variant::Type get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return=NULL);
|
||||
static Vector<StringName> get_method_argument_names(Variant::Type p_type,const StringName& p_method);
|
||||
|
||||
void set_named(const StringName& p_index, const Variant& p_value, bool *r_valid=NULL);
|
||||
Variant get_named(const StringName& p_index, bool *r_valid=NULL) const;
|
||||
|
|
|
@ -1173,6 +1173,56 @@ bool Variant::has_method(const StringName& p_method) const {
|
|||
|
||||
}
|
||||
|
||||
Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type,const StringName& p_method) {
|
||||
|
||||
const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
|
||||
if (!E)
|
||||
return Vector<Variant::Type>();
|
||||
|
||||
return E->get().arg_types;
|
||||
}
|
||||
|
||||
Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type,const StringName& p_method) {
|
||||
|
||||
|
||||
const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
|
||||
if (!E)
|
||||
return Vector<StringName>();
|
||||
|
||||
return E->get().arg_names;
|
||||
|
||||
}
|
||||
|
||||
Variant::Type Variant::get_method_return_type(Variant::Type p_type,const StringName& p_method,bool* r_has_return) {
|
||||
|
||||
const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
|
||||
if (!E)
|
||||
return Variant::NIL;
|
||||
|
||||
if (r_has_return)
|
||||
*r_has_return=E->get().return_type;
|
||||
|
||||
return E->get().return_type;
|
||||
}
|
||||
|
||||
Vector<Variant> Variant::get_method_default_arguments(Variant::Type p_type,const StringName& p_method) {
|
||||
|
||||
const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type];
|
||||
|
||||
const Map<StringName,_VariantCall::FuncData>::Element *E = fd.functions.find(p_method);
|
||||
if (!E)
|
||||
return Vector<Variant>();
|
||||
|
||||
return E->get().default_args;
|
||||
|
||||
}
|
||||
|
||||
void Variant::get_method_list(List<MethodInfo> *p_list) const {
|
||||
|
||||
|
||||
|
|
|
@ -52,8 +52,10 @@ void register_visual_script_types() {
|
|||
ObjectTypeDB::register_type<VisualScriptIndexSet>();
|
||||
ObjectTypeDB::register_type<VisualScriptGlobalConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptMathConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptSingleton>();
|
||||
ObjectTypeDB::register_type<VisualScriptEngineSingleton>();
|
||||
ObjectTypeDB::register_type<VisualScriptSceneNode>();
|
||||
ObjectTypeDB::register_type<VisualScriptSceneTree>();
|
||||
ObjectTypeDB::register_type<VisualScriptResourcePath>();
|
||||
|
||||
ObjectTypeDB::register_type<VisualScriptFunctionCall>();
|
||||
ObjectTypeDB::register_type<VisualScriptPropertySet>();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "visual_script_nodes.h"
|
||||
#include "visual_script_flow_control.h"
|
||||
#include "visual_script_func_nodes.h"
|
||||
#include "os/input.h"
|
||||
#include "os/keyboard.h"
|
||||
|
||||
class VisualScriptEditorSignalEdit : public Object {
|
||||
|
||||
|
@ -363,8 +365,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!script->has_function(edited_func))
|
||||
if (!script->has_function(edited_func)) {
|
||||
graph->hide();
|
||||
select_func_text->show();
|
||||
return;
|
||||
}
|
||||
|
||||
graph->show();
|
||||
select_func_text->hide();
|
||||
|
||||
Ref<Texture> type_icons[Variant::VARIANT_MAX]={
|
||||
Control::get_icon("MiniVariant","EditorIcons"),
|
||||
|
@ -762,6 +770,9 @@ void VisualScriptEditor::_override_pressed(int p_id) {
|
|||
undo_redo->add_undo_method(script.ptr(),"remove_function",name);
|
||||
undo_redo->add_do_method(this,"_update_members");
|
||||
undo_redo->add_undo_method(this,"_update_members");
|
||||
undo_redo->add_do_method(this,"_update_graph");
|
||||
undo_redo->add_undo_method(this,"_update_graph");
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
||||
|
||||
|
@ -858,6 +869,9 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
|
|||
undo_redo->add_undo_method(script.ptr(),"remove_function",name);
|
||||
undo_redo->add_do_method(this,"_update_members");
|
||||
undo_redo->add_undo_method(this,"_update_members");
|
||||
undo_redo->add_do_method(this,"_update_graph");
|
||||
undo_redo->add_undo_method(this,"_update_graph");
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
||||
_update_graph();
|
||||
|
@ -935,6 +949,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
|
|||
//}
|
||||
undo_redo->add_do_method(this,"_update_members");
|
||||
undo_redo->add_undo_method(this,"_update_members");
|
||||
undo_redo->add_do_method(this,"_update_graph");
|
||||
undo_redo->add_undo_method(this,"_update_graph");
|
||||
undo_redo->commit_action();
|
||||
|
||||
} else if (p_button==0) {
|
||||
|
@ -1309,20 +1325,62 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2& p_point,const Variant& p
|
|||
|
||||
if (p_from==graph) {
|
||||
|
||||
|
||||
Dictionary d = p_data;
|
||||
if (d.has("type") &&
|
||||
(
|
||||
String(d["type"])=="visual_script_node_drag" ||
|
||||
String(d["type"])=="visual_script_function_drag" ||
|
||||
String(d["type"])=="visual_script_variable_drag" ||
|
||||
String(d["type"])=="visual_script_signal_drag"
|
||||
) )
|
||||
String(d["type"])=="visual_script_signal_drag" ||
|
||||
String(d["type"])=="obj_property" ||
|
||||
String(d["type"])=="nodes"
|
||||
) ) {
|
||||
|
||||
|
||||
if (String(d["type"])=="obj_property") {
|
||||
|
||||
#ifdef OSX_ENABLED
|
||||
const_cast<VisualScriptEditor*>(this)->_show_hint("Hold Meta to drop a Setter, Shift+Meta to drop a Setter and copy the value.");
|
||||
#else
|
||||
const_cast<VisualScriptEditor*>(this)->_show_hint("Hold Ctrl to drop a Setter, Shift+Ctrl to drop a Setter and copy the value.");
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) {
|
||||
|
||||
if (p_edited_scene!=p_current_node && p_current_node->get_owner()!=p_edited_scene)
|
||||
return NULL;
|
||||
|
||||
Ref<Script> scr = p_current_node->get_script();
|
||||
|
||||
if (scr.is_valid() && scr==script)
|
||||
return p_current_node;
|
||||
|
||||
for(int i=0;i<p_current_node->get_child_count();i++) {
|
||||
Node *n = _find_script_node(p_edited_scene,p_current_node->get_child(i),script);
|
||||
if (n)
|
||||
return n;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_data,Control* p_from){
|
||||
|
||||
if (p_from==graph) {
|
||||
|
@ -1430,6 +1488,165 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
|
|||
_node_selected(node);
|
||||
}
|
||||
}
|
||||
if (d.has("type") && String(d["type"])=="nodes") {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Array nodes = d["nodes"];
|
||||
|
||||
Vector2 ofs = graph->get_scroll_ofs() + p_point;
|
||||
|
||||
ofs/=EDSCALE;
|
||||
|
||||
undo_redo->create_action(TTR("Add Node(s) From Tree"));
|
||||
int base_id = script->get_available_id();
|
||||
|
||||
for(int i=0;i<nodes.size();i++) {
|
||||
|
||||
NodePath np = nodes[i];
|
||||
Node *node = get_node(np);
|
||||
if (!node) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Ref<VisualScriptSceneNode> scene_node;
|
||||
scene_node.instance();
|
||||
scene_node->set_node_path(sn->get_path_to(node));
|
||||
undo_redo->add_do_method(script.ptr(),"add_node",edited_func,base_id,scene_node,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") {
|
||||
|
||||
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 properties because script '"+get_name()+"' is not used in this scene.");
|
||||
//return;
|
||||
}
|
||||
|
||||
Object *obj=d["object"];
|
||||
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
Node *node = obj->cast_to<Node>();
|
||||
Vector2 ofs = graph->get_scroll_ofs() + p_point;
|
||||
ofs/=EDSCALE;
|
||||
#ifdef OSX_ENABLED
|
||||
bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
|
||||
#else
|
||||
bool use_set = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
|
||||
#endif
|
||||
|
||||
bool use_value = Input::get_singleton()->is_key_pressed(KEY_SHIFT);
|
||||
|
||||
if (!node) {
|
||||
|
||||
|
||||
if (use_set)
|
||||
undo_redo->create_action(TTR("Add Setter Property"));
|
||||
else
|
||||
undo_redo->create_action(TTR("Add Getter Property"));
|
||||
|
||||
int base_id = script->get_available_id();
|
||||
|
||||
Ref<VisualScriptNode> vnode;
|
||||
|
||||
if (use_set) {
|
||||
|
||||
Ref<VisualScriptPropertySet> pset;
|
||||
pset.instance();
|
||||
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
|
||||
pset->set_base_type(obj->get_type());
|
||||
pset->set_property(d["property"]);
|
||||
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_type());
|
||||
pget->set_property(d["property"]);
|
||||
vnode=pget;
|
||||
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(script.ptr(),"add_node",edited_func,base_id,vnode,ofs);
|
||||
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();
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
if (use_set)
|
||||
undo_redo->create_action(TTR("Add Setter Property"));
|
||||
else
|
||||
undo_redo->create_action(TTR("Add Getter Property"));
|
||||
|
||||
int base_id = script->get_available_id();
|
||||
|
||||
Ref<VisualScriptNode> vnode;
|
||||
|
||||
if (use_set) {
|
||||
|
||||
Ref<VisualScriptPropertySet> pset;
|
||||
pset.instance();
|
||||
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
|
||||
pset->set_base_path(sn->get_path_to(sn));
|
||||
pset->set_property(d["property"]);
|
||||
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_NODE_PATH);
|
||||
pget->set_base_path(sn->get_path_to(sn));
|
||||
pget->set_property(d["property"]);
|
||||
vnode=pget;
|
||||
|
||||
}
|
||||
undo_redo->add_do_method(script.ptr(),"add_node",edited_func,base_id,vnode,ofs);
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1785,6 +2002,20 @@ void VisualScriptEditor::_graph_disconnected(const String& p_from,int p_from_slo
|
|||
}
|
||||
|
||||
|
||||
void VisualScriptEditor::_show_hint(const String& p_hint) {
|
||||
|
||||
hint_text->set_text(p_hint);
|
||||
hint_text->show();
|
||||
hint_text_timer->start();
|
||||
}
|
||||
|
||||
void VisualScriptEditor::_hide_timer() {
|
||||
|
||||
hint_text->hide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VisualScriptEditor::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_member_button",&VisualScriptEditor::_member_button);
|
||||
|
@ -1812,6 +2043,7 @@ void VisualScriptEditor::_bind_methods() {
|
|||
ObjectTypeDB::bind_method("_on_nodes_delete",&VisualScriptEditor::_on_nodes_delete);
|
||||
ObjectTypeDB::bind_method("_on_nodes_duplicate",&VisualScriptEditor::_on_nodes_duplicate);
|
||||
|
||||
ObjectTypeDB::bind_method("_hide_timer",&VisualScriptEditor::_hide_timer);
|
||||
|
||||
ObjectTypeDB::bind_method("_graph_connected",&VisualScriptEditor::_graph_connected);
|
||||
ObjectTypeDB::bind_method("_graph_disconnected",&VisualScriptEditor::_graph_disconnected);
|
||||
|
@ -1870,8 +2102,28 @@ VisualScriptEditor::VisualScriptEditor() {
|
|||
graph->connect("delete_nodes_request",this,"_on_nodes_delete");
|
||||
graph->connect("duplicate_nodes_request",this,"_on_nodes_duplicate");
|
||||
graph->set_drag_forwarding(this);
|
||||
graph->hide();
|
||||
|
||||
select_func_text = memnew( Label );
|
||||
select_func_text->set_text(TTR("Select or create a function to edit graph"));
|
||||
select_func_text->set_align(Label::ALIGN_CENTER);
|
||||
select_func_text->set_valign(Label::VALIGN_CENTER);
|
||||
select_func_text->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
main_hsplit->add_child(select_func_text);
|
||||
|
||||
|
||||
hint_text = memnew( Label );
|
||||
hint_text->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,100);
|
||||
hint_text->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
|
||||
hint_text->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,0);
|
||||
hint_text->set_align(Label::ALIGN_CENTER);
|
||||
hint_text->set_valign(Label::VALIGN_CENTER);
|
||||
graph->add_child(hint_text);
|
||||
|
||||
hint_text_timer = memnew( Timer );
|
||||
hint_text_timer->set_wait_time(4);
|
||||
hint_text_timer->connect("timeout",this,"_hide_timer");
|
||||
add_child(hint_text_timer);
|
||||
|
||||
//allowed casts (connections)
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
|
|
|
@ -47,6 +47,14 @@ class VisualScriptEditor : public ScriptEditorBase {
|
|||
Tree *members;
|
||||
Tree *nodes;
|
||||
|
||||
Label *hint_text;
|
||||
Timer *hint_text_timer;
|
||||
|
||||
Label *select_func_text;
|
||||
|
||||
void _show_hint(const String& p_hint);
|
||||
void _hide_timer();
|
||||
|
||||
CreateDialog *select_base_type;
|
||||
|
||||
struct VirtualInMenu {
|
||||
|
|
|
@ -93,20 +93,36 @@ StringName VisualScriptFunctionCall::_get_base_type() const {
|
|||
|
||||
int VisualScriptFunctionCall::get_input_value_port_count() const{
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
|
||||
Vector<StringName> names = Variant::get_method_argument_names(basic_type,function);
|
||||
return names.size()+1;
|
||||
|
||||
} else {
|
||||
MethodBind *mb = ObjectTypeDB::get_method(_get_base_type(),function);
|
||||
if (!mb)
|
||||
return 0;
|
||||
|
||||
return mb->get_argument_count() + (call_mode==CALL_MODE_INSTANCE?1:0) - use_default_args;
|
||||
}
|
||||
|
||||
}
|
||||
int VisualScriptFunctionCall::get_output_value_port_count() const{
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
bool returns=false;
|
||||
Variant::get_method_return_type(basic_type,function,&returns);
|
||||
return returns?1:0;
|
||||
|
||||
} else {
|
||||
MethodBind *mb = ObjectTypeDB::get_method(_get_base_type(),function);
|
||||
if (!mb)
|
||||
return 0;
|
||||
|
||||
return mb->has_return() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
String VisualScriptFunctionCall::get_output_sequence_port_text(int p_port) const {
|
||||
|
@ -116,11 +132,11 @@ String VisualScriptFunctionCall::get_output_sequence_port_text(int p_port) const
|
|||
|
||||
PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
if (call_mode==CALL_MODE_INSTANCE) {
|
||||
if (call_mode==CALL_MODE_INSTANCE || call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
if (p_idx==0) {
|
||||
PropertyInfo pi;
|
||||
pi.type=Variant::OBJECT;
|
||||
pi.name="instance";
|
||||
pi.type=(call_mode==CALL_MODE_INSTANCE?Variant::OBJECT:basic_type);
|
||||
pi.name=(call_mode==CALL_MODE_INSTANCE?String("instance"):Variant::get_type_name(basic_type).to_lower());
|
||||
return pi;
|
||||
} else {
|
||||
p_idx--;
|
||||
|
@ -129,13 +145,21 @@ PropertyInfo VisualScriptFunctionCall::get_input_value_port_info(int p_idx) cons
|
|||
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
|
||||
Vector<StringName> names = Variant::get_method_argument_names(basic_type,function);
|
||||
Vector<Variant::Type> types = Variant::get_method_argument_types(basic_type,function);
|
||||
return PropertyInfo(types[p_idx],names[p_idx]);
|
||||
|
||||
} else {
|
||||
|
||||
MethodBind *mb = ObjectTypeDB::get_method(_get_base_type(),function);
|
||||
if (!mb)
|
||||
return PropertyInfo();
|
||||
|
||||
return mb->get_argument_info(p_idx);
|
||||
}
|
||||
#else
|
||||
return PropertyInfo();
|
||||
#endif
|
||||
|
@ -147,6 +171,12 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con
|
|||
|
||||
#ifdef DEBUG_METHODS_ENABLED
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
|
||||
return PropertyInfo(Variant::get_method_return_type(basic_type,function),"");
|
||||
} else {
|
||||
|
||||
MethodBind *mb = ObjectTypeDB::get_method(_get_base_type(),function);
|
||||
if (!mb)
|
||||
return PropertyInfo();
|
||||
|
@ -154,6 +184,7 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con
|
|||
PropertyInfo pi = mb->get_argument_info(-1);
|
||||
pi.name="";
|
||||
return pi;
|
||||
}
|
||||
#else
|
||||
return PropertyInfo();
|
||||
#endif
|
||||
|
@ -162,13 +193,22 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con
|
|||
|
||||
String VisualScriptFunctionCall::get_caption() const {
|
||||
|
||||
return "Call";
|
||||
static const char*cname[4]= {
|
||||
"CallSelf",
|
||||
"CallNode",
|
||||
"CallInstance",
|
||||
"CallBasic"
|
||||
};
|
||||
|
||||
return cname[call_mode];
|
||||
}
|
||||
|
||||
String VisualScriptFunctionCall::get_text() const {
|
||||
|
||||
if (call_mode==CALL_MODE_SELF)
|
||||
return " "+String(function)+"()";
|
||||
else if (call_mode==CALL_MODE_BASIC_TYPE)
|
||||
return Variant::get_type_name(basic_type)+"."+String(function)+"()";
|
||||
else
|
||||
return " "+base_type+"."+String(function)+"()";
|
||||
|
||||
|
@ -176,6 +216,9 @@ String VisualScriptFunctionCall::get_text() const {
|
|||
|
||||
void VisualScriptFunctionCall::_update_defargs() {
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
use_default_args = Variant::get_method_default_arguments(basic_type,function).size();
|
||||
} else {
|
||||
if (!get_visual_script().is_valid())
|
||||
return; //do not change if not valid yet
|
||||
|
||||
|
@ -184,9 +227,26 @@ void VisualScriptFunctionCall::_update_defargs() {
|
|||
return;
|
||||
|
||||
use_default_args=mb->get_default_argument_count();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
|
||||
|
||||
if (basic_type==p_type)
|
||||
return;
|
||||
basic_type=p_type;
|
||||
|
||||
_update_defargs();
|
||||
_change_notify();
|
||||
emit_signal("ports_changed");
|
||||
}
|
||||
|
||||
Variant::Type VisualScriptFunctionCall::get_basic_type() const{
|
||||
|
||||
return basic_type;
|
||||
}
|
||||
|
||||
void VisualScriptFunctionCall::set_base_type(const StringName& p_type) {
|
||||
|
||||
if (base_type==p_type)
|
||||
|
@ -275,6 +335,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo& property) const
|
|||
}
|
||||
}
|
||||
|
||||
if (property.name=="function/basic_type") {
|
||||
if (call_mode!=CALL_MODE_BASIC_TYPE) {
|
||||
property.usage=0;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name=="function/node_path") {
|
||||
if (call_mode!=CALL_MODE_NODE_PATH) {
|
||||
|
@ -296,10 +361,25 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo& property) const
|
|||
|
||||
List<MethodInfo> methods;
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
if (basic_type==Variant::NIL) {
|
||||
property.usage=0;
|
||||
return; //nothing for nil
|
||||
}
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_method_list(&methods);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
StringName base = _get_base_type();
|
||||
ObjectTypeDB::get_method_list(base,&methods);
|
||||
|
||||
|
||||
}
|
||||
|
||||
List<String> mstring;
|
||||
for (List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
|
||||
if (E->get().name.begins_with("_"))
|
||||
|
@ -321,18 +401,29 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo& property) const
|
|||
}
|
||||
|
||||
if (property.name=="function/use_default_args") {
|
||||
|
||||
property.hint=PROPERTY_HINT_RANGE;
|
||||
|
||||
int mc=0;
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
mc = Variant::get_method_default_arguments(basic_type,function).size();
|
||||
} else {
|
||||
MethodBind *mb = ObjectTypeDB::get_method(_get_base_type(),function);
|
||||
if (mb) {
|
||||
|
||||
mc=mb->get_default_argument_count();
|
||||
}
|
||||
}
|
||||
|
||||
if (mc==0) {
|
||||
property.usage=0; //do not show
|
||||
} else {
|
||||
|
||||
property.hint_string="0,"+itos(mc)+",1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -341,6 +432,9 @@ void VisualScriptFunctionCall::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptFunctionCall::set_base_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_type"),&VisualScriptFunctionCall::get_base_type);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptFunctionCall::set_basic_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_basic_type"),&VisualScriptFunctionCall::get_basic_type);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_function","function"),&VisualScriptFunctionCall::set_function);
|
||||
ObjectTypeDB::bind_method(_MD("get_function"),&VisualScriptFunctionCall::get_function);
|
||||
|
||||
|
@ -354,8 +448,17 @@ void VisualScriptFunctionCall::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("get_use_default_args"),&VisualScriptFunctionCall::get_use_default_args);
|
||||
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"function/call_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance"),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
String bt;
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
if (i>0)
|
||||
bt+=",";
|
||||
|
||||
bt+=Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"function/call_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance,Basic Type",PROPERTY_USAGE_NOEDITOR),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"function/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"function/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"function/function"),_SCS("set_function"),_SCS("get_function"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"function/use_default_args"),_SCS("set_use_default_args"),_SCS("get_use_default_args"));
|
||||
|
@ -363,6 +466,7 @@ void VisualScriptFunctionCall::_bind_methods() {
|
|||
BIND_CONSTANT( CALL_MODE_SELF );
|
||||
BIND_CONSTANT( CALL_MODE_NODE_PATH);
|
||||
BIND_CONSTANT( CALL_MODE_INSTANCE);
|
||||
BIND_CONSTANT( CALL_MODE_BASIC_TYPE );
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptFunctionCall::instance(VScriptInstance* p_instance) {
|
||||
|
@ -373,6 +477,7 @@ VisualScriptNodeInstance* VisualScriptFunctionCall::instance(VScriptInstance* p_
|
|||
VisualScriptFunctionCall::VisualScriptFunctionCall() {
|
||||
|
||||
call_mode=CALL_MODE_INSTANCE;
|
||||
basic_type=Variant::NIL;
|
||||
use_default_args=0;
|
||||
base_type="Object";
|
||||
|
||||
|
@ -456,12 +561,12 @@ StringName VisualScriptPropertySet::_get_base_type() const {
|
|||
|
||||
int VisualScriptPropertySet::get_input_value_port_count() const{
|
||||
|
||||
if (use_builtin_value)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
int pc = (call_mode==CALL_MODE_BASIC_TYPE || call_mode==CALL_MODE_INSTANCE)?1:0;
|
||||
|
||||
if (!use_builtin_value)
|
||||
pc++;
|
||||
|
||||
return pc;
|
||||
}
|
||||
int VisualScriptPropertySet::get_output_value_port_count() const{
|
||||
|
||||
|
@ -475,11 +580,11 @@ String VisualScriptPropertySet::get_output_sequence_port_text(int p_port) const
|
|||
|
||||
PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
if (call_mode==CALL_MODE_INSTANCE) {
|
||||
if (call_mode==CALL_MODE_INSTANCE || call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
if (p_idx==0) {
|
||||
PropertyInfo pi;
|
||||
pi.type=Variant::OBJECT;
|
||||
pi.name="instance";
|
||||
pi.type=(call_mode==CALL_MODE_INSTANCE?Variant::OBJECT:basic_type);
|
||||
pi.name=(call_mode==CALL_MODE_INSTANCE?String("instance"):Variant::get_type_name(basic_type).to_lower());
|
||||
return pi;
|
||||
} else {
|
||||
p_idx--;
|
||||
|
@ -493,7 +598,13 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
|
|||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_property_list(&pinfo);
|
||||
} else if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
Node *n = _get_base_node();
|
||||
if (n) {
|
||||
|
@ -505,6 +616,7 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
|
|||
ObjectTypeDB::get_property_list(_get_base_type(),&pinfo);
|
||||
}
|
||||
|
||||
|
||||
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
|
||||
|
||||
if (E->get().name==property) {
|
||||
|
@ -531,15 +643,57 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
|
|||
|
||||
String VisualScriptPropertySet::get_caption() const {
|
||||
|
||||
return "Set";
|
||||
static const char*cname[4]= {
|
||||
"SelfSet",
|
||||
"NodeSet",
|
||||
"InstanceSet",
|
||||
"BasicSet"
|
||||
};
|
||||
|
||||
return cname[call_mode];
|
||||
}
|
||||
|
||||
String VisualScriptPropertySet::get_text() const {
|
||||
|
||||
return property;
|
||||
String prop;
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE)
|
||||
prop=Variant::get_type_name(basic_type)+"."+property;
|
||||
else
|
||||
prop=property;
|
||||
|
||||
if (use_builtin_value) {
|
||||
String bit = builtin_value.get_construct_string();
|
||||
if (bit.length()>40) {
|
||||
bit=bit.substr(0,40);
|
||||
bit+="...";
|
||||
}
|
||||
|
||||
prop+="\n "+bit;
|
||||
}
|
||||
|
||||
return prop;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptPropertySet::set_basic_type(Variant::Type p_type) {
|
||||
|
||||
if (basic_type==p_type)
|
||||
return;
|
||||
basic_type=p_type;
|
||||
|
||||
|
||||
_change_notify();
|
||||
emit_signal("ports_changed");
|
||||
}
|
||||
|
||||
Variant::Type VisualScriptPropertySet::get_basic_type() const{
|
||||
|
||||
return basic_type;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptPropertySet::set_base_type(const StringName& p_type) {
|
||||
|
||||
if (base_type==p_type)
|
||||
|
@ -639,6 +793,12 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
|
|||
}
|
||||
|
||||
|
||||
if (property.name=="property/basic_type") {
|
||||
if (call_mode!=CALL_MODE_BASIC_TYPE) {
|
||||
property.usage=0;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name=="property/node_path") {
|
||||
if (call_mode!=CALL_MODE_NODE_PATH) {
|
||||
property.usage=0;
|
||||
|
@ -659,7 +819,13 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
|
|||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_property_list(&pinfo);
|
||||
|
||||
} else if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
Node *n = _get_base_node();
|
||||
if (n) {
|
||||
|
@ -668,16 +834,20 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
|
|||
ObjectTypeDB::get_property_list(_get_base_type(),&pinfo);
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
ObjectTypeDB::get_property_list(_get_base_type(),&pinfo);
|
||||
|
||||
}
|
||||
|
||||
List<String> mstring;
|
||||
|
||||
for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
|
||||
|
||||
if (E->get().usage&PROPERTY_USAGE_EDITOR)
|
||||
if (E->get().usage&PROPERTY_USAGE_EDITOR) {
|
||||
mstring.push_back(E->get().name);
|
||||
}
|
||||
}
|
||||
|
||||
String ml;
|
||||
for (List<String>::Element *E=mstring.front();E;E=E->next()) {
|
||||
|
@ -687,8 +857,12 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
|
|||
ml+=E->get();
|
||||
}
|
||||
|
||||
if (ml==String()) {
|
||||
property.usage=PROPERTY_USAGE_NOEDITOR; //do not show for editing if empty
|
||||
} else {
|
||||
property.hint_string=ml;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name=="value/builtin") {
|
||||
|
||||
|
@ -697,8 +871,12 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo& property) const {
|
|||
} else {
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_property_list(&pinfo);
|
||||
|
||||
if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
} else if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
Node *n = _get_base_node();
|
||||
if (n) {
|
||||
|
@ -729,6 +907,11 @@ void VisualScriptPropertySet::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptPropertySet::set_base_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_type"),&VisualScriptPropertySet::get_base_type);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptPropertySet::set_basic_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_basic_type"),&VisualScriptPropertySet::get_basic_type);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_property","property"),&VisualScriptPropertySet::set_property);
|
||||
ObjectTypeDB::bind_method(_MD("get_property"),&VisualScriptPropertySet::get_property);
|
||||
|
||||
|
@ -744,8 +927,17 @@ void VisualScriptPropertySet::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_use_builtin_value","enable"),&VisualScriptPropertySet::set_use_builtin_value);
|
||||
ObjectTypeDB::bind_method(_MD("is_using_builtin_value"),&VisualScriptPropertySet::is_using_builtin_value);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/set_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance"),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
String bt;
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
if (i>0)
|
||||
bt+=",";
|
||||
|
||||
bt+=Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/set_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance,Basic Type",PROPERTY_USAGE_NOEDITOR),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"property/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/property"),_SCS("set_property"),_SCS("get_property"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"value/use_builtin"),_SCS("set_use_builtin_value"),_SCS("is_using_builtin_value"));
|
||||
|
@ -754,6 +946,7 @@ void VisualScriptPropertySet::_bind_methods() {
|
|||
BIND_CONSTANT( CALL_MODE_SELF );
|
||||
BIND_CONSTANT( CALL_MODE_NODE_PATH);
|
||||
BIND_CONSTANT( CALL_MODE_INSTANCE);
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptPropertySet::instance(VScriptInstance* p_instance) {
|
||||
|
@ -765,6 +958,7 @@ VisualScriptPropertySet::VisualScriptPropertySet() {
|
|||
|
||||
call_mode=CALL_MODE_INSTANCE;
|
||||
base_type="Object";
|
||||
basic_type=Variant::NIL;
|
||||
|
||||
}
|
||||
|
||||
|
@ -779,7 +973,7 @@ static Ref<VisualScriptNode> create_property_set_node(const String& p_name) {
|
|||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////SET//////////////////////
|
||||
////////////////GET//////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptPropertyGet::get_output_sequence_port_count() const {
|
||||
|
@ -846,7 +1040,7 @@ StringName VisualScriptPropertyGet::_get_base_type() const {
|
|||
|
||||
int VisualScriptPropertyGet::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
return (call_mode==CALL_MODE_BASIC_TYPE || call_mode==CALL_MODE_INSTANCE)?1:0;
|
||||
|
||||
}
|
||||
int VisualScriptPropertyGet::get_output_value_port_count() const{
|
||||
|
@ -861,11 +1055,11 @@ String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const
|
|||
|
||||
PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
if (call_mode==CALL_MODE_INSTANCE) {
|
||||
if (call_mode==CALL_MODE_INSTANCE || call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
if (p_idx==0) {
|
||||
PropertyInfo pi;
|
||||
pi.type=Variant::OBJECT;
|
||||
pi.name="instance";
|
||||
pi.type=(call_mode==CALL_MODE_INSTANCE?Variant::OBJECT:basic_type);
|
||||
pi.name=(call_mode==CALL_MODE_INSTANCE?String("instance"):Variant::get_type_name(basic_type).to_lower());
|
||||
return pi;
|
||||
} else {
|
||||
p_idx--;
|
||||
|
@ -886,7 +1080,13 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons
|
|||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
|
||||
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_property_list(&pinfo);
|
||||
} else if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
Node *n = _get_base_node();
|
||||
if (n) {
|
||||
|
@ -917,11 +1117,22 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons
|
|||
|
||||
String VisualScriptPropertyGet::get_caption() const {
|
||||
|
||||
return "Get";
|
||||
static const char*cname[4]= {
|
||||
"SelfGet",
|
||||
"NodeGet",
|
||||
"InstanceGet",
|
||||
"BasicGet"
|
||||
};
|
||||
|
||||
return cname[call_mode];
|
||||
}
|
||||
|
||||
String VisualScriptPropertyGet::get_text() const {
|
||||
|
||||
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE)
|
||||
return Variant::get_type_name(basic_type)+"."+property;
|
||||
else
|
||||
return property;
|
||||
|
||||
}
|
||||
|
@ -987,6 +1198,25 @@ VisualScriptPropertyGet::CallMode VisualScriptPropertyGet::get_call_mode() const
|
|||
return call_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VisualScriptPropertyGet::set_basic_type(Variant::Type p_type) {
|
||||
|
||||
if (basic_type==p_type)
|
||||
return;
|
||||
basic_type=p_type;
|
||||
|
||||
|
||||
_change_notify();
|
||||
emit_signal("ports_changed");
|
||||
}
|
||||
|
||||
Variant::Type VisualScriptPropertyGet::get_basic_type() const{
|
||||
|
||||
return basic_type;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
if (property.name=="property/base_type") {
|
||||
|
@ -996,6 +1226,12 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const {
|
|||
}
|
||||
|
||||
|
||||
if (property.name=="property/basic_type") {
|
||||
if (call_mode!=CALL_MODE_BASIC_TYPE) {
|
||||
property.usage=0;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name=="property/node_path") {
|
||||
if (call_mode!=CALL_MODE_NODE_PATH) {
|
||||
property.usage=0;
|
||||
|
@ -1016,7 +1252,12 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const {
|
|||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
if (call_mode==CALL_MODE_BASIC_TYPE) {
|
||||
Variant::CallError ce;
|
||||
Variant v = Variant::construct(basic_type,NULL,0,ce);
|
||||
v.get_property_list(&pinfo);
|
||||
|
||||
} else if (call_mode==CALL_MODE_NODE_PATH) {
|
||||
|
||||
Node *n = _get_base_node();
|
||||
if (n) {
|
||||
|
@ -1044,9 +1285,14 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo& property) const {
|
|||
ml+=E->get();
|
||||
}
|
||||
|
||||
if (ml==String()) {
|
||||
property.usage=PROPERTY_USAGE_NOEDITOR; //do not show for editing if empty
|
||||
} else {
|
||||
property.hint_string=ml;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VisualScriptPropertyGet::_bind_methods() {
|
||||
|
@ -1054,6 +1300,11 @@ void VisualScriptPropertyGet::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_base_type","base_type"),&VisualScriptPropertyGet::set_base_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_type"),&VisualScriptPropertyGet::get_base_type);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_basic_type","basic_type"),&VisualScriptPropertyGet::set_basic_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_basic_type"),&VisualScriptPropertyGet::get_basic_type);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_property","property"),&VisualScriptPropertyGet::set_property);
|
||||
ObjectTypeDB::bind_method(_MD("get_property"),&VisualScriptPropertyGet::get_property);
|
||||
|
||||
|
@ -1063,10 +1314,18 @@ void VisualScriptPropertyGet::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptPropertyGet::set_base_path);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_path"),&VisualScriptPropertyGet::get_base_path);
|
||||
|
||||
String bt;
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
if (i>0)
|
||||
bt+=",";
|
||||
|
||||
bt+=Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/set_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance"),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/set_mode",PROPERTY_HINT_ENUM,"Self,Node Path,Instance",PROPERTY_USAGE_NOEDITOR),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/base_type",PROPERTY_HINT_TYPE_STRING,"Object"),_SCS("set_base_type"),_SCS("get_base_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"property/basic_type",PROPERTY_HINT_ENUM,bt),_SCS("set_basic_type"),_SCS("get_basic_type"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"property/node_path",PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE),_SCS("set_base_path"),_SCS("get_base_path"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"property/property"),_SCS("set_property"),_SCS("get_property"));
|
||||
|
||||
|
@ -1084,6 +1343,7 @@ VisualScriptPropertyGet::VisualScriptPropertyGet() {
|
|||
|
||||
call_mode=CALL_MODE_INSTANCE;
|
||||
base_type="Object";
|
||||
basic_type=Variant::NIL;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1564,17 +1824,20 @@ VisualScriptEmitSignal::VisualScriptEmitSignal() {
|
|||
|
||||
void register_visual_script_func_nodes() {
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/call_in_self",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/call_in_node",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_NODE_PATH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/instance_call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/basic_type_call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/self_call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/node_call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_NODE_PATH>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/set",create_property_set_node<VisualScriptPropertySet::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/set_in_self",create_property_set_node<VisualScriptPropertySet::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/set_in_node",create_property_set_node<VisualScriptPropertySet::CALL_MODE_NODE_PATH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/instace_set",create_property_set_node<VisualScriptPropertySet::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/basic_type_set",create_property_set_node<VisualScriptPropertySet::CALL_MODE_BASIC_TYPE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/self_set",create_property_set_node<VisualScriptPropertySet::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/set_property/node_set",create_property_set_node<VisualScriptPropertySet::CALL_MODE_NODE_PATH>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/get",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/get_from_self",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/get_from_node",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_NODE_PATH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/instance_get",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_INSTANCE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/basic_type_get",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_BASIC_TYPE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/self_get",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/get_property/node_get",create_property_get_node<VisualScriptPropertyGet::CALL_MODE_NODE_PATH>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/script/script_call",create_script_call_node<VisualScriptScriptCall::CALL_MODE_SELF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/script/script_call_in_node",create_script_call_node<VisualScriptScriptCall::CALL_MODE_NODE_PATH>);
|
||||
|
|
|
@ -12,11 +12,13 @@ public:
|
|||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE,
|
||||
};
|
||||
private:
|
||||
|
||||
CallMode call_mode;
|
||||
StringName base_type;
|
||||
Variant::Type basic_type;
|
||||
NodePath base_path;
|
||||
StringName function;
|
||||
int use_default_args;
|
||||
|
@ -49,6 +51,9 @@ public:
|
|||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_base_type(const StringName& p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
|
@ -80,10 +85,14 @@ public:
|
|||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE,
|
||||
|
||||
|
||||
};
|
||||
private:
|
||||
|
||||
CallMode call_mode;
|
||||
Variant::Type basic_type;
|
||||
StringName base_type;
|
||||
NodePath base_path;
|
||||
StringName property;
|
||||
|
@ -121,6 +130,9 @@ public:
|
|||
void set_base_type(const StringName& p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_property(const StringName& p_type);
|
||||
StringName get_property() const;
|
||||
|
||||
|
@ -152,10 +164,13 @@ public:
|
|||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE
|
||||
|
||||
};
|
||||
private:
|
||||
|
||||
CallMode call_mode;
|
||||
Variant::Type basic_type;
|
||||
StringName base_type;
|
||||
NodePath base_path;
|
||||
StringName property;
|
||||
|
@ -192,6 +207,9 @@ public:
|
|||
void set_base_type(const StringName& p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_property(const StringName& p_type);
|
||||
StringName get_property() const;
|
||||
|
||||
|
|
|
@ -863,7 +863,7 @@ PropertyInfo VisualScriptGlobalConstant::get_input_value_port_info(int p_idx) co
|
|||
|
||||
PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::INT,"value");
|
||||
return PropertyInfo(Variant::REAL,"value");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1021,52 +1021,52 @@ VisualScriptMathConstant::VisualScriptMathConstant() {
|
|||
////////////////GLOBALSINGLETON///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptSingleton::get_output_sequence_port_count() const {
|
||||
int VisualScriptEngineSingleton::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptSingleton::has_input_sequence_port() const{
|
||||
bool VisualScriptEngineSingleton::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptSingleton::get_input_value_port_count() const{
|
||||
int VisualScriptEngineSingleton::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptSingleton::get_output_value_port_count() const{
|
||||
int VisualScriptEngineSingleton::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptSingleton::get_output_sequence_port_text(int p_port) const {
|
||||
String VisualScriptEngineSingleton::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSingleton::get_input_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptEngineSingleton::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSingleton::get_output_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptEngineSingleton::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::OBJECT,"instance");
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptSingleton::get_caption() const {
|
||||
String VisualScriptEngineSingleton::get_caption() const {
|
||||
|
||||
return "Singleton";
|
||||
return "EngineSingleton";
|
||||
}
|
||||
|
||||
String VisualScriptSingleton::get_text() const {
|
||||
String VisualScriptEngineSingleton::get_text() const {
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
void VisualScriptSingleton::set_singleton(const String& p_string) {
|
||||
void VisualScriptEngineSingleton::set_singleton(const String& p_string) {
|
||||
|
||||
singleton=p_string;
|
||||
|
||||
|
@ -1074,21 +1074,21 @@ void VisualScriptSingleton::set_singleton(const String& p_string) {
|
|||
emit_signal("ports_changed");
|
||||
}
|
||||
|
||||
String VisualScriptSingleton::get_singleton() {
|
||||
String VisualScriptEngineSingleton::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSingleton::instance(VScriptInstance* p_instance) {
|
||||
VisualScriptNodeInstance* VisualScriptEngineSingleton::instance(VScriptInstance* p_instance) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void VisualScriptSingleton::_bind_methods() {
|
||||
void VisualScriptEngineSingleton::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_singleton","name"),&VisualScriptSingleton::set_singleton);
|
||||
ObjectTypeDB::bind_method(_MD("get_singleton"),&VisualScriptSingleton::get_singleton);
|
||||
ObjectTypeDB::bind_method(_MD("set_singleton","name"),&VisualScriptEngineSingleton::set_singleton);
|
||||
ObjectTypeDB::bind_method(_MD("get_singleton"),&VisualScriptEngineSingleton::get_singleton);
|
||||
|
||||
String cc;
|
||||
|
||||
|
@ -1108,7 +1108,7 @@ void VisualScriptSingleton::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"constant",PROPERTY_HINT_ENUM,cc),_SCS("set_singleton"),_SCS("get_singleton"));
|
||||
}
|
||||
|
||||
VisualScriptSingleton::VisualScriptSingleton() {
|
||||
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
|
||||
|
||||
singleton=String();
|
||||
}
|
||||
|
@ -1252,14 +1252,168 @@ VisualScriptSceneNode::VisualScriptSceneNode() {
|
|||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////SceneTree///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptSceneTree::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptSceneTree::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptSceneTree::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptSceneTree::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptSceneTree::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSceneTree::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSceneTree::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::OBJECT,"instance");
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptSceneTree::get_caption() const {
|
||||
|
||||
return "SceneTree";
|
||||
}
|
||||
|
||||
String VisualScriptSceneTree::get_text() const {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSceneTree::instance(VScriptInstance* p_instance) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void VisualScriptSceneTree::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
}
|
||||
|
||||
void VisualScriptSceneTree::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptSceneTree::VisualScriptSceneTree() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////RESPATH///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptResourcePath::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptResourcePath::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptResourcePath::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptResourcePath::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptResourcePath::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptResourcePath::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptResourcePath::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::STRING,"path");
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptResourcePath::get_caption() const {
|
||||
|
||||
return "ResourcePath";
|
||||
}
|
||||
|
||||
String VisualScriptResourcePath::get_text() const {
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void VisualScriptResourcePath::set_resource_path(const String& p_path) {
|
||||
|
||||
path=p_path;
|
||||
_change_notify();
|
||||
emit_signal("ports_changed");
|
||||
}
|
||||
|
||||
String VisualScriptResourcePath::get_resource_path() {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptResourcePath::instance(VScriptInstance* p_instance) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VisualScriptResourcePath::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_resource_path","path"),&VisualScriptResourcePath::set_resource_path);
|
||||
ObjectTypeDB::bind_method(_MD("get_resource_path"),&VisualScriptResourcePath::get_resource_path);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"path",PROPERTY_HINT_FILE),_SCS("set_resource_path"),_SCS("get_resource_path"));
|
||||
}
|
||||
|
||||
VisualScriptResourcePath::VisualScriptResourcePath() {
|
||||
|
||||
path="";
|
||||
}
|
||||
|
||||
|
||||
void register_visual_script_nodes() {
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("data/variable",create_node_generic<VisualScriptVariable>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/constant",create_node_generic<VisualScriptConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/global_constant",create_node_generic<VisualScriptGlobalConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/math_constant",create_node_generic<VisualScriptMathConstant>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/singleton",create_node_generic<VisualScriptSingleton>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/engine_singleton",create_node_generic<VisualScriptEngineSingleton>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/scene_node",create_node_generic<VisualScriptSceneNode>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/scene_tree",create_node_generic<VisualScriptSceneTree>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/resource_path",create_node_generic<VisualScriptResourcePath>);
|
||||
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("index/get",create_node_generic<VisualScriptIndexGet>);
|
||||
|
|
|
@ -315,9 +315,9 @@ public:
|
|||
|
||||
VARIANT_ENUM_CAST( VisualScriptMathConstant::MathConstant )
|
||||
|
||||
class VisualScriptSingleton : public VisualScriptNode {
|
||||
class VisualScriptEngineSingleton : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptSingleton,VisualScriptNode)
|
||||
OBJ_TYPE(VisualScriptEngineSingleton,VisualScriptNode)
|
||||
|
||||
String singleton;
|
||||
|
||||
|
@ -346,7 +346,7 @@ public:
|
|||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSingleton();
|
||||
VisualScriptEngineSingleton();
|
||||
};
|
||||
|
||||
|
||||
|
@ -389,6 +389,77 @@ public:
|
|||
|
||||
|
||||
|
||||
|
||||
class VisualScriptSceneTree : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptSceneTree,VisualScriptNode)
|
||||
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo& property) const;
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSceneTree();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class VisualScriptResourcePath : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptResourcePath,VisualScriptNode)
|
||||
|
||||
String path;
|
||||
protected:
|
||||
|
||||
static void _bind_methods();
|
||||
public:
|
||||
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
|
||||
void set_resource_path(const String &p_path);
|
||||
String get_resource_path();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
|
||||
VisualScriptResourcePath();
|
||||
};
|
||||
|
||||
|
||||
void register_visual_script_nodes();
|
||||
|
||||
#endif // VISUAL_SCRIPT_NODES_H
|
||||
|
|
|
@ -586,6 +586,7 @@ public:
|
|||
EDITOR_SCRIPT
|
||||
};
|
||||
|
||||
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
|
||||
static EditorNode* get_singleton() { return singleton; }
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "editor_file_system.h"
|
||||
#include "create_dialog.h"
|
||||
|
||||
void CustomPropertyEditor::_notification(int p_what) {
|
||||
|
||||
|
@ -431,6 +432,23 @@ bool CustomPropertyEditor::edit(Object* p_owner,const String& p_name,Variant::Ty
|
|||
action_buttons[0]->set_text(TTR("Close"));
|
||||
action_buttons[0]->show();
|
||||
|
||||
} else if (hint==PROPERTY_HINT_TYPE_STRING) {
|
||||
|
||||
if (!create_dialog) {
|
||||
create_dialog = memnew( CreateDialog );
|
||||
create_dialog->connect("create",this,"_create_dialog_callback");
|
||||
add_child(create_dialog);
|
||||
}
|
||||
|
||||
if (hint_text!=String()) {
|
||||
create_dialog->set_base_type(hint_text);
|
||||
} else {
|
||||
create_dialog->set_base_type("Object");
|
||||
}
|
||||
|
||||
create_dialog->popup(false);
|
||||
hide();
|
||||
|
||||
} else {
|
||||
List<String> names;
|
||||
names.push_back("string:");
|
||||
|
@ -1331,6 +1349,13 @@ void CustomPropertyEditor::_text_edit_changed() {
|
|||
|
||||
}
|
||||
|
||||
void CustomPropertyEditor::_create_dialog_callback() {
|
||||
|
||||
|
||||
v=create_dialog->get_selected_type();
|
||||
emit_signal("variant_changed");
|
||||
}
|
||||
|
||||
void CustomPropertyEditor::_modified(String p_string) {
|
||||
|
||||
if (updating)
|
||||
|
@ -1712,6 +1737,7 @@ void CustomPropertyEditor::_bind_methods() {
|
|||
ObjectTypeDB::bind_method("_drag_easing",&CustomPropertyEditor::_drag_easing);
|
||||
ObjectTypeDB::bind_method( "_text_edit_changed",&CustomPropertyEditor::_text_edit_changed);
|
||||
ObjectTypeDB::bind_method( "_menu_option",&CustomPropertyEditor::_menu_option);
|
||||
ObjectTypeDB::bind_method( "_create_dialog_callback",&CustomPropertyEditor::_create_dialog_callback);
|
||||
|
||||
|
||||
|
||||
|
@ -1834,6 +1860,8 @@ CustomPropertyEditor::CustomPropertyEditor() {
|
|||
add_child(slider);
|
||||
slider->set_area_as_parent_rect(5);
|
||||
slider->connect("value_changed",this,"_range_modified");
|
||||
|
||||
create_dialog = NULL;
|
||||
}
|
||||
|
||||
bool PropertyEditor::_might_be_in_instance() {
|
||||
|
@ -2101,6 +2129,12 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String& p
|
|||
} break;
|
||||
case Variant::STRING:
|
||||
|
||||
|
||||
if (p_hint==PROPERTY_HINT_TYPE_STRING) {
|
||||
|
||||
p_item->set_text(1,obj->get(p_name));
|
||||
}
|
||||
|
||||
if (p_hint==PROPERTY_HINT_ENUM) {
|
||||
|
||||
Vector<String> strings = p_hint_text.split(",");
|
||||
|
@ -2367,15 +2401,27 @@ Variant PropertyEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
|
|||
if (!item)
|
||||
return Variant();
|
||||
|
||||
int col = tree->get_column_at_pos(p_point);
|
||||
if (col!=1)
|
||||
return Variant();
|
||||
|
||||
|
||||
Dictionary d = item->get_metadata(0);
|
||||
if (!d.has("name"))
|
||||
return Variant();
|
||||
|
||||
int col = tree->get_column_at_pos(p_point);
|
||||
if (col==0) {
|
||||
|
||||
Dictionary dp;
|
||||
dp["type"]="obj_property";
|
||||
dp["object"]=obj;
|
||||
dp["property"]=d["name"];
|
||||
dp["value"]=obj->get(d["name"]);
|
||||
|
||||
Label *label =memnew( Label );
|
||||
label->set_text(d["name"]);
|
||||
set_drag_preview(label);
|
||||
return dp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Variant val = obj->get(d["name"]);
|
||||
|
||||
if (val.get_type()==Variant::OBJECT) {
|
||||
|
@ -3110,6 +3156,15 @@ void PropertyEditor::update_tree() {
|
|||
item->set_icon( 0,get_icon("Enum","EditorIcons") );
|
||||
|
||||
|
||||
} break;
|
||||
case PROPERTY_HINT_TYPE_STRING: {
|
||||
|
||||
item->set_cell_mode( 1, TreeItem::CELL_MODE_CUSTOM);
|
||||
item->set_editable(1,!read_only);
|
||||
if (show_type_icons)
|
||||
item->set_icon( 0, get_icon("String","EditorIcons") );
|
||||
item->set_text(1,obj->get(p.name));
|
||||
|
||||
} break;
|
||||
default: {
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
*/
|
||||
|
||||
class PropertyValueEvaluator;
|
||||
|
||||
class CreateDialog;
|
||||
class CustomPropertyEditor : public Popup {
|
||||
|
||||
OBJ_TYPE( CustomPropertyEditor, Popup );
|
||||
|
@ -102,6 +102,7 @@ class CustomPropertyEditor : public Popup {
|
|||
|
||||
|
||||
Control *easing_draw;
|
||||
CreateDialog *create_dialog;
|
||||
|
||||
Object* owner;
|
||||
|
||||
|
@ -118,6 +119,7 @@ class CustomPropertyEditor : public Popup {
|
|||
void _focus_exit();
|
||||
void _action_pressed(int p_which);
|
||||
void _type_create_selected(int p_idx);
|
||||
void _create_dialog_callback();
|
||||
|
||||
|
||||
void _color_changed(const Color& p_color);
|
||||
|
|
|
@ -42,6 +42,22 @@
|
|||
#include "scene/main/viewport.h"
|
||||
|
||||
|
||||
void SceneTreeDock::_nodes_drag_begin() {
|
||||
|
||||
|
||||
if (restore_script_editor_on_drag) {
|
||||
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
||||
restore_script_editor_on_drag=false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SceneTreeDock::_input(InputEvent p_event) {
|
||||
|
||||
if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==BUTTON_LEFT) {
|
||||
restore_script_editor_on_drag=false; //lost chance
|
||||
}
|
||||
}
|
||||
|
||||
void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
|
||||
|
||||
|
@ -698,7 +714,13 @@ void SceneTreeDock::_node_selected() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ScriptEditor::get_singleton()->is_visible()) {
|
||||
restore_script_editor_on_drag=true;
|
||||
}
|
||||
|
||||
editor->push_item(node);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SceneTreeDock::_node_renamed() {
|
||||
|
@ -1807,6 +1829,8 @@ void SceneTreeDock::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("_load_request"),&SceneTreeDock::_load_request);
|
||||
ObjectTypeDB::bind_method(_MD("_script_open_request"),&SceneTreeDock::_script_open_request);
|
||||
ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&SceneTreeDock::_unhandled_key_input);
|
||||
ObjectTypeDB::bind_method(_MD("_input"),&SceneTreeDock::_input);
|
||||
ObjectTypeDB::bind_method(_MD("_nodes_drag_begin"),&SceneTreeDock::_nodes_drag_begin);
|
||||
ObjectTypeDB::bind_method(_MD("_delete_confirm"),&SceneTreeDock::_delete_confirm);
|
||||
ObjectTypeDB::bind_method(_MD("_node_prerenamed"),&SceneTreeDock::_node_prerenamed);
|
||||
ObjectTypeDB::bind_method(_MD("_import_subscene"),&SceneTreeDock::_import_subscene);
|
||||
|
@ -1889,6 +1913,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
|
|||
scene_tree->connect("open_script",this,"_script_open_request");
|
||||
scene_tree->connect("nodes_rearranged",this,"_nodes_dragged");
|
||||
scene_tree->connect("files_dropped",this,"_files_dropped");
|
||||
scene_tree->connect("nodes_dragged",this,"_nodes_drag_begin");
|
||||
|
||||
scene_tree->set_undo_redo(&editor_data->get_undo_redo());
|
||||
scene_tree->set_editor_selection(editor_selection);
|
||||
|
@ -1941,7 +1966,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec
|
|||
add_child(menu);
|
||||
menu->connect("item_pressed",this,"_tool_selected");
|
||||
first_enter=true;
|
||||
|
||||
restore_script_editor_on_drag=false;
|
||||
|
||||
vbc->add_constant_override("separation",4);
|
||||
set_process_input(true);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ class SceneTreeDock : public VBoxContainer {
|
|||
};
|
||||
|
||||
|
||||
bool restore_script_editor_on_drag;
|
||||
|
||||
int current_option;
|
||||
CreateDialog *create_dialog;
|
||||
|
@ -128,6 +129,8 @@ class SceneTreeDock : public VBoxContainer {
|
|||
|
||||
void _node_prerenamed(Node* p_node, const String& p_new_name);
|
||||
|
||||
void _nodes_drag_begin();
|
||||
void _input(InputEvent p_event);
|
||||
void _unhandled_key_input(InputEvent p_event);
|
||||
|
||||
void _import_subscene();
|
||||
|
|
|
@ -966,7 +966,7 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2& p_point,Control* p_from)
|
|||
drag_data["nodes"]=objs;
|
||||
|
||||
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN|Tree::DROP_MODE_ON_ITEM);
|
||||
|
||||
emit_signal("nodes_dragged");
|
||||
|
||||
return drag_data;
|
||||
}
|
||||
|
@ -1110,6 +1110,7 @@ void SceneTreeEditor::_bind_methods() {
|
|||
ADD_SIGNAL( MethodInfo("node_renamed") );
|
||||
ADD_SIGNAL( MethodInfo("node_prerename") );
|
||||
ADD_SIGNAL( MethodInfo("node_changed") );
|
||||
ADD_SIGNAL( MethodInfo("nodes_dragged") );
|
||||
ADD_SIGNAL( MethodInfo("nodes_rearranged",PropertyInfo(Variant::ARRAY,"paths"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
|
||||
ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::NODE_PATH,"to_path"),PropertyInfo(Variant::INT,"type") ) );
|
||||
ADD_SIGNAL( MethodInfo("rmb_pressed",PropertyInfo(Variant::VECTOR2,"pos")) ) ;
|
||||
|
|
Loading…
Reference in a new issue