diff options
31 files changed, 830 insertions, 71 deletions
diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp index 22d14ada34..9110f72620 100644 --- a/bin/tests/test_math.cpp +++ b/bin/tests/test_math.cpp @@ -40,6 +40,9 @@ #include "scene/resources/texture.h" #include "vmap.h" #include "os/os.h" + +#include "method_ptrcall.h" + namespace TestMath { @@ -105,8 +108,12 @@ uint32_t ihash3( uint32_t a) return a; } + + + MainLoop* test() { + return NULL; { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 0dfae6584b..2a831dd992 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -29,8 +29,6 @@ #include "http_client.h" #include "io/stream_peer_ssl.h" -VARIANT_ENUM_CAST(HTTPClient::Status); - Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){ diff --git a/core/io/http_client.h b/core/io/http_client.h index ceb0273a7d..32d2e72101 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -201,5 +201,6 @@ public: }; VARIANT_ENUM_CAST(HTTPClient::Method); +VARIANT_ENUM_CAST(HTTPClient::Status); #endif // HTTP_CLIENT_H diff --git a/core/make_binders.py b/core/make_binders.py index 93371dc0a3..1d55c92b89 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -48,7 +48,13 @@ public: $ifnoret return Variant();$ } - +#ifdef PTRCAL_ENABLED + virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) { + + T *instance=p_object->cast_to<T>(); + $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ; + } +#endif MethodBind$argc$$ifret R$$ifconst C$ () { #ifdef DEBUG_METHODS_ENABLED _set_const($ifconst true$$ifnoconst false$); @@ -121,7 +127,12 @@ public: $ifret return Variant(ret);$ $ifnoret return Variant();$ } - +#ifdef PTRCALL_ENABLED + virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) { + __UnexistingClass *instance = (__UnexistingClass*)p_object; + $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret) $ ; + } +#endif MethodBind$argc$$ifret R$$ifconst C$ () { #ifdef DEBUG_METHODS_ENABLED _set_const($ifconst true$$ifnoconst false$); diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index 2bfc26b51e..6c36d80e3e 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -34,8 +34,8 @@ #include "face3.h" #include "vector.h" #include "dvector.h" - #include "variant.h" +#include "method_ptrcall.h" /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -138,4 +138,29 @@ bool BSP_Tree::convex_is_inside(const T& p_convex) const { } +#ifdef PTRCALL_ENABLED + + +template<> +struct PtrToArg<BSP_Tree> { + _FORCE_INLINE_ static BSP_Tree convert(const void* p_ptr) { + BSP_Tree s( Variant( *reinterpret_cast<const Dictionary*>(p_ptr) ) ); + return s; + } + _FORCE_INLINE_ static void encode(BSP_Tree p_val,void* p_ptr) { + Dictionary *d = reinterpret_cast<Dictionary*>(p_ptr); + *d=Variant(p_val); + } +}; + +template<> +struct PtrToArg<const BSP_Tree&> { + _FORCE_INLINE_ static BSP_Tree convert(const void* p_ptr) { + BSP_Tree s( Variant( *reinterpret_cast<const Dictionary*>(p_ptr) ) ); + return s; + } +}; + +#endif + #endif diff --git a/core/math/face3.h b/core/math/face3.h index bc34be9935..3a81da74db 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -264,4 +264,6 @@ bool Face3::intersects_aabb2(const AABB& p_aabb) const { } +//this sucks... + #endif // FACE3_H diff --git a/core/method_bind.h b/core/method_bind.h index 48848c5848..30a848270d 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -33,6 +33,7 @@ #include "variant.h" #include "object.h" #include <stdio.h> +#include "method_ptrcall.h" /** @author Juan Linietsky <reduzio@gmail.com> @@ -85,6 +86,32 @@ struct VariantCaster<const T&> { (VariantCaster<P##m_idx>::cast( (m_idx-1)>=p_arg_count?get_default_argument(m_idx-1):*p_args[m_idx-1] )) //SIMPLE_NUMERIC_TYPE is used to avoid a warning on Variant::get_type_for + +#ifdef PTRCALL_ENABLED + + +#define VARIANT_ENUM_CAST( m_enum ) \ +SIMPLE_NUMERIC_TYPE( m_enum );\ +template<> \ +struct VariantCaster<m_enum> {\ +\ + static _FORCE_INLINE_ m_enum cast(const Variant& p_variant) {\ + return (m_enum)p_variant.operator int();\ + }\ +};\ +template<>\ +struct PtrToArg< m_enum > {\ + _FORCE_INLINE_ static m_enum convert(const void* p_ptr) {\ + return m_enum(*reinterpret_cast<const int*>(p_ptr));\ + }\ + _FORCE_INLINE_ static void encode(m_enum p_val,const void* p_ptr) {\ + *(int*)p_ptr=p_val;\ + }\ +}; + +#else + + #define VARIANT_ENUM_CAST( m_enum ) \ SIMPLE_NUMERIC_TYPE( m_enum );\ template<> \ @@ -96,6 +123,9 @@ struct VariantCaster<m_enum> {\ }; +#endif + + #define CHECK_ARG(m_arg)\ if ((m_arg-1)<p_arg_count) {\ Variant::Type argtype=get_argument_type(m_arg-1);\ @@ -222,6 +252,11 @@ public: } #endif virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error)=0; + +#ifdef PTRCALL_ENABLED + virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret)=0; +#endif + StringName get_name() const; void set_name(const StringName& p_name); _FORCE_INLINE_ int get_method_id() const { return method_id; } @@ -277,6 +312,11 @@ public: #endif } +#ifdef PTRCALL_ENABLED + virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret) {} //todo +#endif + + void set_method(NativeCall p_method) { call_method=p_method; } virtual bool is_const() const { return false; } virtual String get_instance_type() const { return T::get_type_static(); } diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h new file mode 100644 index 0000000000..e38d59fd8f --- /dev/null +++ b/core/method_ptrcall.h @@ -0,0 +1,354 @@ +#ifndef METHOD_PTRCALL_H +#define METHOD_PTRCALL_H + +#include "typedefs.h" +#include "math_2d.h" +#include "variant.h" + +#ifdef PTRCALL_ENABLED + +template<class T> +struct PtrToArg { + +}; + +#define MAKE_PTRARG(m_type) \ +template<>\ +struct PtrToArg<m_type> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + return *reinterpret_cast<const m_type*>(p_ptr);\ + }\ + _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\ + *((m_type*)p_ptr)=p_val;\ + }\ +};\ +template<>\ +struct PtrToArg<const m_type&> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + return *reinterpret_cast<const m_type*>(p_ptr);\ + }\ + _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\ + *((m_type*)p_ptr)=p_val;\ + }\ +} + + +#define MAKE_PTRARGR(m_type,m_ret) \ +template<>\ +struct PtrToArg<m_type> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + return *reinterpret_cast<const m_type*>(p_ptr);\ + }\ + _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\ + *((m_ret*)p_ptr)=p_val;\ + }\ +};\ +template<>\ +struct PtrToArg<const m_type&> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + return *reinterpret_cast<const m_type*>(p_ptr);\ + }\ + _FORCE_INLINE_ static void encode(m_type p_val, void* p_ptr) {\ + *((m_ret*)p_ptr)=p_val;\ + }\ +} + + + +MAKE_PTRARG(bool); +MAKE_PTRARGR(uint8_t,int); +MAKE_PTRARGR(int8_t,int); +MAKE_PTRARGR(uint16_t,int); +MAKE_PTRARGR(int16_t,int); +MAKE_PTRARGR(uint32_t,int); +MAKE_PTRARGR(int32_t,int); +MAKE_PTRARGR(int64_t,int); +MAKE_PTRARGR(uint64_t,int); +MAKE_PTRARG(float); +MAKE_PTRARGR(double,float); + +MAKE_PTRARG(String); +MAKE_PTRARG(Vector2); +MAKE_PTRARG(Rect2); +MAKE_PTRARG(Vector3); +MAKE_PTRARG(Matrix32); +MAKE_PTRARG(Plane); +MAKE_PTRARG(Quat); +MAKE_PTRARG(AABB); +MAKE_PTRARG(Matrix3); +MAKE_PTRARG(Transform); +MAKE_PTRARG(Color); +MAKE_PTRARG(Image); +MAKE_PTRARG(NodePath); +MAKE_PTRARG(RID); +MAKE_PTRARG(InputEvent); +MAKE_PTRARG(Dictionary); +MAKE_PTRARG(Array); +MAKE_PTRARG(ByteArray); +MAKE_PTRARG(IntArray); +MAKE_PTRARG(RealArray); +MAKE_PTRARG(StringArray); +MAKE_PTRARG(Vector2Array); +MAKE_PTRARG(Vector3Array); +MAKE_PTRARG(ColorArray); +MAKE_PTRARG(Variant); + + +//this is for Object + +template<class T> +struct PtrToArg< T* > { + + _FORCE_INLINE_ static T* convert(const void* p_ptr) { + + return const_cast<T*>(reinterpret_cast<const T*>(p_ptr)); + } + + _FORCE_INLINE_ static void encode(T* p_var, void* p_ptr) { + + *((T**)p_ptr)=p_var; + } + +}; + +template<class T> +struct PtrToArg< const T* > { + + _FORCE_INLINE_ static const T* convert(const void* p_ptr) { + + return reinterpret_cast<const T*>(p_ptr); + } + + _FORCE_INLINE_ static void encode(T* p_var, void* p_ptr) { + + *((T**)p_ptr)=p_var; + } + +}; + + +//this is for the special cases used by Variant + +#define MAKE_VECARG(m_type) \ +template<>\ +struct PtrToArg<Vector<m_type> > {\ + _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\ + const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\ + Vector<m_type> ret;\ + int len = dvs->size();\ + ret.resize(len);\ + {\ + DVector<m_type>::Read r=dvs->read();\ + for(int i=0;i<len;i++) {\ + ret[i]=r[i];\ + }\ + } \ + return ret;\ + }\ + _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\ + DVector<m_type> *dv = reinterpret_cast<DVector<m_type> *>(p_ptr);\ + int len=p_vec.size();\ + dv->resize(len);\ + {\ + DVector<m_type>::Write w=dv->write();\ + for(int i=0;i<len;i++) {\ + w[i]=p_vec[i];\ + }\ + } \ + }\ +};\ +template<>\ +struct PtrToArg<const Vector<m_type>& > {\ + _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\ + const DVector<m_type> *dvs = reinterpret_cast<const DVector<m_type> *>(p_ptr);\ + Vector<m_type> ret;\ + int len = dvs->size();\ + ret.resize(len);\ + {\ + DVector<m_type>::Read r=dvs->read();\ + for(int i=0;i<len;i++) {\ + ret[i]=r[i];\ + }\ + } \ + return ret;\ + }\ +} + +MAKE_VECARG(String); +MAKE_VECARG(uint8_t); +MAKE_VECARG(int); +MAKE_VECARG(float); +MAKE_VECARG(Vector2); +MAKE_VECARG(Vector3); +MAKE_VECARG(Color); + +//for stuff that gets converted to Array vectors +#define MAKE_VECARR(m_type) \ +template<>\ +struct PtrToArg<Vector<m_type> > {\ + _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\ + const Array *arr = reinterpret_cast<const Array *>(p_ptr);\ + Vector<m_type> ret;\ + int len = arr->size();\ + ret.resize(len);\ + for(int i=0;i<len;i++) {\ + ret[i]=(*arr)[i];\ + }\ + return ret;\ + }\ + _FORCE_INLINE_ static void encode(Vector<m_type> p_vec, void* p_ptr) {\ + Array *arr = reinterpret_cast<Array *>(p_ptr);\ + int len = p_vec.size();\ + arr->resize(len);\ + for(int i=0;i<len;i++) {\ + (*arr)[i]=p_vec[i];\ + }\ + } \ +};\ +template<>\ +struct PtrToArg<const Vector<m_type>& > {\ + _FORCE_INLINE_ static Vector<m_type> convert(const void* p_ptr) {\ + const Array *arr = reinterpret_cast<const Array *>(p_ptr);\ + Vector<m_type> ret;\ + int len = arr->size();\ + ret.resize(len);\ + for(int i=0;i<len;i++) {\ + ret[i]=(*arr)[i];\ + }\ + return ret;\ + }\ +} + + +MAKE_VECARR(Variant); +MAKE_VECARR(RID); +MAKE_VECARR(Plane); + +#define MAKE_DVECARR(m_type) \ +template<>\ +struct PtrToArg<DVector<m_type> > {\ + _FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\ + const Array *arr = reinterpret_cast<const Array *>(p_ptr);\ + DVector<m_type> ret;\ + int len = arr->size();\ + ret.resize(len);\ + {\ + DVector<m_type>::Write w=ret.write();\ + for(int i=0;i<len;i++) {\ + w[i]=(*arr)[i];\ + }\ + }\ + return ret;\ + }\ + _FORCE_INLINE_ static void encode(DVector<m_type> p_vec, void* p_ptr) {\ + Array *arr = reinterpret_cast<Array *>(p_ptr);\ + int len = p_vec.size();\ + arr->resize(len);\ + {\ + DVector<m_type>::Read r=p_vec.read();\ + for(int i=0;i<len;i++) {\ + (*arr)[i]=r[i];\ + }\ + }\ + } \ +};\ +template<>\ +struct PtrToArg<const DVector<m_type>& > {\ + _FORCE_INLINE_ static DVector<m_type> convert(const void* p_ptr) {\ + const Array *arr = reinterpret_cast<const Array *>(p_ptr);\ + DVector<m_type> ret;\ + int len = arr->size();\ + ret.resize(len);\ + {\ + DVector<m_type>::Write w=ret.write();\ + for(int i=0;i<len;i++) {\ + w[i]=(*arr)[i];\ + }\ + }\ + return ret;\ + }\ +} + +MAKE_DVECARR(Plane); +//for special case StringName + +#define MAKE_STRINGCONV(m_type) \ +template<>\ +struct PtrToArg<m_type> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + m_type s = *reinterpret_cast<const String*>(p_ptr);\ + return s;\ + }\ + _FORCE_INLINE_ static void encode(m_type p_vec, void* p_ptr) {\ + String *arr = reinterpret_cast<String *>(p_ptr);\ + *arr=p_vec;\ + }\ +};\ +\ +template<>\ +struct PtrToArg<const m_type&> {\ + _FORCE_INLINE_ static m_type convert(const void* p_ptr) {\ + m_type s = *reinterpret_cast<const String*>(p_ptr);\ + return s;\ + }\ +} + +MAKE_STRINGCONV(StringName); +MAKE_STRINGCONV(IP_Address); + +template<> +struct PtrToArg<DVector<Face3> > { + _FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) { + const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr); + DVector<Face3> ret; + int len = dvs->size()/3; + ret.resize(len); + { + DVector<Vector3>::Read r=dvs->read(); + DVector<Face3>::Write w=ret.write(); + for(int i=0;i<len;i++) { + w[i].vertex[0]=r[i*3+0]; + w[i].vertex[1]=r[i*3+1]; + w[i].vertex[2]=r[i*3+2]; + } + } + return ret; + } + _FORCE_INLINE_ static void encode(DVector<Face3> p_vec, void* p_ptr) {\ + DVector<Vector3> *arr = reinterpret_cast<DVector<Vector3> *>(p_ptr);\ + int len = p_vec.size();\ + arr->resize(len*3);\ + {\ + DVector<Face3>::Read r=p_vec.read();\ + DVector<Vector3>::Write w=arr->write();\ + for(int i=0;i<len;i++) {\ + w[i*3+0]=r[i].vertex[0];\ + w[i*3+1]=r[i].vertex[1];\ + w[i*3+2]=r[i].vertex[2];\ + }\ + }\ + } \ +}; +template<> +struct PtrToArg<const DVector<Face3>& > { + _FORCE_INLINE_ static DVector<Face3> convert(const void* p_ptr) { + const DVector<Vector3> *dvs = reinterpret_cast<const DVector<Vector3> *>(p_ptr); + DVector<Face3> ret; + int len = dvs->size()/3; + ret.resize(len); + { + DVector<Vector3>::Read r=dvs->read(); + DVector<Face3>::Write w=ret.write(); + for(int i=0;i<len;i++) { + w[i].vertex[0]=r[i*3+0]; + w[i].vertex[1]=r[i*3+1]; + w[i].vertex[2]=r[i*3+2]; + } + } + return ret; + } +}; + + +#endif // METHOD_PTRCALL_H +#endif diff --git a/core/reference.h b/core/reference.h index 8bfbf19ab6..60a256dc99 100644 --- a/core/reference.h +++ b/core/reference.h @@ -329,6 +329,62 @@ public: WeakRef(); }; +#ifdef PTRCALL_ENABLED + +template<class T> +struct PtrToArg< Ref<T> > { + + _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) { + + return Ref<T>(reinterpret_cast<const T*>(p_ptr)); + } + + _FORCE_INLINE_ static void encode(Ref<T> p_val,const void* p_ptr) { + + *((T**)p_ptr)=p_val.ptr(); + } + +}; + + +template<class T> +struct PtrToArg< const Ref<T>& > { + + _FORCE_INLINE_ static Ref<T> convert(const void* p_ptr) { + + return Ref<T>(reinterpret_cast<const T*>(p_ptr)); + } + +}; +//this is for RefPtr + +template<> +struct PtrToArg< RefPtr > { + + _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) { + + return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr(); + } + + _FORCE_INLINE_ static void encode(RefPtr p_val,const void* p_ptr) { + + Ref<Reference> r = p_val; + *((Reference**)p_ptr)=r.ptr(); + } + +}; + +template<> +struct PtrToArg< const RefPtr& > { + + _FORCE_INLINE_ static RefPtr convert(const void* p_ptr) { + + return Ref<Reference>(reinterpret_cast<const Reference*>(p_ptr)).get_ref_ptr(); + } + +}; + +#endif #endif // REFERENCE_H diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 84015d2b04..34e5164b24 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -511,6 +511,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(ByteArray,get); VCALL_LOCALMEM1(ByteArray,push_back); VCALL_LOCALMEM1(ByteArray,resize); + VCALL_LOCALMEM2R(ByteArray,insert); + VCALL_LOCALMEM1(ByteArray,remove); VCALL_LOCALMEM1(ByteArray,append); VCALL_LOCALMEM1(ByteArray,append_array); @@ -519,6 +521,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(IntArray,get); VCALL_LOCALMEM1(IntArray,push_back); VCALL_LOCALMEM1(IntArray,resize); + VCALL_LOCALMEM2R(IntArray,insert); + VCALL_LOCALMEM1(IntArray,remove); VCALL_LOCALMEM1(IntArray,append); VCALL_LOCALMEM1(IntArray,append_array); @@ -527,6 +531,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(RealArray,get); VCALL_LOCALMEM1(RealArray,push_back); VCALL_LOCALMEM1(RealArray,resize); + VCALL_LOCALMEM2R(RealArray,insert); + VCALL_LOCALMEM1(RealArray,remove); VCALL_LOCALMEM1(RealArray,append); VCALL_LOCALMEM1(RealArray,append_array); @@ -535,6 +541,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(StringArray,get); VCALL_LOCALMEM1(StringArray,push_back); VCALL_LOCALMEM1(StringArray,resize); + VCALL_LOCALMEM2R(StringArray,insert); + VCALL_LOCALMEM1(StringArray,remove); VCALL_LOCALMEM1(StringArray,append); VCALL_LOCALMEM1(StringArray,append_array); @@ -543,6 +551,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector2Array,get); VCALL_LOCALMEM1(Vector2Array,push_back); VCALL_LOCALMEM1(Vector2Array,resize); + VCALL_LOCALMEM2R(Vector2Array,insert); + VCALL_LOCALMEM1(Vector2Array,remove); VCALL_LOCALMEM1(Vector2Array,append); VCALL_LOCALMEM1(Vector2Array,append_array); @@ -551,6 +561,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector3Array,get); VCALL_LOCALMEM1(Vector3Array,push_back); VCALL_LOCALMEM1(Vector3Array,resize); + VCALL_LOCALMEM2R(Vector3Array,insert); + VCALL_LOCALMEM1(Vector3Array,remove); VCALL_LOCALMEM1(Vector3Array,append); VCALL_LOCALMEM1(Vector3Array,append_array); @@ -559,6 +571,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(ColorArray,get); VCALL_LOCALMEM1(ColorArray,push_back); VCALL_LOCALMEM1(ColorArray,resize); + VCALL_LOCALMEM2R(ColorArray,insert); + VCALL_LOCALMEM1(ColorArray,remove); VCALL_LOCALMEM1(ColorArray,append); VCALL_LOCALMEM1(ColorArray,append_array); @@ -1484,8 +1498,11 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(RAW_ARRAY,INT,ByteArray,size,varray()); ADDFUNC2(RAW_ARRAY,NIL,ByteArray,set,INT,"idx",INT,"byte",varray()); - //ADDFUNC1(RAW_ARRAY,INT,ByteArray,get,INT,"idx",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,push_back,INT,"byte",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append,INT,"byte",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,append_array,RAW_ARRAY,"array",varray()); + ADDFUNC1(RAW_ARRAY,NIL,ByteArray,remove,INT,"idx",varray()); + ADDFUNC2(RAW_ARRAY,INT,ByteArray,insert,INT,"idx",INT,"byte",varray()); ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray()); ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray()); @@ -1494,38 +1511,56 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INT_ARRAY,INT,IntArray,size,varray()); ADDFUNC2(INT_ARRAY,NIL,IntArray,set,INT,"idx",INT,"integer",varray()); - //ADDFUNC1(INT_ARRAY,INT,IntArray,get,INT,"idx",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,push_back,INT,"integer",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,append,INT,"integer",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,append_array,INT_ARRAY,"array",varray()); + ADDFUNC1(INT_ARRAY,NIL,IntArray,remove,INT,"idx",varray()); + ADDFUNC2(INT_ARRAY,INT,IntArray,insert,INT,"idx",INT,"integer",varray()); ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray()); ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray()); ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray()); - //ADDFUNC1(REAL_ARRAY,REAL,RealArray,get,INT,"idx",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,push_back,REAL,"value",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,append,REAL,"value",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,append_array,REAL_ARRAY,"array",varray()); + ADDFUNC1(REAL_ARRAY,NIL,RealArray,remove,INT,"idx",varray()); + ADDFUNC2(REAL_ARRAY,INT,RealArray,insert,INT,"idx",REAL,"value",varray()); ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray()); ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray()); ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray()); - //ADDFUNC1(STRING_ARRAY,STRING,StringArray,get,INT,"idx",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,push_back,STRING,"string",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,append,STRING,"string",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,append_array,STRING_ARRAY,"array",varray()); + ADDFUNC1(STRING_ARRAY,NIL,StringArray,remove,INT,"idx",varray()); + ADDFUNC2(STRING_ARRAY,INT,StringArray,insert,INT,"idx",STRING,"string",varray()); ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray()); ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray()); ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray()); - //ADDFUNC1(VECTOR2_ARRAY,VECTOR2,Vector2Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,push_back,VECTOR2,"vector2",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append,VECTOR2,"vector2",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,append_array,VECTOR2_ARRAY,"array",varray()); + ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,remove,INT,"idx",varray()); + ADDFUNC2(VECTOR2_ARRAY,INT,Vector2Array,insert,INT,"idx",VECTOR2,"vector2",varray()); ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray()); ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray()); ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray()); - //ADDFUNC1(VECTOR3_ARRAY,VECTOR3,Vector3Array,get,INT,"idx",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,push_back,VECTOR3,"vector3",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append,VECTOR3,"vector3",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,append_array,VECTOR3_ARRAY,"array",varray()); + ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,remove,INT,"idx",varray()); + ADDFUNC2(VECTOR3_ARRAY,INT,Vector3Array,insert,INT,"idx",VECTOR3,"vector3",varray()); ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray()); ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray()); ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray()); - //ADDFUNC1(COLOR_ARRAY,COLOR,ColorArray,get,INT,"idx",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,push_back,COLOR,"color",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append,COLOR,"color",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,append_array,COLOR_ARRAY,"array",varray()); + ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,remove,INT,"idx",varray()); + ADDFUNC2(COLOR_ARRAY,INT,ColorArray,insert,INT,"idx",COLOR,"color",varray()); ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray()); //pointerbased diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 067d73034b..808bf20c25 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8497,6 +8497,31 @@ Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="color" type="Color"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="ColorArray"> + </argument> + <description> + Append an [ColorArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="color" type="Color"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="color" type="Color"> </argument> @@ -8504,6 +8529,13 @@ Append a value to the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -17113,6 +17145,31 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="integer" type="int"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="IntArray"> + </argument> + <description> + Append an [IntArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="integer" type="int"> + </argument> + <description> + Insert a new int at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="integer" type="int"> </argument> @@ -17120,6 +17177,13 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Append a value to the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -30127,6 +30191,19 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="byte" type="int"> + </argument> + <description> + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="RawArray"> + </argument> + <description> + Append an [RawArray] at the end of this array. + </description> + </method> <method name="get_string_from_ascii"> <return type="String"> </return> @@ -30141,6 +30218,17 @@ A similar effect may be achieved moving this node's descendants. Returns a copy of the array's contents formatted as String, assuming the array is formatted as UTF-8. Slower than get_string_from_ascii(), but works for UTF-8. Usually you should prefer this function over get_string_from_ascii() to support international input. </description> </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="byte" type="int"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="byte" type="int"> </argument> @@ -30148,6 +30236,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -30487,6 +30582,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="value" type="float"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="RealArray"> + </argument> + <description> + Append an [RealArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="value" type="float"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="value" type="float"> </argument> @@ -30494,6 +30614,13 @@ A similar effect may be achieved moving this node's descendants. Append an element at the end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -37898,6 +38025,31 @@ A similar effect may be achieved moving this node's descendants. Create from a generic array. </description> </method> + <method name="append"> + <argument index="0" name="string" type="String"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="StringArray"> + </argument> + <description> + Append an [StringArray] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="string" type="String"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="string" type="String"> </argument> @@ -37905,6 +38057,13 @@ A similar effect may be achieved moving this node's descendants. Append a string element at end of the array. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -42793,6 +42952,31 @@ A similar effect may be achieved moving this node's descendants. Construct a new [Vector2Array]. Optionally, you can pass in an Array that will be converted. </description> </method> + <method name="append"> + <argument index="0" name="vector2" type="Vector2"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="Vector2Array"> + </argument> + <description> + Append an [Vector2Array] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="vector2" type="Vector2"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="vector2" type="Vector2"> </argument> @@ -42800,6 +42984,13 @@ A similar effect may be achieved moving this node's descendants. Insert a [Vector2] at the end. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> @@ -43052,6 +43243,31 @@ A similar effect may be achieved moving this node's descendants. Construct a new Vector3Array. Optionally, you can pass in an Array that will be converted. </description> </method> + <method name="append"> + <argument index="0" name="vector3" type="Vector3"> + </argument> + <description> + Append an element at the end of the array (alias of [method push_back]). + </description> + </method> + <method name="append_array"> + <argument index="0" name="array" type="Vector3Array"> + </argument> + <description> + Append an [Vector3Array] at the end of this array. + </description> + </method> + <method name="insert"> + <return type="int"> + </return> + <argument index="0" name="idx" type="int"> + </argument> + <argument index="1" name="vector3" type="Vector3"> + </argument> + <description> + Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). + </description> + </method> <method name="push_back"> <argument index="0" name="vector3" type="Vector3"> </argument> @@ -43059,6 +43275,13 @@ A similar effect may be achieved moving this node's descendants. Insert a Vector3 at the end. </description> </method> + <method name="remove"> + <argument index="0" name="idx" type="int"> + </argument> + <description> + Remove an element from the array by index. + </description> + </method> <method name="resize"> <argument index="0" name="idx" type="int"> </argument> diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index b8c44a4fc8..872f047c95 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -822,40 +822,6 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool }*/ } - if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") { - - print_line("FOUND application"); - if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).") - } else { - - String aname = get_project_name(); - string_table[attr_value]=aname; - } - } - if (tname=="activity" && /*nspace=="android" &&*/ attrname=="label") { - - print_line("FOUND activity name"); - if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)") - } else { - String aname; - if (this->name!="") { - aname=this->name; - } else { - aname = Globals::get_singleton()->get("application/name"); - - } - - if (aname=="") { - aname=_MKSTR(VERSION_NAME); - } - - print_line("APP NAME IS..."+aname); - string_table[attr_value]=aname; - } - } - if (tname=="uses-permission" && /*nspace=="android" &&*/ attrname=="name") { if (value.begins_with("godot.custom")) { @@ -880,13 +846,11 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool if (tname=="supports-screens" ) { - if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Screen res name in a resource, should be plaintext") - } else if (attrname=="smallScreens") { + if (attrname=="smallScreens") { encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); - } else if (attrname=="mediumScreens") { + } else if (attrname=="normalScreens") { encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index 9f82f084e5..71a7e77266 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -116,7 +116,7 @@ void AudioServerJavascript::sample_set_data(RID p_sample, const DVector<uint8_t> } -const DVector<uint8_t> AudioServerJavascript::sample_get_data(RID p_sample) const{ +DVector<uint8_t> AudioServerJavascript::sample_get_data(RID p_sample) const{ return DVector<uint8_t>(); diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index bb9a91f78a..e27192cd93 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -132,7 +132,7 @@ public: virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer); - virtual const DVector<uint8_t> sample_get_data(RID p_sample) const; + virtual DVector<uint8_t> sample_get_data(RID p_sample) const; virtual void sample_set_mix_rate(RID p_sample,int p_rate); virtual int sample_get_mix_rate(RID p_sample) const; diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 8d64686335..e1c33cb018 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -142,6 +142,8 @@ public: virtual String get_name(); + virtual void alert(const String& p_alert, const String& p_title="ALERT!"); + virtual void set_cursor_shape(CursorShape p_shape); virtual void set_mouse_show(bool p_show); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index b5503fcd73..45c500ec39 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1209,6 +1209,22 @@ String OS_OSX::get_name() { return "OSX"; } +void OS_OSX::alert(const String& p_alert, const String& p_title) { + // Set OS X-compliant variables + NSAlert *window = [[NSAlert alloc] init]; + NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()]; + NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()]; + + [window addButtonWithTitle:@"OK"]; + [window setMessageText:ns_title]; + [window setInformativeText:ns_alert]; + [window setAlertStyle:NSWarningAlertStyle]; + + // Display it, then release + [window runModal]; + [window release]; +} + void OS_OSX::set_cursor_shape(CursorShape p_shape) { if (cursor_shape==p_shape) diff --git a/platform/windows/godot.manifest b/platform/windows/godot.manifest new file mode 100644 index 0000000000..c095f007b0 --- /dev/null +++ b/platform/windows/godot.manifest @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level="asInvoker" uiAccess="false"/> + </requestedPrivileges> + </security> + </trustInfo> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- Windows 10 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + <!-- Windows Vista --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + </application> + </compatibility> +</assembly> diff --git a/platform/windows/godot_res.rc b/platform/windows/godot_res.rc index 5f1e951e0f..d069ecdc79 100644 --- a/platform/windows/godot_res.rc +++ b/platform/windows/godot_res.rc @@ -1,3 +1,4 @@ +#include <winuser.h> #include "core/version.h" #ifndef _STR #define _STR(m_x) #m_x @@ -6,6 +7,8 @@ GODOT_ICON ICON platform/windows/godot.ico +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST platform/windows/godot.manifest + 1 VERSIONINFO FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,0 PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,0 diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index bb40c5ed93..c3b40f7add 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -271,7 +271,7 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char,CharType p_next,const Vec } -float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const { +float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const { if (!valid) return 0; @@ -686,7 +686,7 @@ bool DynamicFont::is_distance_field_hint() const{ return false; } -float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const { +float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const { if (!data_at_size.is_valid()) return 0; diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 508d630218..9ad1b4edbf 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -143,7 +143,7 @@ public: Size2 get_char_size(CharType p_char,CharType p_next,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const; - float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const; + float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const; @@ -199,7 +199,7 @@ public: virtual bool is_distance_field_hint() const; - virtual float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const; + virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const; DynamicFont(); ~DynamicFont(); diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 0b9f95da4f..456e6a5ee7 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -142,7 +142,7 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char,CharType p_next) const { } -float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const { +float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const { const_cast<DynamicFontAtSize*>(this)->_update_char(p_char); @@ -455,7 +455,7 @@ bool DynamicFont::is_distance_field_hint() const{ return false; } -float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const { +float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const { if (!data_at_size.is_valid()) return 0; diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h index 6b72fb3703..136edff2fc 100644 --- a/scene/resources/dynamic_font_stb.h +++ b/scene/resources/dynamic_font_stb.h @@ -112,7 +112,7 @@ public: Size2 get_char_size(CharType p_char,CharType p_next=0) const; - float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const; + float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const; @@ -152,7 +152,7 @@ public: virtual bool is_distance_field_hint() const; - virtual float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const; + virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const; DynamicFont(); ~DynamicFont(); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 0d8d224037..6ad8a95565 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -506,7 +506,7 @@ Ref<BitmapFont> BitmapFont::get_fallback() const{ return fallback; } -float BitmapFont::draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next,const Color& p_modulate) const { +float BitmapFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next, const Color& p_modulate) const { const Character * c = char_map.getptr(p_char); diff --git a/scene/resources/font.h b/scene/resources/font.h index 91f4874932..67836564cd 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -59,7 +59,7 @@ public: void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const; void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const; - virtual float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const=0; + virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0; Font(); @@ -155,7 +155,7 @@ public: void set_distance_field_hint(bool p_distance_field); bool is_distance_field_hint() const; - float draw_char(RID p_canvas_item, const Point2& p_pos, const CharType& p_char,const CharType& p_next=0,const Color& p_modulate=Color(1,1,1)) const; + float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const; BitmapFont(); ~BitmapFont(); diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index d1fc614c90..f28220531b 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -52,7 +52,7 @@ void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) { geometry_hint=p_geometry_hint; } -const DVector<Face3>& RoomBounds::get_geometry_hint() const { +DVector<Face3> RoomBounds::get_geometry_hint() const { return geometry_hint; } diff --git a/scene/resources/room.h b/scene/resources/room.h index 3ed41a3e61..dc5e284838 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -56,7 +56,7 @@ public: BSP_Tree get_bounds() const; void set_geometry_hint(const DVector<Face3>& geometry_hint); - const DVector<Face3>& get_geometry_hint() const; + DVector<Face3> get_geometry_hint() const; RoomBounds(); ~RoomBounds(); diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp index 8b5b5e4f46..853714be2a 100644 --- a/servers/audio/audio_server_sw.cpp +++ b/servers/audio/audio_server_sw.cpp @@ -388,7 +388,7 @@ void AudioServerSW::sample_set_data(RID p_sample, const DVector<uint8_t>& p_buff AUDIO_LOCK sample_manager->sample_set_data(p_sample,p_buffer); } -const DVector<uint8_t> AudioServerSW::sample_get_data(RID p_sample) const { +DVector<uint8_t> AudioServerSW::sample_get_data(RID p_sample) const { AUDIO_LOCK return sample_manager->sample_get_data(p_sample); } diff --git a/servers/audio/audio_server_sw.h b/servers/audio/audio_server_sw.h index 8d3d992e2b..fda952fa94 100644 --- a/servers/audio/audio_server_sw.h +++ b/servers/audio/audio_server_sw.h @@ -126,7 +126,7 @@ public: const void* sample_get_data_ptr(RID p_sample) const; virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer); - virtual const DVector<uint8_t> sample_get_data(RID p_sample) const; + virtual DVector<uint8_t> sample_get_data(RID p_sample) const; virtual void sample_set_mix_rate(RID p_sample,int p_rate); virtual int sample_get_mix_rate(RID p_sample) const; diff --git a/servers/audio_server.h b/servers/audio_server.h index c56820dcbb..50194af4a5 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -169,7 +169,7 @@ public: virtual void sample_set_signed_data(RID p_sample, const DVector<float>& p_buffer); virtual void sample_set_data(RID p_sample, const DVector<uint8_t>& p_buffer)=0; - virtual const DVector<uint8_t> sample_get_data(RID p_sample) const=0; + virtual DVector<uint8_t> sample_get_data(RID p_sample) const=0; virtual void sample_set_mix_rate(RID p_sample,int p_rate)=0; virtual int sample_get_mix_rate(RID p_sample) const=0; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index a55c835787..e68a53659b 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -466,10 +466,7 @@ void EditorFileDialog::_item_dc_selected(int p_item) { if (d["dir"]) { - //print_line("change dir: "+String(d["name"])); dir_access->change_dir(d["name"]); - if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || MODE_OPEN_ANY) - file->set_text(""); call_deferred("_update_file_list"); call_deferred("_update_dir"); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 7ecd2951d4..10e4fc8475 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1138,6 +1138,7 @@ void ScriptEditor::_menu_option(int p_option) { if (trim_trailing_whitespace_on_save) { _trim_trailing_whitespace(current->get_text_edit()); } + editor->push_item(current->get_edited_script()->cast_to<Object>()); editor->save_resource_as( current->get_edited_script() ); } break; |