diff --git a/example/2d_tutorial/src/pubspec.lock b/example/2d_tutorial/src/pubspec.lock index bc90a0f..4064706 100644 --- a/example/2d_tutorial/src/pubspec.lock +++ b/example/2d_tutorial/src/pubspec.lock @@ -199,7 +199,7 @@ packages: path: "../../../src/dart/godot_dart" relative: true source: path - version: "0.1.0" + version: "0.1.1" godot_dart_build: dependency: "direct dev" description: diff --git a/example/2d_tutorial/src/pubspec.yaml b/example/2d_tutorial/src/pubspec.yaml index 24767c3..0660daa 100644 --- a/example/2d_tutorial/src/pubspec.yaml +++ b/example/2d_tutorial/src/pubspec.yaml @@ -17,3 +17,7 @@ dev_dependencies: build_runner: ^2.3.3 godot_dart_build: path: ../../../src/dart/godot_dart_build + +dependency_overrides: + godot_dart: + path: ../../../src/dart/godot_dart diff --git a/src/cpp/editor/dart_templates.cpp b/src/cpp/editor/dart_templates.cpp index 5074836..8b82486 100644 --- a/src/cpp/editor/dart_templates.cpp +++ b/src/cpp/editor/dart_templates.cpp @@ -43,7 +43,7 @@ const char *dart_script = "import 'dart:ffi';\n" "\n" "import 'package:godot_dart/godot_dart.dart';\n" "\n" - "part '__CLASS_NAME__.g.dart';\n" + "part '__FILE_NAME__.g.dart';\n" "\n" "@GodotScript()\n" "class __CLASS_NAME__ extends __BASE_CLASS__ {\n" diff --git a/src/cpp/script/dart_script_language.cpp b/src/cpp/script/dart_script_language.cpp index 7303df2..5cf6ec6 100644 --- a/src/cpp/script/dart_script_language.cpp +++ b/src/cpp/script/dart_script_language.cpp @@ -110,9 +110,14 @@ godot::PackedStringArray DartScriptLanguage::_get_string_delimiters() const { godot::Ref DartScriptLanguage::_make_template(const godot::String &_template, const godot::String &class_name, const godot::String &base_class_name) const { + static godot::String space(" "); + godot::String source_template(dart_script); - godot::String source = - source_template.replace("__CLASS_NAME__", class_name).replace("__BASE_CLASS__", base_class_name); + godot::String actual_class_name = class_name.capitalize().replace(space, godot::String()); + + godot::String source = source_template.replace("__FILE_NAME__", class_name) + .replace("__CLASS_NAME__", actual_class_name) + .replace("__BASE_CLASS__", base_class_name); godot::Ref script; script.instantiate(); @@ -122,6 +127,12 @@ godot::Ref DartScriptLanguage::_make_template(const godot::String return script; } +godot::TypedArray DartScriptLanguage::_get_built_in_templates( + const godot::StringName &object) const { + // Won't be called for now because _is_using_templates returns false, but look into maybe supporting them? + return godot::TypedArray(); +} + godot::Dictionary DartScriptLanguage::_validate(const godot::String &script, const godot::String &path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines) const { diff --git a/src/cpp/script/dart_script_language.h b/src/cpp/script/dart_script_language.h index 25d1ec4..d2ea0c4 100644 --- a/src/cpp/script/dart_script_language.h +++ b/src/cpp/script/dart_script_language.h @@ -29,8 +29,9 @@ class DartScriptLanguage : public godot::ScriptLanguageExtension { godot::Ref _make_template(const godot::String &_template, const godot::String &class_name, const godot::String &base_class_name) const override; bool _is_using_templates() override { - return true; + return false; } + godot::TypedArray _get_built_in_templates(const godot::StringName &object) const override; godot::Dictionary _validate(const godot::String &script, const godot::String &path, bool validate_functions, bool validate_errors, bool validate_warnings, bool validate_safe_lines) const override; godot::String _validate_path(const godot::String &path) const override; @@ -41,6 +42,9 @@ class DartScriptLanguage : public godot::ScriptLanguageExtension { bool _supports_builtin_mode() const override { return false; } + bool _can_inherit_from_file() const override { + return false; + } int _find_function(const godot::String &class_name, const godot::String &funciton_name) const override; bool _overrides_external_editor() override { return false;