-Display on animation editor which keys are invalid and which tracks are unresolved
-Added a tool to clean up unresolved tracks and unused keys
This commit is contained in:
parent
35fa048af5
commit
200b7bb87c
19 changed files with 381 additions and 20 deletions
|
|
@ -207,6 +207,11 @@ extern bool _err_error_exists;
|
|||
_err_error_exists=false;\
|
||||
} \
|
||||
|
||||
#define ERR_PRINTS(m_string) \
|
||||
{ \
|
||||
_err_print_error(FUNCTION_STR,__FILE__,__LINE__,String(m_string).utf8().get_data()); \
|
||||
_err_error_exists=false;\
|
||||
} \
|
||||
|
||||
/** Print a warning string.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -314,6 +314,7 @@ void Object::set(const StringName& p_name, const Variant& p_value, bool *r_valid
|
|||
|
||||
_edited=true;
|
||||
#endif
|
||||
|
||||
if (script_instance) {
|
||||
|
||||
if (script_instance->set(p_name,p_value)) {
|
||||
|
|
@ -326,9 +327,9 @@ void Object::set(const StringName& p_name, const Variant& p_value, bool *r_valid
|
|||
|
||||
//try built-in setgetter
|
||||
{
|
||||
if (ObjectTypeDB::set_property(this,p_name,p_value)) {
|
||||
if (r_valid)
|
||||
*r_valid=true;
|
||||
if (ObjectTypeDB::set_property(this,p_name,p_value,r_valid)) {
|
||||
//if (r_valid)
|
||||
// *r_valid=true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1694,6 +1695,26 @@ void Object::get_translatable_strings(List<String> *p_strings) const {
|
|||
|
||||
}
|
||||
|
||||
Variant::Type Object::get_static_property_type(const StringName& p_property, bool *r_valid) const {
|
||||
|
||||
bool valid;
|
||||
Variant::Type t = ObjectTypeDB::get_property_type(get_type_name(),p_property,&valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
*r_valid=true;
|
||||
return t;
|
||||
}
|
||||
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->get_property_type(p_property,r_valid);
|
||||
}
|
||||
if (r_valid)
|
||||
*r_valid=false;
|
||||
|
||||
return Variant::NIL;
|
||||
|
||||
}
|
||||
|
||||
bool Object::is_queued_for_deletion() const {
|
||||
return _is_queued_for_deletion;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -606,6 +606,8 @@ public:
|
|||
void set_block_signals(bool p_block);
|
||||
bool is_blocking_signals() const;
|
||||
|
||||
Variant::Type get_static_property_type(const StringName& p_property,bool *r_valid=NULL) const;
|
||||
|
||||
virtual void get_translatable_strings(List<String> *p_strings) const;
|
||||
|
||||
virtual void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
|
||||
|
|
|
|||
|
|
@ -612,6 +612,7 @@ void ObjectTypeDB::add_property(StringName p_type,const PropertyInfo& p_pinfo, c
|
|||
psg._setptr=mb_set;
|
||||
psg._getptr=mb_get;
|
||||
psg.index=p_index;
|
||||
psg.type=p_pinfo.type;
|
||||
|
||||
type->property_setget[p_pinfo.name]=psg;
|
||||
|
||||
|
|
@ -634,7 +635,7 @@ void ObjectTypeDB::get_property_list(StringName p_type,List<PropertyInfo> *p_lis
|
|||
}
|
||||
|
||||
}
|
||||
bool ObjectTypeDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value) {
|
||||
bool ObjectTypeDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value,bool *r_valid) {
|
||||
|
||||
|
||||
TypeInfo *type=types.getptr(p_object->get_type_name());
|
||||
|
|
@ -643,13 +644,17 @@ bool ObjectTypeDB::set_property(Object* p_object,const StringName& p_property, c
|
|||
const PropertySetGet *psg = check->property_setget.getptr(p_property);
|
||||
if (psg) {
|
||||
|
||||
if (!psg->setter)
|
||||
if (!psg->setter) {
|
||||
if (r_valid)
|
||||
*r_valid=false;
|
||||
return true; //return true but do nothing
|
||||
}
|
||||
|
||||
Variant::CallError ce;
|
||||
|
||||
if (psg->index>=0) {
|
||||
Variant index=psg->index;
|
||||
const Variant* arg[2]={&index,&p_value};
|
||||
Variant::CallError ce;
|
||||
// p_object->call(psg->setter,arg,2,ce);
|
||||
if (psg->_setptr) {
|
||||
psg->_setptr->call(p_object,arg,2,ce);
|
||||
|
|
@ -660,13 +665,16 @@ bool ObjectTypeDB::set_property(Object* p_object,const StringName& p_property, c
|
|||
|
||||
} else {
|
||||
const Variant* arg[1]={&p_value};
|
||||
Variant::CallError ce;
|
||||
if (psg->_setptr) {
|
||||
psg->_setptr->call(p_object,arg,1,ce);
|
||||
} else {
|
||||
p_object->call(psg->setter,arg,1,ce);
|
||||
}
|
||||
}
|
||||
|
||||
if (r_valid)
|
||||
*r_valid=ce.error==Variant::CallError::CALL_OK;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -718,6 +726,29 @@ bool ObjectTypeDB::get_property(Object* p_object,const StringName& p_property, V
|
|||
return false;
|
||||
}
|
||||
|
||||
Variant::Type ObjectTypeDB::get_property_type(const StringName& p_type, const StringName& p_property,bool *r_is_valid) {
|
||||
|
||||
TypeInfo *type=types.getptr(p_type);
|
||||
TypeInfo *check=type;
|
||||
while(check) {
|
||||
const PropertySetGet *psg = check->property_setget.getptr(p_property);
|
||||
if (psg) {
|
||||
|
||||
if (r_is_valid)
|
||||
*r_is_valid=true;
|
||||
|
||||
return psg->type;
|
||||
}
|
||||
|
||||
check=check->inherits_ptr;
|
||||
}
|
||||
if (r_is_valid)
|
||||
*r_is_valid=false;
|
||||
|
||||
return Variant::NIL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ObjectTypeDB::set_method_flags(StringName p_type,StringName p_method,int p_flags) {
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ class ObjectTypeDB {
|
|||
StringName getter;
|
||||
MethodBind *_setptr;
|
||||
MethodBind *_getptr;
|
||||
Variant::Type type;
|
||||
};
|
||||
|
||||
struct TypeInfo {
|
||||
|
|
@ -456,8 +457,9 @@ public:
|
|||
|
||||
static void add_property(StringName p_type,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index=-1);
|
||||
static void get_property_list(StringName p_type,List<PropertyInfo> *p_list,bool p_no_inheritance=false);
|
||||
static bool set_property(Object* p_object,const StringName& p_property, const Variant& p_value);
|
||||
static bool set_property(Object* p_object, const StringName& p_property, const Variant& p_value, bool *r_valid=NULL);
|
||||
static bool get_property(Object* p_object,const StringName& p_property, Variant& r_value);
|
||||
static Variant::Type get_property_type(const StringName& p_type, const StringName& p_property,bool *r_is_valid=NULL);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -267,6 +267,20 @@ void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properti
|
|||
}
|
||||
}
|
||||
|
||||
Variant::Type PlaceHolderScriptInstance::get_property_type(const StringName& p_name,bool *r_is_valid) const {
|
||||
|
||||
if (values.has(p_name)) {
|
||||
if (r_is_valid)
|
||||
*r_is_valid=true;
|
||||
return values[p_name].get_type();
|
||||
}
|
||||
if (r_is_valid)
|
||||
*r_is_valid=false;
|
||||
|
||||
return Variant::NIL;
|
||||
}
|
||||
|
||||
|
||||
void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties,const Map<StringName,Variant>& p_values) {
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ public:
|
|||
virtual StringName get_instance_base_type() const=0; // this may not work in all scripts, will return empty if so
|
||||
virtual ScriptInstance* instance_create(Object *p_this)=0;
|
||||
virtual bool instance_has(const Object *p_this) const=0;
|
||||
|
||||
|
||||
virtual bool has_source_code() const=0;
|
||||
virtual String get_source_code() const=0;
|
||||
|
|
@ -109,6 +110,7 @@ public:
|
|||
virtual bool set(const StringName& p_name, const Variant& p_value)=0;
|
||||
virtual bool get(const StringName& p_name, Variant &r_ret) const=0;
|
||||
virtual void get_property_list(List<PropertyInfo> *p_properties) const=0;
|
||||
virtual Variant::Type get_property_type(const StringName& p_name,bool *r_is_valid=NULL) const=0;
|
||||
|
||||
virtual void get_method_list(List<MethodInfo> *p_list) const=0;
|
||||
virtual bool has_method(const StringName& p_method) const=0;
|
||||
|
|
@ -208,6 +210,7 @@ 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 { return false; }
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ public:
|
|||
|
||||
Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error);
|
||||
Variant call(const StringName& p_method,const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant());
|
||||
static Variant construct(const Variant::Type,const Variant** p_args,int p_argcount,CallError &r_error);
|
||||
static Variant construct(const Variant::Type,const Variant** p_args,int p_argcount,CallError &r_error,bool p_strict=true);
|
||||
|
||||
void get_method_list(List<MethodInfo> *p_list) const;
|
||||
bool has_method(const StringName& p_method) const;
|
||||
|
|
|
|||
|
|
@ -959,7 +959,7 @@ Variant Variant::call(const StringName& p_method,const Variant** p_args,int p_ar
|
|||
#define VCALL(m_type,m_method) _VariantCall::_call_##m_type##_##m_method
|
||||
|
||||
|
||||
Variant Variant::construct(const Variant::Type p_type,const Variant** p_args,int p_argcount,CallError &r_error) {
|
||||
Variant Variant::construct(const Variant::Type p_type, const Variant** p_args, int p_argcount, CallError &r_error, bool p_strict) {
|
||||
|
||||
r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
ERR_FAIL_INDEX_V(p_type,VARIANT_MAX,Variant());
|
||||
|
|
@ -1035,7 +1035,7 @@ Variant Variant::construct(const Variant::Type p_type,const Variant** p_args,int
|
|||
|
||||
} else if (p_argcount==1 && p_args[0]->type==p_type) {
|
||||
return *p_args[0]; //copy construct
|
||||
} else if (p_argcount==1 && Variant::can_convert(p_args[0]->type,p_type)) {
|
||||
} else if (p_argcount==1 && (!p_strict || Variant::can_convert(p_args[0]->type,p_type))) {
|
||||
//near match construct
|
||||
|
||||
switch(p_type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue