Make script templates follow the GDScript style guide

This commit is contained in:
Michael Alexsander 2022-03-27 23:00:02 -03:00
parent a0071029f2
commit 42df9ed059
11 changed files with 41 additions and 16 deletions

View File

@ -2,8 +2,9 @@
extends _BASE_ 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. # Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity") var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")

View File

@ -2,8 +2,9 @@
extends _BASE_ 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. # Get the gravity from the project settings to be synced with RigidDynamicBody nodes.
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")

View File

@ -2,10 +2,12 @@
@tool @tool
extends EditorPlugin extends EditorPlugin
func _enter_tree() -> void: func _enter_tree() -> void:
# Initialization of the plugin goes here. # Initialization of the plugin goes here.
pass pass
func _exit_tree() -> void: func _exit_tree() -> void:
# Clean-up of the plugin goes here. # Clean-up of the plugin goes here.
pass pass

View File

@ -2,6 +2,7 @@
@tool @tool
extends EditorScript extends EditorScript
func _run() -> void:
# Called when the script is executed (using File -> Run in Script Editor). # Called when the script is executed (using File -> Run in Script Editor).
func _run() -> void:
pass pass

View File

@ -2,10 +2,12 @@
extends _BASE_ extends _BASE_
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
pass # Replace with function body. pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
pass pass

View File

@ -1,38 +1,50 @@
# meta-description: Visual shader's node plugin template # meta-description: Visual shader's node plugin template
@tool @tool
extends _BASE_
class_name VisualShaderNode_CLASS_ class_name VisualShaderNode_CLASS_
extends _BASE_
func _get_name() -> String: func _get_name() -> String:
return "_CLASS_" return "_CLASS_"
func _get_category() -> String: func _get_category() -> String:
return "" return ""
func _get_description() -> String: func _get_description() -> String:
return "" return ""
func _get_return_icon_type() -> int: func _get_return_icon_type() -> int:
return PORT_TYPE_SCALAR return PORT_TYPE_SCALAR
func _get_input_port_count() -> int: func _get_input_port_count() -> int:
return 0 return 0
func _get_input_port_name(port: int) -> String: func _get_input_port_name(port: int) -> String:
return "" return ""
func _get_input_port_type(port: int) -> int: func _get_input_port_type(port: int) -> int:
return PORT_TYPE_SCALAR return PORT_TYPE_SCALAR
func _get_output_port_count() -> int: func _get_output_port_count() -> int:
return 1 return 1
func _get_output_port_name(port: int) -> String: func _get_output_port_name(port: int) -> String:
return "result" return "result"
func _get_output_port_type(port: int) -> int: func _get_output_port_type(port: int) -> int:
return PORT_TYPE_SCALAR 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;" return output_vars[0] + " = 0.0;"

View File

@ -68,14 +68,21 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
if (!EDITOR_GET("text_editor/completion/add_type_hints")) { if (!EDITOR_GET("text_editor/completion/add_type_hints")) {
processed_template = processed_template.replace(": int", "") processed_template = processed_template.replace(": int", "")
.replace(": String", "") .replace(": String", "")
.replace(": Array[String]", "")
.replace(": float", "") .replace(": float", "")
.replace(":=", "=") .replace(":=", "=")
.replace(" -> String", "")
.replace(" -> int", "")
.replace(" -> void", ""); .replace(" -> void", "");
} }
#else #else
processed_template = processed_template.replace(": int", "") processed_template = processed_template.replace(": int", "")
.replace(": String", "") .replace(": String", "")
.replace(": Array[String]", "")
.replace(": float", "") .replace(": float", "")
.replace(":=", "=")
.replace(" -> String", "")
.replace(" -> int", "")
.replace(" -> void", ""); .replace(" -> void", "");
#endif #endif

View File

@ -1,4 +1,5 @@
// meta-description: Basic plugin template // meta-description: Basic plugin template
#if TOOLS #if TOOLS
using _BINDINGS_NAMESPACE_; using _BINDINGS_NAMESPACE_;
using System; using System;

View File

@ -1,4 +1,5 @@
// meta-description: Basic editor script template // meta-description: Basic editor script template
#if TOOLS #if TOOLS
using _BINDINGS_NAMESPACE_; using _BINDINGS_NAMESPACE_;
using System; using System;
@ -6,9 +7,9 @@ using System;
[Tool] [Tool]
public partial class _CLASS_ : _BASE_ public partial class _CLASS_ : _BASE_
{ {
// Called when the script is executed (using File -> Run in Script Editor).
public override void _Run() public override void _Run()
{ {
// Called when the script is executed (using File -> Run in Script Editor).
} }
} }
#endif #endif

View File

@ -8,12 +8,10 @@ public partial class _CLASS_ : _BASE_
// Called when the node enters the scene tree for the first time. // Called when the node enters the scene tree for the first time.
public override void _Ready() public override void _Ready()
{ {
} }
// Called every frame. 'delta' is the elapsed time since the previous frame. // Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(float delta) public override void _Process(float delta)
{ {
} }
} }

View File

@ -5,5 +5,4 @@ using System;
public partial class _CLASS_ : _BASE_ public partial class _CLASS_ : _BASE_
{ {
} }