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

Add @hide_from_dialog and @suffix annotations for GDScript classes #100690

Closed

Conversation

Lazy-Rabbit-2001
Copy link
Contributor

@Lazy-Rabbit-2001 Lazy-Rabbit-2001 commented Dec 21, 2024

Another alternative that closes: godotengine/godot-proposals#11238
Follows up #100135
For the discussion, see the proposal

@hide_from_dialog allows you to hide a global script with a global type name hidden from the create dialog. @suffix allows you to set a custom suffix for the script. A custom suffix will replace the file name with the suffix you set. An empty custom suffix will hide the suffix from all create dialogs.
E.g.

@suffix("Custom suffix")
class_name MyClass
extends Node

this will turn

Node
| - MyClass (my_class.gd)

into

Node
| - MyClass (Custom suffix)

Note

I added few protected variables in Script class and getter methods, which is beneficial for the future continuations based on this pr

Alternative: #100349
Only one of the two pr will be merged, and the other one will be closed if not.

@RandomShaper
Copy link
Member

hide_from_dialog sounds too specific to me, like too bound to the current editor UX. I'd suggest something more abstract, conveying something like 'hidden from UI', 'not selectable', etc. Is there maybe a possibility of having an annotation to mark the class as internal, leveraging what the class DB already provides? Maybe not possible or fitting, but I wanted to point out possible alternative approaches.

@Lazy-Rabbit-2001
Copy link
Contributor Author

Lazy-Rabbit-2001 commented Dec 21, 2024

hide_from_dialog sounds too specific to me, like too bound to the current editor UX. I'd suggest something more abstract, conveying something like 'hidden from UI', 'not selectable', etc.

Yep this annotation only affects the behavior in the create dialog, and imo if some words like @hidden or @not_selectable is resorted to, the meaning would be inaccurate: How this script will be hidden? How will this script being non-selectable be? Personally, although @hide_from_dialog sounds specific, it conveys more direct, accurate to the users what this annotation wants to express and what effect(s) the annotation will take on this script.
In my perspective I don't advocate using unclear or abstract word for a more conceptual and you-know-what-it-is thing.

@HolonProduction
Copy link
Member

I think this doesn't just sound to specific, I think it is to specific to be an annotation. If we add an annotation for every slight tweak that could be made to the current UI, we will end up with too much annotations in the long run.

godotengine/godot-proposals#11238 isn't an issue that is brought up frequently (AFAIK), would be great to find a good solution, but adding two new annotations for it feels like a kind of annotation inflation to me. (Meaning it decreases the average impact that an annotation has and thus raises total annotations, I don't think this is desirable.)

@Lazy-Rabbit-2001
Copy link
Contributor Author

I think this doesn't just sound to specific, I think it is to specific to be an annotation. If we add an annotation for every slight tweak that could be made to the current UI, we will end up with too much annotations in the long run.

godotengine/godot-proposals#11238 isn't an issue that is brought up frequently (AFAIK), would be great to find a good solution, but adding two new annotations for it feels like a kind of annotation inflation to me. (Meaning it decreases the average impact that an annotation has and thus raises total annotations, I don't think this is desirable.)

(Will be off-topic) The problem is that the script cannot serialize and store metadata. Storing the metadata of a script may require a new file, but the crux is in which way this should be implemented. At least adding any redundant dangling file would be a worse practice. Meanwhile, it's also important to make it easy-moved, i.e. if you move it to another directory, it still works without users editing .godot or .uid file. .gdmeta is the best practice for this, but as i said that is a future beam.
(On-topic) I'm currently thinking of adding special comments beginning with #meta: xxxx = [], but not sure if parsing it would be a hacky process...

@dalexeev
Copy link
Member

dalexeev commented Dec 21, 2024

There are already two PRs with an annotation to hide a class from editor dialogs:

In this case, introducing an annotation looks ok to me, although I'm not sure about the semantics (should it be something specific like @hide_from_editor or general like @internal). Retroactively, it would have been better to initially split this functionality into two keywords/annotations to avoid exclusive logic. But now this would break compatibility.

Regarding the suffix, I agree with HolonProduction and commented in the linked proposal that in my opinion the annotation for the suffix is ​​too specific to appear at the language level. And maybe the ability to customize "suffix" is not a problem to be solved at all.

@Lazy-Rabbit-2001
Copy link
Contributor Author

I completely forgot what i said:

As what i said above I personally do not prefer adding scripting element to solve the problem

Well... I think I'd better keep what I said...

@Lazy-Rabbit-2001 Lazy-Rabbit-2001 deleted the script-hide-suffix branch December 21, 2024 13:06
@AThousandShips AThousandShips removed this from the 4.x milestone Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement specific functional metadatas for Script instances that contain custom global classes
6 participants