Editor: Remove unused Class Name field from Create Script dialog

This commit is contained in:
Danil Alexeev 2023-09-12 11:52:43 +03:00
parent 5c43e4c1ef
commit 26ce861910
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
18 changed files with 69 additions and 139 deletions

View file

@ -15,7 +15,7 @@ func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity.y += gravity * delta
# Handle Jump.
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY

View file

@ -15,7 +15,7 @@ func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity.y -= gravity * delta
# Handle Jump.
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY

View file

@ -1,6 +1,7 @@
# meta-description: Basic plugin template
@tool
extends EditorPlugin
extends _BASE_
func _enter_tree() -> void:

View file

@ -1,6 +1,7 @@
# meta-description: Basic import script template
@tool
extends EditorScenePostImport
extends _BASE_
# Called by the editor when a scene has this script set as the import script in the import tab.

View file

@ -1,6 +1,7 @@
# meta-description: Basic import script template (no comments)
@tool
extends EditorScenePostImport
extends _BASE_
func _post_import(scene: Node) -> Object:

View file

@ -1,6 +1,7 @@
# meta-description: Basic editor script template
@tool
extends EditorScript
extends _BASE_
# Called when the script is executed (using File -> Run in Script Editor).

View file

@ -1,15 +1,16 @@
# meta-description: Base template for rich text effects
@tool
class_name _CLASS_
# Having a class name is handy for picking the effect in the Inspector.
class_name RichText_CLASS_
extends _BASE_
# To use this effect:
# - Enable BBCode on a RichTextLabel.
# - Register this effect on the label.
# - Use [_CLASS_ param=2.0]hello[/_CLASS_] in text.
var bbcode := "_CLASS_"
# - Use [_CLASS_SNAKE_CASE_ param=2.0]hello[/_CLASS_SNAKE_CASE_] in text.
var bbcode := "_CLASS_SNAKE_CASE_"
func _process_custom_fx(char_fx: CharFXTransform) -> bool:

View file

@ -1,6 +1,7 @@
# meta-description: Visual shader's node plugin template
@tool
# Having a class name is required for a custom node.
class_name VisualShaderNode_CLASS_
extends _BASE_
@ -17,7 +18,7 @@ func _get_description() -> String:
return ""
func _get_return_icon_type() -> int:
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
@ -29,7 +30,7 @@ func _get_input_port_name(port: int) -> String:
return ""
func _get_input_port_type(port: int) -> int:
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
@ -41,10 +42,10 @@ func _get_output_port_name(port: int) -> String:
return "result"
func _get_output_port_type(port: int) -> int:
func _get_output_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_code(input_vars: Array[String], output_vars: Array[String],
mode: int, type: int) -> String:
mode: Shader.Mode, type: VisualShader.Type) -> String:
return output_vars[0] + " = 0.0;"

View file

@ -501,7 +501,9 @@ public:
virtual Vector<ScriptTemplate> get_built_in_templates(StringName p_object) override;
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override;
virtual Script *create_script() const override;
virtual bool has_named_classes() const override;
#ifndef DISABLE_DEPRECATED
virtual bool has_named_classes() const override { return false; }
#endif
virtual bool supports_builtin_mode() const override;
virtual bool supports_documentation() const override;
virtual bool can_inherit_from_file() const override { return true; }

View file

@ -75,19 +75,25 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
#endif
if (!type_hints) {
processed_template = processed_template.replace(": int", "")
.replace(": Shader.Mode", "")
.replace(": VisualShader.Type", "")
.replace(": float", "")
.replace(": String", "")
.replace(": Array[String]", "")
.replace(": float", "")
.replace(": Node", "")
.replace(": CharFXTransform", "")
.replace(":=", "=")
.replace(" -> String", "")
.replace(" -> int", "")
.replace(" -> void", "")
.replace(" -> bool", "")
.replace(" -> void", "");
.replace(" -> int", "")
.replace(" -> PortType", "")
.replace(" -> String", "")
.replace(" -> Object", "");
}
processed_template = processed_template.replace("_BASE_", p_base_class_name)
.replace("_CLASS_", p_class_name.to_pascal_case())
.replace("_CLASS_SNAKE_CASE_", p_class_name.to_snake_case().validate_identifier())
.replace("_CLASS_", p_class_name.to_pascal_case().validate_identifier())
.replace("_TS_", _get_indentation());
scr->set_source_code(processed_template);
return scr;
@ -190,10 +196,6 @@ bool GDScriptLanguage::validate(const String &p_script, const String &p_path, Li
return true;
}
bool GDScriptLanguage::has_named_classes() const {
return false;
}
bool GDScriptLanguage::supports_builtin_mode() const {
return true;
}