mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 06:03:09 +00:00
VisualScript can now execute visual scripts, but there is no debugger or profiler yet.
This commit is contained in:
parent
6d5d23fa8d
commit
259418f827
@ -178,7 +178,7 @@ public:
|
||||
virtual void get_reserved_words(List<String> *p_words) const=0;
|
||||
virtual void get_comment_delimiters(List<String> *p_delimiters) const=0;
|
||||
virtual void get_string_delimiters(List<String> *p_delimiters) const=0;
|
||||
virtual String get_template(const String& p_class_name, const String& p_base_class_name) const=0;
|
||||
virtual Ref<Script> get_template(const String& p_class_name, const String& p_base_class_name) const=0;
|
||||
virtual bool validate(const String& p_script, int &r_line_error,int &r_col_error,String& r_test_error, const String& p_path="",List<String> *r_functions=NULL) const=0;
|
||||
virtual Script *create_script() const=0;
|
||||
virtual bool has_named_classes() const=0;
|
||||
|
@ -1213,7 +1213,9 @@ def detect_modules():
|
||||
register_cpp=""
|
||||
unregister_cpp=""
|
||||
|
||||
for x in glob.glob("modules/*"):
|
||||
files = glob.glob("modules/*")
|
||||
files.sort() #so register_module_types does not change that often, and also plugins are registered in alphabetic order
|
||||
for x in files:
|
||||
if (not os.path.isdir(x)):
|
||||
continue
|
||||
x=x.replace("modules/","") # rest of world
|
||||
|
@ -44,7 +44,7 @@ void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
|
||||
|
||||
|
||||
}
|
||||
String GDScriptLanguage::get_template(const String& p_class_name, const String& p_base_class_name) const {
|
||||
Ref<Script> GDScriptLanguage::get_template(const String& p_class_name, const String& p_base_class_name) const {
|
||||
|
||||
String _template = String()+
|
||||
"\nextends %BASE%\n\n"+
|
||||
@ -58,7 +58,14 @@ String GDScriptLanguage::get_template(const String& p_class_name, const String&
|
||||
"\n"+
|
||||
"\n";
|
||||
|
||||
return _template.replace("%BASE%",p_base_class_name);
|
||||
_template = _template.replace("%BASE%",p_base_class_name);
|
||||
|
||||
Ref<GDScript> script;
|
||||
script.instance();
|
||||
script->set_source_code(_template);
|
||||
|
||||
return script;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -375,7 +375,7 @@ public:
|
||||
virtual void get_reserved_words(List<String> *p_words) const;
|
||||
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
|
||||
virtual void get_string_delimiters(List<String> *p_delimiters) const;
|
||||
virtual String get_template(const String& p_class_name, const String& p_base_class_name) const;
|
||||
virtual Ref<Script> get_template(const String& p_class_name, const String& p_base_class_name) const;
|
||||
virtual bool validate(const String& p_script,int &r_line_error,int &r_col_error,String& r_test_error, const String& p_path="",List<String> *r_functions=NULL) const;
|
||||
virtual Script *create_script() const;
|
||||
virtual bool has_named_classes() const;
|
||||
|
@ -46,7 +46,8 @@ void register_visual_script_types() {
|
||||
ObjectTypeDB::register_virtual_type<VisualScriptNode>();
|
||||
ObjectTypeDB::register_type<VisualScriptFunction>();
|
||||
ObjectTypeDB::register_type<VisualScriptOperator>();
|
||||
ObjectTypeDB::register_type<VisualScriptVariable>();
|
||||
ObjectTypeDB::register_type<VisualScriptVariableSet>();
|
||||
ObjectTypeDB::register_type<VisualScriptVariableGet>();
|
||||
ObjectTypeDB::register_type<VisualScriptConstant>();
|
||||
ObjectTypeDB::register_type<VisualScriptIndexGet>();
|
||||
ObjectTypeDB::register_type<VisualScriptIndexSet>();
|
||||
@ -56,6 +57,7 @@ void register_visual_script_types() {
|
||||
ObjectTypeDB::register_type<VisualScriptSceneNode>();
|
||||
ObjectTypeDB::register_type<VisualScriptSceneTree>();
|
||||
ObjectTypeDB::register_type<VisualScriptResourcePath>();
|
||||
ObjectTypeDB::register_type<VisualScriptSelf>();
|
||||
|
||||
ObjectTypeDB::register_type<VisualScriptFunctionCall>();
|
||||
ObjectTypeDB::register_type<VisualScriptPropertySet>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
#include "script_language.h"
|
||||
|
||||
|
||||
class VScriptInstance;
|
||||
class VisualScriptInstance;
|
||||
class VisualScriptNodeInstance;
|
||||
class VisualScript;
|
||||
|
||||
@ -45,22 +45,69 @@ public:
|
||||
|
||||
virtual String get_caption() const=0;
|
||||
virtual String get_text() const=0;
|
||||
virtual String get_category() const=0;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance)=0;
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance)=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptNodeInstance {
|
||||
friend class VisualScriptInstance;
|
||||
|
||||
|
||||
|
||||
enum { //input argument addressing
|
||||
INPUT_SHIFT=1<<24,
|
||||
INPUT_MASK=INPUT_SHIFT-1,
|
||||
INPUT_DEFAULT_VALUE_BIT=INPUT_SHIFT, // from unassigned input port, using default value (edited by user)
|
||||
INPUT_UNSEQUENCED_READ_BIT=INPUT_SHIFT<<1, //from unsequenced read (requires calling a function, used for constants, variales, etc).
|
||||
};
|
||||
|
||||
|
||||
int id;
|
||||
int sequence_index;
|
||||
VisualScriptNodeInstance **sequence_outputs;
|
||||
int sequence_output_count;
|
||||
int *input_ports;
|
||||
int input_port_count;
|
||||
int *output_ports;
|
||||
int output_port_count;
|
||||
int working_mem_idx;
|
||||
|
||||
VisualScriptNode *base;
|
||||
|
||||
public:
|
||||
|
||||
virtual int step()=0; //do a step, return which sequence port to go out
|
||||
enum {
|
||||
STEP_SHIFT=1<<24,
|
||||
STEP_MASK=STEP_SHIFT-1,
|
||||
STEP_FLAG_PUSH_STACK_BIT=STEP_SHIFT, //push bit to stack
|
||||
STEP_FLAG_GO_BACK_BIT=STEP_SHIFT<<1, //go back to previous node
|
||||
STEP_EXIT_FUNCTION_BIT=STEP_SHIFT<<2, //return from function
|
||||
|
||||
virtual Variant get_input_value(int p_idx)=0;
|
||||
virtual Variant get_output_value(int p_idx)=0;
|
||||
FLOW_STACK_PUSHED_BIT=1<<30, //in flow stack, means bit was pushed (must go back here if end of sequence)
|
||||
FLOW_STACK_MASK=FLOW_STACK_PUSHED_BIT-1
|
||||
|
||||
virtual VisualScriptNode* get_node()=0;
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ int get_input_port_count() const { return input_port_count; }
|
||||
_FORCE_INLINE_ int get_output_port_count() const { return output_port_count; }
|
||||
_FORCE_INLINE_ int get_sequence_output_count() const { return sequence_output_count; }
|
||||
|
||||
_FORCE_INLINE_ int get_id() const { return id; }
|
||||
|
||||
virtual int get_working_memory_size() const { return 0; }
|
||||
|
||||
//unsequenced ports are those that can return a value even if no sequence happened through them, used for constants, variables, etc.
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str)=0; //do a step, return which sequence port to go out
|
||||
|
||||
Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>( base ); }
|
||||
|
||||
VisualScriptNodeInstance();
|
||||
virtual ~VisualScriptNodeInstance();
|
||||
};
|
||||
|
||||
@ -112,6 +159,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
friend class VisualScriptInstance;
|
||||
|
||||
StringName base_type;
|
||||
struct Argument {
|
||||
@ -133,6 +181,7 @@ private:
|
||||
|
||||
int function_id;
|
||||
|
||||
|
||||
Function() { function_id=-1; }
|
||||
|
||||
};
|
||||
@ -146,8 +195,18 @@ private:
|
||||
|
||||
Map<StringName,Function> functions;
|
||||
Map<StringName,Variable> variables;
|
||||
Map<StringName,StringName> script_variable_remap;
|
||||
Map<StringName,Vector<Argument> > custom_signals;
|
||||
|
||||
Map<Object*,VisualScriptInstance*> instances;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Set<PlaceHolderScriptInstance*> placeholders;
|
||||
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
|
||||
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
|
||||
void _update_placeholders();
|
||||
#endif
|
||||
|
||||
void _set_variable_info(const StringName& p_name,const Dictionary& p_info);
|
||||
Dictionary _get_variable_info(const StringName& p_name) const;
|
||||
|
||||
@ -248,15 +307,103 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptInstance : public ScriptInstance {
|
||||
|
||||
Object *owner;
|
||||
Ref<VisualScript> script;
|
||||
|
||||
Map<StringName,Variant> variables; //using variable path, not script
|
||||
Map<int,VisualScriptNodeInstance*> instances;
|
||||
|
||||
struct Function {
|
||||
int node;
|
||||
int max_stack;
|
||||
int trash_pos;
|
||||
int return_pos;
|
||||
int flow_stack_size;
|
||||
int node_count;
|
||||
int argument_count;
|
||||
bool valid;
|
||||
|
||||
struct UnsequencedGet {
|
||||
VisualScriptNodeInstance* from;
|
||||
int from_port;
|
||||
int to_stack;
|
||||
};
|
||||
|
||||
Vector<UnsequencedGet> unsequenced_gets;
|
||||
|
||||
};
|
||||
|
||||
Map<StringName,Function> functions;
|
||||
|
||||
Vector<Variant> default_values;
|
||||
int max_input_args,max_output_args;
|
||||
|
||||
|
||||
//Map<StringName,Function> functions;
|
||||
|
||||
public:
|
||||
virtual bool set(const StringName& p_name, const Variant& p_value);
|
||||
virtual bool get(const StringName& p_name, Variant &r_ret) const;
|
||||
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
|
||||
virtual Variant::Type get_property_type(const StringName& p_name,bool *r_is_valid=NULL) const;
|
||||
|
||||
virtual void get_method_list(List<MethodInfo> *p_list) const;
|
||||
virtual bool has_method(const StringName& p_method) const;
|
||||
virtual Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error);
|
||||
virtual void notification(int p_notification);
|
||||
|
||||
bool set_variable(const StringName& p_variable,const Variant& p_value) {
|
||||
|
||||
Map<StringName,Variant>::Element *E=variables.find(p_variable);
|
||||
if (!E)
|
||||
return false;
|
||||
|
||||
E->get()=p_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get_variable(const StringName& p_variable,Variant* r_variable) const {
|
||||
|
||||
const Map<StringName,Variant>::Element *E=variables.find(p_variable);
|
||||
if (!E)
|
||||
return false;
|
||||
|
||||
*r_variable=E->get();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual Ref<Script> get_script() const;
|
||||
|
||||
_FORCE_INLINE_ VisualScript *get_script_ptr() { return script.ptr(); }
|
||||
_FORCE_INLINE_ Object *get_owner_ptr() { return owner; }
|
||||
|
||||
void create(const Ref<VisualScript>& p_script,Object *p_owner);
|
||||
|
||||
virtual ScriptLanguage *get_language();
|
||||
|
||||
VisualScriptInstance();
|
||||
~VisualScriptInstance();
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String& p_type);
|
||||
|
||||
class VisualScriptLanguage : public ScriptLanguage {
|
||||
|
||||
Map<String,VisualScriptNodeRegisterFunc> register_funcs;
|
||||
|
||||
|
||||
public:
|
||||
StringName notification;
|
||||
|
||||
static VisualScriptLanguage* singleton;
|
||||
|
||||
Mutex *lock;
|
||||
|
||||
virtual String get_name() const;
|
||||
|
||||
/* LANGUAGE FUNCTIONS */
|
||||
@ -270,7 +417,7 @@ public:
|
||||
virtual void get_reserved_words(List<String> *p_words) const;
|
||||
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
|
||||
virtual void get_string_delimiters(List<String> *p_delimiters) const;
|
||||
virtual String get_template(const String& p_class_name, const String& p_base_class_name) const;
|
||||
virtual Ref<Script> get_template(const String& p_class_name, const String& p_base_class_name) const;
|
||||
virtual bool validate(const String& p_script, int &r_line_error,int &r_col_error,String& r_test_error, const String& p_path="",List<String> *r_functions=NULL) const;
|
||||
virtual Script *create_script() const;
|
||||
virtual bool has_named_classes() const;
|
||||
@ -313,6 +460,7 @@ public:
|
||||
|
||||
|
||||
VisualScriptLanguage();
|
||||
~VisualScriptLanguage();
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
#include "visual_script_builtin_funcs.h"
|
||||
|
||||
#include "math_funcs.h"
|
||||
#include "object_type_db.h"
|
||||
#include "reference.h"
|
||||
#include "func_ref.h"
|
||||
#include "os/os.h"
|
||||
#include "variant_parser.h"
|
||||
#include "io/marshalls.h"
|
||||
|
||||
const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX]={
|
||||
"sin",
|
||||
@ -538,12 +544,550 @@ VisualScriptBuiltinFunc::BuiltinFunc VisualScriptBuiltinFunc::get_func() {
|
||||
}
|
||||
|
||||
|
||||
#define VALIDATE_ARG_NUM(m_arg) \
|
||||
if (!p_inputs[m_arg]->is_num()) {\
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;\
|
||||
r_error.argument=m_arg;\
|
||||
r_error.expected=Variant::REAL;\
|
||||
return 0;\
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptBuiltinFunc::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceBuiltinFunc : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptBuiltinFunc *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
VisualScriptBuiltinFunc::BuiltinFunc func;
|
||||
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
switch(func) {
|
||||
case VisualScriptBuiltinFunc::MATH_SIN: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::sin(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_COS: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::cos(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_TAN: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::tan(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_SINH: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::sinh(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_COSH: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::cosh(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_TANH: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::tanh(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ASIN: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::asin(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ACOS: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::acos(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ATAN: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::atan(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ATAN2: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::atan2(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_SQRT: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::sqrt(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_FMOD: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::fmod(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_FPOSMOD: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::fposmod(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_FLOOR: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::floor(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_CEIL: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::ceil(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ROUND: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::round(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ABS: {
|
||||
|
||||
if (p_inputs[0]->get_type()==Variant::INT) {
|
||||
|
||||
int64_t i = *p_inputs[0];
|
||||
*p_outputs[0]=ABS(i);
|
||||
} else if (p_inputs[0]->get_type()==Variant::REAL) {
|
||||
|
||||
real_t r = *p_inputs[0];
|
||||
*p_outputs[0]=Math::abs(r);
|
||||
} else {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::REAL;
|
||||
|
||||
}
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_SIGN: {
|
||||
|
||||
if (p_inputs[0]->get_type()==Variant::INT) {
|
||||
|
||||
int64_t i = *p_inputs[0];
|
||||
*p_outputs[0]= i < 0 ? -1 : ( i > 0 ? +1 : 0);
|
||||
} else if (p_inputs[0]->get_type()==Variant::REAL) {
|
||||
|
||||
real_t r = *p_inputs[0];
|
||||
*p_outputs[0]= r < 0.0 ? -1.0 : ( r > 0.0 ? +1.0 : 0.0);
|
||||
} else {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::REAL;
|
||||
|
||||
}
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_POW: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::pow(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_LOG: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::log(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_EXP: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::exp(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ISNAN: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::is_nan(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_ISINF: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::is_inf(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_EASE: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::ease(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_DECIMALS: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::step_decimals(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_STEPIFY: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::stepify(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_LERP: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
VALIDATE_ARG_NUM(2);
|
||||
*p_outputs[0]=Math::lerp(*p_inputs[0],*p_inputs[1],*p_inputs[2]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_DECTIME: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
VALIDATE_ARG_NUM(2);
|
||||
*p_outputs[0]=Math::dectime(*p_inputs[0],*p_inputs[1],*p_inputs[2]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RANDOMIZE: {
|
||||
Math::randomize();
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RAND: {
|
||||
*p_outputs[0]=Math::rand();
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RANDF: {
|
||||
*p_outputs[0]=Math::randf();
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RANDOM: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
*p_outputs[0]=Math::random(*p_inputs[0],*p_inputs[1]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_SEED: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
uint32_t seed=*p_inputs[0];
|
||||
Math::seed(seed);
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RANDSEED: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
uint32_t seed=*p_inputs[0];
|
||||
int ret = Math::rand_from_seed(&seed);
|
||||
Array reta;
|
||||
reta.push_back(ret);
|
||||
reta.push_back(seed);
|
||||
*p_outputs[0]=reta;
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_DEG2RAD: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::deg2rad(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_RAD2DEG: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::rad2deg(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_LINEAR2DB: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::linear2db(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::MATH_DB2LINEAR: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
*p_outputs[0]=Math::db2linear(*p_inputs[0]);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::LOGIC_MAX: {
|
||||
|
||||
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT) {
|
||||
|
||||
int64_t a = *p_inputs[0];
|
||||
int64_t b = *p_inputs[1];
|
||||
*p_outputs[0]=MAX(a,b);
|
||||
} else {
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
|
||||
real_t a = *p_inputs[0];
|
||||
real_t b = *p_inputs[1];
|
||||
|
||||
*p_outputs[0]=MAX(a,b);
|
||||
}
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::LOGIC_MIN: {
|
||||
|
||||
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT) {
|
||||
|
||||
int64_t a = *p_inputs[0];
|
||||
int64_t b = *p_inputs[1];
|
||||
*p_outputs[0]=MIN(a,b);
|
||||
} else {
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
|
||||
real_t a = *p_inputs[0];
|
||||
real_t b = *p_inputs[1];
|
||||
|
||||
*p_outputs[0]=MIN(a,b);
|
||||
}
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::LOGIC_CLAMP: {
|
||||
|
||||
if (p_inputs[0]->get_type()==Variant::INT && p_inputs[1]->get_type()==Variant::INT && p_inputs[2]->get_type()==Variant::INT) {
|
||||
|
||||
int64_t a = *p_inputs[0];
|
||||
int64_t b = *p_inputs[1];
|
||||
int64_t c = *p_inputs[2];
|
||||
*p_outputs[0]=CLAMP(a,b,c);
|
||||
} else {
|
||||
VALIDATE_ARG_NUM(0);
|
||||
VALIDATE_ARG_NUM(1);
|
||||
VALIDATE_ARG_NUM(2);
|
||||
|
||||
real_t a = *p_inputs[0];
|
||||
real_t b = *p_inputs[1];
|
||||
real_t c = *p_inputs[2];
|
||||
|
||||
*p_outputs[0]=CLAMP(a,b,c);
|
||||
}
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2: {
|
||||
|
||||
VALIDATE_ARG_NUM(0);
|
||||
int64_t num = *p_inputs[0];
|
||||
*p_outputs[0] = nearest_power_of_2(num);
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::OBJ_WEAKREF: {
|
||||
|
||||
if (p_inputs[0]->get_type()!=Variant::OBJECT) {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::OBJECT;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
if (p_inputs[0]->is_ref()) {
|
||||
|
||||
REF r = *p_inputs[0];
|
||||
if (!r.is_valid()) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ref<WeakRef> wref = memnew( WeakRef );
|
||||
wref->set_ref(r);
|
||||
*p_outputs[0]=wref;
|
||||
} else {
|
||||
Object *obj = *p_inputs[0];
|
||||
if (!obj) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
Ref<WeakRef> wref = memnew( WeakRef );
|
||||
wref->set_obj(obj);
|
||||
*p_outputs[0]=wref;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::FUNC_FUNCREF: {
|
||||
|
||||
if (p_inputs[0]->get_type()!=Variant::OBJECT) {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::OBJECT;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
if (p_inputs[1]->get_type()!=Variant::STRING && p_inputs[1]->get_type()!=Variant::NODE_PATH) {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=1;
|
||||
r_error.expected=Variant::STRING;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
Ref<FuncRef> fr = memnew( FuncRef);
|
||||
|
||||
fr->set_instance(*p_inputs[0]);
|
||||
fr->set_function(*p_inputs[1]);
|
||||
|
||||
*p_outputs[0]=fr;
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TYPE_CONVERT: {
|
||||
|
||||
VALIDATE_ARG_NUM(1);
|
||||
int type=*p_inputs[1];
|
||||
if (type<0 || type>=Variant::VARIANT_MAX) {
|
||||
|
||||
*p_outputs[0]=RTR("Invalid type argument to convert(), use TYPE_* constants.");
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::INT;
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
*p_outputs[0]=Variant::construct(Variant::Type(type),p_inputs,1,r_error);
|
||||
}
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TYPE_OF: {
|
||||
|
||||
|
||||
*p_outputs[0] = p_inputs[0]->get_type();
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TYPE_EXISTS: {
|
||||
|
||||
|
||||
*p_outputs[0] = ObjectTypeDB::type_exists(*p_inputs[0]);
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TEXT_STR: {
|
||||
|
||||
String str = *p_inputs[0];
|
||||
|
||||
*p_outputs[0]=str;
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TEXT_PRINT: {
|
||||
|
||||
String str = *p_inputs[0];
|
||||
print_line(str);
|
||||
|
||||
|
||||
} break;
|
||||
|
||||
case VisualScriptBuiltinFunc::TEXT_PRINTERR: {
|
||||
|
||||
String str = *p_inputs[0];
|
||||
|
||||
//str+="\n";
|
||||
OS::get_singleton()->printerr("%s\n",str.utf8().get_data());
|
||||
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
|
||||
String str = *p_inputs[0];
|
||||
|
||||
//str+="\n";
|
||||
OS::get_singleton()->print("%s",str.utf8().get_data());
|
||||
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::VAR_TO_STR: {
|
||||
|
||||
String vars;
|
||||
VariantWriter::write_to_string(*p_inputs[0],vars);
|
||||
*p_outputs[0]=vars;
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::STR_TO_VAR: {
|
||||
|
||||
if (p_inputs[0]->get_type()!=Variant::STRING) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::STRING;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VariantParser::StreamString ss;
|
||||
ss.s=*p_inputs[0];
|
||||
|
||||
String errs;
|
||||
int line;
|
||||
Error err = VariantParser::parse(&ss,*p_outputs[0],errs,line);
|
||||
|
||||
if (err!=OK) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::STRING;
|
||||
*p_outputs[0]="Parse error at line "+itos(line)+": "+errs;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::VAR_TO_BYTES: {
|
||||
|
||||
|
||||
ByteArray barr;
|
||||
int len;
|
||||
Error err = encode_variant(*p_inputs[0],NULL,len);
|
||||
if (err) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::NIL;
|
||||
*p_outputs[0]="Unexpected error encoding variable to bytes, likely unserializable type found (Object or RID).";
|
||||
return 0;
|
||||
}
|
||||
|
||||
barr.resize(len);
|
||||
{
|
||||
ByteArray::Write w = barr.write();
|
||||
encode_variant(*p_inputs[0],w.ptr(),len);
|
||||
|
||||
}
|
||||
*p_outputs[0]=barr;
|
||||
} break;
|
||||
case VisualScriptBuiltinFunc::BYTES_TO_VAR: {
|
||||
|
||||
if (p_inputs[0]->get_type()!=Variant::RAW_ARRAY) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::RAW_ARRAY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ByteArray varr=*p_inputs[0];
|
||||
Variant ret;
|
||||
{
|
||||
ByteArray::Read r=varr.read();
|
||||
Error err = decode_variant(ret,r.ptr(),varr.size(),NULL);
|
||||
if (err!=OK) {
|
||||
*p_outputs[0]=RTR("Not enough bytes for decoding bytes, or invalid format.");
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.argument=0;
|
||||
r_error.expected=Variant::RAW_ARRAY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*p_outputs[0]=ret;
|
||||
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptBuiltinFunc::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceBuiltinFunc * instance = memnew(VisualScriptNodeInstanceBuiltinFunc );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->func=func;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptBuiltinFunc::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_func","which"),&VisualScriptBuiltinFunc::set_func);
|
||||
@ -577,66 +1121,66 @@ static Ref<VisualScriptNode> create_builtin_func_node(const String& p_name) {
|
||||
void register_visual_script_builtin_func_node() {
|
||||
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/sin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/cos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/tan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/sinh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SINH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/cosh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COSH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/tanh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TANH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/cos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/tan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sinh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SINH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/cosh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_COSH>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/tanh",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_TANH>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/asin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ASIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/acos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ACOS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/atan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/atan2",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN2>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/asin",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ASIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/acos",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ACOS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/atan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/atan2",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ATAN2>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/sqrt",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SQRT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/fmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FMOD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/fposmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FPOSMOD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/floor",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FLOOR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/ceil",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_CEIL>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/round",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ROUND>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/abs",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ABS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/sign",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIGN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/pow",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_POW>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/log",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LOG>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/exp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EXP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/isnan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISNAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/isinf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISINF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sqrt",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SQRT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FMOD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/fposmod",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FPOSMOD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/floor",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_FLOOR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ceil",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_CEIL>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/round",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ROUND>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/abs",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ABS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/sign",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SIGN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/pow",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_POW>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/log",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LOG>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/exp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EXP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/isnan",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISNAN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/isinf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_ISINF>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/ease",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EASE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/decimals",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECIMALS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/stepify",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEPIFY>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/lerp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/dectime",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECTIME>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/randomize",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOMIZE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/rand",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAND>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/randf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/random",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOM>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/ease",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_EASE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/decimals",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECIMALS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/stepify",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_STEPIFY>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/lerp",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LERP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/dectime",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DECTIME>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randomize",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOMIZE>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/rand",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAND>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randf",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/random",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDOM>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/seed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SEED>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/randseed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDSEED>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/deg2rad",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DEG2RAD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/rad2deg",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAD2DEG>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/linear2db",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LINEAR2DB>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/db2linear",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DB2LINEAR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/seed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_SEED>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/randseed",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RANDSEED>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/deg2rad",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DEG2RAD>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/rad2deg",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_RAD2DEG>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/linear2db",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_LINEAR2DB>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/db2linear",create_builtin_func_node<VisualScriptBuiltinFunc::MATH_DB2LINEAR>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/max",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MAX>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/min",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/clamp",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_CLAMP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/nearest_po2",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/max",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MAX>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/min",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_MIN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/clamp",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_CLAMP>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/nearest_po2",create_builtin_func_node<VisualScriptBuiltinFunc::LOGIC_NEAREST_PO2>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/weakref",create_builtin_func_node<VisualScriptBuiltinFunc::OBJ_WEAKREF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/funcref",create_builtin_func_node<VisualScriptBuiltinFunc::FUNC_FUNCREF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/printraw",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTRAW>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/var2str",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_STR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/str2var",create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/var2bytes",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/builtin/bytes2var",create_builtin_func_node<VisualScriptBuiltinFunc::BYTES_TO_VAR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/weakref",create_builtin_func_node<VisualScriptBuiltinFunc::OBJ_WEAKREF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/funcref",create_builtin_func_node<VisualScriptBuiltinFunc::FUNC_FUNCREF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/printraw",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTRAW>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2str",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_STR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/str2var",create_builtin_func_node<VisualScriptBuiltinFunc::STR_TO_VAR>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/var2bytes",create_builtin_func_node<VisualScriptBuiltinFunc::VAR_TO_BYTES>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/built_in/bytes2var",create_builtin_func_node<VisualScriptBuiltinFunc::BYTES_TO_VAR>);
|
||||
|
||||
}
|
||||
|
@ -91,11 +91,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_func(BuiltinFunc p_which);
|
||||
BuiltinFunc get_func();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptBuiltinFunc();
|
||||
};
|
||||
|
@ -425,6 +425,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
|
||||
GraphNode *gnode = memnew( GraphNode );
|
||||
gnode->set_title(node->get_caption());
|
||||
|
||||
if (EditorSettings::get_singleton()->has("visual_script/color_"+node->get_category())) {
|
||||
gnode->set_modulate(EditorSettings::get_singleton()->get("visual_script/color_"+node->get_category()));
|
||||
}
|
||||
|
||||
gnode->set_meta("__vnode",node);
|
||||
gnode->set_name(itos(E->get()));
|
||||
gnode->connect("dragged",this,"_node_moved",varray(E->get()));
|
||||
@ -1377,6 +1381,16 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2& p_point,const Variant& p
|
||||
const_cast<VisualScriptEditor*>(this)->_show_hint("Hold Ctrl to drop a Setter, Shift+Ctrl to drop a Setter and copy the value.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (String(d["type"])=="visual_script_variable_drag") {
|
||||
|
||||
#ifdef OSX_ENABLED
|
||||
const_cast<VisualScriptEditor*>(this)->_show_hint("Hold Meta to drop a Variable Setter.");
|
||||
#else
|
||||
const_cast<VisualScriptEditor*>(this)->_show_hint("Hold Ctrl to drop a Variable Setter.");
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -1448,6 +1462,11 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
|
||||
|
||||
if (d.has("type") && String(d["type"])=="visual_script_variable_drag") {
|
||||
|
||||
#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
|
||||
Vector2 ofs = graph->get_scroll_ofs() + p_point;
|
||||
if (graph->is_using_snap()) {
|
||||
int snap = graph->get_snap();
|
||||
@ -1456,9 +1475,19 @@ void VisualScriptEditor::drop_data_fw(const Point2& p_point,const Variant& p_dat
|
||||
|
||||
ofs/=EDSCALE;
|
||||
|
||||
Ref<VisualScriptVariable> vnode;
|
||||
vnode.instance();
|
||||
vnode->set_variable(d["variable"]);
|
||||
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;
|
||||
}
|
||||
|
||||
int new_id = script->get_available_id();
|
||||
|
||||
|
@ -93,9 +93,38 @@ void VisualScriptReturn::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptReturn::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceReturn : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptReturn *node;
|
||||
VisualScriptInstance *instance;
|
||||
bool with_value;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (with_value) {
|
||||
*p_working_mem = *p_inputs[0];
|
||||
} else {
|
||||
*p_working_mem = Variant();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptReturn::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceReturn * instance = memnew(VisualScriptNodeInstanceReturn );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->with_value=with_value;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptReturn::VisualScriptReturn() {
|
||||
@ -174,9 +203,33 @@ void VisualScriptCondition::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptCondition::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceCondition : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptCondition *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (p_inputs[0]->operator bool())
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptCondition::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceCondition * instance = memnew(VisualScriptNodeInstanceCondition );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptCondition::VisualScriptCondition() {
|
||||
@ -244,11 +297,36 @@ void VisualScriptWhile::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptWhile::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceWhile : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptWhile *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
bool keep_going = p_inputs[0]->operator bool();
|
||||
|
||||
if (keep_going)
|
||||
return 0|STEP_FLAG_PUSH_STACK_BIT;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptWhile::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceWhile * instance = memnew(VisualScriptNodeInstanceWhile );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptWhile::VisualScriptWhile() {
|
||||
|
||||
}
|
||||
@ -316,9 +394,79 @@ void VisualScriptIterator::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIterator::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceIterator : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptIterator *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
virtual int get_working_memory_size() const { return 2; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (p_start_sequence) {
|
||||
p_working_mem[0]=*p_inputs[0];
|
||||
bool valid;
|
||||
bool can_iter = p_inputs[0]->iter_init(p_working_mem[1],valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str=RTR("Input type not iterable: ")+Variant::get_type_name(p_inputs[0]->get_type());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!can_iter)
|
||||
return 1; //nothing to iterate
|
||||
|
||||
|
||||
*p_outputs[0]=p_working_mem[0].iter_get( p_working_mem[1],valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str=RTR("Iterator became invalid");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
bool valid;
|
||||
bool can_iter = p_working_mem[0].iter_next(p_working_mem[1],valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str=RTR("Iterator became invalid: ")+Variant::get_type_name(p_inputs[0]->get_type());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!can_iter)
|
||||
return 1; //nothing to iterate
|
||||
|
||||
|
||||
*p_outputs[0]=p_working_mem[0].iter_get( p_working_mem[1],valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str=RTR("Iterator became invalid");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0|STEP_FLAG_PUSH_STACK_BIT; //go around
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIterator::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceIterator * instance = memnew(VisualScriptNodeInstanceIterator );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptIterator::VisualScriptIterator() {
|
||||
@ -396,11 +544,48 @@ void VisualScriptSequence::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSequence::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceSequence : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptSequence *node;
|
||||
VisualScriptInstance *instance;
|
||||
int steps;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (p_start_sequence) {
|
||||
|
||||
p_working_mem[0]=0;
|
||||
}
|
||||
|
||||
int step = p_working_mem[0];
|
||||
|
||||
*p_outputs[0]=step;
|
||||
|
||||
if (step+1==steps)
|
||||
return step;
|
||||
else {
|
||||
p_working_mem[0]=step+1;
|
||||
return step|STEP_FLAG_PUSH_STACK_BIT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSequence::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceSequence * instance = memnew(VisualScriptNodeInstanceSequence );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->steps=steps;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptSequence::VisualScriptSequence() {
|
||||
|
||||
steps=1;
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void set_return_type(Variant::Type);
|
||||
Variant::Type get_return_type() const;
|
||||
@ -39,7 +40,7 @@ public:
|
||||
bool is_return_value_enabled() const;
|
||||
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptReturn();
|
||||
};
|
||||
@ -72,9 +73,10 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptCondition();
|
||||
};
|
||||
@ -107,9 +109,10 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptWhile();
|
||||
};
|
||||
@ -143,9 +146,10 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptIterator();
|
||||
};
|
||||
@ -180,11 +184,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void set_steps(int p_steps);
|
||||
int get_steps() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSequence();
|
||||
};
|
||||
|
@ -485,11 +485,96 @@ void VisualScriptFunctionCall::_bind_methods() {
|
||||
BIND_CONSTANT( CALL_MODE_BASIC_TYPE );
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptFunctionCall::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceFunctionCall : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
VisualScriptFunctionCall::CallMode call_mode;
|
||||
NodePath node_path;
|
||||
int input_args;
|
||||
bool returns;
|
||||
StringName function;
|
||||
|
||||
VisualScriptFunctionCall *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
switch(call_mode) {
|
||||
|
||||
case VisualScriptFunctionCall::CALL_MODE_SELF: {
|
||||
|
||||
Object *object=instance->get_owner_ptr();
|
||||
|
||||
if (returns) {
|
||||
*p_outputs[0] = object->call(function,p_inputs,input_args,r_error);
|
||||
} else {
|
||||
object->call(function,p_inputs,input_args,r_error);
|
||||
}
|
||||
} break;
|
||||
case VisualScriptFunctionCall::CALL_MODE_NODE_PATH: {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Base object is not a Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node* another = node->get_node(node_path);
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Path does not lead Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (returns) {
|
||||
*p_outputs[0] = another->call(function,p_inputs,input_args,r_error);
|
||||
} else {
|
||||
another->call(function,p_inputs,input_args,r_error);
|
||||
}
|
||||
|
||||
} break;
|
||||
case VisualScriptFunctionCall::CALL_MODE_INSTANCE:
|
||||
case VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE: {
|
||||
|
||||
Variant v = *p_inputs[0];
|
||||
print_line("inputs: "+String(v));
|
||||
if (returns) {
|
||||
*p_outputs[0] = v.call(function,p_inputs+1,input_args,r_error);
|
||||
} else {
|
||||
v.call(function,p_inputs+1,input_args,r_error);
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptFunctionCall::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceFunctionCall * instance = memnew(VisualScriptNodeInstanceFunctionCall );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->function=function;
|
||||
instance->call_mode=call_mode;
|
||||
instance->returns=get_output_value_port_count();
|
||||
instance->node_path=base_path;
|
||||
instance->input_args = get_input_value_port_count() - ( (call_mode==CALL_MODE_BASIC_TYPE || call_mode==CALL_MODE_INSTANCE) ? 1: 0 );
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptFunctionCall::VisualScriptFunctionCall() {
|
||||
|
||||
call_mode=CALL_MODE_INSTANCE;
|
||||
@ -983,9 +1068,116 @@ void VisualScriptPropertySet::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptPropertySet::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstancePropertySet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
VisualScriptPropertySet::CallMode call_mode;
|
||||
NodePath node_path;
|
||||
StringName property;
|
||||
bool use_builtin;
|
||||
Variant builtin_val;
|
||||
|
||||
VisualScriptPropertySet *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
switch(call_mode) {
|
||||
|
||||
case VisualScriptPropertySet::CALL_MODE_SELF: {
|
||||
|
||||
Object *object=instance->get_owner_ptr();
|
||||
|
||||
bool valid;
|
||||
|
||||
if (use_builtin) {
|
||||
object->set(property,builtin_val,&valid);
|
||||
} else {
|
||||
object->set(property,*p_inputs[0],&valid);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Invalid index property name.";
|
||||
}
|
||||
} break;
|
||||
case VisualScriptPropertySet::CALL_MODE_NODE_PATH: {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Base object is not a Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node* another = node->get_node(node_path);
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Path does not lead Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
|
||||
if (use_builtin) {
|
||||
another->set(property,builtin_val,&valid);
|
||||
} else {
|
||||
another->set(property,*p_inputs[0],&valid);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Invalid index property name.";
|
||||
}
|
||||
|
||||
} break;
|
||||
case VisualScriptPropertySet::CALL_MODE_INSTANCE:
|
||||
case VisualScriptPropertySet::CALL_MODE_BASIC_TYPE: {
|
||||
|
||||
Variant v = *p_inputs[0];
|
||||
|
||||
bool valid;
|
||||
|
||||
if (use_builtin) {
|
||||
v.set(property,builtin_val,&valid);
|
||||
} else {
|
||||
v.set(property,p_inputs[1],&valid);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Invalid index property name.";
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptPropertySet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstancePropertySet * instance = memnew(VisualScriptNodeInstancePropertySet );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->property=property;
|
||||
instance->call_mode=call_mode;
|
||||
instance->node_path=base_path;
|
||||
instance->use_builtin=use_builtin_value;
|
||||
instance->builtin_val=builtin_value;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptPropertySet::VisualScriptPropertySet() {
|
||||
@ -1012,12 +1204,12 @@ static Ref<VisualScriptNode> create_property_set_node(const String& p_name) {
|
||||
|
||||
int VisualScriptPropertyGet::get_output_sequence_port_count() const {
|
||||
|
||||
return 1;
|
||||
return (call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?0:1;
|
||||
}
|
||||
|
||||
bool VisualScriptPropertyGet::has_input_sequence_port() const{
|
||||
|
||||
return true;
|
||||
return (call_mode==CALL_MODE_SELF || call_mode==CALL_MODE_NODE_PATH)?false:true;
|
||||
}
|
||||
void VisualScriptPropertyGet::_update_base_type() {
|
||||
//cache it because this information may not be available on load
|
||||
@ -1385,9 +1577,107 @@ void VisualScriptPropertyGet::_bind_methods() {
|
||||
BIND_CONSTANT( CALL_MODE_INSTANCE);
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptPropertyGet::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstancePropertyGet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
VisualScriptPropertyGet::CallMode call_mode;
|
||||
NodePath node_path;
|
||||
StringName property;
|
||||
|
||||
VisualScriptPropertyGet *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return (call_mode==VisualScriptPropertyGet::CALL_MODE_SELF || call_mode==VisualScriptPropertyGet::CALL_MODE_NODE_PATH); }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
//these two modes can be get directly, so they use unsequenced mode
|
||||
switch(call_mode) {
|
||||
|
||||
case VisualScriptPropertyGet::CALL_MODE_SELF: {
|
||||
|
||||
Object *object=instance->get_owner_ptr();
|
||||
|
||||
bool valid;
|
||||
|
||||
*r_value = object->get(property,&valid);
|
||||
|
||||
if (!valid) {
|
||||
//r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error=RTR("Invalid index property name.");
|
||||
return false;
|
||||
}
|
||||
} break;
|
||||
case VisualScriptPropertyGet::CALL_MODE_NODE_PATH: {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
//r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error=RTR("Base object is not a Node!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Node* another = node->get_node(node_path);
|
||||
if (!node) {
|
||||
//r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error=RTR("Path does not lead Node!");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool valid;
|
||||
|
||||
|
||||
*r_value = another->get(property,&valid);
|
||||
|
||||
if (!valid) {
|
||||
//r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error=vformat(RTR("Invalid index property name '%s' in node %s."),String(property),another->get_name());
|
||||
return false;
|
||||
}
|
||||
|
||||
} break;
|
||||
default: {};
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
bool valid;
|
||||
Variant v = *p_inputs[0];
|
||||
|
||||
*p_outputs[0] = v.get(property,&valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str=RTR("Invalid index property name.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptPropertyGet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstancePropertyGet * instance = memnew(VisualScriptNodeInstancePropertyGet );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->property=property;
|
||||
instance->call_mode=call_mode;
|
||||
instance->node_path=base_path;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptPropertyGet::VisualScriptPropertyGet() {
|
||||
@ -1463,7 +1753,9 @@ Node *VisualScriptScriptCall::_get_base_node() const {
|
||||
|
||||
int VisualScriptScriptCall::get_input_value_port_count() const{
|
||||
|
||||
|
||||
#if 1
|
||||
return argument_count;
|
||||
#else
|
||||
if (call_mode==CALL_MODE_SELF) {
|
||||
|
||||
Ref<VisualScript> vs = get_visual_script();
|
||||
@ -1501,6 +1793,7 @@ int VisualScriptScriptCall::get_input_value_port_count() const{
|
||||
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
int VisualScriptScriptCall::get_output_value_port_count() const{
|
||||
@ -1573,6 +1866,48 @@ String VisualScriptScriptCall::get_text() const {
|
||||
return " "+String(function)+"()";
|
||||
}
|
||||
|
||||
void VisualScriptScriptCall::_update_argument_count() {
|
||||
|
||||
//try to remember the amount of arguments in the function, because if loaded from scratch
|
||||
//this information will not be available
|
||||
|
||||
if (call_mode==CALL_MODE_SELF) {
|
||||
|
||||
Ref<VisualScript> vs = get_visual_script();
|
||||
if (vs.is_valid()) {
|
||||
|
||||
if (!vs->has_function(function))
|
||||
return ;
|
||||
|
||||
int id = vs->get_function_node_id(function);
|
||||
if (id<0)
|
||||
return;
|
||||
|
||||
Ref<VisualScriptFunction> func = vs->get_node(function,id);
|
||||
|
||||
argument_count=func->get_argument_count();
|
||||
}
|
||||
} else {
|
||||
|
||||
Node*base = _get_base_node();
|
||||
if (!base)
|
||||
return;
|
||||
|
||||
Ref<Script> script = base->get_script();
|
||||
if (!script.is_valid())
|
||||
return ;
|
||||
|
||||
List<MethodInfo> functions;
|
||||
script->get_method_list(&functions);
|
||||
for (List<MethodInfo>::Element *E=functions.front();E;E=E->next()) {
|
||||
if (E->get().name==function) {
|
||||
argument_count=E->get().arguments.size();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptScriptCall::set_function(const StringName& p_type){
|
||||
@ -1581,7 +1916,7 @@ void VisualScriptScriptCall::set_function(const StringName& p_type){
|
||||
return;
|
||||
|
||||
function=p_type;
|
||||
|
||||
_update_argument_count();
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
@ -1597,7 +1932,7 @@ void VisualScriptScriptCall::set_base_path(const NodePath& p_type) {
|
||||
return;
|
||||
|
||||
base_path=p_type;
|
||||
|
||||
_update_argument_count();
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
@ -1614,11 +1949,25 @@ void VisualScriptScriptCall::set_call_mode(CallMode p_mode) {
|
||||
return;
|
||||
|
||||
call_mode=p_mode;
|
||||
|
||||
_update_argument_count();
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
|
||||
}
|
||||
|
||||
void VisualScriptScriptCall::set_argument_count(int p_count) {
|
||||
|
||||
argument_count=p_count;
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
|
||||
}
|
||||
|
||||
int VisualScriptScriptCall::get_argument_count() const {
|
||||
|
||||
return argument_count;
|
||||
}
|
||||
|
||||
VisualScriptScriptCall::CallMode VisualScriptScriptCall::get_call_mode() const {
|
||||
|
||||
return call_mode;
|
||||
@ -1703,24 +2052,95 @@ void VisualScriptScriptCall::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_base_path","base_path"),&VisualScriptScriptCall::set_base_path);
|
||||
ObjectTypeDB::bind_method(_MD("get_base_path"),&VisualScriptScriptCall::get_base_path);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_argument_count","argument_count"),&VisualScriptScriptCall::set_argument_count);
|
||||
ObjectTypeDB::bind_method(_MD("get_argument_count"),&VisualScriptScriptCall::get_argument_count);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"function/call_mode",PROPERTY_HINT_ENUM,"Self,Node Path"),_SCS("set_call_mode"),_SCS("get_call_mode"));
|
||||
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::STRING,"function/argument_count"),_SCS("set_argument_count"),_SCS("get_argument_count"));
|
||||
|
||||
BIND_CONSTANT( CALL_MODE_SELF );
|
||||
BIND_CONSTANT( CALL_MODE_NODE_PATH);
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptScriptCall::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceScriptCall : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
VisualScriptScriptCall::CallMode call_mode;
|
||||
NodePath node_path;
|
||||
int input_args;
|
||||
bool returns;
|
||||
StringName function;
|
||||
|
||||
VisualScriptScriptCall *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
switch(call_mode) {
|
||||
|
||||
case VisualScriptScriptCall::CALL_MODE_SELF: {
|
||||
|
||||
Object *object=instance->get_owner_ptr();
|
||||
|
||||
*p_outputs[0] = object->call(function,p_inputs,input_args,r_error);
|
||||
|
||||
} break;
|
||||
case VisualScriptScriptCall::CALL_MODE_NODE_PATH: {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Base object is not a Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node* another = node->get_node(node_path);
|
||||
if (!node) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Path does not lead Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
*p_outputs[0] = another->call(function,p_inputs,input_args,r_error);
|
||||
|
||||
} break;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptScriptCall::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceScriptCall * instance = memnew(VisualScriptNodeInstanceScriptCall );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->function=function;
|
||||
instance->call_mode=call_mode;
|
||||
instance->node_path=base_path;
|
||||
instance->input_args = argument_count;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptScriptCall::VisualScriptScriptCall() {
|
||||
|
||||
call_mode=CALL_MODE_SELF;
|
||||
argument_count=0;
|
||||
|
||||
|
||||
}
|
||||
@ -1736,7 +2156,7 @@ static Ref<VisualScriptNode> create_script_call_node(const String& p_name) {
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////SCRIPT CALL//////////////////////
|
||||
////////////////EMIT//////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptEmitSignal::get_output_sequence_port_count() const {
|
||||
@ -1865,14 +2285,78 @@ void VisualScriptEmitSignal::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptEmitSignal::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceEmitSignal : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
VisualScriptEmitSignal *node;
|
||||
VisualScriptInstance *instance;
|
||||
int argcount;
|
||||
StringName name;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
Object *obj = instance->get_owner_ptr();
|
||||
|
||||
obj->emit_signal(name,p_inputs,argcount);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptEmitSignal::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceEmitSignal * instance = memnew(VisualScriptNodeInstanceEmitSignal );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->name=name;
|
||||
instance->argcount=get_input_value_port_count();
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptEmitSignal::VisualScriptEmitSignal() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Ref<VisualScriptNode> create_basic_type_call_node(const String& p_name) {
|
||||
|
||||
Vector<String> path = p_name.split("/");
|
||||
ERR_FAIL_COND_V(path.size()<4,Ref<VisualScriptNode>());
|
||||
String base_type = path[2];
|
||||
String method = path[3];
|
||||
|
||||
Ref<VisualScriptFunctionCall> node;
|
||||
node.instance();
|
||||
|
||||
Variant::Type type=Variant::VARIANT_MAX;
|
||||
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
|
||||
if (Variant::get_type_name(Variant::Type(i))==base_type) {
|
||||
type=Variant::Type(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ERR_FAIL_COND_V(type==Variant::VARIANT_MAX,Ref<VisualScriptNode>());
|
||||
|
||||
|
||||
node->set_call_mode(VisualScriptFunctionCall::CALL_MODE_BASIC_TYPE);
|
||||
node->set_basic_type(type);
|
||||
node->set_function(method);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void register_visual_script_func_nodes() {
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/call_method/instance_call",create_function_call_node<VisualScriptFunctionCall::CALL_MODE_INSTANCE>);
|
||||
@ -1895,4 +2379,17 @@ void register_visual_script_func_nodes() {
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/script/emit_signal",create_node_generic<VisualScriptEmitSignal>);
|
||||
|
||||
|
||||
for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
||||
|
||||
Variant::Type t = Variant::Type(i);
|
||||
String type_name = Variant::get_type_name(t);
|
||||
Variant::CallError ce;
|
||||
Variant vt = Variant::construct(t,NULL,0,ce);
|
||||
List<MethodInfo> ml;
|
||||
vt.get_method_list(&ml);
|
||||
|
||||
for (List<MethodInfo>::Element *E=ml.front();E;E=E->next()) {
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/basic_types/"+type_name+"/"+E->get().name,create_basic_type_call_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
@ -69,7 +70,7 @@ public:
|
||||
void set_use_default_args(int p_amount);
|
||||
int get_use_default_args() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptFunctionCall();
|
||||
};
|
||||
@ -127,6 +128,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_base_type(const StringName& p_type);
|
||||
StringName get_base_type() const;
|
||||
@ -149,7 +151,7 @@ public:
|
||||
void set_builtin_value(const Variant &p_value);
|
||||
Variant get_builtin_value() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptPropertySet();
|
||||
};
|
||||
@ -204,6 +206,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_base_type(const StringName& p_type);
|
||||
StringName get_base_type() const;
|
||||
@ -220,7 +223,7 @@ public:
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptPropertyGet();
|
||||
};
|
||||
@ -246,11 +249,13 @@ private:
|
||||
CallMode call_mode;
|
||||
NodePath base_path;
|
||||
StringName function;
|
||||
int argument_count;
|
||||
|
||||
|
||||
Node *_get_base_node() const;
|
||||
|
||||
|
||||
void _update_argument_count();
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo& property) const;
|
||||
|
||||
@ -274,6 +279,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_function(const StringName& p_type);
|
||||
StringName get_function() const;
|
||||
@ -284,9 +290,11 @@ public:
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
void set_argument_count(int p_count);
|
||||
int get_argument_count() const;
|
||||
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptScriptCall();
|
||||
};
|
||||
@ -328,11 +336,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_signal(const StringName& p_type);
|
||||
StringName get_signal() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptEmitSignal();
|
||||
};
|
||||
|
@ -53,7 +53,15 @@ bool VisualScriptFunction::_set(const StringName& p_name, const Variant& p_valu
|
||||
|
||||
}
|
||||
|
||||
if (p_name=="stack/stackless") {
|
||||
set_stack_less(p_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p_name=="stack/size") {
|
||||
stack_size=p_value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -81,6 +89,16 @@ bool VisualScriptFunction::_get(const StringName& p_name,Variant &r_ret) const
|
||||
|
||||
}
|
||||
|
||||
if (p_name=="stack/stackless") {
|
||||
r_ret=stack_less;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (p_name=="stack/size") {
|
||||
r_ret=stack_size;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void VisualScriptFunction::_get_property_list( List<PropertyInfo> *p_list) const {
|
||||
@ -96,6 +114,11 @@ void VisualScriptFunction::_get_property_list( List<PropertyInfo> *p_list) cons
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"argument/"+itos(i+1)+"/type",PROPERTY_HINT_ENUM,argt));
|
||||
p_list->push_back(PropertyInfo(Variant::STRING,"argument/"+itos(i+1)+"/name"));
|
||||
}
|
||||
if (!stack_less) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT,"stack/size",PROPERTY_HINT_RANGE,"1,100000"));
|
||||
}
|
||||
p_list->push_back(PropertyInfo(Variant::BOOL,"stack/stackless"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -201,15 +224,75 @@ int VisualScriptFunction::get_argument_count() const {
|
||||
return arguments.size();
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceFunction : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptFunction::instance(VScriptInstance* p_instance) {
|
||||
VisualScriptFunction *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
return NULL;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
int ac = node->get_argument_count();
|
||||
|
||||
for(int i=0;i<ac;i++) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
Variant::Type expected = node->get_argument_type(i);
|
||||
if (expected!=Variant::NIL) {
|
||||
if (!Variant::can_convert_strict(p_inputs[i]->get_type(),expected)) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||
r_error.expected=expected;
|
||||
r_error.argument=i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*p_outputs[i]=*p_inputs[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptFunction::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceFunction * instance = memnew(VisualScriptNodeInstanceFunction );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptFunction::VisualScriptFunction() {
|
||||
|
||||
stack_size=256;
|
||||
stack_less=false;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptFunction::set_stack_less(bool p_enable) {
|
||||
stack_less=p_enable;
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
bool VisualScriptFunction::is_stack_less() const {
|
||||
return stack_less;
|
||||
}
|
||||
|
||||
void VisualScriptFunction::set_stack_size(int p_size) {
|
||||
|
||||
ERR_FAIL_COND(p_size <1 || p_size>100000);
|
||||
stack_size=p_size;
|
||||
}
|
||||
|
||||
int VisualScriptFunction::get_stack_size() const {
|
||||
|
||||
return stack_size;
|
||||
}
|
||||
|
||||
|
||||
@ -425,9 +508,45 @@ void VisualScriptOperator::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptOperator::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceOperator : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
bool unary;
|
||||
Variant::Operator op;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
bool valid;
|
||||
if (unary) {
|
||||
|
||||
Variant::evaluate(op,*p_inputs[0],Variant(),*p_outputs[0],valid);
|
||||
} else {
|
||||
Variant::evaluate(op,*p_inputs[0],*p_inputs[1],*p_outputs[0],valid);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
if (p_outputs[0]->get_type()==Variant::STRING) {
|
||||
r_error_str=*p_outputs[0];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptOperator::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceOperator * instance = memnew(VisualScriptNodeInstanceOperator );
|
||||
instance->unary=get_input_value_port_count()==1;
|
||||
instance->op=op;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptOperator::VisualScriptOperator() {
|
||||
@ -447,50 +566,42 @@ static Ref<VisualScriptNode> create_op_node(const String& p_name) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////VARIABLE//////////////////
|
||||
////////////////VARIABLE GET//////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptVariable::get_output_sequence_port_count() const {
|
||||
int VisualScriptVariableGet::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptVariableGet::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptVariableGet::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptVariableGet::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool VisualScriptVariable::has_input_sequence_port() const{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptVariable::get_input_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptVariable::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptVariable::get_output_sequence_port_text(int p_port) const {
|
||||
String VisualScriptVariableGet::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptVariable::get_input_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptVariableGet::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name="set";
|
||||
if (get_visual_script().is_valid() && get_visual_script()->has_variable(variable)) {
|
||||
PropertyInfo vinfo = get_visual_script()->get_variable_info(variable);
|
||||
pinfo.type=vinfo.type;
|
||||
pinfo.hint=vinfo.hint;
|
||||
pinfo.hint_string=vinfo.hint_string;
|
||||
}
|
||||
return pinfo;
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptVariable::get_output_value_port_info(int p_idx) const{
|
||||
PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name="get";
|
||||
pinfo.name="value";
|
||||
if (get_visual_script().is_valid() && get_visual_script()->has_variable(variable)) {
|
||||
PropertyInfo vinfo = get_visual_script()->get_variable_info(variable);
|
||||
pinfo.type=vinfo.type;
|
||||
@ -501,17 +612,17 @@ PropertyInfo VisualScriptVariable::get_output_value_port_info(int p_idx) const{
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptVariable::get_caption() const {
|
||||
String VisualScriptVariableGet::get_caption() const {
|
||||
|
||||
return "Variable";
|
||||
}
|
||||
|
||||
String VisualScriptVariable::get_text() const {
|
||||
String VisualScriptVariableGet::get_text() const {
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
void VisualScriptVariable::set_variable(StringName p_variable) {
|
||||
void VisualScriptVariableGet::set_variable(StringName p_variable) {
|
||||
|
||||
if (variable==p_variable)
|
||||
return;
|
||||
@ -520,12 +631,12 @@ void VisualScriptVariable::set_variable(StringName p_variable) {
|
||||
|
||||
}
|
||||
|
||||
StringName VisualScriptVariable::get_variable() const{
|
||||
StringName VisualScriptVariableGet::get_variable() const{
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
void VisualScriptVariable::_validate_property(PropertyInfo& property) const {
|
||||
void VisualScriptVariableGet::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
if (property.name=="variable/name" && get_visual_script().is_valid()) {
|
||||
Ref<VisualScript> vs = get_visual_script();
|
||||
@ -545,22 +656,192 @@ void VisualScriptVariable::_validate_property(PropertyInfo& property) const {
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptVariable::_bind_methods() {
|
||||
void VisualScriptVariableGet::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_variable","name"),&VisualScriptVariable::set_variable);
|
||||
ObjectTypeDB::bind_method(_MD("get_variable"),&VisualScriptVariable::get_variable);
|
||||
ObjectTypeDB::bind_method(_MD("set_variable","name"),&VisualScriptVariableGet::set_variable);
|
||||
ObjectTypeDB::bind_method(_MD("get_variable"),&VisualScriptVariableGet::get_variable);
|
||||
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"variable/name"),_SCS("set_variable"),_SCS("get_variable"));
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptVariable::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceVariableGet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptVariableGet *node;
|
||||
VisualScriptInstance *instance;
|
||||
StringName variable;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
if (instance->get_variable(variable,r_value)==false) {
|
||||
r_error=RTR("VariableGet not found in script: ")+"'"+String(variable)+"'";
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptVariableGet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceVariableGet * instance = memnew(VisualScriptNodeInstanceVariableGet );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->variable=variable;
|
||||
return instance;
|
||||
}
|
||||
VisualScriptVariableGet::VisualScriptVariableGet() {
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VisualScriptVariable::VisualScriptVariable() {
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////VARIABLE GET//////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptVariableSet::get_output_sequence_port_count() const {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool VisualScriptVariableSet::has_input_sequence_port() const{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptVariableSet::get_input_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptVariableSet::get_output_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptVariableSet::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptVariableSet::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name="set";
|
||||
if (get_visual_script().is_valid() && get_visual_script()->has_variable(variable)) {
|
||||
PropertyInfo vinfo = get_visual_script()->get_variable_info(variable);
|
||||
pinfo.type=vinfo.type;
|
||||
pinfo.hint=vinfo.hint;
|
||||
pinfo.hint_string=vinfo.hint_string;
|
||||
}
|
||||
return pinfo;
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptVariableSet::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptVariableSet::get_caption() const {
|
||||
|
||||
return "VariableSet";
|
||||
}
|
||||
|
||||
String VisualScriptVariableSet::get_text() const {
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
void VisualScriptVariableSet::set_variable(StringName p_variable) {
|
||||
|
||||
if (variable==p_variable)
|
||||
return;
|
||||
variable=p_variable;
|
||||
ports_changed_notify();
|
||||
|
||||
}
|
||||
|
||||
StringName VisualScriptVariableSet::get_variable() const{
|
||||
|
||||
return variable;
|
||||
}
|
||||
|
||||
void VisualScriptVariableSet::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
if (property.name=="variable/name" && get_visual_script().is_valid()) {
|
||||
Ref<VisualScript> vs = get_visual_script();
|
||||
List<StringName> vars;
|
||||
vs->get_variable_list(&vars);
|
||||
|
||||
String vhint;
|
||||
for (List<StringName>::Element *E=vars.front();E;E=E->next()) {
|
||||
if (vhint!=String())
|
||||
vhint+=",";
|
||||
|
||||
vhint+=E->get().operator String();
|
||||
}
|
||||
|
||||
property.hint=PROPERTY_HINT_ENUM;
|
||||
property.hint_string=vhint;
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptVariableSet::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_variable","name"),&VisualScriptVariableSet::set_variable);
|
||||
ObjectTypeDB::bind_method(_MD("get_variable"),&VisualScriptVariableSet::get_variable);
|
||||
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING,"variable/name"),_SCS("set_variable"),_SCS("get_variable"));
|
||||
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceVariableSet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptVariableSet *node;
|
||||
VisualScriptInstance *instance;
|
||||
StringName variable;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
if (instance->set_variable(variable,*p_inputs[0])==false) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD ;
|
||||
r_error_str=RTR("VariableSet not found in script: ")+"'"+String(variable)+"'";
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptVariableSet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceVariableSet * instance = memnew(VisualScriptNodeInstanceVariableSet );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->variable=variable;
|
||||
return instance;
|
||||
}
|
||||
VisualScriptVariableSet::VisualScriptVariableSet() {
|
||||
|
||||
|
||||
}
|
||||
@ -679,9 +960,33 @@ void VisualScriptConstant::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptConstant::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceConstant : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
Variant constant;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
*r_value=constant;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptConstant::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceConstant * instance = memnew(VisualScriptNodeInstanceConstant );
|
||||
instance->constant=value;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptConstant::VisualScriptConstant() {
|
||||
@ -747,11 +1052,34 @@ String VisualScriptIndexGet::get_text() const {
|
||||
}
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIndexGet::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
bool valid;
|
||||
*p_outputs[0] = p_inputs[0]->get(*p_inputs[1],&valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Invalid get: "+p_inputs[0]->get_construct_string();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIndexGet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceIndexGet * instance = memnew(VisualScriptNodeInstanceIndexGet );
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptIndexGet::VisualScriptIndexGet() {
|
||||
|
||||
|
||||
@ -816,11 +1144,35 @@ String VisualScriptIndexSet::get_text() const {
|
||||
}
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIndexSet::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
bool valid;
|
||||
*p_outputs[0]=*p_inputs[0];
|
||||
p_outputs[0]->set(*p_inputs[1],*p_inputs[2],&valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str="Invalid set: "+p_inputs[1]->get_construct_string();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptIndexSet::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceIndexSet * instance = memnew(VisualScriptNodeInstanceIndexSet );
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptIndexSet::VisualScriptIndexSet() {
|
||||
|
||||
|
||||
@ -889,10 +1241,33 @@ int VisualScriptGlobalConstant::get_global_constant() {
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceGlobalConstant : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptGlobalConstant::instance(VScriptInstance* p_instance) {
|
||||
int index;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
return NULL;
|
||||
*r_value = GlobalConstants::get_global_constant_value(index);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptGlobalConstant::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceGlobalConstant * instance = memnew(VisualScriptNodeInstanceGlobalConstant );
|
||||
instance->index=index;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void VisualScriptGlobalConstant::_bind_methods() {
|
||||
@ -931,6 +1306,17 @@ const char* VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX]={
|
||||
"E",
|
||||
"Sqrt2",
|
||||
};
|
||||
|
||||
double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX]={
|
||||
1.0,
|
||||
Math_PI,
|
||||
Math_PI*2,
|
||||
Math_PI*0.5,
|
||||
2.71828182845904523536,
|
||||
Math::sqrt(2.0)
|
||||
};
|
||||
|
||||
|
||||
int VisualScriptMathConstant::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
@ -962,7 +1348,7 @@ PropertyInfo VisualScriptMathConstant::get_input_value_port_info(int p_idx) cons
|
||||
|
||||
PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::INT,"value");
|
||||
return PropertyInfo(Variant::REAL,"value");
|
||||
}
|
||||
|
||||
|
||||
@ -987,13 +1373,36 @@ VisualScriptMathConstant::MathConstant VisualScriptMathConstant::get_math_consta
|
||||
return constant;
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceMathConstant : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
float value;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
*r_value = value;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptMathConstant::instance(VScriptInstance* p_instance) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptMathConstant::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceMathConstant * instance = memnew(VisualScriptNodeInstanceMathConstant );
|
||||
instance->value=const_value[constant];
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptMathConstant::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_math_constant","which"),&VisualScriptMathConstant::set_math_constant);
|
||||
@ -1080,11 +1489,35 @@ String VisualScriptEngineSingleton::get_singleton() {
|
||||
|
||||
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptEngineSingleton::instance(VScriptInstance* p_instance) {
|
||||
class VisualScriptNodeInstanceEngineSingleton : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
return NULL;
|
||||
Object* singleton;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
*r_value=singleton;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptEngineSingleton::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceEngineSingleton * instance = memnew(VisualScriptNodeInstanceEngineSingleton );
|
||||
instance->singleton=Globals::get_singleton()->get_singleton_object(singleton);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptEngineSingleton::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_singleton","name"),&VisualScriptEngineSingleton::set_singleton);
|
||||
@ -1176,12 +1609,53 @@ NodePath VisualScriptSceneNode::get_node_path() {
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceSceneNode : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSceneNode::instance(VScriptInstance* p_instance) {
|
||||
VisualScriptSceneNode *node;
|
||||
VisualScriptInstance *instance;
|
||||
NodePath path;
|
||||
|
||||
return NULL;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
r_error="Base object is not a Node!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Node* another = node->get_node(path);
|
||||
if (!node) {
|
||||
r_error="Path does not lead Node!";
|
||||
return false;
|
||||
}
|
||||
|
||||
*r_value=another;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSceneNode::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceSceneNode * instance = memnew(VisualScriptNodeInstanceSceneNode );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
instance->path=path;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
static Node* _find_script_node(Node* p_edited_scene,Node* p_current_node,const Ref<Script> &script) {
|
||||
@ -1302,12 +1776,51 @@ String VisualScriptSceneTree::get_text() const {
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceSceneTree : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSceneTree::instance(VScriptInstance* p_instance) {
|
||||
VisualScriptSceneTree *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
return NULL;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
Node* node = instance->get_owner_ptr()->cast_to<Node>();
|
||||
if (!node) {
|
||||
r_error="Base object is not a Node!";
|
||||
return false;
|
||||
}
|
||||
|
||||
SceneTree* tree = node->get_tree();
|
||||
if (!tree) {
|
||||
r_error="Attempt to get SceneTree while node is not in the active tree.";
|
||||
return false;
|
||||
}
|
||||
|
||||
*r_value=tree;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSceneTree::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceSceneTree * instance = memnew(VisualScriptNodeInstanceSceneTree );
|
||||
instance->node=this;
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
void VisualScriptSceneTree::_validate_property(PropertyInfo& property) const {
|
||||
|
||||
}
|
||||
@ -1382,10 +1895,31 @@ String VisualScriptResourcePath::get_resource_path() {
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceResourcePath : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptResourcePath::instance(VScriptInstance* p_instance) {
|
||||
String path;
|
||||
|
||||
return NULL;
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
*r_value = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptResourcePath::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceResourcePath * instance = memnew(VisualScriptNodeInstanceResourcePath );
|
||||
instance->path=path;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@ -1404,9 +1938,104 @@ VisualScriptResourcePath::VisualScriptResourcePath() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////RESPATH///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptSelf::get_output_sequence_port_count() const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptSelf::has_input_sequence_port() const{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int VisualScriptSelf::get_input_value_port_count() const{
|
||||
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptSelf::get_output_value_port_count() const{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptSelf::get_output_sequence_port_text(int p_port) const {
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const{
|
||||
|
||||
return PropertyInfo(Variant::OBJECT,"instance");
|
||||
}
|
||||
|
||||
|
||||
String VisualScriptSelf::get_caption() const {
|
||||
|
||||
return "Self";
|
||||
}
|
||||
|
||||
String VisualScriptSelf::get_text() const {
|
||||
|
||||
if (get_visual_script().is_valid())
|
||||
return get_visual_script()->get_instance_base_type();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
class VisualScriptNodeInstanceSelf : public VisualScriptNodeInstance {
|
||||
public:
|
||||
|
||||
VisualScriptInstance* instance;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
virtual bool is_output_port_unsequenced(int p_idx) const { return true; }
|
||||
virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const {
|
||||
|
||||
*r_value = instance->get_owner_ptr();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int step(const Variant** p_inputs,Variant** p_outputs,bool p_start_sequence,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance* VisualScriptSelf::instance(VisualScriptInstance* p_instance) {
|
||||
|
||||
VisualScriptNodeInstanceSelf * instance = memnew(VisualScriptNodeInstanceSelf );
|
||||
instance->instance=p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VisualScriptSelf::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
VisualScriptSelf::VisualScriptSelf() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void register_visual_script_nodes() {
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("data/variable",create_node_generic<VisualScriptVariable>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/set_variable",create_node_generic<VisualScriptVariableGet>);
|
||||
VisualScriptLanguage::singleton->add_register_func("data/get_variable",create_node_generic<VisualScriptVariableSet>);
|
||||
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>);
|
||||
@ -1414,6 +2043,7 @@ void register_visual_script_nodes() {
|
||||
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("data/self",create_node_generic<VisualScriptSelf>);
|
||||
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("index/get_index",create_node_generic<VisualScriptIndexGet>);
|
||||
|
@ -14,6 +14,10 @@ class VisualScriptFunction : public VisualScriptNode {
|
||||
};
|
||||
|
||||
Vector<Argument> arguments;
|
||||
|
||||
bool stack_less;
|
||||
int stack_size;
|
||||
|
||||
protected:
|
||||
|
||||
bool _set(const StringName& p_name, const Variant& p_value);
|
||||
@ -38,6 +42,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void add_argument(Variant::Type p_type,const String& p_name,int p_index=-1);
|
||||
void set_argument_type(int p_argidx,Variant::Type p_type);
|
||||
@ -47,7 +52,14 @@ public:
|
||||
void remove_argument(int p_argidx);
|
||||
int get_argument_count() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
|
||||
void set_stack_less(bool p_enable);
|
||||
bool is_stack_less() const;
|
||||
|
||||
void set_stack_size(int p_size);
|
||||
int get_stack_size() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptFunction();
|
||||
};
|
||||
@ -80,19 +92,20 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "operators"; }
|
||||
|
||||
void set_operator(Variant::Operator p_op);
|
||||
Variant::Operator get_operator() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptOperator();
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptVariable : public VisualScriptNode {
|
||||
class VisualScriptVariableGet : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptVariable,VisualScriptNode)
|
||||
OBJ_TYPE(VisualScriptVariableGet,VisualScriptNode)
|
||||
|
||||
|
||||
StringName variable;
|
||||
@ -118,15 +131,56 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_variable(StringName p_var);
|
||||
StringName get_variable() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptVariable();
|
||||
VisualScriptVariableGet();
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptVariableSet : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptVariableSet,VisualScriptNode)
|
||||
|
||||
|
||||
StringName variable;
|
||||
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 String get_category() const { return "data"; }
|
||||
|
||||
void set_variable(StringName p_var);
|
||||
StringName get_variable() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptVariableSet();
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptConstant : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptConstant,VisualScriptNode)
|
||||
@ -156,6 +210,7 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_constant_type(Variant::Type p_type);
|
||||
Variant::Type get_constant_type() const;
|
||||
@ -163,7 +218,7 @@ public:
|
||||
void set_constant_value(Variant p_value);
|
||||
Variant get_constant_value() const;
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptConstant();
|
||||
};
|
||||
@ -192,8 +247,9 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "operators"; }
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptIndexGet();
|
||||
};
|
||||
@ -222,8 +278,9 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "operators"; }
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptIndexSet();
|
||||
};
|
||||
@ -255,11 +312,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_global_constant(int p_which);
|
||||
int get_global_constant();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptGlobalConstant();
|
||||
};
|
||||
@ -283,6 +341,7 @@ public:
|
||||
|
||||
private:
|
||||
static const char* const_name[MATH_CONSTANT_MAX];
|
||||
static double const_value[MATH_CONSTANT_MAX];
|
||||
MathConstant constant;
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -304,11 +363,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_math_constant(MathConstant p_which);
|
||||
MathConstant get_math_constant();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptMathConstant();
|
||||
};
|
||||
@ -340,11 +400,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_singleton(const String &p_string);
|
||||
String get_singleton();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptEngineSingleton();
|
||||
};
|
||||
@ -378,11 +439,12 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_node_path(const NodePath &p_path);
|
||||
NodePath get_node_path();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSceneNode();
|
||||
};
|
||||
@ -416,8 +478,9 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSceneTree();
|
||||
};
|
||||
@ -450,16 +513,54 @@ public:
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_resource_path(const String &p_path);
|
||||
String get_resource_path();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VScriptInstance* p_instance);
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptResourcePath();
|
||||
};
|
||||
|
||||
|
||||
class VisualScriptSelf : public VisualScriptNode {
|
||||
|
||||
OBJ_TYPE(VisualScriptSelf,VisualScriptNode)
|
||||
|
||||
|
||||
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;
|
||||
virtual String get_category() const { return "data"; }
|
||||
|
||||
void set_resource_path(const String &p_path);
|
||||
String get_resource_path();
|
||||
|
||||
virtual VisualScriptNodeInstance* instance(VisualScriptInstance* p_instance);
|
||||
|
||||
VisualScriptSelf();
|
||||
};
|
||||
|
||||
|
||||
void register_visual_script_nodes();
|
||||
|
||||
#endif // VISUAL_SCRIPT_NODES_H
|
||||
|
@ -41,6 +41,8 @@ void Container::_child_minsize_changed() {
|
||||
|
||||
void Container::add_child_notify(Node *p_child) {
|
||||
|
||||
Control::add_child_notify(p_child);
|
||||
|
||||
Control *control = p_child->cast_to<Control>();
|
||||
if (!control)
|
||||
return;
|
||||
@ -50,18 +52,24 @@ void Container::add_child_notify(Node *p_child) {
|
||||
control->connect("visibility_changed",this,"_child_minsize_changed");
|
||||
queue_sort();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Container::move_child_notify(Node *p_child) {
|
||||
|
||||
Control::move_child_notify(p_child);
|
||||
|
||||
if (!p_child->cast_to<Control>())
|
||||
return;
|
||||
|
||||
queue_sort();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Container::remove_child_notify(Node *p_child) {
|
||||
|
||||
Control::remove_child_notify(p_child);
|
||||
|
||||
Control *control = p_child->cast_to<Control>();
|
||||
if (!control)
|
||||
|
@ -422,6 +422,32 @@ void Control::_resize(const Size2& p_size) {
|
||||
_size_changed();
|
||||
}
|
||||
|
||||
//moved theme configuration here, so controls can set up even if still not inside active scene
|
||||
|
||||
void Control::add_child_notify(Node *p_child) {
|
||||
|
||||
Control *child_c=p_child->cast_to<Control>();
|
||||
if (!child_c)
|
||||
return;
|
||||
|
||||
if (child_c->data.theme.is_null() && data.theme_owner) {
|
||||
child_c->data.theme_owner=data.theme_owner;
|
||||
child_c->notification(NOTIFICATION_THEME_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
void Control::remove_child_notify(Node *p_child) {
|
||||
|
||||
Control *child_c=p_child->cast_to<Control>();
|
||||
if (!child_c)
|
||||
return;
|
||||
|
||||
if (child_c->data.theme_owner && child_c->data.theme.is_null()) {
|
||||
child_c->data.theme_owner=NULL;
|
||||
//notification(NOTIFICATION_THEME_CHANGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Control::_notification(int p_notification) {
|
||||
@ -512,10 +538,10 @@ void Control::_notification(int p_notification) {
|
||||
}
|
||||
|
||||
|
||||
if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
|
||||
data.theme_owner=data.parent->data.theme_owner;
|
||||
notification(NOTIFICATION_THEME_CHANGED);
|
||||
}
|
||||
//if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
|
||||
// data.theme_owner=data.parent->data.theme_owner;
|
||||
// notification(NOTIFICATION_THEME_CHANGED);
|
||||
//}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_CANVAS: {
|
||||
@ -547,10 +573,10 @@ void Control::_notification(int p_notification) {
|
||||
|
||||
data.parent=NULL;
|
||||
data.parent_canvas_item=NULL;
|
||||
if (data.theme_owner && data.theme.is_null()) {
|
||||
data.theme_owner=NULL;
|
||||
//if (data.theme_owner && data.theme.is_null()) {
|
||||
// data.theme_owner=NULL;
|
||||
//notification(NOTIFICATION_THEME_CHANGED);
|
||||
}
|
||||
//}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_MOVED_IN_PARENT: {
|
||||
|
@ -194,12 +194,16 @@ private:
|
||||
void _font_changed();
|
||||
|
||||
|
||||
|
||||
friend class Viewport;
|
||||
void _modal_stack_remove();
|
||||
void _modal_set_prev_focus_owner(ObjectID p_prev);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void add_child_notify(Node *p_child);
|
||||
virtual void remove_child_notify(Node *p_child);
|
||||
|
||||
//virtual void _window_input_event(InputEvent p_event);
|
||||
|
||||
bool _set(const StringName& p_name, const Variant& p_value);
|
||||
|
@ -196,6 +196,8 @@ void GraphEdit::_graph_node_moved(Node *p_gn) {
|
||||
|
||||
void GraphEdit::add_child_notify(Node *p_child) {
|
||||
|
||||
Control::add_child_notify(p_child);
|
||||
|
||||
top_layer->call_deferred("raise"); //top layer always on top!
|
||||
GraphNode *gn = p_child->cast_to<GraphNode>();
|
||||
if (gn) {
|
||||
@ -205,10 +207,14 @@ void GraphEdit::add_child_notify(Node *p_child) {
|
||||
_graph_node_moved(gn);
|
||||
gn->set_stop_mouse(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GraphEdit::remove_child_notify(Node *p_child) {
|
||||
|
||||
Control::remove_child_notify(p_child);
|
||||
|
||||
top_layer->call_deferred("raise"); //top layer always on top!
|
||||
GraphNode *gn = p_child->cast_to<GraphNode>();
|
||||
if (gn) {
|
||||
|
@ -189,6 +189,8 @@ void GraphNode::_notification(int p_what) {
|
||||
if (p_what==NOTIFICATION_DRAW) {
|
||||
|
||||
Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame");
|
||||
sb=sb->duplicate();
|
||||
sb->call("set_modulate",modulate);
|
||||
Ref<Texture> port =get_icon("port");
|
||||
Ref<Texture> close =get_icon("close");
|
||||
int close_offset = get_constant("close_offset");
|
||||
@ -198,6 +200,9 @@ void GraphNode::_notification(int p_what) {
|
||||
Point2i icofs = -port->get_size()*0.5;
|
||||
int edgeofs=get_constant("port_offset");
|
||||
icofs.y+=sb->get_margin(MARGIN_TOP);
|
||||
|
||||
|
||||
|
||||
draw_style_box(sb,Rect2(Point2(),get_size()));
|
||||
|
||||
int w = get_size().width-sb->get_minimum_size().x;
|
||||
@ -590,6 +595,16 @@ void GraphNode::_input_event(const InputEvent& p_ev) {
|
||||
|
||||
}
|
||||
|
||||
void GraphNode::set_modulate(const Color &p_color) {
|
||||
|
||||
modulate=p_color;
|
||||
update();
|
||||
}
|
||||
|
||||
Color GraphNode::get_modulate() const{
|
||||
|
||||
return modulate;
|
||||
}
|
||||
|
||||
void GraphNode::_bind_methods() {
|
||||
|
||||
@ -620,6 +635,8 @@ void GraphNode::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
|
||||
ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate);
|
||||
ObjectTypeDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
|
||||
ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
|
||||
@ -637,4 +654,5 @@ GraphNode::GraphNode() {
|
||||
show_close=false;
|
||||
connpos_dirty=true;
|
||||
set_stop_mouse(false);
|
||||
modulate=Color(1,1,1,1);
|
||||
}
|
||||
|
@ -77,6 +77,8 @@ class GraphNode : public Container {
|
||||
|
||||
Vector2 drag_from;
|
||||
bool selected;
|
||||
|
||||
Color modulate;
|
||||
protected:
|
||||
|
||||
|
||||
@ -128,6 +130,9 @@ public:
|
||||
Color get_connection_output_color(int p_idx);
|
||||
|
||||
|
||||
void set_modulate(const Color& p_color);
|
||||
Color get_modulate() const;
|
||||
|
||||
virtual Size2 get_minimum_size() const;
|
||||
|
||||
GraphNode();
|
||||
|
@ -400,6 +400,7 @@ void TabContainer::_child_renamed_callback() {
|
||||
|
||||
void TabContainer::add_child_notify(Node *p_child) {
|
||||
|
||||
Control::add_child_notify(p_child);
|
||||
|
||||
Control *c = p_child->cast_to<Control>();
|
||||
if (!c)
|
||||
@ -532,6 +533,8 @@ Control* TabContainer::get_current_tab_control() const {
|
||||
|
||||
void TabContainer::remove_child_notify(Node *p_child) {
|
||||
|
||||
Control::remove_child_notify(p_child);
|
||||
|
||||
int tc = get_tab_count();
|
||||
if (current==tc-1) {
|
||||
current--;
|
||||
|
@ -141,7 +141,7 @@ void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const {
|
||||
r.pos.y-=expand_margin[MARGIN_TOP];
|
||||
r.size.x+=expand_margin[MARGIN_LEFT]+expand_margin[MARGIN_RIGHT];
|
||||
r.size.y+=expand_margin[MARGIN_TOP]+expand_margin[MARGIN_BOTTOM];
|
||||
VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center);
|
||||
VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
|
||||
}
|
||||
|
||||
void StyleBoxTexture::set_draw_center(bool p_draw) {
|
||||
@ -193,6 +193,19 @@ Rect2 StyleBoxTexture::get_region_rect() const {
|
||||
}
|
||||
|
||||
|
||||
void StyleBoxTexture::set_modulate(const Color& p_modulate) {
|
||||
if (modulate==p_modulate)
|
||||
return;
|
||||
modulate=p_modulate;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Color StyleBoxTexture::get_modulate() const {
|
||||
|
||||
return modulate;
|
||||
}
|
||||
|
||||
|
||||
void StyleBoxTexture::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
|
||||
@ -210,6 +223,10 @@ void StyleBoxTexture::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
|
||||
ObjectTypeDB::bind_method(_MD("get_draw_center"),&StyleBoxTexture::get_draw_center);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_modulate","color"),&StyleBoxTexture::set_modulate);
|
||||
ObjectTypeDB::bind_method(_MD("get_modulate"),&StyleBoxTexture::get_modulate);
|
||||
|
||||
|
||||
ADD_SIGNAL(MethodInfo("texture_changed"));
|
||||
|
||||
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_texture"),_SCS("get_texture") );
|
||||
@ -222,6 +239,7 @@ void StyleBoxTexture::_bind_methods() {
|
||||
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
|
||||
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
|
||||
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
|
||||
ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate/color" ), _SCS("set_modulate"),_SCS("get_modulate"));
|
||||
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_center" ) , _SCS("set_draw_center"),_SCS("get_draw_center"));
|
||||
|
||||
}
|
||||
@ -234,6 +252,7 @@ StyleBoxTexture::StyleBoxTexture() {
|
||||
expand_margin[i]=0;
|
||||
}
|
||||
draw_center=true;
|
||||
modulate=Color(1,1,1,1);
|
||||
|
||||
}
|
||||
StyleBoxTexture::~StyleBoxTexture() {
|
||||
|
@ -84,6 +84,7 @@ class StyleBoxTexture : public StyleBox {
|
||||
Rect2 region_rect;
|
||||
Ref<Texture> texture;
|
||||
bool draw_center;
|
||||
Color modulate;
|
||||
|
||||
|
||||
protected:
|
||||
@ -109,6 +110,9 @@ public:
|
||||
bool get_draw_center() const;
|
||||
virtual Size2 get_center_size() const;
|
||||
|
||||
void set_modulate(const Color& p_modulate);
|
||||
Color get_modulate() const;
|
||||
|
||||
|
||||
virtual void draw(RID p_canvas_item,const Rect2& p_rect) const;
|
||||
|
||||
|
@ -647,6 +647,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||
|
||||
set("import/automatic_reimport_on_sources_changed",true);
|
||||
|
||||
set("visual_script/color_functions",Color(1,0.9,0.9));
|
||||
set("visual_script/color_data",Color(0.9,1.0,0.9));
|
||||
set("visual_script/color_operators",Color(0.9,0.9,1.0));
|
||||
set("visual_script/color_flow_control",Color(1.0,1.0,0.8));
|
||||
|
||||
if (p_extra_config.is_valid()) {
|
||||
|
||||
if (p_extra_config->has_section("init_projects") && p_extra_config->has_section_key("init_projects", "list")) {
|
||||
@ -945,6 +950,8 @@ bool EditorSettings::_save_text_editor_theme(String p_file) {
|
||||
cf->set_value(theme_section, "word_highlighted_color", ((Color)get("text_editor/word_highlighted_color")).to_html());
|
||||
cf->set_value(theme_section, "search_result_color", ((Color)get("text_editor/search_result_color")).to_html());
|
||||
cf->set_value(theme_section, "search_result_border_color", ((Color)get("text_editor/search_result_border_color")).to_html());
|
||||
|
||||
|
||||
Error err = cf->save(p_file);
|
||||
|
||||
if (err == OK) {
|
||||
|
@ -117,20 +117,20 @@ void ScriptCreateDialog::ok_pressed() {
|
||||
|
||||
|
||||
|
||||
String text = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
|
||||
Script *script = ScriptServer::get_language( language_menu->get_selected() )->create_script();
|
||||
script->set_source_code(text);
|
||||
|
||||
Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
|
||||
//scr->set_source_code(text);
|
||||
|
||||
|
||||
if (cname!="")
|
||||
script->set_name(cname);
|
||||
scr->set_name(cname);
|
||||
|
||||
|
||||
Ref<Script> scr(script);
|
||||
|
||||
if (!internal->is_pressed()) {
|
||||
|
||||
|
||||
String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
|
||||
script->set_path(lpath);
|
||||
scr->set_path(lpath);
|
||||
if (!path_valid) {
|
||||
|
||||
alert->set_text(TTR("Invalid path!"));
|
||||
@ -145,7 +145,7 @@ void ScriptCreateDialog::ok_pressed() {
|
||||
alert->popup_centered_minsize();
|
||||
return;
|
||||
}
|
||||
scr->set_path(lpath);
|
||||
//scr->set_path(lpath);
|
||||
//EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user