-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Improve the editor template workflow for users and devs #53957
Conversation
As per the GDScript style guide, indentation should use tabs by default. Or is this about templates being written with spaces instead of tabs (to convert from spaces to tabs)? Official script templates should be indented with tabs, still. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend reading the GDScript style guide: https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_styleguide.html
modules/gdscript/editor_templates/CharacterBody2D/basic_mouv.gd
Outdated
Show resolved
Hide resolved
modules/gdscript/editor_templates/CharacterBody2D/basic_mouv.gd
Outdated
Show resolved
Hide resolved
modules/gdscript/editor_templates/CharacterBody2D/basic_mouv.gd
Outdated
Show resolved
Hide resolved
Not sure from the changes if you handle this or not, but I think templates at the root of the template folder (like now) can be handled as Object or Node templates for backward compatibility. PS. Also, did you call the two files basic_mouv on purpose? Looks like a typo, and we better use full qualified names in the engine anyway. |
The parser will replace the tab and 4 spaces by In the end, the result of the indentation will be the one defined in the editor's configuration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is the replacement syntax changed from %BASE%
to _BASE_
? Is there a reason to use _
over %
? It seems to me that _
could be conflicting with valid scripts.
@raulsntos Yes, if you use To avoid this I changed the syntax to a valid one. As this syntax only concerns templates, I don't think is an issue, it seems to me the lesser evil. |
Good enough for me, I guess the chances of someone wanting to use a world like |
I thought about doubling the underscore at one point |
I'm working with @fabriceci on this PR.
The new system ensure that proposed templates can be applied for this node and should not include non existing methods for the node selected.
|
They are suitable for all nodes though, just not all objects. Which is why I mentioned both. But since the syntax for placeholders was changed, I guess this is already a compatibility breaking change. |
What I mean is if someone wrote a template suitable for all Control nodes (template include method calls from Control class) with the old system in the old root directory. With the new system, we put it in a Control subfolder and it won't be proposed for Node2D or Node3D derivated nodes. If this template is left in the root template directory and considered to be suitable for all Object, it will kill one of the avdandage of the new system (if a template is proposed, it is suitable). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
I've left some comments about the physics templates and the general API in core, I'm not very familiar with specific script implementations.
modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
Outdated
Show resolved
Hide resolved
eb2f101
to
a512161
Compare
4b9a84f
to
51e9047
Compare
editor/script_create_dialog.cpp
Outdated
// Update last used dictionaries | ||
if (is_using_templates && !parent_name->get_text().begins_with("\"res:")) { | ||
if (sinfo.origin == ScriptLanguage::TemplateLocation::TEMPLATE_PROJECT) { | ||
// Save the last used template for this node into the project dictionnary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Save the last used template for this node into the project dictionnary. | |
// Save the last used template for this node into the project dictionary. |
Misspelled dictionary. Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Was a mix-up with the french spelling...
51e9047
to
4fe1e78
Compare
Co-Authored-By: jmb462 <[email protected]>
4fe1e78
to
9d5b807
Compare
Thanks! |
The script templates page wasn't updated after godotengine/godot#53957 The templates are now per node type and folder organization has changed. A few behaviours and configuration have also changed. Documenting based on current editor behaviour and source code HEAD. Fixes godotengine#5887
The script templates page wasn't updated after godotengine/godot#53957 The templates are now per node type and folder organization has changed. A few behaviours and configuration have also changed. Documenting based on current editor behaviour and source code HEAD. Fixes godotengine#5887
The script templates page wasn't updated after godotengine/godot#53957 The templates are now per node type and folder organization has changed. A few behaviours and configuration have also changed. Documenting based on current editor behaviour and source code HEAD. Fixes godotengine#5887
Co-Authored-By: jmb462 [email protected]
This PR attempts to improve/rewrite the script template workflow to make the usage as easy/smooth as possible.
Closes godotengine/godot-proposals#3365
fix #36605
fix #28799
fix #44534
fix #46436
close godotengine/godot-proposals#1899
What are the main changes?
How it can be used by core dev
The original motivation was to provide a more relevant template for CharacterBody nodes in order to :
- help to avoid the common error we see in issues (like forget to assign the result of move and slide in 3.x)
- help to make the transition in 4.0 (act like a tutorial)
- fast prototyping, you have a moving character in few seconds
default.template.mp4
How it works?
The template folders have the following structure
To add a template simply create a file in the correct folder (
template_path/node_type/file.ext
), that's it.By default:
You can customize the template info with metas at the begning of your templates. Metas starts with the single-line comment syntax of your language:
Example of description:
It works exactly the same for built-in and user templates
Notes
gdscript.cpp