summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-03-28 15:48:38 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-03-28 16:21:00 +0200
commitc9b75431f313fae16e9f4c9e60d7f5eaed0aaec0 (patch)
tree4f5b49ebd9e81cd5e66a92af0b7b1a53eee49169
parent41d075de5865c8b088c83219431661bc2d1f1802 (diff)
Refactor GDScript/C# script templates logic to be editor-only
Not a full refactor as it still goes through ScriptLanguage so it's hacky, but at least it can now compile without this.
-rw-r--r--modules/gdscript/SCsub5
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd (renamed from modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd (renamed from modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd (renamed from modules/gdscript/editor_templates/EditorPlugin/plugin.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd (renamed from modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/Node/default.gd (renamed from modules/gdscript/editor_templates/Node/default.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/Object/empty.gd (renamed from modules/gdscript/editor_templates/Object/empty.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/SCsub (renamed from modules/gdscript/editor_templates/SCsub)0
-rw-r--r--modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd (renamed from modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd)0
-rw-r--r--modules/gdscript/gdscript_editor.cpp19
-rw-r--r--modules/mono/SCsub3
-rw-r--r--modules/mono/csharp_script.cpp6
-rw-r--r--modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs (renamed from modules/mono/editor_templates/CharacterBody2D/basic_movement.cs)0
-rw-r--r--modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs (renamed from modules/mono/editor_templates/CharacterBody3D/basic_movement.cs)0
-rw-r--r--modules/mono/editor/script_templates/EditorPlugin/plugin.cs (renamed from modules/mono/editor_templates/EditorPlugin/plugin.cs)0
-rw-r--r--modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs (renamed from modules/mono/editor_templates/EditorScript/basic_editor_script.cs)0
-rw-r--r--modules/mono/editor/script_templates/Node/default.cs (renamed from modules/mono/editor_templates/Node/default.cs)0
-rw-r--r--modules/mono/editor/script_templates/Object/empty.cs (renamed from modules/mono/editor_templates/Object/empty.cs)0
-rw-r--r--modules/mono/editor/script_templates/SCsub (renamed from modules/mono/editor_templates/SCsub)0
-rw-r--r--modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs (renamed from modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs)0
20 files changed, 15 insertions, 18 deletions
diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub
index c6121ec7fe..2f507db548 100644
--- a/modules/gdscript/SCsub
+++ b/modules/gdscript/SCsub
@@ -10,6 +10,8 @@ env_gdscript.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_gdscript.add_source_files(env.modules_sources, "./editor/*.cpp")
+ SConscript("editor/script_templates/SCsub")
+
# Those two modules are required for the language server protocol
if env["module_jsonrpc_enabled"] and env["module_websocket_enabled"]:
env_gdscript.add_source_files(env.modules_sources, "./language_server/*.cpp")
@@ -18,8 +20,7 @@ if env["tools"]:
# in regular builds where all modules are enabled.
env_gdscript.Append(CPPDEFINES=["GDSCRIPT_NO_LSP"])
+
if env["tests"]:
env_gdscript.Append(CPPDEFINES=["TESTS_ENABLED"])
env_gdscript.add_source_files(env.modules_sources, "./tests/*.cpp")
-
-SConscript("editor_templates/SCsub")
diff --git a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
index a379d915a9..a379d915a9 100644
--- a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
diff --git a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
index 360b199e56..360b199e56 100644
--- a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
diff --git a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd
index b27b3e5655..b27b3e5655 100644
--- a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd
+++ b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd
diff --git a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd
index fdb8550d43..fdb8550d43 100644
--- a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd
+++ b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd
diff --git a/modules/gdscript/editor_templates/Node/default.gd b/modules/gdscript/editor/script_templates/Node/default.gd
index cb96a21537..cb96a21537 100644
--- a/modules/gdscript/editor_templates/Node/default.gd
+++ b/modules/gdscript/editor/script_templates/Node/default.gd
diff --git a/modules/gdscript/editor_templates/Object/empty.gd b/modules/gdscript/editor/script_templates/Object/empty.gd
index 387786b0a4..387786b0a4 100644
--- a/modules/gdscript/editor_templates/Object/empty.gd
+++ b/modules/gdscript/editor/script_templates/Object/empty.gd
diff --git a/modules/gdscript/editor_templates/SCsub b/modules/gdscript/editor/script_templates/SCsub
index 2266ef2d01..2266ef2d01 100644
--- a/modules/gdscript/editor_templates/SCsub
+++ b/modules/gdscript/editor/script_templates/SCsub
diff --git a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd
index 283a95d3b4..283a95d3b4 100644
--- a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
+++ b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 4a6e1eb497..fd8fcea7b3 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -33,7 +33,6 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/io/file_access.h"
-#include "editor_templates/templates.gen.h"
#include "gdscript_analyzer.h"
#include "gdscript_compiler.h"
#include "gdscript_parser.h"
@@ -44,6 +43,7 @@
#include "core/config/project_settings.h"
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
+#include "editor/script_templates/templates.gen.h"
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -64,8 +64,11 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
Ref<GDScript> script;
script.instantiate();
String processed_template = p_template;
+ bool type_hints = false;
#ifdef TOOLS_ENABLED
- if (!EDITOR_GET("text_editor/completion/add_type_hints")) {
+ type_hints = EDITOR_GET("text_editor/completion/add_type_hints");
+#endif
+ if (!type_hints) {
processed_template = processed_template.replace(": int", "")
.replace(": String", "")
.replace(": Array[String]", "")
@@ -75,16 +78,6 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
.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
processed_template = processed_template.replace("_BASE_", p_base_class_name)
.replace("_CLASS_", p_class_name)
@@ -95,11 +88,13 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
Vector<ScriptLanguage::ScriptTemplate> GDScriptLanguage::get_built_in_templates(StringName p_object) {
Vector<ScriptLanguage::ScriptTemplate> templates;
+#ifdef TOOLS_ENABLED
for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) {
if (TEMPLATES[i].inherit == p_object) {
templates.append(TEMPLATES[i]);
}
}
+#endif
return templates;
}
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index db35e804aa..3bafa351a9 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -63,5 +63,4 @@ elif env["platform"] == "android":
if env["tools"]:
env_mono.add_source_files(env.modules_sources, "editor/*.cpp")
-
-SConscript("editor_templates/SCsub")
+ SConscript("editor/script_templates/SCsub")
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 7ed0422236..0953bde9bb 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -45,17 +45,17 @@
#ifdef TOOLS_ENABLED
#include "core/os/keyboard.h"
#include "editor/bindings_generator.h"
+#include "editor/editor_internal_calls.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/node_dock.h"
+#include "editor/script_templates/templates.gen.h"
#endif
#ifdef DEBUG_METHODS_ENABLED
#include "class_db_api_json.h"
#endif
-#include "editor/editor_internal_calls.h"
-#include "editor_templates/templates.gen.h"
#include "godotsharp_dirs.h"
#include "mono_gd/gd_mono_cache.h"
#include "mono_gd/gd_mono_class.h"
@@ -373,11 +373,13 @@ Ref<Script> CSharpLanguage::make_template(const String &p_template, const String
Vector<ScriptLanguage::ScriptTemplate> CSharpLanguage::get_built_in_templates(StringName p_object) {
Vector<ScriptLanguage::ScriptTemplate> templates;
+#ifdef TOOLS_ENABLED
for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) {
if (TEMPLATES[i].inherit == p_object) {
templates.append(TEMPLATES[i]);
}
}
+#endif
return templates;
}
diff --git a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs
index 2ca81ab7cd..2ca81ab7cd 100644
--- a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs
+++ b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs
diff --git a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs
index a6935fe497..a6935fe497 100644
--- a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs
+++ b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs
diff --git a/modules/mono/editor_templates/EditorPlugin/plugin.cs b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs
index eba5fd12a4..eba5fd12a4 100644
--- a/modules/mono/editor_templates/EditorPlugin/plugin.cs
+++ b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs
diff --git a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs
index 1b347edc1c..1b347edc1c 100644
--- a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs
+++ b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs
diff --git a/modules/mono/editor_templates/Node/default.cs b/modules/mono/editor/script_templates/Node/default.cs
index 4c86d1666f..4c86d1666f 100644
--- a/modules/mono/editor_templates/Node/default.cs
+++ b/modules/mono/editor/script_templates/Node/default.cs
diff --git a/modules/mono/editor_templates/Object/empty.cs b/modules/mono/editor/script_templates/Object/empty.cs
index 34526d514f..34526d514f 100644
--- a/modules/mono/editor_templates/Object/empty.cs
+++ b/modules/mono/editor/script_templates/Object/empty.cs
diff --git a/modules/mono/editor_templates/SCsub b/modules/mono/editor/script_templates/SCsub
index 39f6cb5c01..39f6cb5c01 100644
--- a/modules/mono/editor_templates/SCsub
+++ b/modules/mono/editor/script_templates/SCsub
diff --git a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs
index a1b93e7daa..a1b93e7daa 100644
--- a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs
+++ b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs