diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/dictionary.cpp | 14 | ||||
-rw-r--r-- | core/dictionary.h | 2 | ||||
-rw-r--r-- | core/io/networked_multiplayer_peer.cpp | 29 | ||||
-rw-r--r-- | core/io/networked_multiplayer_peer.h | 40 | ||||
-rw-r--r-- | core/make_binders.py | 5 | ||||
-rw-r--r-- | core/method_bind.cpp | 7 | ||||
-rw-r--r-- | core/method_bind.h | 7 | ||||
-rw-r--r-- | core/object.h | 2 | ||||
-rw-r--r-- | core/script_language.h | 1 |
9 files changed, 106 insertions, 1 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 6204a87054..6770b798f1 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -232,6 +232,20 @@ Error Dictionary::parse_json(const String& p_json) { return OK; } +Dictionary Dictionary::copy() const { + + Dictionary n(is_shared()); + + List<Variant> keys; + get_key_list(&keys); + + for(List<Variant>::Element *E=keys.front();E;E=E->next()) { + n[E->get()]=operator[](E->get()); + } + + return n; +} + String Dictionary::to_json() const { return JSON::print(*this); diff --git a/core/dictionary.h b/core/dictionary.h index ae79fab9c3..6a5f4e20e6 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -83,6 +83,8 @@ public: Array keys() const; Array values() const; + Dictionary copy() const; + Dictionary(const Dictionary& p_from); Dictionary(bool p_shared=false); ~Dictionary(); diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp new file mode 100644 index 0000000000..79f3e129e1 --- /dev/null +++ b/core/io/networked_multiplayer_peer.cpp @@ -0,0 +1,29 @@ +#include "networked_multiplayer_peer.h" + + +void NetworkedMultiplayerPeer::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode ); + ObjectTypeDB::bind_method(_MD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer ); + ObjectTypeDB::bind_method(_MD("set_channel","id"), &NetworkedMultiplayerPeer::set_channel ); + + ObjectTypeDB::bind_method(_MD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer ); + ObjectTypeDB::bind_method(_MD("get_packet_channel"), &NetworkedMultiplayerPeer::get_packet_channel ); + + ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll ); + + + BIND_CONSTANT( TARGET_ALL_PEERS ); + + BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE ); + BIND_CONSTANT( TRANSFER_MODE_RELIABLE ); + BIND_CONSTANT( TRANSFER_MODE_ORDERED ); + + ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::INT,"id"))); + ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::INT,"id"))); +} + +NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() { + + +} diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h new file mode 100644 index 0000000000..f140b57b8b --- /dev/null +++ b/core/io/networked_multiplayer_peer.h @@ -0,0 +1,40 @@ +#ifndef NETWORKED_MULTIPLAYER_PEER_H +#define NETWORKED_MULTIPLAYER_PEER_H + +#include "io/packet_peer.h" + +class NetworkedMultiplayerPeer : public PacketPeer { + + OBJ_TYPE(NetworkedMultiplayerPeer,PacketPeer); + +protected: + static void _bind_methods(); +public: + + enum { + TARGET_ALL_PEERS=0xFFFFFF // send to this for all peers + }; + + enum TransferMode { + TRANSFER_MODE_UNRELIABLE, + TRANSFER_MODE_RELIABLE, + TRANSFER_MODE_ORDERED + }; + + virtual void set_transfer_mode(TransferMode p_mode)=0; + virtual void set_target_peer(int p_peer)=0; + virtual void set_channel(int p_channel)=0; + + + virtual int get_packet_peer() const=0; + virtual int get_packet_channel() const=0; + + + virtual void poll()=0; + + NetworkedMultiplayerPeer(); +}; + +VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::TransferMode ) + +#endif // NetworkedMultiplayerPeer_H diff --git a/core/make_binders.py b/core/make_binders.py index c14f07ac83..7584722965 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -62,6 +62,8 @@ public: #else set_argument_count($argc$); #endif + + $ifret _set_returns(true); $ }; }; @@ -140,6 +142,9 @@ public: #else set_argument_count($argc$); #endif + $ifret _set_returns(true); $ + + }; }; diff --git a/core/method_bind.cpp b/core/method_bind.cpp index b41fa33887..a99d0af636 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -64,6 +64,12 @@ void MethodBind::_set_const(bool p_const) { _const=p_const; } +void MethodBind::_set_returns(bool p_returns) { + + _returns=p_returns; +} + + StringName MethodBind::get_name() const { return name; } @@ -118,6 +124,7 @@ MethodBind::MethodBind() { argument_types=NULL; #endif _const=false; + _returns=false; } MethodBind::~MethodBind() { diff --git a/core/method_bind.h b/core/method_bind.h index 30a848270d..3d62e38daa 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -154,6 +154,8 @@ VARIANT_ENUM_CAST( wchar_t ); VARIANT_ENUM_CAST( Margin ); VARIANT_ENUM_CAST( Orientation ); VARIANT_ENUM_CAST( HAlign ); +VARIANT_ENUM_CAST( Variant::Type ); +VARIANT_ENUM_CAST( Variant::Operator ); class MethodBind { @@ -170,11 +172,13 @@ class MethodBind { StringName ret_type; #endif bool _const; + bool _returns; protected: void _set_const(bool p_const); + void _set_returns(bool p_returns); #ifdef DEBUG_METHODS_ENABLED virtual Variant::Type _gen_argument_type(int p_arg) const=0; void _generate_argument_types(int p_count); @@ -261,6 +265,7 @@ public: void set_name(const StringName& p_name); _FORCE_INLINE_ int get_method_id() const { return method_id; } _FORCE_INLINE_ bool is_const() const { return _const; } + _FORCE_INLINE_ bool has_return() const { return _returns; } void set_default_arguments(const Vector<Variant>& p_defargs); @@ -321,7 +326,7 @@ public: virtual bool is_const() const { return false; } virtual String get_instance_type() const { return T::get_type_static(); } - MethodBindNative() { call_method=NULL; } + MethodBindNative() { call_method=NULL; _set_returns(true);} }; diff --git a/core/object.h b/core/object.h index d7b0f09df9..400ab3070e 100644 --- a/core/object.h +++ b/core/object.h @@ -68,6 +68,8 @@ enum PropertyHint { PROPERTY_HINT_IMAGE_COMPRESS_LOSSY, PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS, PROPERTY_HINT_OBJECT_ID, + PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose + PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts) PROPERTY_HINT_MAX, }; diff --git a/core/script_language.h b/core/script_language.h index 6d75b83aaf..499dbe14a7 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -110,6 +110,7 @@ public: virtual bool get_property_default_value(const StringName& p_property,Variant& r_value) const=0; virtual void update_exports() {} //editor tool + virtual void get_method_list(List<MethodInfo> *p_list) const=0; Script() {} |