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

GDScript 2.0: @export_category interferes with the property inspector tooltip #64432

Closed
permelin opened this issue Aug 15, 2022 · 5 comments · Fixed by #81221
Closed

GDScript 2.0: @export_category interferes with the property inspector tooltip #64432

permelin opened this issue Aug 15, 2022 · 5 comments · Fixed by #81221

Comments

@permelin
Copy link
Contributor

Godot version

v4.0.alpha.custom_build [f2a6168]

System information

Linux

Issue description

Properties can be documented by giving them a description with ## comments. That description is then showed as a tooltip in the inspector, like this.
example1

However, any properties following an @export_category annotation will only have a "no description" tooltip.
example2

This bug actually predates @export_category and also occurs when using PROPERTY_USAGE_CATEGORY directly in _get_property_list().

The problem is that EditorInspector::update_tree() assumes that any property with PROPERTY_USAGE_CATEGORY either has a name that is a class name or a hint_string that is a path to a script. And it uses that class/path to look up the description of subsequent properties.

One possible fix is to simply add the required hint string to @export_category. I've verified that this works.

--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3826,6 +3826,7 @@ bool GDScriptParser::export_group_annotations(const AnnotationNode *p_annotation
        switch (t_usage) {
                case PROPERTY_USAGE_CATEGORY: {
                        annotation->export_info.usage = t_usage;
+                       annotation->export_info.hint_string = script_path;
                } break;

One downside to that is that the tooltip of the category itself will be the description of the script ("This is a description of the script" in the screenshots above).

I guess the alternative is to change EditorInspector::update_tree() which is a 670 line hairy monster.

Steps to reproduce

See screenshots above.

Minimal reproduction project

No response

@Calinou Calinou added this to the 4.0 milestone Aug 15, 2022
@Calinou Calinou moved this to To Assess in 4.x Priority Issues Aug 15, 2022
@Calinou Calinou changed the title @export_category interferes with the property inspector tooltip GDScript 2.0: @export_category interferes with the property inspector tooltip Aug 15, 2022
@adamscott
Copy link
Member

Confirmed on master (fcba87e).

Minimal reproduction project

64432.zip

@akien-mga
Copy link
Member

I can't reproduce the bug in 4.2-dev5, while it's reproducible up to 4.2-dev4.

I don't see right away which change would have solved it in https://godotengine.github.io/godot-interactive-changelog/#4.2-dev5, maybe @dalexeev has an idea?

@TechnoLukas
Copy link

TechnoLukas commented Feb 13, 2024

It also depends on placement of @export_category().
For example if category is not placed at the first place, then it works:

## Description 0
@export_range(1, 10, 1, "or_greater") var speed_up = 1

@export_category("category 1")
## Description 1
@export var model_path := ""
## Description 2
@export_range(1, 10, 1, "or_greater") var action_repeat := 8

@export_category("category 2")
## Description 3
@export_range(1, 10, 1, "or_greater") var num_mod := 1

Though if it would be placed on the first place, then it won't work :

@export_category("category 0")
## Description 0
@export_range(1, 10, 1, "or_greater") var speed_up = 1

@export_category("category 1")
## Description 1
@export var model_path := ""
## Description 2
@export_range(1, 10, 1, "or_greater") var action_repeat := 8

@export_category("category 2")
## Description 3
@export_range(1, 10, 1, "or_greater") var num_mod := 1

@dalexeev
Copy link
Member

@TechnoLukas See #88318. For the future, feel free to open a new issue instead of commenting on a closed old one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment