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

Include type in tooltip #287

Merged
merged 1 commit into from
Oct 23, 2024
Merged

Include type in tooltip #287

merged 1 commit into from
Oct 23, 2024

Conversation

DoomTas3r
Copy link
Contributor

@DoomTas3r DoomTas3r commented Oct 23, 2024

The variant name as a string is appended to the description. If null, then no type is shown

Helping with #271 (comment)
image
image
image
image
image
image

Copy link
Member

@cassidyjames cassidyjames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let someone else review the implementation/code itself, but I like this from a UX perspective. :) It keeps the slightly technical information in the tooltip where we're already exposing that sort of thing, and displays it consistently. 👍🏻

In the spirit of progressive disclosure, it can help learners (or mentors/instructors!) better understand how/why things work the way they do, without overloading the block UI itself.

@DoomTas3r DoomTas3r marked this pull request as ready for review October 23, 2024 18:22
Comment on lines 220 to 249
if definition.variant_type == Variant.Type.TYPE_NIL:
return definition.description
elif definition.variant_type == Variant.Type.TYPE_BOOL:
variant_as_string = "Boolean"
elif definition.variant_type == Variant.Type.TYPE_INT:
variant_as_string = "Integer"
elif definition.variant_type == Variant.Type.TYPE_FLOAT:
variant_as_string = "Float"
elif definition.variant_type == Variant.Type.TYPE_STRING:
variant_as_string = "String"
elif definition.variant_type == Variant.Type.TYPE_VECTOR2:
variant_as_string = "Vector2"
elif definition.variant_type == Variant.Type.TYPE_COLOR:
variant_as_string = "Color"
elif definition.variant_type == Variant.Type.TYPE_NODE_PATH:
variant_as_string = "NodePath"
elif definition.variant_type == Variant.Type.TYPE_OBJECT:
variant_as_string = "Object"
elif definition.variant_type == Variant.Type.TYPE_CALLABLE:
variant_as_string = "Callable"
elif definition.variant_type == Variant.Type.TYPE_SIGNAL:
variant_as_string = "Signal"
elif definition.variant_type == Variant.Type.TYPE_DICTIONARY:
variant_as_string = "Dictionary"
elif definition.variant_type == Variant.Type.TYPE_ARRAY:
variant_as_string = "Array"
else:
variant_as_string = "Undefined"

return definition.description + "\n\nType: [b]" + variant_as_string + "[/b]"
Copy link
Member

@wjt wjt Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead do this:

Suggested change
if definition.variant_type == Variant.Type.TYPE_NIL:
return definition.description
elif definition.variant_type == Variant.Type.TYPE_BOOL:
variant_as_string = "Boolean"
elif definition.variant_type == Variant.Type.TYPE_INT:
variant_as_string = "Integer"
elif definition.variant_type == Variant.Type.TYPE_FLOAT:
variant_as_string = "Float"
elif definition.variant_type == Variant.Type.TYPE_STRING:
variant_as_string = "String"
elif definition.variant_type == Variant.Type.TYPE_VECTOR2:
variant_as_string = "Vector2"
elif definition.variant_type == Variant.Type.TYPE_COLOR:
variant_as_string = "Color"
elif definition.variant_type == Variant.Type.TYPE_NODE_PATH:
variant_as_string = "NodePath"
elif definition.variant_type == Variant.Type.TYPE_OBJECT:
variant_as_string = "Object"
elif definition.variant_type == Variant.Type.TYPE_CALLABLE:
variant_as_string = "Callable"
elif definition.variant_type == Variant.Type.TYPE_SIGNAL:
variant_as_string = "Signal"
elif definition.variant_type == Variant.Type.TYPE_DICTIONARY:
variant_as_string = "Dictionary"
elif definition.variant_type == Variant.Type.TYPE_ARRAY:
variant_as_string = "Array"
else:
variant_as_string = "Undefined"
return definition.description + "\n\nType: [b]" + variant_as_string + "[/b]"
if definition.variant_type == Variant.Type.TYPE_NIL:
return definition.description
return definition.description + "\n\nType: [b]" + type_string(definition.variant_type)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except perhaps not appending the type in the NIL case, as you already did. I'll edit my suggestion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for amending this. When I got back to my computer to test the branch I thought it would be clearer to use a format string, so I took the liberty of making that change in your patch.

@wjt wjt merged commit 7ac2a2b into endlessm:main Oct 23, 2024
3 checks passed
@wjt
Copy link
Member

wjt commented Oct 23, 2024

This is a really nice improvement. Thanks for thinking of it & submitting it!

@DoomTas3r DoomTas3r deleted the type-in-tooltip branch October 24, 2024 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants