The dumbest yet best way to fix xd

btw. if you see an older commit referencing some issue or pr just keep in mind that it no longer exists because i accidentally rm -rf'd the data partition on the staropensource server and lost all databases including the forgejo database. unfortunate, i know, but it happened.
This commit is contained in:
JeremyStar™ 2024-04-23 21:01:51 +02:00
parent f5e50b1f6b
commit 7c6feb4caf
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -167,18 +167,35 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
match(typeof(value)):
# Primitives
Variant.Type.TYPE_NIL: replacement = "null"
Variant.Type.TYPE_BOOL: replacement = str(value)
Variant.Type.TYPE_INT: replacement = str(value)
Variant.Type.TYPE_FLOAT: replacement = str(value)
Variant.Type.TYPE_STRING: replacement = "\"" + value + "\""
Variant.Type.TYPE_STRING_NAME: replacement = "\"" + value + "\""
Variant.Type.TYPE_NIL:
replacement = "null"
type = ""
Variant.Type.TYPE_BOOL:
replacement = str(value)
type = "bool"
Variant.Type.TYPE_INT:
replacement = str(value)
type = "int"
Variant.Type.TYPE_FLOAT:
replacement = str(value)
type = "float"
Variant.Type.TYPE_STRING:
replacement = "\"" + value + "\""
type = "String"
Variant.Type.TYPE_STRING_NAME:
replacement = "\"" + value + "\""
type = "StringName"
# Non-primitives
Variant.Type.TYPE_OBJECT: replacement = str(value)
Variant.Type.TYPE_OBJECT:
replacement = str(value)
type = "Object"
Variant.Type.TYPE_COLOR:
if config_stringify_color_range8: replacement = "r=" + _sa(value.r8) + " g=" + _sa(value.g8) + " b=" + _sa(value.b8) + " a=" + _sa(value.a8)
else: replacement = "r=" + _sa(value.r) + " g=" + _sa(value.g) + " b=" + _sa(value.b) + " a=" + _sa(value.a)
Variant.Type.TYPE_RID: replacement = "id=" + _sa(value.get_id()) + " valid=" + _sa(value.is_valid())
type = "Color"
Variant.Type.TYPE_RID:
replacement = "id=" + _sa(value.get_id()) + " valid=" + _sa(value.is_valid())
type = "RID"
Variant.Type.TYPE_ARRAY:
if config_stringify_array:
if value.size() == 0:
@ -190,6 +207,10 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
else: replacement += ", " + _sa(item)
replacement += " ]"
else: replacement = str(value)
if value.get_typed_builtin() != TYPE_NIL:
type = "Array[" + type_string(typeof(value.get_typed_builtin())) + "]"
else:
type = "Array"
Variant.Type.TYPE_DICTIONARY:
if config_stringify_dictionary:
if value.size() == 0: replacement = "{}"
@ -200,44 +221,75 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
else: replacement += ", " + _sa(key)
replacement += " }"
else: replacement = str(value)
type = "Dictionary"
# TODO: Packed Arrays
# Nodes & scripting
Variant.Type.TYPE_NODE_PATH: replacement = str(value)
Variant.Type.TYPE_CALLABLE: replacement = "valid=" + _sa(value.is_valid()) + " standard=" + _sa(value.is_standard()) + " object=" + _sa(value.get_object() ) + " method=" + value.get_method() + " args=" + _sa(value.get_bound_arguments())
Variant.Type.TYPE_SIGNAL: replacement = "name=" + _sa(value.get_name()) + " object=" + _sa(value.get_object())
Variant.Type.TYPE_NODE_PATH:
replacement = str(value)
type = "NodePath"
Variant.Type.TYPE_CALLABLE:
replacement = "valid=" + _sa(value.is_valid()) + " standard=" + _sa(value.is_standard()) + " object=" + _sa(value.get_object() ) + " method=" + value.get_method() + " args=" + _sa(value.get_bound_arguments())
type = "Callable"
Variant.Type.TYPE_SIGNAL:
replacement = "name=" + _sa(value.get_name()) + " object=" + _sa(value.get_object())
type = "Signal"
# 2D
Variant.Type.TYPE_VECTOR2: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
Variant.Type.TYPE_VECTOR2I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
Variant.Type.TYPE_RECT2: replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
Variant.Type.TYPE_RECT2I: replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
Variant.Type.TYPE_TRANSFORM2D: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " origin=" + _sa(value.origin)
Variant.Type.TYPE_VECTOR2:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
type = "Vector2"
Variant.Type.TYPE_VECTOR2I:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
type = "Vector2i"
Variant.Type.TYPE_RECT2:
replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
type = "Rect2"
Variant.Type.TYPE_RECT2I:
replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
type = "Rect2i"
Variant.Type.TYPE_TRANSFORM2D:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " origin=" + _sa(value.origin)
type = "Transform2D"
# 3D
Variant.Type.TYPE_VECTOR3: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
Variant.Type.TYPE_VECTOR3I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
Variant.Type.TYPE_PLANE: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " d=" + _sa(value.d) + " normal=" + _sa(value.normal)
Variant.Type.TYPE_QUATERNION: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
Variant.Type.TYPE_AABB: replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
Variant.Type.TYPE_TRANSFORM3D: replacement = "basis=" + _sa(value.basis) + " origin=" + _sa(value.origin)
Variant.Type.TYPE_BASIS: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
Variant.Type.TYPE_PROJECTION: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
Variant.Type.TYPE_VECTOR3:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
type = "Vector3"
Variant.Type.TYPE_VECTOR3I:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
type = "Vector3i"
Variant.Type.TYPE_PLANE:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " d=" + _sa(value.d) + " normal=" + _sa(value.normal)
type = "Plane"
Variant.Type.TYPE_QUATERNION:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
type = "Quaternion"
Variant.Type.TYPE_AABB:
replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
type = "AABB"
Variant.Type.TYPE_TRANSFORM3D:
replacement = "basis=" + _sa(value.basis) + " origin=" + _sa(value.origin)
type = "Transform3D"
Variant.Type.TYPE_BASIS:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
type = "Basis"
Variant.Type.TYPE_PROJECTION:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
type = "Projection"
# 4D
Variant.Type.TYPE_VECTOR4: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
Variant.Type.TYPE_VECTOR4I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
# etc
Variant.Type.TYPE_MAX: replacement = str(value)
Variant.Type.TYPE_VECTOR4:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
type = "Vector4"
Variant.Type.TYPE_VECTOR4I:
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
type = "Vector4i"
_:
replacement = str(value)
type = "(unknown) "
type = "unknown"
# Replace
if config_stringify_show_type and type == "":
match(typeof(value)):
Variant.Type.TYPE_NIL: type = ""
Variant.Type.TYPE_MAX: type = "(invalid) "
Variant.Type.TYPE_ARRAY:
if value.get_typed_builtin() != TYPE_NIL:
type = "(" + type_string(typeof(value)).to_lower() + "[" + type_string(typeof(value.get_typed_builtin())).to_lower() + "]) "
_: type = "(" + type_string(typeof(value)).to_lower() + ") " # something is causing almost everything to be displayed as a boolean, which is not true. i don't know what's the problem here however.
if config_stringify_show_type:
if type != "": type = "(" + type.to_lower() + ") "
else:
type = ""
var quote: String = "'" if !no_quotes else ""
template = template.replace("%" + placeholder + "%", quote + type + replacement + quote)
return template