From b67082e9ddf676825d52759c83d20ce524420676 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 21 Mar 2022 15:09:56 +0100 Subject: [PATCH] Added gdscript support for the new types . --- modules/gdscript/gdscript_editor.cpp | 7 ++++--- modules/gdscript/gdscript_functions.cpp | 8 ++++++++ modules/gdscript/gdscript_parser.cpp | 5 +++++ modules/gdscript/gdscript_tokenizer.cpp | 5 +++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 791117fad..6450fea3c 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2180,9 +2180,10 @@ static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p } static const char *_type_names[Variant::VARIANT_MAX] = { - "null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", - "Color", "NodePath", "RID", "Object", "Dictionary", "Array", "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", - "PoolVector2Array", "PoolVector3Array", "PoolColorArray" + "null", "bool", "int", "float", "String", "Vector2", "Vector2i", "Rect2", "Rect2i", "Vector3", "Vector3i", "Transform2D", "Plane", + "Quat", "AABB", "Basis", "Transform", "Color", "NodePath", "RID", "Object", "Dictionary", "Array", + "PoolByteArray", "PoolIntArray", "PoolRealArray", "PoolStringArray", + "PoolVector2Array", "PoolVector2iArray", "PoolVector3Array", "PoolVector3iArray", "PoolColorArray" }; for (int i = 0; i < Variant::VARIANT_MAX; i++) { diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index b1d9f964b..a114bac8b 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1359,10 +1359,18 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ PoolVector d = *p_args[0]; r_ret = d.size(); } break; + case Variant::POOL_VECTOR2I_ARRAY: { + PoolVector d = *p_args[0]; + r_ret = d.size(); + } break; case Variant::POOL_VECTOR3_ARRAY: { PoolVector d = *p_args[0]; r_ret = d.size(); } break; + case Variant::POOL_VECTOR3I_ARRAY: { + PoolVector d = *p_args[0]; + r_ret = d.size(); + } break; case Variant::POOL_COLOR_ARRAY: { PoolVector d = *p_args[0]; r_ret = d.size(); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index dc0d6c82e..5c643dc40 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -6725,13 +6725,16 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { case Variant::POOL_REAL_ARRAY: case Variant::POOL_STRING_ARRAY: case Variant::POOL_VECTOR2_ARRAY: + case Variant::POOL_VECTOR2I_ARRAY: case Variant::POOL_VECTOR3_ARRAY: + case Variant::POOL_VECTOR3I_ARRAY: case Variant::ARRAY: case Variant::STRING: { error = index_type.builtin_type != Variant::INT && index_type.builtin_type != Variant::REAL; } break; // Expect String only case Variant::RECT2: + case Variant::RECT2I: case Variant::PLANE: case Variant::QUAT: case Variant::AABB: @@ -6740,7 +6743,9 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { } break; // Expect String or number case Variant::VECTOR2: + case Variant::VECTOR2I: case Variant::VECTOR3: + case Variant::VECTOR3I: case Variant::TRANSFORM2D: case Variant::BASIS: case Variant::TRANSFORM: { diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 742a40046..75cb4b7a5 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -151,9 +151,12 @@ static const _bit _type_list[] = { { Variant::REAL, "float" }, { Variant::STRING, "String" }, { Variant::VECTOR2, "Vector2" }, + { Variant::VECTOR2I, "Vector2i" }, { Variant::RECT2, "Rect2" }, + { Variant::RECT2I, "Rect2i" }, { Variant::TRANSFORM2D, "Transform2D" }, { Variant::VECTOR3, "Vector3" }, + { Variant::VECTOR3I, "Vector3i" }, { Variant::AABB, "AABB" }, { Variant::PLANE, "Plane" }, { Variant::QUAT, "Quat" }, @@ -170,7 +173,9 @@ static const _bit _type_list[] = { { Variant::POOL_REAL_ARRAY, "PoolRealArray" }, { Variant::POOL_STRING_ARRAY, "PoolStringArray" }, { Variant::POOL_VECTOR2_ARRAY, "PoolVector2Array" }, + { Variant::POOL_VECTOR2I_ARRAY, "PoolVector2iArray" }, { Variant::POOL_VECTOR3_ARRAY, "PoolVector3Array" }, + { Variant::POOL_VECTOR3I_ARRAY, "PoolVector3iArray" }, { Variant::POOL_COLOR_ARRAY, "PoolColorArray" }, { Variant::VARIANT_MAX, nullptr }, };