diff options
Diffstat (limited to 'core/object.h')
-rw-r--r-- | core/object.h | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/core/object.h b/core/object.h index eb885f5d20..eb0e78a8c3 100644 --- a/core/object.h +++ b/core/object.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -54,6 +54,7 @@ enum PropertyHint { PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc" PROPERTY_HINT_EXP_EASING, /// exponential easing funciton (Math::ease) PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer) + PROPERTY_HINT_SPRITE_FRAME, PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer) PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags) PROPERTY_HINT_ALL_FLAGS, @@ -81,7 +82,8 @@ enum PropertyUsageFlags { PROPERTY_USAGE_BUNDLE=128, //used for optimized bundles PROPERTY_USAGE_CATEGORY=256, PROPERTY_USAGE_STORE_IF_NONZERO=512, //only store if nonzero - PROPERTY_USAGE_NO_INSTANCE_STATE=1024, + PROPERTY_USAGE_STORE_IF_NONONE=1024, //only store if false + PROPERTY_USAGE_NO_INSTANCE_STATE=2048, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, @@ -96,6 +98,8 @@ enum PropertyUsageFlags { #define ADD_PROPERTYI( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), m_property, m_setter, m_getter, m_index ) #define ADD_PROPERTYNZ( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter ) #define ADD_PROPERTYINZ( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONZERO), m_setter, m_getter, m_index ) +#define ADD_PROPERTYNO( m_property, m_setter, m_getter ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter ) +#define ADD_PROPERTYINO( m_property, m_setter, m_getter, m_index ) ObjectTypeDB::add_property( get_type_static(), (m_property).added_usage(PROPERTY_USAGE_STORE_IF_NONONE), m_setter, m_getter, m_index ) struct PropertyInfo { @@ -111,6 +115,9 @@ struct PropertyInfo { PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) { type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage; } + bool operator<(const PropertyInfo& p_info) const { + return name<p_info.name; + } }; @@ -175,10 +182,10 @@ public:\ virtual String get_type() const { \ return String(#m_type);\ }\ -virtual StringName get_type_name() const { \ +virtual const StringName* _get_type_namev() const { \ if (!_type_name)\ _type_name=get_type_static();\ - return _type_name;\ + return &_type_name;\ }\ static _FORCE_INLINE_ void* get_type_ptr_static() { \ static int ptr;\ @@ -384,6 +391,8 @@ friend void postinitialize_handler(Object*); ScriptInstance *script_instance; RefPtr script; Dictionary metadata; + mutable StringName _type_name; + mutable const StringName* _type_ptr; void _add_user_signal(const String& p_name, const Array& p_pargs=Array()); bool _has_user_signal(const StringName& p_name) const; @@ -397,7 +406,6 @@ friend void postinitialize_handler(Object*); protected: - virtual bool _use_builtin_script() const { return false; } virtual void _initialize_typev() { initialize_type(); } virtual bool _setv(const StringName& p_name,const Variant &p_property) { return false; }; @@ -442,10 +450,17 @@ protected: Variant _call_deferred_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error); - + virtual const StringName* _get_type_namev() const { + if (!_type_name) + _type_name=get_type_static(); + return &_type_name; + } DVector<String> _get_meta_list_bind() const; Array _get_property_list_bind() const; + Array _get_method_list_bind() const; + + void _clear_internal_resource_paths(const Variant &p_var); public: //should be protected, but bug in clang++ static void initialize_type(); @@ -517,11 +532,19 @@ public: virtual String get_type() const { return "Object"; } virtual String get_save_type() const { return get_type(); } //type stored when saving - virtual StringName get_type_name() const { return StringName("Object"); } + + + virtual bool is_type(const String& p_type) const { return (p_type=="Object"); } virtual bool is_type_ptr(void *p_ptr) const { return get_type_ptr_static()==p_ptr; } - + _FORCE_INLINE_ const StringName& get_type_name() const { + if (!_type_ptr) { + return *_get_type_namev(); + } else { + return *_type_ptr; + } + } /* IAPI */ // void set(const String& p_name, const Variant& p_value); @@ -572,6 +595,7 @@ public: void emit_signal(const StringName& p_name,VARIANT_ARG_LIST); void get_signal_list(List<MethodInfo> *p_signals ) const; void get_signal_connection_list(const StringName& p_signal,List<Connection> *p_connections) const; + void get_all_signal_connections(List<Connection> *p_connections) const; Error connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds=Vector<Variant>(),uint32_t p_flags=0); void disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method); @@ -589,8 +613,14 @@ public: StringName XL_MESSAGE(const StringName& p_message) const; //translate message (internationalization) StringName tr(const StringName& p_message) const; //translate message (alternative) + bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete() + bool is_queued_for_deletion() const; + _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate=p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } + + void clear_internal_resource_paths(); + Object(); virtual ~Object(); @@ -643,6 +673,8 @@ public: #endif + + }; //needed by macros |