diff options
57 files changed, 1176 insertions, 698 deletions
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index b63e0adc45..a025ca5730 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -442,8 +442,14 @@ String DirAccessPack::get_drive(int p_drive) { return ""; } -Error DirAccessPack::change_dir(String p_dir) { +PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) { String nd = p_dir.replace("\\", "/"); + + // Special handling since simplify_path() will forbid it + if (p_dir == "..") { + return current->parent; + } + bool absolute = false; if (nd.begins_with("res://")) { nd = nd.replace_first("res://", ""); @@ -483,13 +489,21 @@ Error DirAccessPack::change_dir(String p_dir) { pd = pd->subdirs[p]; } else { - return ERR_INVALID_PARAMETER; + return nullptr; } } - current = pd; + return pd; +} - return OK; +Error DirAccessPack::change_dir(String p_dir) { + PackedData::PackedDir *pd = _find_dir(p_dir); + if (pd) { + current = pd; + return OK; + } else { + return ERR_INVALID_PARAMETER; + } } String DirAccessPack::get_current_dir(bool p_include_drive) { @@ -507,13 +521,17 @@ String DirAccessPack::get_current_dir(bool p_include_drive) { bool DirAccessPack::file_exists(String p_file) { p_file = fix_path(p_file); - return current->files.has(p_file); + PackedData::PackedDir *pd = _find_dir(p_file.get_base_dir()); + if (!pd) { + return false; + } + return pd->files.has(p_file.get_file()); } bool DirAccessPack::dir_exists(String p_dir) { p_dir = fix_path(p_dir); - return current->subdirs.has(p_dir); + return _find_dir(p_dir) != nullptr; } Error DirAccessPack::make_dir(String p_dir) { diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 5c58dc01b4..c13626a5aa 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -122,6 +122,9 @@ public: _FORCE_INLINE_ FileAccess *try_open_path(const String &p_path); _FORCE_INLINE_ bool has_path(const String &p_path); + _FORCE_INLINE_ DirAccess *try_open_directory(const String &p_path); + _FORCE_INLINE_ bool has_directory(const String &p_path); + PackedData(); ~PackedData(); }; @@ -199,6 +202,16 @@ bool PackedData::has_path(const String &p_path) { return files.has(PathMD5(p_path.md5_buffer())); } +bool PackedData::has_directory(const String &p_path) { + DirAccess *da = try_open_directory(p_path); + if (da) { + memdelete(da); + return true; + } else { + return false; + } +} + class DirAccessPack : public DirAccess { PackedData::PackedDir *current; @@ -206,6 +219,8 @@ class DirAccessPack : public DirAccess { List<String> list_files; bool cdir = false; + PackedData::PackedDir *_find_dir(String p_dir); + public: virtual Error list_dir_begin(); virtual String get_next(); @@ -235,4 +250,13 @@ public: ~DirAccessPack() {} }; +DirAccess *PackedData::try_open_directory(const String &p_path) { + DirAccess *da = memnew(DirAccessPack()); + if (da->change_dir(p_path) != OK) { + memdelete(da); + da = nullptr; + } + return da; +} + #endif // FILE_ACCESS_PACK_H diff --git a/core/math/color.h b/core/math/color.h index 94502a79bf..a9be9e9035 100644 --- a/core/math/color.h +++ b/core/math/color.h @@ -209,9 +209,10 @@ struct Color { _FORCE_INLINE_ Color() {} /** - * RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0 + * RGBA construct parameters. + * Alpha is not optional as otherwise we can't bind the RGB version for scripting. */ - _FORCE_INLINE_ Color(float p_r, float p_g, float p_b, float p_a = 1.0) { + _FORCE_INLINE_ Color(float p_r, float p_g, float p_b, float p_a) { r = p_r; g = p_g; b = p_b; @@ -219,6 +220,16 @@ struct Color { } /** + * RGB construct parameters. + */ + _FORCE_INLINE_ Color(float p_r, float p_g, float p_b) { + r = p_r; + g = p_g; + b = p_b; + a = 1.0; + } + + /** * Construct a Color from another Color, but with the specified alpha value. */ _FORCE_INLINE_ Color(const Color &p_c, float p_a) { diff --git a/core/math/color_names.inc b/core/math/color_names.inc index cbc821026e..523c7e3c59 100644 --- a/core/math/color_names.inc +++ b/core/math/color_names.inc @@ -61,9 +61,7 @@ static NamedColor named_colors[] = { { "gold", Color(1.00, 0.84, 0.00) }, { "goldenrod", Color(0.85, 0.65, 0.13) }, { "gray", Color(0.75, 0.75, 0.75) }, - { "webgray", Color(0.50, 0.50, 0.50) }, { "green", Color(0.00, 1.00, 0.00) }, - { "webgreen", Color(0.00, 0.50, 0.00) }, { "greenyellow", Color(0.68, 1.00, 0.18) }, { "honeydew", Color(0.94, 1.00, 0.94) }, { "hotpink", Color(1.00, 0.41, 0.71) }, @@ -93,7 +91,6 @@ static NamedColor named_colors[] = { { "linen", Color(0.98, 0.94, 0.90) }, { "magenta", Color(1.00, 0.00, 1.00) }, { "maroon", Color(0.69, 0.19, 0.38) }, - { "webmaroon", Color(0.50, 0.00, 0.00) }, { "mediumaquamarine", Color(0.40, 0.80, 0.67) }, { "mediumblue", Color(0.00, 0.00, 0.80) }, { "mediumorchid", Color(0.73, 0.33, 0.83) }, @@ -126,7 +123,6 @@ static NamedColor named_colors[] = { { "plum", Color(0.87, 0.63, 0.87) }, { "powderblue", Color(0.69, 0.88, 0.90) }, { "purple", Color(0.63, 0.13, 0.94) }, - { "webpurple", Color(0.50, 0.00, 0.50) }, { "rebeccapurple", Color(0.40, 0.20, 0.60) }, { "red", Color(1.00, 0.00, 0.00) }, { "rosybrown", Color(0.74, 0.56, 0.56) }, @@ -148,9 +144,13 @@ static NamedColor named_colors[] = { { "teal", Color(0.00, 0.50, 0.50) }, { "thistle", Color(0.85, 0.75, 0.85) }, { "tomato", Color(1.00, 0.39, 0.28) }, - { "turquoise", Color(0.25, 0.88, 0.82) }, { "transparent", Color(1.00, 1.00, 1.00, 0.00) }, + { "turquoise", Color(0.25, 0.88, 0.82) }, { "violet", Color(0.93, 0.51, 0.93) }, + { "webgray", Color(0.50, 0.50, 0.50) }, + { "webgreen", Color(0.00, 0.50, 0.00) }, + { "webmaroon", Color(0.50, 0.00, 0.00) }, + { "webpurple", Color(0.50, 0.00, 0.50) }, { "wheat", Color(0.96, 0.87, 0.70) }, { "white", Color(1.00, 1.00, 1.00) }, { "whitesmoke", Color(0.96, 0.96, 0.96) }, diff --git a/core/math/transform.cpp b/core/math/transform.cpp index d36fd6a63d..733bb4d55e 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -200,6 +200,13 @@ Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) : origin(p_origin) { } +Transform::Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin) : + origin(p_origin) { + basis.set_axis(0, p_x); + basis.set_axis(1, p_y); + basis.set_axis(2, p_z); +} + Transform::Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz) { basis = Basis(xx, xy, xz, yx, yy, yz, zx, zy, zz); origin = Vector3(ox, oy, oz); diff --git a/core/math/transform.h b/core/math/transform.h index 71847d36ac..c63dbcb989 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -106,9 +106,10 @@ public: operator String() const; - Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz); - Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3()); Transform() {} + Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3()); + Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin); + Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz); }; _FORCE_INLINE_ Vector3 Transform::xform(const Vector3 &p_vector) const { diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index ef3eb6800a..fd3c6f8806 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -51,7 +51,7 @@ FileAccess *FileAccess::create(AccessType p_access) { } bool FileAccess::exists(const String &p_name) { - if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name)) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_name)) { return true; } @@ -456,7 +456,7 @@ void FileAccess::store_double(double p_dest) { } uint64_t FileAccess::get_modified_time(const String &p_file) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file)) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { return 0; } @@ -469,7 +469,7 @@ uint64_t FileAccess::get_modified_time(const String &p_file) { } uint32_t FileAccess::get_unix_permissions(const String &p_file) { - if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_file)) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { return 0; } @@ -482,6 +482,10 @@ uint32_t FileAccess::get_unix_permissions(const String &p_file) { } Error FileAccess::set_unix_permissions(const String &p_file, uint32_t p_permissions) { + if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && (PackedData::get_singleton()->has_path(p_file) || PackedData::get_singleton()->has_directory(p_file))) { + return ERR_UNAVAILABLE; + } + FileAccess *fa = create_for_path(p_file); ERR_FAIL_COND_V_MSG(!fa, ERR_CANT_CREATE, "Cannot create FileAccess for path '" + p_file + "'."); diff --git a/core/string/ustring.h b/core/string/ustring.h index 35475a2124..201b439b12 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -433,10 +433,10 @@ public: /** * The constructors must not depend on other overloads */ - /* String(char32_t p_char);*/ _FORCE_INLINE_ String() {} _FORCE_INLINE_ String(const String &p_str) { _cowdata._ref(p_str._cowdata); } + String &operator=(const String &p_str) { _cowdata._ref(p_str._cowdata); return *this; diff --git a/core/variant/variant.h b/core/variant/variant.h index 8bb28b2406..ee08373b27 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -467,7 +467,7 @@ public: return res; } - Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b); + static Variant::Type get_operator_return_type(Operator p_operator, Type p_type_a, Type p_type_b); typedef void (*ValidatedOperatorEvaluator)(const Variant *left, const Variant *right, Variant *r_ret); static ValidatedOperatorEvaluator get_validated_operator_evaluator(Operator p_operator, Type p_type_a, Type p_type_b); #ifdef PTRCALL_ENABLED diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp index e263d98815..b777323e82 100644 --- a/core/variant/variant_construct.cpp +++ b/core/variant/variant_construct.cpp @@ -292,7 +292,7 @@ public: } static Variant::Type get_base_type() { - return Variant::CALLABLE; + return Variant::SIGNAL; } }; @@ -448,6 +448,90 @@ public: } }; +template <class T> +class VariantConstructNoArgs { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantTypeChanger<T>::change_and_reset(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static void validated_construct(Variant &r_ret, const Variant **p_args) { + VariantTypeChanger<T>::change_and_reset(&r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrToArg<T>::encode(T(), base); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return GetTypeInfo<T>::VARIANT_TYPE; + } +}; + +class VariantConstructNoArgsNil { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantInternal::clear(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static void validated_construct(Variant &r_ret, const Variant **p_args) { + VariantInternal::clear(&r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + ERR_FAIL_MSG("can't ptrcall nil constructor"); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::NIL; + } +}; + +class VariantConstructNoArgsObject { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantInternal::clear(&r_ret); + VariantInternal::object_assign_null(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static void validated_construct(Variant &r_ret, const Variant **p_args) { + VariantInternal::clear(&r_ret); + VariantInternal::object_assign_null(&r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrToArg<Object *>::encode(nullptr, base); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::OBJECT; + } +}; + struct VariantConstructData { void (*construct)(Variant &r_base, const Variant **p_args, Callable::CallError &r_error); Variant::ValidatedConstructor validated_construct; @@ -459,35 +543,6 @@ struct VariantConstructData { static LocalVector<VariantConstructData> construct_data[Variant::VARIANT_MAX]; -static void variant_initialize_nil(Variant *v) { - VariantInternal::clear(v); -} - -template <class T> -static void variant_initialize(Variant *v) { - VariantTypeChanger<T>::change(v); -} - -template <class T> -static void variant_initialize_zero(Variant *v) { - VariantTypeChanger<T>::change(v); - *VariantGetInternalPtr<T>::get_ptr(v) = 0; -} - -static void variant_initialize_false(Variant *v) { - VariantTypeChanger<bool>::change(v); - *VariantGetInternalPtr<bool>::get_ptr(v) = false; -} - -static void variant_initialize_obj(Variant *v) { - VariantInternal::clear(v); - VariantInternal::object_assign_null(v); -} - -typedef void (*VariantInitializeFunc)(Variant *v); - -static VariantInitializeFunc initialize_funcs[Variant::VARIANT_MAX]; - template <class T> static void add_constructor(const Vector<String> &arg_names) { ERR_FAIL_COND_MSG(arg_names.size() != T::get_argument_count(), "Argument names size mismatch for " + Variant::get_type_name(T::get_base_type()) + "."); @@ -503,174 +558,176 @@ static void add_constructor(const Vector<String> &arg_names) { } void Variant::_register_variant_constructors() { + add_constructor<VariantConstructNoArgsNil>(sarray()); add_constructor<VariantConstructorNil>(sarray("from")); + add_constructor<VariantConstructNoArgs<bool>>(sarray()); add_constructor<VariantConstructor<bool, bool>>(sarray("from")); add_constructor<VariantConstructor<bool, int64_t>>(sarray("from")); add_constructor<VariantConstructor<bool, double>>(sarray("from")); + add_constructor<VariantConstructNoArgs<int64_t>>(sarray()); add_constructor<VariantConstructor<int64_t, int64_t>>(sarray("from")); add_constructor<VariantConstructor<int64_t, double>>(sarray("from")); + add_constructor<VariantConstructor<int64_t, bool>>(sarray("from")); + add_constructor<VariantConstructNoArgs<double>>(sarray()); add_constructor<VariantConstructor<double, double>>(sarray("from")); add_constructor<VariantConstructor<double, int64_t>>(sarray("from")); + add_constructor<VariantConstructor<double, bool>>(sarray("from")); + add_constructor<VariantConstructNoArgs<String>>(sarray()); add_constructor<VariantConstructor<String, String>>(sarray("from")); add_constructor<VariantConstructor<String, StringName>>(sarray("from")); add_constructor<VariantConstructor<String, NodePath>>(sarray("from")); + add_constructor<VariantConstructNoArgs<Vector2>>(sarray()); add_constructor<VariantConstructor<Vector2, Vector2>>(sarray("from")); add_constructor<VariantConstructor<Vector2, Vector2i>>(sarray("from")); add_constructor<VariantConstructor<Vector2, double, double>>(sarray("x", "y")); + add_constructor<VariantConstructNoArgs<Vector2i>>(sarray()); add_constructor<VariantConstructor<Vector2i, Vector2i>>(sarray("from")); add_constructor<VariantConstructor<Vector2i, Vector2>>(sarray("from")); add_constructor<VariantConstructor<Vector2i, int64_t, int64_t>>(sarray("x", "y")); + add_constructor<VariantConstructNoArgs<Rect2>>(sarray()); add_constructor<VariantConstructor<Rect2, Rect2>>(sarray("from")); add_constructor<VariantConstructor<Rect2, Rect2i>>(sarray("from")); add_constructor<VariantConstructor<Rect2, Vector2, Vector2>>(sarray("position", "size")); add_constructor<VariantConstructor<Rect2, double, double, double, double>>(sarray("x", "y", "width", "height")); + add_constructor<VariantConstructNoArgs<Rect2i>>(sarray()); add_constructor<VariantConstructor<Rect2i, Rect2i>>(sarray("from")); add_constructor<VariantConstructor<Rect2i, Rect2>>(sarray("from")); add_constructor<VariantConstructor<Rect2i, Vector2i, Vector2i>>(sarray("position", "size")); add_constructor<VariantConstructor<Rect2i, int64_t, int64_t, int64_t, int64_t>>(sarray("x", "y", "width", "height")); + add_constructor<VariantConstructNoArgs<Vector3>>(sarray()); add_constructor<VariantConstructor<Vector3, Vector3>>(sarray("from")); add_constructor<VariantConstructor<Vector3, Vector3i>>(sarray("from")); add_constructor<VariantConstructor<Vector3, double, double, double>>(sarray("x", "y", "z")); + add_constructor<VariantConstructNoArgs<Vector3i>>(sarray()); add_constructor<VariantConstructor<Vector3i, Vector3i>>(sarray("from")); add_constructor<VariantConstructor<Vector3i, Vector3>>(sarray("from")); add_constructor<VariantConstructor<Vector3i, int64_t, int64_t, int64_t>>(sarray("x", "y", "z")); + add_constructor<VariantConstructNoArgs<Transform2D>>(sarray()); add_constructor<VariantConstructor<Transform2D, Transform2D>>(sarray("from")); - add_constructor<VariantConstructor<Transform2D, Vector2, Vector2, Vector2>>(sarray("x", "y", "origin")); + add_constructor<VariantConstructor<Transform2D, float, Vector2>>(sarray("rotation", "position")); + add_constructor<VariantConstructor<Transform2D, Vector2, Vector2, Vector2>>(sarray("x_axis", "y_axis", "origin")); + add_constructor<VariantConstructNoArgs<Plane>>(sarray()); add_constructor<VariantConstructor<Plane, Plane>>(sarray("from")); add_constructor<VariantConstructor<Plane, Vector3, double>>(sarray("normal", "d")); add_constructor<VariantConstructor<Plane, Vector3, Vector3>>(sarray("point", "normal")); add_constructor<VariantConstructor<Plane, Vector3, Vector3, Vector3>>(sarray("point1", "point2", "point3")); + add_constructor<VariantConstructor<Plane, double, double, double, double>>(sarray("a", "b", "c", "d")); + add_constructor<VariantConstructNoArgs<Quat>>(sarray()); add_constructor<VariantConstructor<Quat, Quat>>(sarray("from")); add_constructor<VariantConstructor<Quat, Basis>>(sarray("from")); add_constructor<VariantConstructor<Quat, Vector3>>(sarray("euler")); add_constructor<VariantConstructor<Quat, Vector3, double>>(sarray("axis", "angle")); add_constructor<VariantConstructor<Quat, Vector3, Vector3>>(sarray("arc_from", "arc_to")); + add_constructor<VariantConstructor<Quat, double, double, double, double>>(sarray("x", "y", "z", "w")); + add_constructor<VariantConstructNoArgs<::AABB>>(sarray()); add_constructor<VariantConstructor<::AABB, ::AABB>>(sarray("from")); add_constructor<VariantConstructor<::AABB, Vector3, Vector3>>(sarray("position", "size")); + add_constructor<VariantConstructNoArgs<Basis>>(sarray()); add_constructor<VariantConstructor<Basis, Basis>>(sarray("from")); add_constructor<VariantConstructor<Basis, Quat>>(sarray("from")); - add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x", "y", "z")); + add_constructor<VariantConstructor<Basis, Vector3>>(sarray("euler")); + add_constructor<VariantConstructor<Basis, Vector3, double>>(sarray("axis", "phi")); + add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis")); + add_constructor<VariantConstructNoArgs<Transform>>(sarray()); add_constructor<VariantConstructor<Transform, Transform>>(sarray("from")); add_constructor<VariantConstructor<Transform, Basis, Vector3>>(sarray("basis", "origin")); + add_constructor<VariantConstructor<Transform, Vector3, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis", "origin")); + add_constructor<VariantConstructNoArgs<Color>>(sarray()); add_constructor<VariantConstructor<Color, Color>>(sarray("from")); + add_constructor<VariantConstructor<Color, Color, double>>(sarray("from", "alpha")); + add_constructor<VariantConstructor<Color, double, double, double>>(sarray("r", "g", "b")); + add_constructor<VariantConstructor<Color, double, double, double, double>>(sarray("r", "g", "b", "a")); + add_constructor<VariantConstructNoArgs<StringName>>(sarray()); add_constructor<VariantConstructor<StringName, StringName>>(sarray("from")); add_constructor<VariantConstructor<StringName, String>>(sarray("from")); + add_constructor<VariantConstructNoArgs<NodePath>>(sarray()); add_constructor<VariantConstructor<NodePath, NodePath>>(sarray("from")); add_constructor<VariantConstructor<NodePath, String>>(sarray("from")); + add_constructor<VariantConstructNoArgs<::RID>>(sarray()); add_constructor<VariantConstructor<::RID, ::RID>>(sarray("from")); + add_constructor<VariantConstructNoArgsObject>(sarray()); add_constructor<VariantConstructorObject>(sarray("from")); add_constructor<VariantConstructorNilObject>(sarray("from")); + add_constructor<VariantConstructNoArgs<Callable>>(sarray()); add_constructor<VariantConstructor<Callable, Callable>>(sarray("from")); add_constructor<VariantConstructorCallableArgs>(sarray("object", "method")); + add_constructor<VariantConstructNoArgs<Signal>>(sarray()); add_constructor<VariantConstructor<Signal, Signal>>(sarray("from")); add_constructor<VariantConstructorSignalArgs>(sarray("object", "signal")); + add_constructor<VariantConstructNoArgs<Dictionary>>(sarray()); add_constructor<VariantConstructor<Dictionary, Dictionary>>(sarray("from")); + add_constructor<VariantConstructNoArgs<Array>>(sarray()); add_constructor<VariantConstructor<Array, Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedByteArray>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedInt32Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedInt64Array>>(sarray("from")); - add_constructor<VariantConstructorToArray<PackedFloat64Array>>(sarray("from")); + add_constructor<VariantConstructorToArray<PackedFloat32Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedFloat64Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedStringArray>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedVector2Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedVector3Array>>(sarray("from")); add_constructor<VariantConstructorToArray<PackedColorArray>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedByteArray>>(sarray()); add_constructor<VariantConstructor<PackedByteArray, PackedByteArray>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedByteArray>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedInt32Array>>(sarray()); add_constructor<VariantConstructor<PackedInt32Array, PackedInt32Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedInt32Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedInt64Array>>(sarray()); add_constructor<VariantConstructor<PackedInt64Array, PackedInt64Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedInt64Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedFloat32Array>>(sarray()); add_constructor<VariantConstructor<PackedFloat32Array, PackedFloat32Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedFloat32Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedFloat64Array>>(sarray()); add_constructor<VariantConstructor<PackedFloat64Array, PackedFloat64Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedFloat64Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedStringArray>>(sarray()); add_constructor<VariantConstructor<PackedStringArray, PackedStringArray>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedStringArray>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedVector2Array>>(sarray()); add_constructor<VariantConstructor<PackedVector2Array, PackedVector2Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedVector2Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedVector3Array>>(sarray()); add_constructor<VariantConstructor<PackedVector3Array, PackedVector3Array>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedVector3Array>>(sarray("from")); + add_constructor<VariantConstructNoArgs<PackedColorArray>>(sarray()); add_constructor<VariantConstructor<PackedColorArray, PackedColorArray>>(sarray("from")); add_constructor<VariantConstructorFromArray<PackedColorArray>>(sarray("from")); - - initialize_funcs[NIL] = variant_initialize_nil; - - // atomic types - initialize_funcs[BOOL] = variant_initialize_false; - initialize_funcs[INT] = variant_initialize_zero<int64_t>; - initialize_funcs[FLOAT] = variant_initialize_zero<double>; - initialize_funcs[STRING] = variant_initialize<String>; - - // math types - initialize_funcs[VECTOR2] = variant_initialize<Vector2>; - initialize_funcs[VECTOR2I] = variant_initialize<Vector2i>; - initialize_funcs[RECT2] = variant_initialize<Rect2>; - initialize_funcs[RECT2I] = variant_initialize<Rect2i>; - initialize_funcs[VECTOR3] = variant_initialize<Vector3>; - initialize_funcs[VECTOR3I] = variant_initialize<Vector3i>; - initialize_funcs[TRANSFORM2D] = variant_initialize<Transform2D>; - initialize_funcs[PLANE] = variant_initialize<Plane>; - initialize_funcs[QUAT] = variant_initialize<Quat>; - initialize_funcs[AABB] = variant_initialize<::AABB>; - initialize_funcs[BASIS] = variant_initialize<Basis>; - initialize_funcs[TRANSFORM] = variant_initialize<Transform>; - - // misc types - initialize_funcs[COLOR] = variant_initialize<Color>; - initialize_funcs[STRING_NAME] = variant_initialize<StringName>; - initialize_funcs[NODE_PATH] = variant_initialize<NodePath>; - initialize_funcs[RID] = variant_initialize<::RID>; - initialize_funcs[OBJECT] = variant_initialize_obj; - initialize_funcs[CALLABLE] = variant_initialize<Callable>; - initialize_funcs[SIGNAL] = variant_initialize<Signal>; - initialize_funcs[DICTIONARY] = variant_initialize<Dictionary>; - initialize_funcs[ARRAY] = variant_initialize<Array>; - - // typed arrays - initialize_funcs[PACKED_BYTE_ARRAY] = variant_initialize<PackedByteArray>; - initialize_funcs[PACKED_INT32_ARRAY] = variant_initialize<PackedInt32Array>; - initialize_funcs[PACKED_INT64_ARRAY] = variant_initialize<PackedInt64Array>; - initialize_funcs[PACKED_FLOAT32_ARRAY] = variant_initialize<PackedFloat32Array>; - initialize_funcs[PACKED_FLOAT64_ARRAY] = variant_initialize<PackedFloat64Array>; - initialize_funcs[PACKED_STRING_ARRAY] = variant_initialize<PackedStringArray>; - initialize_funcs[PACKED_VECTOR2_ARRAY] = variant_initialize<PackedVector2Array>; - initialize_funcs[PACKED_VECTOR3_ARRAY] = variant_initialize<PackedVector3Array>; - initialize_funcs[PACKED_COLOR_ARRAY] = variant_initialize<PackedColorArray>; } void Variant::_unregister_variant_constructors() { @@ -680,35 +737,29 @@ void Variant::_unregister_variant_constructors() { } void Variant::construct(Variant::Type p_type, Variant &base, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { - if (p_argcount == 0) { - initialize_funcs[p_type](&base); - r_error.error = Callable::CallError::CALL_OK; - - } else { - uint32_t s = construct_data[p_type].size(); - for (uint32_t i = 0; i < s; i++) { - int argc = construct_data[p_type][i].argument_count; - if (argc != p_argcount) { - continue; - } - bool args_match = true; - for (int j = 0; j < argc; j++) { - if (!Variant::can_convert_strict(p_args[j]->get_type(), construct_data[p_type][i].get_argument_type(j))) { - args_match = false; - break; - } - } - - if (!args_match) { - continue; + uint32_t s = construct_data[p_type].size(); + for (uint32_t i = 0; i < s; i++) { + int argc = construct_data[p_type][i].argument_count; + if (argc != p_argcount) { + continue; + } + bool args_match = true; + for (int j = 0; j < argc; j++) { + if (!Variant::can_convert_strict(p_args[j]->get_type(), construct_data[p_type][i].get_argument_type(j))) { + args_match = false; + break; } + } - construct_data[p_type][i].construct(base, p_args, r_error); - return; + if (!args_match) { + continue; } - r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; + construct_data[p_type][i].construct(base, p_args, r_error); + return; } + + r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; } int Variant::get_constructor_count(Variant::Type p_type) { diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index eca02ad4ae..3ac7f32dec 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -937,6 +937,180 @@ struct VariantInitializer<PackedColorArray> { }; template <class T> +struct VariantZeroAssigner { +}; + +template <> +struct VariantZeroAssigner<bool> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_bool(v) = false; } +}; + +template <> +struct VariantZeroAssigner<int64_t> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_int(v) = 0; } +}; + +template <> +struct VariantZeroAssigner<double> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_float(v) = 0.0; } +}; + +template <> +struct VariantZeroAssigner<float> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_float(v) = 0.0; } +}; + +template <> +struct VariantZeroAssigner<String> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<Vector2> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_vector2(v) = Vector2(); } +}; + +template <> +struct VariantZeroAssigner<Vector2i> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_vector2i(v) = Vector2i(); } +}; + +template <> +struct VariantZeroAssigner<Rect2> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_rect2(v) = Rect2(); } +}; + +template <> +struct VariantZeroAssigner<Rect2i> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_rect2i(v) = Rect2i(); } +}; + +template <> +struct VariantZeroAssigner<Vector3> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_vector3(v) = Vector3(); } +}; + +template <> +struct VariantZeroAssigner<Vector3i> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_vector3i(v) = Vector3i(); } +}; + +template <> +struct VariantZeroAssigner<Transform2D> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_transform2d(v) = Transform2D(); } +}; + +template <> +struct VariantZeroAssigner<Plane> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_plane(v) = Plane(); } +}; + +template <> +struct VariantZeroAssigner<Quat> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_quat(v) = Quat(); } +}; + +template <> +struct VariantZeroAssigner<AABB> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_aabb(v) = AABB(); } +}; + +template <> +struct VariantZeroAssigner<Basis> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_basis(v) = Basis(); } +}; + +template <> +struct VariantZeroAssigner<Transform> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_transform(v) = Transform(); } +}; + +template <> +struct VariantZeroAssigner<Color> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_color(v) = Color(); } +}; + +template <> +struct VariantZeroAssigner<StringName> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<NodePath> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<::RID> { + static _FORCE_INLINE_ void zero(Variant *v) { *VariantInternal::get_rid(v) = RID(); } +}; + +template <> +struct VariantZeroAssigner<Callable> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<Signal> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<Dictionary> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedByteArray> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedInt32Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedInt64Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedFloat32Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedFloat64Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedStringArray> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedVector2Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedVector3Array> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <> +struct VariantZeroAssigner<PackedColorArray> { + static _FORCE_INLINE_ void zero(Variant *v) {} +}; + +template <class T> struct VariantTypeChanger { static _FORCE_INLINE_ void change(Variant *v) { if (v->get_type() != GetTypeInfo<T>::VARIANT_TYPE || GetTypeInfo<T>::VARIANT_TYPE >= Variant::PACKED_BYTE_ARRAY) { //second condition removed by optimizer @@ -944,6 +1118,14 @@ struct VariantTypeChanger { VariantInitializer<T>::init(v); } } + static _FORCE_INLINE_ void change_and_reset(Variant *v) { + if (v->get_type() != GetTypeInfo<T>::VARIANT_TYPE || GetTypeInfo<T>::VARIANT_TYPE >= Variant::PACKED_BYTE_ARRAY) { //second condition removed by optimizer + VariantInternal::clear(v); + VariantInitializer<T>::init(v); + } + + VariantZeroAssigner<T>::zero(v); + } }; #endif // VARIANT_INTERNAL_H diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index 4704deac20..8e55c1d6cd 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -2145,8 +2145,8 @@ static const char *_op_names[Variant::OP_MAX] = { "-", "*", "/", - "- (negation)", - "+ (positive)", + "-", + "+", "%", "<<", ">>", diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 2b1770f12b..ee65bbc07e 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1594,43 +1594,40 @@ <constant name="OP_MODULE" value="12" enum="Variant.Operator"> Remainder/modulo operator ([code]%[/code]). </constant> - <constant name="OP_STRING_CONCAT" value="13" enum="Variant.Operator"> - String concatenation operator ([code]+[/code]). - </constant> - <constant name="OP_SHIFT_LEFT" value="14" enum="Variant.Operator"> + <constant name="OP_SHIFT_LEFT" value="13" enum="Variant.Operator"> Left shift operator ([code]<<[/code]). </constant> - <constant name="OP_SHIFT_RIGHT" value="15" enum="Variant.Operator"> + <constant name="OP_SHIFT_RIGHT" value="14" enum="Variant.Operator"> Right shift operator ([code]>>[/code]). </constant> - <constant name="OP_BIT_AND" value="16" enum="Variant.Operator"> + <constant name="OP_BIT_AND" value="15" enum="Variant.Operator"> Bitwise AND operator ([code]&[/code]). </constant> - <constant name="OP_BIT_OR" value="17" enum="Variant.Operator"> + <constant name="OP_BIT_OR" value="16" enum="Variant.Operator"> Bitwise OR operator ([code]|[/code]). </constant> - <constant name="OP_BIT_XOR" value="18" enum="Variant.Operator"> + <constant name="OP_BIT_XOR" value="17" enum="Variant.Operator"> Bitwise XOR operator ([code]^[/code]). </constant> - <constant name="OP_BIT_NEGATE" value="19" enum="Variant.Operator"> + <constant name="OP_BIT_NEGATE" value="18" enum="Variant.Operator"> Bitwise NOT operator ([code]~[/code]). </constant> - <constant name="OP_AND" value="20" enum="Variant.Operator"> + <constant name="OP_AND" value="19" enum="Variant.Operator"> Logical AND operator ([code]and[/code] or [code]&&[/code]). </constant> - <constant name="OP_OR" value="21" enum="Variant.Operator"> + <constant name="OP_OR" value="20" enum="Variant.Operator"> Logical OR operator ([code]or[/code] or [code]||[/code]). </constant> - <constant name="OP_XOR" value="22" enum="Variant.Operator"> + <constant name="OP_XOR" value="21" enum="Variant.Operator"> Logical XOR operator (not implemented in GDScript). </constant> - <constant name="OP_NOT" value="23" enum="Variant.Operator"> + <constant name="OP_NOT" value="22" enum="Variant.Operator"> Logical NOT operator ([code]not[/code] or [code]![/code]). </constant> - <constant name="OP_IN" value="24" enum="Variant.Operator"> + <constant name="OP_IN" value="23" enum="Variant.Operator"> Logical IN operator ([code]in[/code]). </constant> - <constant name="OP_MAX" value="25" enum="Variant.Operator"> + <constant name="OP_MAX" value="24" enum="Variant.Operator"> Represents the size of the [enum Variant.Operator] enum. </constant> </constants> diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index 4f95b44f83..a4972612d9 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -17,6 +17,22 @@ <method name="AABB"> <return type="AABB"> </return> + <description> + Constructs a default-initialized [AABB] with default (zero) values of [member position] and [member size]. + </description> + </method> + <method name="AABB"> + <return type="AABB"> + </return> + <argument index="0" name="from" type="AABB"> + </argument> + <description> + Constructs an [AABB] as a copy of the given [AABB]. + </description> + </method> + <method name="AABB"> + <return type="AABB"> + </return> <argument index="0" name="position" type="Vector3"> </argument> <argument index="1" name="size" type="Vector3"> diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index d0f90f513d..86ef5bef4c 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -46,37 +46,44 @@ <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedColorArray"> + <description> + Constructs an empty [Array]. + </description> + </method> + <method name="Array"> + <return type="Array"> + </return> + <argument index="0" name="from" type="Array"> </argument> <description> - Constructs an array from a [PackedColorArray]. + Constructs an [Array] as a copy of the given [Array]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedVector3Array"> + <argument index="0" name="from" type="PackedByteArray"> </argument> <description> - Constructs an array from a [PackedVector3Array]. + Constructs an array from a [PackedByteArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedVector2Array"> + <argument index="0" name="from" type="PackedColorArray"> </argument> <description> - Constructs an array from a [PackedVector2Array]. + Constructs an array from a [PackedColorArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedStringArray"> + <argument index="0" name="from" type="PackedFloat32Array"> </argument> <description> - Constructs an array from a [PackedStringArray]. + Constructs an array from a [PackedFloat32Array]. </description> </method> <method name="Array"> @@ -91,10 +98,10 @@ <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedFloat32Array"> + <argument index="0" name="from" type="PackedInt32Array"> </argument> <description> - Constructs an array from a [PackedFloat32Array]. + Constructs an array from a [PackedInt32Array]. </description> </method> <method name="Array"> @@ -109,19 +116,28 @@ <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedInt32Array"> + <argument index="0" name="from" type="PackedStringArray"> </argument> <description> - Constructs an array from a [PackedInt32Array]. + Constructs an array from a [PackedStringArray]. </description> </method> <method name="Array"> <return type="Array"> </return> - <argument index="0" name="from" type="PackedByteArray"> + <argument index="0" name="from" type="PackedVector2Array"> </argument> <description> - Constructs an array from a [PackedByteArray]. + Constructs an array from a [PackedVector2Array]. + </description> + </method> + <method name="Array"> + <return type="Array"> + </return> + <argument index="0" name="from" type="PackedVector3Array"> + </argument> + <description> + Constructs an array from a [PackedVector3Array]. </description> </method> <method name="append"> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 4201a31402..908f316e4e 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -22,20 +22,17 @@ <method name="Basis"> <return type="Basis"> </return> - <argument index="0" name="from" type="Quat"> - </argument> <description> - Constructs a pure rotation basis matrix from the given quaternion. + Constructs a default-initialized [Basis] set to [constant IDENTITY]. </description> </method> <method name="Basis"> <return type="Basis"> </return> - <argument index="0" name="from" type="Vector3"> + <argument index="0" name="from" type="Basis"> </argument> <description> - Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle). - Consider using the [Quat] constructor instead, which uses a quaternion instead of Euler angles. + Constructs a [Basis] as a copy of the given [Basis]. </description> </method> <method name="Basis"> @@ -52,6 +49,25 @@ <method name="Basis"> <return type="Basis"> </return> + <argument index="0" name="euler" type="Vector3"> + </argument> + <description> + Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle). + Consider using the [Quat] constructor instead, which uses a quaternion instead of Euler angles. + </description> + </method> + <method name="Basis"> + <return type="Basis"> + </return> + <argument index="0" name="from" type="Quat"> + </argument> + <description> + Constructs a pure rotation basis matrix from the given quaternion. + </description> + </method> + <method name="Basis"> + <return type="Basis"> + </return> <argument index="0" name="x_axis" type="Vector3"> </argument> <argument index="1" name="y_axis" type="Vector3"> diff --git a/doc/classes/Callable.xml b/doc/classes/Callable.xml index 7aaf087540..c31efc2581 100644 --- a/doc/classes/Callable.xml +++ b/doc/classes/Callable.xml @@ -39,12 +39,28 @@ <method name="Callable"> <return type="Callable"> </return> + <description> + Constructs a null [Callable] with no object nor method bound. + </description> + </method> + <method name="Callable"> + <return type="Callable"> + </return> + <argument index="0" name="from" type="Callable"> + </argument> + <description> + Constructs a [Callable] as a copy of the given [Callable]. + </description> + </method> + <method name="Callable"> + <return type="Callable"> + </return> <argument index="0" name="object" type="Object"> </argument> - <argument index="1" name="method_name" type="StringName"> + <argument index="1" name="method" type="StringName"> </argument> <description> - Creates a new [Callable] for the method called [code]method_name[/code] in the specified [code]object[/code]. + Creates a new [Callable] for the method called [code]method[/code] in the specified [code]object[/code]. </description> </method> <method name="bind" qualifiers="vararg"> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index ca52d27a52..721fea8a19 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -19,71 +19,28 @@ <method name="Color"> <return type="Color"> </return> - <argument index="0" name="from" type="String"> - </argument> <description> - Constructs a color from an HTML hexadecimal color string in RGB or RGBA format. See also [method @GDScript.ColorN]. - [codeblocks] - [gdscript] - # Each of the following creates the same color RGBA(178, 217, 10, 255). - var c3 = Color("#b2d90a") # RGB format with "#". - var c4 = Color("b2d90a") # RGB format. - var c1 = Color("#b2d90aff") # RGBA format with "#". - var c2 = Color("b2d90aff") # RGBA format. - [/gdscript] - [csharp] - // Each of the following creates the same color RGBA(178, 217, 10, 255). - var c3 = new Color("#b2d90a"); - var c4 = new Color("b2d90a"); // RGB format. - var c1 = new Color("#b2d90aff"); - var c2 = new Color("b2d90aff"); // RGBA format. - [/csharp] - [/codeblocks] - You can also use the "web color" short-hand form by only using 3 or 4 digits. - [codeblocks] - [gdscript] - # Each of the following creates the same color RGBA(17, 34, 51, 255). - var c3 = Color("#123") # RGB format with "#". - var c4 = Color("123") # RGB format. - var c1 = Color("#123f") # RGBA format with "#". - var c2 = Color("123f") # RGBA format. - [/gdscript] - [csharp] - // Each of the following creates the same color RGBA(17, 34, 51, 255). - var c3 = new Color("#123"); - var c4 = new Color("123"); // RGB format. - var c1 = new Color("#123f"); - var c2 = new Color("123f"); // RGBA format. - [/csharp] - [/codeblocks] + Constructs a default-initialized [Color] with all components set to [code]0[/code]. </description> </method> <method name="Color"> <return type="Color"> </return> - <argument index="0" name="from" type="int"> + <argument index="0" name="from" type="Color"> </argument> <description> - Constructs a color from a 32-bit integer (each byte represents a component of the RGBA profile). - [codeblocks] - [gdscript] - var c = Color(274) # Equivalent to RGBA(0, 0, 1, 18) - [/gdscript] - [csharp] - var c = new Color(274); // Equivalent to RGBA(0, 0, 1, 18) - [/csharp] - [/codeblocks] + Constructs a [Color] as a copy of the given [Color]. </description> </method> <method name="Color"> <return type="Color"> </return> - <argument index="0" name="c" type="Color"> + <argument index="0" name="from" type="Color"> </argument> - <argument index="1" name="a" type="float"> + <argument index="1" name="alpha" type="float"> </argument> <description> - Constructs a color from an existing color, but with a custom alpha value. + Constructs a [Color] from an existing color, but with a custom alpha value. [codeblocks] [gdscript] var red = Color(Color.red, 0.5) # 50% transparent red. @@ -103,14 +60,16 @@ </argument> <argument index="2" name="b" type="float"> </argument> + <argument index="3" name="a" type="float"> + </argument> <description> - Constructs a color from an RGB profile using values between 0 and 1. Alpha will always be 1. + Constructs a [Color] from an RGBA profile using values between 0 and 1. [codeblocks] [gdscript] - var color = Color(0.2, 1.0, 0.7) # Equivalent to RGBA(51, 255, 178, 255) + var color = Color(0.2, 1.0, 0.7, 0.8) # Equivalent to RGBA(51, 255, 178, 204) [/gdscript] [csharp] - var color = new Color(0.2f, 1.0f, 0.7f); // Equivalent to RGBA(51, 255, 178, 255) + var color = new Color(0.2f, 1.0f, 0.7f, 0.8f); // Equivalent to RGBA(51, 255, 178, 255, 204) [/csharp] [/codeblocks] </description> @@ -124,16 +83,14 @@ </argument> <argument index="2" name="b" type="float"> </argument> - <argument index="3" name="a" type="float"> - </argument> <description> - Constructs a color from an RGBA profile using values between 0 and 1. + Constructs a color from an RGB profile using values between 0 and 1. Alpha will always be 1. [codeblocks] [gdscript] - var color = Color(0.2, 1.0, 0.7, 0.8) # Equivalent to RGBA(51, 255, 178, 204) + var color = Color(0.2, 1.0, 0.7) # Equivalent to RGBA(51, 255, 178, 255) [/gdscript] [csharp] - var color = new Color(0.2f, 1.0f, 0.7f, 0.8f); // Equivalent to RGBA(51, 255, 178, 255, 204) + var color = new Color(0.2f, 1.0f, 0.7f); // Equivalent to RGBA(51, 255, 178, 255) [/csharp] [/codeblocks] </description> diff --git a/doc/classes/DTLSServer.xml b/doc/classes/DTLSServer.xml index 8bdaeb9211..91a04b1f28 100644 --- a/doc/classes/DTLSServer.xml +++ b/doc/classes/DTLSServer.xml @@ -132,7 +132,7 @@ // Try to contact server Dtls.PutPacket("The Answer Is..42!".ToUTF8()); } - while (Dtls.GetAvailablePacketCount() > 0) + while (Dtls.GetAvailablePacketCount() > 0) { GD.Print("Connected: " + Dtls.GetPacket().GetStringFromUTF8()); Connected = true; diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 8095d95551..a7a3632fef 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -171,6 +171,22 @@ <link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link> </tutorials> <methods> + <method name="Dictionary"> + <return type="Dictionary"> + </return> + <description> + Constructs an empty [Dictionary]. + </description> + </method> + <method name="Dictionary"> + <return type="Dictionary"> + </return> + <argument index="0" name="from" type="Dictionary"> + </argument> + <description> + Constructs a [Dictionary] as a copy of the given [Dictionary]. + </description> + </method> <method name="clear"> <return type="void"> </return> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 3613c408b2..a069bdd836 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -210,6 +210,38 @@ <argument index="0" name="overlay" type="Control"> </argument> <description> + Called by the engine when the 2D editor's viewport is updated. Use the [code]overlay[/code] [Control] for drawing. You can update the viewport manually by calling [method update_overlays]. + [codeblocks] + [gdscript] + func forward_canvas_draw_over_viewport(overlay): + # Draw a circle at cursor position. + overlay.draw_circle(overlay.get_local_mouse_position(), 64) + + func forward_canvas_gui_input(event): + if event is InputEventMouseMotion: + # Redraw viewport when cursor is moved. + update_overlays() + return true + return false + [/gdscript] + [csharp] + public override void ForwardCanvasDrawOverViewport(Godot.Control overlay) + { + // Draw a circle at cursor position. + overlay.DrawCircle(overlay.GetLocalMousePosition(), 64, Colors.White); + } + + public override bool ForwardCanvasGuiInput(InputEvent @event) + { + if (@event is InputEventMouseMotion) + { + // Redraw viewport when cursor is moved. + UpdateOverlays(); + return true; + } + return false; + [/csharp] + [/codeblocks] </description> </method> <method name="forward_canvas_force_draw_over_viewport" qualifiers="virtual"> @@ -218,6 +250,8 @@ <argument index="0" name="overlay" type="Control"> </argument> <description> + This method is the same as [method forward_canvas_draw_over_viewport], except it draws on top of everything. Useful when you need an extra layer that shows over anything else. + You need to enable calling of this method by using [method set_force_draw_over_forwarding_enabled]. </description> </method> <method name="forward_canvas_gui_input" qualifiers="virtual"> @@ -550,6 +584,7 @@ <return type="void"> </return> <description> + Enables calling of [method forward_canvas_force_draw_over_viewport] when the 2D editor's viewport is updated. You need to call this method only once and it will work permanently for this plugin. </description> </method> <method name="set_input_event_forwarding_always_enabled"> @@ -581,7 +616,7 @@ <return type="int"> </return> <description> - Updates the overlays of the editor (2D/3D) viewport. + Updates the overlays of the 2D and 3D editor viewport. Causes [method forward_canvas_draw_over_viewport] and [method forward_canvas_force_draw_over_viewport] to be called. </description> </method> </methods> diff --git a/doc/classes/FuncRef.xml b/doc/classes/FuncRef.xml deleted file mode 100644 index dc9246ad35..0000000000 --- a/doc/classes/FuncRef.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="FuncRef" inherits="Reference" version="4.0"> - <brief_description> - Reference to a function in an object. - </brief_description> - <description> - In GDScript, functions are not [i]first-class objects[/i]. This means it is impossible to store them directly as variables, return them from another function, or pass them as arguments. - However, by creating a [FuncRef] using the [method @GDScript.funcref] function, a reference to a function in a given object can be created, passed around and called. - </description> - <tutorials> - </tutorials> - <methods> - <method name="call_func" qualifiers="vararg"> - <return type="Variant"> - </return> - <description> - Calls the referenced function previously set in [member function] or [method @GDScript.funcref]. - </description> - </method> - <method name="call_funcv"> - <return type="Variant"> - </return> - <argument index="0" name="arg_array" type="Array"> - </argument> - <description> - Calls the referenced function previously set in [member function] or [method @GDScript.funcref]. Contrarily to [method call_func], this method does not support a variable number of arguments but expects all parameters to be passed via a single [Array]. - </description> - </method> - <method name="is_valid" qualifiers="const"> - <return type="bool"> - </return> - <description> - Returns whether the object still exists and has the function assigned. - </description> - </method> - <method name="set_instance"> - <return type="void"> - </return> - <argument index="0" name="instance" type="Object"> - </argument> - <description> - The object containing the referenced function. This object must be of a type actually inheriting from [Object], not a built-in type such as [int], [Vector2] or [Dictionary]. - </description> - </method> - </methods> - <members> - <member name="function" type="StringName" setter="set_function" getter="get_function" default="@"""> - The name of the referenced function. - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/NodePath.xml b/doc/classes/NodePath.xml index f711ba4d6b..980bea0d9f 100644 --- a/doc/classes/NodePath.xml +++ b/doc/classes/NodePath.xml @@ -28,6 +28,22 @@ <method name="NodePath"> <return type="NodePath"> </return> + <description> + Constructs an empty [NodePath]. + </description> + </method> + <method name="NodePath"> + <return type="NodePath"> + </return> + <argument index="0" name="from" type="NodePath"> + </argument> + <description> + Constructs a [NodePath] as a copy of the given [NodePath]. + </description> + </method> + <method name="NodePath"> + <return type="NodePath"> + </return> <argument index="0" name="from" type="String"> </argument> <description> diff --git a/doc/classes/PackedByteArray.xml b/doc/classes/PackedByteArray.xml index 7c2d566466..5ac5f15fb2 100644 --- a/doc/classes/PackedByteArray.xml +++ b/doc/classes/PackedByteArray.xml @@ -13,6 +13,22 @@ <method name="PackedByteArray"> <return type="PackedByteArray"> </return> + <description> + Constructs an empty [PackedByteArray]. + </description> + </method> + <method name="PackedByteArray"> + <return type="PackedByteArray"> + </return> + <argument index="0" name="from" type="PackedByteArray"> + </argument> + <description> + Constructs a [PackedByteArray] as a copy of the given [PackedByteArray]. + </description> + </method> + <method name="PackedByteArray"> + <return type="PackedByteArray"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedColorArray.xml b/doc/classes/PackedColorArray.xml index c42d14c5bd..e4b9e02be7 100644 --- a/doc/classes/PackedColorArray.xml +++ b/doc/classes/PackedColorArray.xml @@ -13,6 +13,22 @@ <method name="PackedColorArray"> <return type="PackedColorArray"> </return> + <description> + Constructs an empty [PackedColorArray]. + </description> + </method> + <method name="PackedColorArray"> + <return type="PackedColorArray"> + </return> + <argument index="0" name="from" type="PackedColorArray"> + </argument> + <description> + Constructs a [PackedColorArray] as a copy of the given [PackedColorArray]. + </description> + </method> + <method name="PackedColorArray"> + <return type="PackedColorArray"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedFloat32Array.xml b/doc/classes/PackedFloat32Array.xml index dd84648251..1b2091f72b 100644 --- a/doc/classes/PackedFloat32Array.xml +++ b/doc/classes/PackedFloat32Array.xml @@ -14,6 +14,22 @@ <method name="PackedFloat32Array"> <return type="PackedFloat32Array"> </return> + <description> + Constructs an empty [PackedFloat32Array]. + </description> + </method> + <method name="PackedFloat32Array"> + <return type="PackedFloat32Array"> + </return> + <argument index="0" name="from" type="PackedFloat32Array"> + </argument> + <description> + Constructs a [PackedFloat32Array] as a copy of the given [PackedFloat32Array]. + </description> + </method> + <method name="PackedFloat32Array"> + <return type="PackedFloat32Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedFloat64Array.xml b/doc/classes/PackedFloat64Array.xml index 91c3f4874b..a55ac6bacc 100644 --- a/doc/classes/PackedFloat64Array.xml +++ b/doc/classes/PackedFloat64Array.xml @@ -14,6 +14,22 @@ <method name="PackedFloat64Array"> <return type="PackedFloat64Array"> </return> + <description> + Constructs an empty [PackedFloat64Array]. + </description> + </method> + <method name="PackedFloat64Array"> + <return type="PackedFloat64Array"> + </return> + <argument index="0" name="from" type="PackedFloat64Array"> + </argument> + <description> + Constructs a [PackedFloat64Array] as a copy of the given [PackedFloat64Array]. + </description> + </method> + <method name="PackedFloat64Array"> + <return type="PackedFloat64Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedInt32Array.xml b/doc/classes/PackedInt32Array.xml index a0a9922d0c..ecf8abd1eb 100644 --- a/doc/classes/PackedInt32Array.xml +++ b/doc/classes/PackedInt32Array.xml @@ -14,6 +14,22 @@ <method name="PackedInt32Array"> <return type="PackedInt32Array"> </return> + <description> + Constructs an empty [PackedInt32Array]. + </description> + </method> + <method name="PackedInt32Array"> + <return type="PackedInt32Array"> + </return> + <argument index="0" name="from" type="PackedInt32Array"> + </argument> + <description> + Constructs a [PackedInt32Array] as a copy of the given [PackedInt32Array]. + </description> + </method> + <method name="PackedInt32Array"> + <return type="PackedInt32Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedInt64Array.xml b/doc/classes/PackedInt64Array.xml index 542dabcfa0..a254a6ff5f 100644 --- a/doc/classes/PackedInt64Array.xml +++ b/doc/classes/PackedInt64Array.xml @@ -14,6 +14,22 @@ <method name="PackedInt64Array"> <return type="PackedInt64Array"> </return> + <description> + Constructs an empty [PackedInt64Array]. + </description> + </method> + <method name="PackedInt64Array"> + <return type="PackedInt64Array"> + </return> + <argument index="0" name="from" type="PackedInt64Array"> + </argument> + <description> + Constructs a [PackedInt64Array] as a copy of the given [PackedInt64Array]. + </description> + </method> + <method name="PackedInt64Array"> + <return type="PackedInt64Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedStringArray.xml b/doc/classes/PackedStringArray.xml index 7c710cf0fb..c50ec38a93 100644 --- a/doc/classes/PackedStringArray.xml +++ b/doc/classes/PackedStringArray.xml @@ -14,6 +14,22 @@ <method name="PackedStringArray"> <return type="PackedStringArray"> </return> + <description> + Constructs an empty [PackedStringArray]. + </description> + </method> + <method name="PackedStringArray"> + <return type="PackedStringArray"> + </return> + <argument index="0" name="from" type="PackedStringArray"> + </argument> + <description> + Constructs a [PackedStringArray] as a copy of the given [PackedStringArray]. + </description> + </method> + <method name="PackedStringArray"> + <return type="PackedStringArray"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedVector2Array.xml b/doc/classes/PackedVector2Array.xml index 98034afc93..0bd658c488 100644 --- a/doc/classes/PackedVector2Array.xml +++ b/doc/classes/PackedVector2Array.xml @@ -14,6 +14,22 @@ <method name="PackedVector2Array"> <return type="PackedVector2Array"> </return> + <description> + Constructs an empty [PackedVector2Array]. + </description> + </method> + <method name="PackedVector2Array"> + <return type="PackedVector2Array"> + </return> + <argument index="0" name="from" type="PackedVector2Array"> + </argument> + <description> + Constructs a [PackedVector2Array] as a copy of the given [PackedVector2Array]. + </description> + </method> + <method name="PackedVector2Array"> + <return type="PackedVector2Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/PackedVector3Array.xml b/doc/classes/PackedVector3Array.xml index 3db33fbcd9..5b835f2fbf 100644 --- a/doc/classes/PackedVector3Array.xml +++ b/doc/classes/PackedVector3Array.xml @@ -13,6 +13,22 @@ <method name="PackedVector3Array"> <return type="PackedVector3Array"> </return> + <description> + Constructs an empty [PackedVector3Array]. + </description> + </method> + <method name="PackedVector3Array"> + <return type="PackedVector3Array"> + </return> + <argument index="0" name="from" type="PackedVector3Array"> + </argument> + <description> + Constructs a [PackedVector3Array] as a copy of the given [PackedVector3Array]. + </description> + </method> + <method name="PackedVector3Array"> + <return type="PackedVector3Array"> + </return> <argument index="0" name="from" type="Array"> </argument> <description> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 9352eee1eb..bb0b25a552 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -13,6 +13,22 @@ <method name="Plane"> <return type="Plane"> </return> + <description> + Constructs a default-initialized [Plane] with all components set to [code]0[/code]. + </description> + </method> + <method name="Plane"> + <return type="Plane"> + </return> + <argument index="0" name="from" type="Plane"> + </argument> + <description> + Constructs a [Plane] as a copy of the given [Plane]. + </description> + </method> + <method name="Plane"> + <return type="Plane"> + </return> <argument index="0" name="a" type="float"> </argument> <argument index="1" name="b" type="float"> @@ -28,25 +44,36 @@ <method name="Plane"> <return type="Plane"> </return> - <argument index="0" name="v1" type="Vector3"> + <argument index="0" name="normal" type="Vector3"> + </argument> + <argument index="1" name="d" type="float"> </argument> - <argument index="1" name="v2" type="Vector3"> + <description> + Creates a plane from the normal and the plane's distance to the origin. + </description> + </method> + <method name="Plane"> + <return type="Plane"> + </return> + <argument index="0" name="point" type="Vector3"> </argument> - <argument index="2" name="v3" type="Vector3"> + <argument index="1" name="normal" type="Vector3"> </argument> <description> - Creates a plane from the three points, given in clockwise order. + Creates a plane from the given position and a plane normal. </description> </method> <method name="Plane"> <return type="Plane"> </return> - <argument index="0" name="normal" type="Vector3"> + <argument index="0" name="point1" type="Vector3"> </argument> - <argument index="1" name="d" type="float"> + <argument index="1" name="point2" type="Vector3"> + </argument> + <argument index="2" name="point3" type="Vector3"> </argument> <description> - Creates a plane from the normal and the plane's distance to the origin. + Creates a plane from the three points, given in clockwise order. </description> </method> <method name="center"> diff --git a/doc/classes/Quat.xml b/doc/classes/Quat.xml index 76cfa0d99d..edfe99a8b8 100644 --- a/doc/classes/Quat.xml +++ b/doc/classes/Quat.xml @@ -16,16 +16,27 @@ <method name="Quat"> <return type="Quat"> </return> - <argument index="0" name="x" type="float"> - </argument> - <argument index="1" name="y" type="float"> + <description> + Constructs a default-initialized quaternion with all components set to [code]0[/code]. + </description> + </method> + <method name="Quat"> + <return type="Quat"> + </return> + <argument index="0" name="from" type="Quat"> </argument> - <argument index="2" name="z" type="float"> + <description> + Constructs a [Quat] as a copy of the given [Quat]. + </description> + </method> + <method name="Quat"> + <return type="Quat"> + </return> + <argument index="0" name="arc_from" type="Vector3"> </argument> - <argument index="3" name="w" type="float"> + <argument index="1" name="arc_to" type="Vector3"> </argument> <description> - Constructs a quaternion defined by the given values. </description> </method> <method name="Quat"> @@ -57,6 +68,21 @@ Constructs a quaternion from the given [Basis]. </description> </method> + <method name="Quat"> + <return type="Quat"> + </return> + <argument index="0" name="x" type="float"> + </argument> + <argument index="1" name="y" type="float"> + </argument> + <argument index="2" name="z" type="float"> + </argument> + <argument index="3" name="w" type="float"> + </argument> + <description> + Constructs a quaternion defined by the given values. + </description> + </method> <method name="cubic_slerp"> <return type="Quat"> </return> diff --git a/doc/classes/RID.xml b/doc/classes/RID.xml index 644c427120..d944f7a86a 100644 --- a/doc/classes/RID.xml +++ b/doc/classes/RID.xml @@ -12,10 +12,17 @@ <method name="RID"> <return type="RID"> </return> - <argument index="0" name="from" type="Object"> + <description> + Constructs an empty [RID] with the invalid ID [code]0[/code]. + </description> + </method> + <method name="RID"> + <return type="RID"> + </return> + <argument index="0" name="from" type="RID"> </argument> <description> - Creates a new RID instance with the ID of a given resource. When not handed a valid resource, silently stores the unused ID 0. + Constructs a [RID] as a copy of the given [RID]. </description> </method> <method name="get_id"> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index a72ba35a98..b970d0188c 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -17,6 +17,31 @@ <method name="Rect2"> <return type="Rect2"> </return> + <description> + Constructs a default-initialized [Rect2] with default (zero) values of [member position] and [member size]. + </description> + </method> + <method name="Rect2"> + <return type="Rect2"> + </return> + <argument index="0" name="from" type="Rect2"> + </argument> + <description> + Constructs a [Rect2] as a copy of the given [Rect2]. + </description> + </method> + <method name="Rect2"> + <return type="Rect2"> + </return> + <argument index="0" name="from" type="Rect2i"> + </argument> + <description> + Constructs a [Rect2] from a [Rect2i]. + </description> + </method> + <method name="Rect2"> + <return type="Rect2"> + </return> <argument index="0" name="position" type="Vector2"> </argument> <argument index="1" name="size" type="Vector2"> @@ -40,15 +65,6 @@ Constructs a [Rect2] by x, y, width, and height. </description> </method> - <method name="Rect2"> - <return type="Rect2"> - </return> - <argument index="0" name="from" type="Rect2i"> - </argument> - <description> - Constructs a [Rect2] from a [Rect2i]. - </description> - </method> <method name="abs"> <return type="Rect2"> </return> diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index de2932e816..5c9162baf4 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -15,6 +15,31 @@ <method name="Rect2i"> <return type="Rect2i"> </return> + <description> + Constructs a default-initialized [Rect2i] with default (zero) values of [member position] and [member size]. + </description> + </method> + <method name="Rect2i"> + <return type="Rect2i"> + </return> + <argument index="0" name="from" type="Rect2i"> + </argument> + <description> + Constructs a [Rect2i] as a copy of the given [Rect2i]. + </description> + </method> + <method name="Rect2i"> + <return type="Rect2i"> + </return> + <argument index="0" name="from" type="Rect2"> + </argument> + <description> + Constructs a new [Rect2i] from [Rect2]. The floating point coordinates will be truncated. + </description> + </method> + <method name="Rect2i"> + <return type="Rect2i"> + </return> <argument index="0" name="position" type="Vector2i"> </argument> <argument index="1" name="size" type="Vector2i"> @@ -38,15 +63,6 @@ Constructs a [Rect2i] by x, y, width, and height. </description> </method> - <method name="Rect2i"> - <return type="Rect2i"> - </return> - <argument index="0" name="from" type="Rect2"> - </argument> - <description> - Constructs a new [Rect2i] from [Rect2]. The floating point coordinates will be truncated. - </description> - </method> <method name="abs"> <return type="Rect2i"> </return> diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml index 51490caf6f..bd091899ac 100644 --- a/doc/classes/Signal.xml +++ b/doc/classes/Signal.xml @@ -11,12 +11,28 @@ <method name="Signal"> <return type="Signal"> </return> + <description> + Constructs a null [Signal] with no object nor signal name bound. + </description> + </method> + <method name="Signal"> + <return type="Signal"> + </return> + <argument index="0" name="from" type="Signal"> + </argument> + <description> + Constructs a [Signal] as a copy of the given [Signal]. + </description> + </method> + <method name="Signal"> + <return type="Signal"> + </return> <argument index="0" name="object" type="Object"> </argument> - <argument index="1" name="signal_name" type="StringName"> + <argument index="1" name="signal" type="StringName"> </argument> <description> - Creates a new signal named [code]signal_name[/code] in the given object. + Creates a new [Signal] with the name [code]signal[/code] in the specified [code]object[/code]. </description> </method> <method name="connect"> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index fcd8f57cd1..a600a575aa 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -13,154 +13,17 @@ <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="bool"> - </argument> - <description> - Constructs a new String from the given [bool]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <description> - Constructs a new String from the given [int]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <description> - Constructs a new String from the given [float]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Vector2"> - </argument> - <description> - Constructs a new String from the given [Vector2]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Vector2i"> - </argument> - <description> - Constructs a new String from the given [Vector2i]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Rect2"> - </argument> - <description> - Constructs a new String from the given [Rect2]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Rect2i"> - </argument> - <description> - Constructs a new String from the given [Rect2i]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Vector3"> - </argument> - <description> - Constructs a new String from the given [Vector3]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Vector3i"> - </argument> - <description> - Constructs a new String from the given [Vector3i]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Transform2D"> - </argument> - <description> - Constructs a new String from the given [Transform2D]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Plane"> - </argument> - <description> - Constructs a new String from the given [Plane]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Quat"> - </argument> - <description> - Constructs a new String from the given [Quat]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="AABB"> - </argument> - <description> - Constructs a new String from the given [AABB]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Basis"> - </argument> - <description> - Constructs a new String from the given [Basis]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Transform"> - </argument> - <description> - Constructs a new String from the given [Transform]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Color"> - </argument> <description> - Constructs a new String from the given [Color]. + Constructs an empty [String] ([code]""[/code]). </description> </method> <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="StringName"> + <argument index="0" name="from" type="String"> </argument> <description> - Constructs a new String from the given [StringName]. + Constructs a [String] as a copy of the given [String]. </description> </method> <method name="String"> @@ -175,127 +38,10 @@ <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="RID"> - </argument> - <description> - Constructs a new String from the given [RID]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Callable"> - </argument> - <description> - Constructs a new String from the given [Callable]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Signal"> - </argument> - <description> - Constructs a new String from the given [Signal]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Dictionary"> - </argument> - <description> - Constructs a new String from the given [Dictionary]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="Array"> - </argument> - <description> - Constructs a new String from the given [Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedByteArray"> - </argument> - <description> - Constructs a new String from the given [PackedByteArray]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedInt32Array"> - </argument> - <description> - Constructs a new String from the given [PackedInt32Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedInt64Array"> - </argument> - <description> - Constructs a new String from the given [PackedInt64Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedFloat32Array"> - </argument> - <description> - Constructs a new String from the given [PackedFloat32Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedFloat64Array"> - </argument> - <description> - Constructs a new String from the given [PackedFloat64Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedStringArray"> - </argument> - <description> - Constructs a new String from the given [PackedStringArray]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedVector2Array"> - </argument> - <description> - Constructs a new String from the given [PackedVector2Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedVector3Array"> - </argument> - <description> - Constructs a new String from the given [PackedVector3Array]. - </description> - </method> - <method name="String"> - <return type="String"> - </return> - <argument index="0" name="from" type="PackedColorArray"> + <argument index="0" name="from" type="StringName"> </argument> <description> - Constructs a new String from the given [PackedColorArray]. + Constructs a new String from the given [StringName]. </description> </method> <method name="begins_with"> diff --git a/doc/classes/StringName.xml b/doc/classes/StringName.xml index 5d8ac6fdcc..a847d44120 100644 --- a/doc/classes/StringName.xml +++ b/doc/classes/StringName.xml @@ -12,6 +12,22 @@ <method name="StringName"> <return type="StringName"> </return> + <description> + Constructs an empty [StringName]. + </description> + </method> + <method name="StringName"> + <return type="StringName"> + </return> + <argument index="0" name="from" type="StringName"> + </argument> + <description> + Constructs a [StringName] as a copy of the given [StringName]. + </description> + </method> + <method name="StringName"> + <return type="StringName"> + </return> <argument index="0" name="from" type="String"> </argument> <description> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index 8e539e64f7..920a6c704e 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -19,54 +19,43 @@ <method name="Transform"> <return type="Transform"> </return> - <argument index="0" name="x_axis" type="Vector3"> - </argument> - <argument index="1" name="y_axis" type="Vector3"> - </argument> - <argument index="2" name="z_axis" type="Vector3"> - </argument> - <argument index="3" name="origin" type="Vector3"> - </argument> <description> - Constructs a Transform from four [Vector3] values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). + Constructs a default-initialized [Transform] set to [constant IDENTITY]. </description> </method> <method name="Transform"> <return type="Transform"> </return> - <argument index="0" name="basis" type="Basis"> - </argument> - <argument index="1" name="origin" type="Vector3"> + <argument index="0" name="from" type="Transform"> </argument> <description> - Constructs a Transform from a [Basis] and [Vector3]. + Constructs a [Transform] as a copy of the given [Transform]. </description> </method> <method name="Transform"> <return type="Transform"> </return> - <argument index="0" name="from" type="Transform2D"> + <argument index="0" name="basis" type="Basis"> </argument> - <description> - Constructs a Transform from a [Transform2D]. - </description> - </method> - <method name="Transform"> - <return type="Transform"> - </return> - <argument index="0" name="from" type="Quat"> + <argument index="1" name="origin" type="Vector3"> </argument> <description> - Constructs a Transform from a [Quat]. The origin will be [code]Vector3(0, 0, 0)[/code]. + Constructs a Transform from a [Basis] and [Vector3]. </description> </method> <method name="Transform"> <return type="Transform"> </return> - <argument index="0" name="from" type="Basis"> + <argument index="0" name="x_axis" type="Vector3"> + </argument> + <argument index="1" name="y_axis" type="Vector3"> + </argument> + <argument index="2" name="z_axis" type="Vector3"> + </argument> + <argument index="3" name="origin" type="Vector3"> </argument> <description> - Constructs the Transform from a [Basis]. The origin will be Vector3(0, 0, 0). + Constructs a Transform from four [Vector3] values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). </description> </method> <method name="affine_inverse"> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 66adeab3a6..af67ad2bd4 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -17,6 +17,22 @@ <method name="Transform2D"> <return type="Transform2D"> </return> + <description> + Constructs a default-initialized [Transform] set to [constant IDENTITY]. + </description> + </method> + <method name="Transform2D"> + <return type="Transform2D"> + </return> + <argument index="0" name="from" type="Transform2D"> + </argument> + <description> + Constructs a [Transform2D] as a copy of the given [Transform2D]. + </description> + </method> + <method name="Transform2D"> + <return type="Transform2D"> + </return> <argument index="0" name="rotation" type="float"> </argument> <argument index="1" name="position" type="Vector2"> @@ -38,15 +54,6 @@ Constructs the transform from 3 [Vector2] values representing [member x], [member y], and the [member origin] (the three column vectors). </description> </method> - <method name="Transform2D"> - <return type="Transform2D"> - </return> - <argument index="0" name="from" type="Transform"> - </argument> - <description> - Constructs the transform from a 3D [Transform]. - </description> - </method> <method name="affine_inverse"> <return type="Transform2D"> </return> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 231e0ed06a..da1526df52 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -20,6 +20,22 @@ <method name="Vector2"> <return type="Vector2"> </return> + <description> + Constructs a default-initialized [Vector2] with all components set to [code]0[/code]. + </description> + </method> + <method name="Vector2"> + <return type="Vector2"> + </return> + <argument index="0" name="from" type="Vector2"> + </argument> + <description> + Constructs a [Vector2] as a copy of the given [Vector2]. + </description> + </method> + <method name="Vector2"> + <return type="Vector2"> + </return> <argument index="0" name="from" type="Vector2i"> </argument> <description> diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml index 75ddc46dab..e5b85dff9e 100644 --- a/doc/classes/Vector2i.xml +++ b/doc/classes/Vector2i.xml @@ -17,12 +17,17 @@ <method name="Vector2i"> <return type="Vector2i"> </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> + <description> + Constructs a default-initialized [Vector2i] with all components set to [code]0[/code]. + </description> + </method> + <method name="Vector2i"> + <return type="Vector2i"> + </return> + <argument index="0" name="from" type="Vector2i"> </argument> <description> - Constructs a new [Vector2i] from the given [code]x[/code] and [code]y[/code]. + Constructs a [Vector2i] as a copy of the given [Vector2i]. </description> </method> <method name="Vector2i"> @@ -34,6 +39,17 @@ Constructs a new [Vector2i] from [Vector2]. The floating point coordinates will be truncated. </description> </method> + <method name="Vector2i"> + <return type="Vector2i"> + </return> + <argument index="0" name="x" type="int"> + </argument> + <argument index="1" name="y" type="int"> + </argument> + <description> + Constructs a new [Vector2i] from the given [code]x[/code] and [code]y[/code]. + </description> + </method> <method name="abs"> <return type="Vector2i"> </return> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 7e47f768b4..356c9501e1 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -20,6 +20,22 @@ <method name="Vector3"> <return type="Vector3"> </return> + <description> + Constructs a default-initialized [Vector3] with all components set to [code]0[/code]. + </description> + </method> + <method name="Vector3"> + <return type="Vector3"> + </return> + <argument index="0" name="from" type="Vector3"> + </argument> + <description> + Constructs a [Vector3] as a copy of the given [Vector3]. + </description> + </method> + <method name="Vector3"> + <return type="Vector3"> + </return> <argument index="0" name="from" type="Vector3i"> </argument> <description> diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml index 45e237fb23..761bddaeef 100644 --- a/doc/classes/Vector3i.xml +++ b/doc/classes/Vector3i.xml @@ -17,14 +17,17 @@ <method name="Vector3i"> <return type="Vector3i"> </return> - <argument index="0" name="x" type="int"> - </argument> - <argument index="1" name="y" type="int"> - </argument> - <argument index="2" name="z" type="int"> + <description> + Constructs a default-initialized [Vector3i] with all components set to [code]0[/code]. + </description> + </method> + <method name="Vector3i"> + <return type="Vector3i"> + </return> + <argument index="0" name="from" type="Vector3i"> </argument> <description> - Returns a [Vector3i] with the given components. + Constructs a [Vector3i] as a copy of the given [Vector3i]. </description> </method> <method name="Vector3i"> @@ -36,6 +39,19 @@ Constructs a new [Vector3i] from [Vector3]. The floating point coordinates will be truncated. </description> </method> + <method name="Vector3i"> + <return type="Vector3i"> + </return> + <argument index="0" name="x" type="int"> + </argument> + <argument index="1" name="y" type="int"> + </argument> + <argument index="2" name="z" type="int"> + </argument> + <description> + Returns a [Vector3i] with the given components. + </description> + </method> <method name="abs"> <return type="Vector3i"> </return> diff --git a/doc/classes/bool.xml b/doc/classes/bool.xml index ce4d000a9b..e9f4c2ecf4 100644 --- a/doc/classes/bool.xml +++ b/doc/classes/bool.xml @@ -94,10 +94,17 @@ <method name="bool"> <return type="bool"> </return> - <argument index="0" name="from" type="int"> + <description> + Constructs a default-initialized [bool] set to [code]false[/code]. + </description> + </method> + <method name="bool"> + <return type="bool"> + </return> + <argument index="0" name="from" type="bool"> </argument> <description> - Cast an [int] value to a boolean value, this method will return [code]false[/code] if [code]0[/code] is passed in, and [code]true[/code] for all other ints. + Constructs a [bool] as a copy of the given [bool]. </description> </method> <method name="bool"> @@ -112,11 +119,10 @@ <method name="bool"> <return type="bool"> </return> - <argument index="0" name="from" type="String"> + <argument index="0" name="from" type="int"> </argument> <description> - Cast a [String] value to a boolean value, this method will return [code]false[/code] if [code]""[/code] is passed in, and [code]true[/code] for all non-empty strings. - Examples: [code]bool("False")[/code] returns [code]true[/code], [code]bool("")[/code] returns [code]false[/code]. + Cast an [int] value to a boolean value, this method will return [code]false[/code] if [code]0[/code] is passed in, and [code]true[/code] for all other ints. </description> </method> </methods> diff --git a/doc/classes/float.xml b/doc/classes/float.xml index 16a696f959..8153d62bc9 100644 --- a/doc/classes/float.xml +++ b/doc/classes/float.xml @@ -12,28 +12,35 @@ <method name="float"> <return type="float"> </return> - <argument index="0" name="from" type="bool"> + <description> + Constructs a default-initialized [float] set to [code]0.0[/code]. + </description> + </method> + <method name="float"> + <return type="float"> + </return> + <argument index="0" name="from" type="float"> </argument> <description> - Cast a [bool] value to a floating-point value, [code]float(true)[/code] will be equal to 1.0 and [code]float(false)[/code] will be equal to 0.0. + Constructs a [float] as a copy of the given [float]. </description> </method> <method name="float"> <return type="float"> </return> - <argument index="0" name="from" type="int"> + <argument index="0" name="from" type="bool"> </argument> <description> - Cast an [int] value to a floating-point value, [code]float(1)[/code] will be equal to 1.0. + Cast a [bool] value to a floating-point value, [code]float(true)[/code] will be equal to 1.0 and [code]float(false)[/code] will be equal to 0.0. </description> </method> <method name="float"> <return type="float"> </return> - <argument index="0" name="from" type="String"> + <argument index="0" name="from" type="int"> </argument> <description> - Cast a [String] value to a floating-point value. This method accepts float value strings like [code]"1.23"[/code] and exponential notation strings for its parameter so calling [code]float("1e3")[/code] will return 1000.0 and calling [code]float("1e-3")[/code] will return 0.001. Calling this method with an invalid float string will return 0. This method stops parsing at the first invalid character and will return the parsed result so far, so calling [code]float("1a3")[/code] will return 1 while calling [code]float("1e3a2")[/code] will return 1000.0. + Cast an [int] value to a floating-point value, [code]float(1)[/code] will be equal to [code]1.0[/code]. </description> </method> </methods> diff --git a/doc/classes/int.xml b/doc/classes/int.xml index 2c9f0ad371..27d873831b 100644 --- a/doc/classes/int.xml +++ b/doc/classes/int.xml @@ -26,28 +26,35 @@ <method name="int"> <return type="int"> </return> - <argument index="0" name="from" type="bool"> + <description> + Constructs a default-initialized [int] set to [code]0[/code]. + </description> + </method> + <method name="int"> + <return type="int"> + </return> + <argument index="0" name="from" type="int"> </argument> <description> - Cast a [bool] value to an integer value, [code]int(true)[/code] will be equals to 1 and [code]int(false)[/code] will be equals to 0. + Constructs an [int] as a copy of the given [int]. </description> </method> <method name="int"> <return type="int"> </return> - <argument index="0" name="from" type="float"> + <argument index="0" name="from" type="bool"> </argument> <description> - Cast a float value to an integer value, this method simply removes the number fractions, so for example [code]int(2.7)[/code] will be equals to 2, [code]int(.1)[/code] will be equals to 0 and [code]int(-2.7)[/code] will be equals to -2. + Cast a [bool] value to an integer value, [code]int(true)[/code] will be equals to 1 and [code]int(false)[/code] will be equals to 0. </description> </method> <method name="int"> <return type="int"> </return> - <argument index="0" name="from" type="String"> + <argument index="0" name="from" type="float"> </argument> <description> - Cast a [String] value to an integer value, this method is an integer parser from a string, so calling this method with an invalid integer string will return 0, a valid string will be something like [code]'1.7'[/code]. This method will ignore all non-number characters, so calling [code]int('1e3')[/code] will return 13. + Cast a float value to an integer value, this method simply removes the number fractions, so for example [code]int(2.7)[/code] will be equals to 2, [code]int(.1)[/code] will be equals to 0 and [code]int(-2.7)[/code] will be equals to -2. </description> </method> </methods> diff --git a/editor/doc_data.cpp b/editor/doc_data.cpp index 5cede65fa6..6767159721 100644 --- a/editor/doc_data.cpp +++ b/editor/doc_data.cpp @@ -569,11 +569,61 @@ void DocData::generate(bool p_basic_types) { method_list.sort(); Variant::get_constructor_list(Variant::Type(i), &method_list); + for (int j = 0; j < Variant::OP_AND; j++) { //showing above 'and' is pretty confusing and there are a lot of variations + + for (int k = 0; k < Variant::VARIANT_MAX; k++) { + Variant::Type rt = Variant::get_operator_return_type(Variant::Operator(j), Variant::Type(i), Variant::Type(k)); + if (rt != Variant::NIL) { + //has operator + MethodInfo mi; + mi.name = "operator " + Variant::get_operator_name(Variant::Operator(j)); + mi.return_val.type = rt; + if (k != Variant::NIL) { + PropertyInfo arg; + arg.name = "right"; + arg.type = Variant::Type(k); + mi.arguments.push_back(arg); + } + method_list.push_back(mi); + } + } + } + + if (Variant::is_keyed(Variant::Type(i))) { + MethodInfo mi; + mi.name = "operator []"; + mi.return_val.type = Variant::NIL; + mi.return_val.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + + PropertyInfo arg; + arg.name = "key"; + arg.type = Variant::NIL; + arg.usage = PROPERTY_USAGE_NIL_IS_VARIANT; + mi.arguments.push_back(arg); + + method_list.push_back(mi); + } else if (Variant::has_indexing(Variant::Type(i))) { + MethodInfo mi; + mi.name = "operator []"; + mi.return_val.type = Variant::get_indexed_element_type(Variant::Type(i)); + PropertyInfo arg; + arg.name = "index"; + arg.type = Variant::INT; + mi.arguments.push_back(arg); + + method_list.push_back(mi); + } + for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { MethodInfo &mi = E->get(); MethodDoc method; method.name = mi.name; + if (method.name == cname) { + method.qualifiers = "constructor"; + } else if (method.name.begins_with("operator")) { + method.qualifiers = "operator"; + } for (int j = 0; j < mi.arguments.size(); j++) { PropertyInfo arginfo = mi.arguments[j]; diff --git a/editor/doc_data.h b/editor/doc_data.h index 5fa20c6f0c..2cb475d137 100644 --- a/editor/doc_data.h +++ b/editor/doc_data.h @@ -43,6 +43,9 @@ public: String enumeration; String default_value; bool operator<(const ArgumentDoc &p_arg) const { + if (name == p_arg.name) { + return type < p_arg.type; + } return name < p_arg.name; } }; @@ -55,6 +58,20 @@ public: String description; Vector<ArgumentDoc> arguments; bool operator<(const MethodDoc &p_method) const { + if (name == p_method.name) { + // Must be a constructor since there is no overloading. + // We want this arbitrary order for a class "Foo": + // - 1. Default constructor: Foo() + // - 2. Copy constructor: Foo(Foo) + // - 3+. Other constructors Foo(Bar, ...) based on first argument's name + if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1. + return arguments.size() < p_method.arguments.size(); + } + if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2. + return (arguments[0].type == return_type) || (p_method.arguments[0].type != p_method.return_type); + } + return arguments[0] < p_method.arguments[0]; + } return name < p_method.name; } }; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 2052319e3e..ee0ee91893 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2665,7 +2665,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { editor = p_editor; path = "res://"; - ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_C); + // `KEY_MASK_CMD | KEY_C` conflicts with other editor shortcuts. + ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_C); ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D); ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE); ED_SHORTCUT("filesystem_dock/rename", TTR("Rename")); diff --git a/main/main.cpp b/main/main.cpp index 0667180c28..3905366598 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1608,7 +1608,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { GLOBAL_DEF("application/config/icon", String()); ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon", PropertyInfo(Variant::STRING, "application/config/icon", - PROPERTY_HINT_FILE, "*.png,*.webp")); + PROPERTY_HINT_FILE, "*.png,*.webp,*.svg,*.svgz")); GLOBAL_DEF("application/config/macos_native_icon", String()); ProjectSettings::get_singleton()->set_custom_property_info("application/config/macos_native_icon", diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 0582d95f63..6043351e84 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -35,8 +35,13 @@ extern "C" { #endif +#include <stddef.h> #include <stdint.h> -#include <wchar.h> + +#ifndef __cplusplus +typedef uint32_t char32_t; +typedef uint16_t char16_t; +#endif typedef char32_t godot_char_type; diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index a3f428c12d..d90b3e52d0 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -387,24 +387,6 @@ [/codeblock] </description> </method> - <method name="funcref"> - <return type="FuncRef"> - </return> - <argument index="0" name="instance" type="Object"> - </argument> - <argument index="1" name="funcname" type="String"> - </argument> - <description> - Returns a reference to the specified function [code]funcname[/code] in the [code]instance[/code] node. As functions aren't first-class objects in GDscript, use [code]funcref[/code] to store a [FuncRef] in a variable and call it later. - [codeblock] - func foo(): - return("bar") - - a = funcref(self, "foo") - print(a.call_func()) # Prints bar - [/codeblock] - </description> - </method> <method name="get_stack"> <return type="Array"> </return> @@ -922,35 +904,6 @@ [/codeblock] </description> </method> - <method name="randf_range"> - <return type="float"> - </return> - <argument index="0" name="from" type="float"> - </argument> - <argument index="1" name="to" type="float"> - </argument> - <description> - Random range, any floating point value between [code]from[/code] and [code]to[/code]. - [codeblock] - prints(randf_range(-10, 10), randf_range(-10, 10)) # Prints e.g. -3.844535 7.45315 - [/codeblock] - </description> - </method> - <method name="randi_range"> - <return type="int"> - </return> - <argument index="0" name="from" type="int"> - </argument> - <argument index="1" name="to" type="int"> - </argument> - <description> - Random range, any 32-bit integer value between [code]from[/code] and [code]to[/code] (inclusive). If [code]to[/code] is lesser than [code]from[/code] they are swapped. - [codeblock] - print(randi_range(0, 1)) # Prints 0 or 1 - print(randi_range(-10, 1000)) # Prints any number from -10 to 1000 - [/codeblock] - </description> - </method> <method name="rand_seed"> <return type="Array"> </return> @@ -970,6 +923,20 @@ [/codeblock] </description> </method> + <method name="randf_range"> + <return type="float"> + </return> + <argument index="0" name="from" type="float"> + </argument> + <argument index="1" name="to" type="float"> + </argument> + <description> + Random range, any floating point value between [code]from[/code] and [code]to[/code]. + [codeblock] + prints(randf_range(-10, 10), randf_range(-10, 10)) # Prints e.g. -3.844535 7.45315 + [/codeblock] + </description> + </method> <method name="randi"> <return type="int"> </return> @@ -983,6 +950,21 @@ [/codeblock] </description> </method> + <method name="randi_range"> + <return type="int"> + </return> + <argument index="0" name="from" type="int"> + </argument> + <argument index="1" name="to" type="int"> + </argument> + <description> + Random range, any 32-bit integer value between [code]from[/code] and [code]to[/code] (inclusive). If [code]to[/code] is lesser than [code]from[/code] they are swapped. + [codeblock] + print(randi_range(0, 1)) # Prints 0 or 1 + print(randi_range(-10, 1000)) # Prints any number from -10 to 1000 + [/codeblock] + </description> + </method> <method name="randomize"> <return type="void"> </return> diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index ca1215b0bd..000fbd0140 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -166,63 +166,60 @@ <constant name="OBJ_WEAKREF" value="50" enum="BuiltinFunc"> Create a [WeakRef] from the input. </constant> - <constant name="FUNC_FUNCREF" value="51" enum="BuiltinFunc"> - Create a [FuncRef] from the input. - </constant> - <constant name="TYPE_CONVERT" value="52" enum="BuiltinFunc"> + <constant name="TYPE_CONVERT" value="51" enum="BuiltinFunc"> Convert between types. </constant> - <constant name="TYPE_OF" value="53" enum="BuiltinFunc"> + <constant name="TYPE_OF" value="52" enum="BuiltinFunc"> Return the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned. </constant> - <constant name="TYPE_EXISTS" value="54" enum="BuiltinFunc"> + <constant name="TYPE_EXISTS" value="53" enum="BuiltinFunc"> Checks if a type is registered in the [ClassDB]. </constant> - <constant name="TEXT_CHAR" value="55" enum="BuiltinFunc"> + <constant name="TEXT_CHAR" value="54" enum="BuiltinFunc"> Return a character with the given ascii value. </constant> - <constant name="TEXT_STR" value="56" enum="BuiltinFunc"> + <constant name="TEXT_STR" value="55" enum="BuiltinFunc"> Convert the input to a string. </constant> - <constant name="TEXT_PRINT" value="57" enum="BuiltinFunc"> + <constant name="TEXT_PRINT" value="56" enum="BuiltinFunc"> Print the given string to the output window. </constant> - <constant name="TEXT_PRINTERR" value="58" enum="BuiltinFunc"> + <constant name="TEXT_PRINTERR" value="57" enum="BuiltinFunc"> Print the given string to the standard error output. </constant> - <constant name="TEXT_PRINTRAW" value="59" enum="BuiltinFunc"> + <constant name="TEXT_PRINTRAW" value="58" enum="BuiltinFunc"> Print the given string to the standard output, without adding a newline. </constant> - <constant name="VAR_TO_STR" value="60" enum="BuiltinFunc"> + <constant name="VAR_TO_STR" value="59" enum="BuiltinFunc"> Serialize a [Variant] to a string. </constant> - <constant name="STR_TO_VAR" value="61" enum="BuiltinFunc"> + <constant name="STR_TO_VAR" value="60" enum="BuiltinFunc"> Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR]. </constant> - <constant name="VAR_TO_BYTES" value="62" enum="BuiltinFunc"> + <constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc"> Serialize a [Variant] to a [PackedByteArray]. </constant> - <constant name="BYTES_TO_VAR" value="63" enum="BuiltinFunc"> + <constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc"> Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES]. </constant> - <constant name="COLORN" value="64" enum="BuiltinFunc"> + <constant name="COLORN" value="63" enum="BuiltinFunc"> Return the [Color] with the given name and alpha ranging from 0 to 1. [b]Note:[/b] Names are defined in [code]color_names.inc[/code]. </constant> - <constant name="MATH_SMOOTHSTEP" value="65" enum="BuiltinFunc"> + <constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc"> Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula: [codeblock] var t = clamp((weight - from) / (to - from), 0.0, 1.0) return t * t * (3.0 - 2.0 * t) [/codeblock] </constant> - <constant name="MATH_POSMOD" value="66" enum="BuiltinFunc"> + <constant name="MATH_POSMOD" value="65" enum="BuiltinFunc"> </constant> - <constant name="MATH_LERP_ANGLE" value="67" enum="BuiltinFunc"> + <constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc"> </constant> - <constant name="TEXT_ORD" value="68" enum="BuiltinFunc"> + <constant name="TEXT_ORD" value="67" enum="BuiltinFunc"> </constant> - <constant name="FUNC_MAX" value="69" enum="BuiltinFunc"> + <constant name="FUNC_MAX" value="68" enum="BuiltinFunc"> Represents the size of the [enum BuiltinFunc] enum. </constant> </constants> diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index fdce55320c..bea5e9e432 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -905,6 +905,8 @@ bool AudioServer::is_bus_channel_active(int p_bus, int p_channel) const { } void AudioServer::set_global_rate_scale(float p_scale) { + ERR_FAIL_COND(p_scale <= 0); + global_rate_scale = p_scale; } |