Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoherent Property hint_string with Array #89816

Closed
m21-cerutti opened this issue Mar 23, 2024 · 1 comment · Fixed by #90716
Closed

Incoherent Property hint_string with Array #89816

m21-cerutti opened this issue Mar 23, 2024 · 1 comment · Fixed by #90716

Comments

@m21-cerutti
Copy link

m21-cerutti commented Mar 23, 2024

Tested versions

Godot v4.2.stable (46dc277)

System information

Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.5152) - 11th Gen Intel(R) Core(TM) i7-11700KF @ 3.60GHz (16 Threads)

Issue description

When trying to do a custom inspector for a "in-game" tool, I have problems with PROPERTY_HINT_TYPE_STRING wrong documentation, or bug that the last type (for the element) is its name as string instead of a type value (Variant).
Make the parsing for nested type incoherent.

In the documentation for 2D Array:
1D Array

hint_string = "%d:" % [elem_type]
hint_string = "%d/%d:%s" % [elem_type, elem_hint, elem_hint_string]

2D Array

hint_string = "%d:%d:" % [TYPE_ARRAY, elem_type]
hint_string = "%d:%d/%d:%s" % [TYPE_ARRAY, elem_type, elem_hint, elem_hint_string]

https://docs.godotengine.org/en/4.2/classes/class_@globalscope.html#enum-globalscope-propertyhint

But what I get for 1D Array:

hint_string = "%d:%s" % [elem_type, elem_type_name]

And for 2D Array:

hint_string = "%d:%s" % [TYPE_ARRAY, TYPE_ARRAY_name]

There is also some incoherency between arrays and non arrays about PropertyHint and get_property_list().
Like why using hint_string instead of class_name for built_in types ?
Why mixing type names and type values in hint_string ? Ok for for using "/" for property_hint separation, if checking for nested type only would check the first part, but would expect first part with type values only. I think there is something to do to allow like type stacking.

Steps to reproduce

  1. Use the associated MRP that test on
@export var test_bool: bool = false
@export var test_string: String = "test"
@export var test_arraybool: Array[bool] = [true, false]
@export var test_arayaraaystring: Array[Array] = [["string1", "string2"],["string3", "string4"]]
@export var test_arayaraaybool: Array[Array] = [[true, true],[true, false]]

@export var testResource: CustomResource = CustomResource.new()
@export var test_arayresource: Array[CustomResource] = [CustomResource.new()]
  1. Run the main scene

Get result :

{ "name": "test_bool", "class_name": &"", "type": 1, "hint": 0, "hint_string": "bool", "usage": 4102 }

{ "name": "test_string", "class_name": &"", "type": 4, "hint": 0, "hint_string": "String", "usage": 4102 }

{ "name": "test_arraybool", "class_name": &"", "type": 28, "hint": 23, "hint_string": "1:bool", "usage": 4102 }

{ "name": "test_arayaraaystring", "class_name": &"", "type": 28, "hint": 23, "hint_string": "28:Array", "usage": 4102 }

{ "name": "test_arayaraaybool", "class_name": &"", "type": 28, "hint": 23, "hint_string": "28:Array", "usage": 4102 }

{ "name": "testResource", "class_name": &"CustomResource", "type": 24, "hint": 17, "hint_string": "CustomResource", "usage": 4102 }

{ "name": "test_arayresource", "class_name": &"", "type": 28, "hint": 23, "hint_string": "24/17:CustomResource", "usage": 4102 }

What would be expected (with some sugestions about class_name):

{ "name": "test_bool", "class_name": &"bool", "type": 1, "hint": 0, "hint_string": "1", "usage": 4102 }

{ "name": "test_string", "class_name": &"String", "type": 4, "hint": 0, "hint_string": "4", "usage": 4102 }

{ "name": "test_arraybool", "class_name": &"Array[bool]", "type": 28, "hint": 23, "hint_string": "1/:bool", "usage": 4102 }

{ "name": "test_arayaraaystring", "class_name": &"Array[Array]", "type": 28, "hint": 23, "hint_string": "28:", "usage": 4102 }

{ "name": "test_arayaraaybool", "class_name": &"", "type": 28, "hint": 23, "hint_string": "28:", "usage": 4102 }

{ "name": "test_ressource", "class_name": &"CustomResource", "type": 24, "hint": 17, "hint_string": "CustomResource", "usage": 4102 }

{ "name": "test_arayressource", "class_name": &"", "type": 28, "hint": 23, "hint_string": "24/17:CustomResource", "usage": 4102 }

Note that due to limitation with nested types, test_arayaraaystring and test_arayaraaybool are the same.

Minimal reproduction project (MRP)

IncoherentProperty.zip

@m21-cerutti
Copy link
Author

m21-cerutti commented Mar 24, 2024

Also for enum it's kind of special parsing case since we can have ":" for index values:

{ "name": "test_enum", "class_name": &"res://test_script.gd.Test", "type": 2, "hint": 2, "hint_string": "Test 1:0,Test 2:1", "usage": 69638 }
{ "name": "test_arayenum", "class_name": &"", "type": 28, "hint": 23, "hint_string": "2/2:Test 1:0,Test 2:1", "usage": 69638 }

We could have instead


{ "name": "test_enum", "class_name": &"res://test_script.gd.Test", "type": 2, "hint": 2, "hint_string": "Test 1,0;Test 2,1", "usage": 69638 }
{ "name": "test_arayenum", "class_name": &"", "type": 28, "hint": 23, "hint_string": "2/2:Test 1,0;Test 2,1", "usage": 69638 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants