-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 autocompletion for OS.has_feature()
's parameter
#4240
Comments
You can actually use |
Oh, the things one doesn't think about... |
This should be easy to add, but I don't think the list of features is available anywhere. So either it should be hardcoded into GDScript auto-completion or we need add a central list of possible features in the editor to harness for the completion list. |
There's also the question of whether we should add hardcoded string constants such as Constants have a few upsides over string literals:
Using strings should still be supported for custom feature tags, but all default feature tags would have an associated constant. |
All of those are very compelling arguments (there's some performance overhead concern #4234 #4023 (reply in thread)). # Note: "OS." behind the constants may be excluded should they be available in the global scope)
OS.has_feature(OS.FEATURE_WINDOWS)
OS.has_feature(OS.FEATURE_IOS) compared to the concise, more readable and less repetitive: OS.has_feature("windows")
OS.has_feature("ios") I believe suggesting Strings would also allow custom Feature Tags to be more easily included in the autocompletion, if that ends up being desirable.
This is a very compelling argument in favour of constants. I may not be a fan of the way the method would look, but it'd be inconsiderate to not take the other languages in account. I could be very wrong, but most methods I know that suggest constants really only make use of constants. |
Describe the project you are working on
A not-so typical Puzzle Bubble-like that has made general use of
OS.has_feature("debug")
Describe the problem or limitation you are having in your project
In my code I make decent use out of Feature Tags. Although I only use the most common ones, a great chunk of them are available by default, for developers that want to fine-tune their project when exporting.
However, there's a bit of a... moving back 'n' forth between the list of all Feature Tags and the Script Editor.
It's quite easy to be a little forgetful, misspell a Feature Tag and having to check the list once more just to make sure it's among the default ones. It definitely doesn't help that the Strings vary in length and capitalisation (in 3.x).
It's a bit of an annoyance, seeing as, in the average project, constant Strings are passed as arguments for
OS.has_feature()
s anyhow.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Add parameter autocompletion to
OS.has_feature()
, displaying all of the non-custom Feature Tags.It's very similar to
Input.is_action_pressed()
and derivates, whose action autocompletion also aim to solve the same issue.I don't have much else to say. If it could be integrated with custom Feature Tags it'd be nice too, but it doesn't look possible in any way as of now.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
(mockup):
If this enhancement will not be used often, can it be worked around with a few lines of script?
Not really. Well, you could assign each common Tag to a constant in a script, and they'll technically be autocompleted. Bit of a silly workaround.
Is there a reason why this should be core and not an add-on in the asset library?
No add-on can implement this.
The text was updated successfully, but these errors were encountered: