summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Alexsander <michaelalexsander@protonmail.com>2022-03-27 23:00:02 -0300
committerMichael Alexsander <michaelalexsander@protonmail.com>2022-03-28 01:32:12 -0300
commit42df9ed0599154cd4894cbcf0c6d9761c5ab3a4e (patch)
treecd54171a269f5280bd7480ed7b571c243029d13b
parenta0071029f2c4ec006d3443f25aa77e2c2c7a1ece (diff)
Make script templates follow the GDScript style guide
-rw-r--r--modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd5
-rw-r--r--modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd5
-rw-r--r--modules/gdscript/editor_templates/EditorPlugin/plugin.gd10
-rw-r--r--modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd5
-rw-r--r--modules/gdscript/editor_templates/Node/default.gd2
-rw-r--r--modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd16
-rw-r--r--modules/gdscript/gdscript_editor.cpp7
-rw-r--r--modules/mono/editor_templates/EditorPlugin/plugin.cs1
-rw-r--r--modules/mono/editor_templates/EditorScript/basic_editor_script.cs3
-rw-r--r--modules/mono/editor_templates/Node/default.cs2
-rw-r--r--modules/mono/editor_templates/Object/empty.cs1
11 files changed, 41 insertions, 16 deletions
diff --git a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd b/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
index 34b5ba45b7..a379d915a9 100644
--- a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
+++ b/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
@@ -2,8 +2,9 @@
extends _BASE_
-const SPEED: float = 300.0
-const JUMP_VELOCITY: float = -400.0
+
+const SPEED = 300.0
+const JUMP_VELOCITY = -400.0
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")
diff --git a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd b/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd
index cbc9cf1064..360b199e56 100644
--- a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd
+++ b/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd
@@ -2,8 +2,9 @@
extends _BASE_
-const SPEED: float = 5.0
-const JUMP_VELOCITY: float = 4.5
+
+const SPEED = 5.0
+const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")
diff --git a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd b/modules/gdscript/editor_templates/EditorPlugin/plugin.gd
index 8614bb8b17..b27b3e5655 100644
--- a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd
+++ b/modules/gdscript/editor_templates/EditorPlugin/plugin.gd
@@ -2,10 +2,12 @@
@tool
extends EditorPlugin
+
func _enter_tree() -> void:
- # Initialization of the plugin goes here.
- pass
+ # Initialization of the plugin goes here.
+ pass
+
func _exit_tree() -> void:
- # Clean-up of the plugin goes here.
- pass
+ # Clean-up of the plugin goes here.
+ pass
diff --git a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd b/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd
index fdb174c7ed..fdb8550d43 100644
--- a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd
+++ b/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd
@@ -2,6 +2,7 @@
@tool
extends EditorScript
+
+# Called when the script is executed (using File -> Run in Script Editor).
func _run() -> void:
- # Called when the script is executed (using File -> Run in Script Editor).
- pass
+ pass
diff --git a/modules/gdscript/editor_templates/Node/default.gd b/modules/gdscript/editor_templates/Node/default.gd
index ee5c0b99cc..cb96a21537 100644
--- a/modules/gdscript/editor_templates/Node/default.gd
+++ b/modules/gdscript/editor_templates/Node/default.gd
@@ -2,10 +2,12 @@
extends _BASE_
+
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
+
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
diff --git a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd b/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
index cf6d68333d..283a95d3b4 100644
--- a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
+++ b/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
@@ -1,38 +1,50 @@
# meta-description: Visual shader's node plugin template
@tool
-extends _BASE_
class_name VisualShaderNode_CLASS_
+extends _BASE_
+
func _get_name() -> String:
return "_CLASS_"
+
func _get_category() -> String:
return ""
+
func _get_description() -> String:
return ""
+
func _get_return_icon_type() -> int:
return PORT_TYPE_SCALAR
+
func _get_input_port_count() -> int:
return 0
+
func _get_input_port_name(port: int) -> String:
return ""
+
func _get_input_port_type(port: int) -> int:
return PORT_TYPE_SCALAR
+
func _get_output_port_count() -> int:
return 1
+
func _get_output_port_name(port: int) -> String:
return "result"
+
func _get_output_port_type(port: int) -> int:
return PORT_TYPE_SCALAR
-func _get_code(input_vars: Array[String], output_vars: Array[String], mode: int, type: int) -> String:
+
+func _get_code(input_vars: Array[String], output_vars: Array[String],
+ mode: int, type: int) -> String:
return output_vars[0] + " = 0.0;"
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 350962ba1b..c06137c3cc 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -68,14 +68,21 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
if (!EDITOR_GET("text_editor/completion/add_type_hints")) {
processed_template = processed_template.replace(": int", "")
.replace(": String", "")
+ .replace(": Array[String]", "")
.replace(": float", "")
.replace(":=", "=")
+ .replace(" -> String", "")
+ .replace(" -> int", "")
.replace(" -> void", "");
}
#else
processed_template = processed_template.replace(": int", "")
.replace(": String", "")
+ .replace(": Array[String]", "")
.replace(": float", "")
+ .replace(":=", "=")
+ .replace(" -> String", "")
+ .replace(" -> int", "")
.replace(" -> void", "");
#endif
diff --git a/modules/mono/editor_templates/EditorPlugin/plugin.cs b/modules/mono/editor_templates/EditorPlugin/plugin.cs
index 6e6a799be6..eba5fd12a4 100644
--- a/modules/mono/editor_templates/EditorPlugin/plugin.cs
+++ b/modules/mono/editor_templates/EditorPlugin/plugin.cs
@@ -1,4 +1,5 @@
// meta-description: Basic plugin template
+
#if TOOLS
using _BINDINGS_NAMESPACE_;
using System;
diff --git a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs b/modules/mono/editor_templates/EditorScript/basic_editor_script.cs
index 2088822890..1b347edc1c 100644
--- a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs
+++ b/modules/mono/editor_templates/EditorScript/basic_editor_script.cs
@@ -1,4 +1,5 @@
// meta-description: Basic editor script template
+
#if TOOLS
using _BINDINGS_NAMESPACE_;
using System;
@@ -6,9 +7,9 @@ using System;
[Tool]
public partial class _CLASS_ : _BASE_
{
+ // Called when the script is executed (using File -> Run in Script Editor).
public override void _Run()
{
- // Called when the script is executed (using File -> Run in Script Editor).
}
}
#endif
diff --git a/modules/mono/editor_templates/Node/default.cs b/modules/mono/editor_templates/Node/default.cs
index 73d69dd993..4c86d1666f 100644
--- a/modules/mono/editor_templates/Node/default.cs
+++ b/modules/mono/editor_templates/Node/default.cs
@@ -8,12 +8,10 @@ public partial class _CLASS_ : _BASE_
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
-
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(float delta)
{
-
}
}
diff --git a/modules/mono/editor_templates/Object/empty.cs b/modules/mono/editor_templates/Object/empty.cs
index e5bee64fe1..34526d514f 100644
--- a/modules/mono/editor_templates/Object/empty.cs
+++ b/modules/mono/editor_templates/Object/empty.cs
@@ -5,5 +5,4 @@ using System;
public partial class _CLASS_ : _BASE_
{
-
}