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:
parent
f5e50b1f6b
commit
7c6feb4caf
1 changed files with 89 additions and 37 deletions
126
src/misc.gd
126
src/misc.gd
|
@ -167,18 +167,35 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
|
||||||
|
|
||||||
match(typeof(value)):
|
match(typeof(value)):
|
||||||
# Primitives
|
# Primitives
|
||||||
Variant.Type.TYPE_NIL: replacement = "null"
|
Variant.Type.TYPE_NIL:
|
||||||
Variant.Type.TYPE_BOOL: replacement = str(value)
|
replacement = "null"
|
||||||
Variant.Type.TYPE_INT: replacement = str(value)
|
type = ""
|
||||||
Variant.Type.TYPE_FLOAT: replacement = str(value)
|
Variant.Type.TYPE_BOOL:
|
||||||
Variant.Type.TYPE_STRING: replacement = "\"" + value + "\""
|
replacement = str(value)
|
||||||
Variant.Type.TYPE_STRING_NAME: replacement = "\"" + 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
|
# Non-primitives
|
||||||
Variant.Type.TYPE_OBJECT: replacement = str(value)
|
Variant.Type.TYPE_OBJECT:
|
||||||
|
replacement = str(value)
|
||||||
|
type = "Object"
|
||||||
Variant.Type.TYPE_COLOR:
|
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)
|
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)
|
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:
|
Variant.Type.TYPE_ARRAY:
|
||||||
if config_stringify_array:
|
if config_stringify_array:
|
||||||
if value.size() == 0:
|
if value.size() == 0:
|
||||||
|
@ -190,6 +207,10 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
|
||||||
else: replacement += ", " + _sa(item)
|
else: replacement += ", " + _sa(item)
|
||||||
replacement += " ]"
|
replacement += " ]"
|
||||||
else: replacement = str(value)
|
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:
|
Variant.Type.TYPE_DICTIONARY:
|
||||||
if config_stringify_dictionary:
|
if config_stringify_dictionary:
|
||||||
if value.size() == 0: replacement = "{}"
|
if value.size() == 0: replacement = "{}"
|
||||||
|
@ -200,44 +221,75 @@ func stringify_variables(template: String, variables: Dictionary, no_quotes: boo
|
||||||
else: replacement += ", " + _sa(key)
|
else: replacement += ", " + _sa(key)
|
||||||
replacement += " }"
|
replacement += " }"
|
||||||
else: replacement = str(value)
|
else: replacement = str(value)
|
||||||
|
type = "Dictionary"
|
||||||
# TODO: Packed Arrays
|
# TODO: Packed Arrays
|
||||||
# Nodes & scripting
|
# Nodes & scripting
|
||||||
Variant.Type.TYPE_NODE_PATH: replacement = str(value)
|
Variant.Type.TYPE_NODE_PATH:
|
||||||
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())
|
replacement = str(value)
|
||||||
Variant.Type.TYPE_SIGNAL: replacement = "name=" + _sa(value.get_name()) + " object=" + _sa(value.get_object())
|
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
|
# 2D
|
||||||
Variant.Type.TYPE_VECTOR2: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
|
Variant.Type.TYPE_VECTOR2:
|
||||||
Variant.Type.TYPE_VECTOR2I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y)
|
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)
|
type = "Vector2"
|
||||||
Variant.Type.TYPE_RECT2I: replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
|
Variant.Type.TYPE_VECTOR2I:
|
||||||
Variant.Type.TYPE_TRANSFORM2D: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " origin=" + _sa(value.origin)
|
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
|
# 3D
|
||||||
Variant.Type.TYPE_VECTOR3: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
|
Variant.Type.TYPE_VECTOR3:
|
||||||
Variant.Type.TYPE_VECTOR3I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
|
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)
|
type = "Vector3"
|
||||||
Variant.Type.TYPE_QUATERNION: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
|
Variant.Type.TYPE_VECTOR3I:
|
||||||
Variant.Type.TYPE_AABB: replacement = "size=" + _sa(value.size) + " pos=" + _sa(value.position) + " end=" + _sa(value.end)
|
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
|
||||||
Variant.Type.TYPE_TRANSFORM3D: replacement = "basis=" + _sa(value.basis) + " origin=" + _sa(value.origin)
|
type = "Vector3i"
|
||||||
Variant.Type.TYPE_BASIS: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z)
|
Variant.Type.TYPE_PLANE:
|
||||||
Variant.Type.TYPE_PROJECTION: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
|
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
|
# 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_VECTOR4:
|
||||||
Variant.Type.TYPE_VECTOR4I: replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
|
replacement = "x=" + _sa(value.x) + " y=" + _sa(value.y) + " z=" + _sa(value.z) + " w=" + _sa(value.w)
|
||||||
# etc
|
type = "Vector4"
|
||||||
Variant.Type.TYPE_MAX: replacement = str(value)
|
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)
|
replacement = str(value)
|
||||||
type = "(unknown) "
|
type = "unknown"
|
||||||
|
|
||||||
# Replace
|
# Replace
|
||||||
if config_stringify_show_type and type == "":
|
if config_stringify_show_type:
|
||||||
match(typeof(value)):
|
if type != "": type = "(" + type.to_lower() + ") "
|
||||||
Variant.Type.TYPE_NIL: type = ""
|
else:
|
||||||
Variant.Type.TYPE_MAX: type = "(invalid) "
|
type = ""
|
||||||
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.
|
|
||||||
var quote: String = "'" if !no_quotes else ""
|
var quote: String = "'" if !no_quotes else ""
|
||||||
template = template.replace("%" + placeholder + "%", quote + type + replacement + quote)
|
template = template.replace("%" + placeholder + "%", quote + type + replacement + quote)
|
||||||
return template
|
return template
|
||||||
|
|
Loading…
Reference in a new issue