diff options
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/csharp_script.cpp | 29 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 2 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 40 | ||||
-rw-r--r-- | modules/mono/editor/godotsharp_editor.cpp | 4 | ||||
-rw-r--r-- | modules/mono/godotsharp_dirs.cpp | 9 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 7 |
6 files changed, 65 insertions, 26 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 7143177c3f..2e1cdf8d01 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -284,13 +284,15 @@ Ref<Script> CSharpLanguage::get_template(const String &p_class_name, const Strin "// // Update game logic here.\n" "// \n" "// }\n" - "//}\n"; + "}\n"; - script_template = script_template.replace("%BASE_CLASS_NAME%", p_base_class_name).replace("%CLASS_NAME%", p_class_name); + script_template = script_template.replace("%BASE_CLASS_NAME%", p_base_class_name) + .replace("%CLASS_NAME%", p_class_name); Ref<CSharpScript> script; script.instance(); script->set_source_code(script_template); + script->set_name(p_class_name); return script; } @@ -302,7 +304,12 @@ Script *CSharpLanguage::create_script() const { bool CSharpLanguage::has_named_classes() const { - return true; + return false; +} + +bool CSharpLanguage::supports_builtin_mode() const { + + return false; } static String variant_type_to_managed_name(const String &p_var_type_name) { @@ -481,13 +488,17 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) { GDMonoAssembly *proj_assembly = gdmono->get_project_assembly(); + String name = ProjectSettings::get_singleton()->get("application/config/name"); + if (name.empty()) { + name = "UnnamedProject"; + } + if (proj_assembly) { String proj_asm_path = proj_assembly->get_path(); if (!FileAccess::exists(proj_assembly->get_path())) { // Maybe it wasn't loaded from the default path, so check this as well - String proj_asm_name = ProjectSettings::get_singleton()->get("application/config/name"); - proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(proj_asm_name); + proj_asm_path = GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(name); if (!FileAccess::exists(proj_asm_path)) return; // No assembly to load } @@ -495,8 +506,7 @@ void CSharpLanguage::reload_assemblies_if_needed(bool p_soft_reload) { if (FileAccess::get_modified_time(proj_asm_path) <= proj_assembly->get_modified_time()) return; // Already up to date } else { - String proj_asm_name = ProjectSettings::get_singleton()->get("application/config/name"); - if (!FileAccess::exists(GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(proj_asm_name))) + if (!FileAccess::exists(GodotSharpDirs::get_res_temp_assemblies_dir().plus_file(name))) return; // No assembly to load } } @@ -1713,11 +1723,6 @@ Error CSharpScript::reload(bool p_keep_state) { return ERR_FILE_MISSING_DEPENDENCIES; } -String CSharpScript::get_node_type() const { - - return ""; // ? -} - ScriptLanguage *CSharpScript::get_language() const { return CSharpLanguage::get_singleton(); diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 6b8475fb61..65a6450da5 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -138,7 +138,6 @@ public: virtual bool is_tool() const { return tool; } virtual Ref<Script> get_base_script() const; - virtual String get_node_type() const; virtual ScriptLanguage *get_language() const; /* TODO */ virtual void get_script_method_list(List<MethodInfo> *p_list) const {} @@ -270,6 +269,7 @@ public: /* TODO */ virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { return true; } virtual Script *create_script() const; virtual bool has_named_classes() const; + virtual bool supports_builtin_mode() const; /* TODO? */ virtual int find_function(const String &p_function, const String &p_code) const { return -1; } virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const; /* TODO? */ Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 1d1bcfb03f..6cb4d09a51 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -438,6 +438,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo return sln_error; } + if (verbose_output) + OS::get_singleton()->print("Core API solution and C# project generated successfully!\n"); + return OK; } @@ -530,6 +533,9 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir, return sln_error; } + if (verbose_output) + OS::get_singleton()->print("Editor API solution and C# project generated successfully!\n"); + return OK; } @@ -1389,13 +1395,20 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { cpp_file.push_back(CLOSE_BLOCK "}\n"); - return _save_file(path_join(p_output_dir, "mono_glue.gen.cpp"), cpp_file); + Error save_err = _save_file(path_join(p_output_dir, "mono_glue.gen.cpp"), cpp_file); + if (save_err != OK) + return save_err; + + OS::get_singleton()->print("Mono glue generated successfully!\n"); + + return OK; } Error BindingsGenerator::_save_file(const String &p_path, const List<String> &p_content) { FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE); + ERR_EXPLAIN("Cannot open file: " + p_path); ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE); for (const List<String>::Element *E = p_content.front(); E; E = E->next()) { @@ -1471,7 +1484,8 @@ void BindingsGenerator::_populate_object_type_interfaces() { itype.memory_own = itype.is_reference; if (!ClassDB::is_class_exposed(type_cname)) { - WARN_PRINTS("Ignoring type " + String(type_cname) + " because it's not exposed"); + if (verbose_output) + WARN_PRINTS("Ignoring type " + String(type_cname) + " because it's not exposed"); class_list.pop_front(); continue; } @@ -1535,9 +1549,11 @@ void BindingsGenerator::_populate_object_type_interfaces() { // which could actually will return something differnet. // Let's put this to notify us if that ever happens. if (itype.name != "Object" || imethod.name != "free") { - WARN_PRINTS("Notification: New unexpected virtual non-overridable method found.\n" - "We only expected Object.free, but found " + - itype.name + "." + imethod.name); + if (verbose_output) { + WARN_PRINTS("Notification: New unexpected virtual non-overridable method found.\n" + "We only expected Object.free, but found " + + itype.name + "." + imethod.name); + } } } else { ERR_PRINTS("Missing MethodBind for non-virtual method: " + itype.name + "." + imethod.name); @@ -2043,7 +2059,8 @@ BindingsGenerator::BindingsGenerator() { void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) { - int options_count = 3; + const int NUM_OPTIONS = 3; + int options_left = NUM_OPTIONS; String mono_glue_option = "--generate-mono-glue"; String cs_core_api_option = "--generate-cs-core-api"; @@ -2053,7 +2070,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) const List<String>::Element *elem = p_cmdline_args.front(); - while (elem && options_count) { + while (elem && options_left) { if (elem->get() == mono_glue_option) { @@ -2066,7 +2083,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) ERR_PRINTS("--generate-mono-glue: No output directory specified"); } - --options_count; + --options_left; } else if (elem->get() == cs_core_api_option) { @@ -2079,7 +2096,7 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) ERR_PRINTS(cs_core_api_option + ": No output directory specified"); } - --options_count; + --options_left; } else if (elem->get() == cs_editor_api_option) { @@ -2096,13 +2113,16 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) ERR_PRINTS(cs_editor_api_option + ": No output directory specified"); } - --options_count; + --options_left; } elem = elem->next(); } verbose_output = false; + + if (options_left != NUM_OPTIONS) + exit(0); } #endif diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 30e7653256..ebfbdafeaf 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -71,6 +71,10 @@ bool GodotSharpEditor::_create_project_solution() { String path = OS::get_singleton()->get_resource_dir(); String name = ProjectSettings::get_singleton()->get("application/config/name"); + if (name.empty()) { + name = "UnnamedProject"; + } + String guid = CSharpProject::generate_game_project(path, name); if (guid.length()) { diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 6bcf0e2355..7cc2168b70 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -122,7 +122,14 @@ private: #ifdef TOOLS_ENABLED mono_solutions_dir = mono_user_dir.plus_file("solutions"); build_logs_dir = mono_user_dir.plus_file("build_logs"); - String base_path = String("res://") + ProjectSettings::get_singleton()->get("application/config/name"); + + String name = ProjectSettings::get_singleton()->get("application/config/name"); + if (name.empty()) { + name = "UnnamedProject"; + } + + String base_path = String("res://") + name; + sln_filepath = ProjectSettings::get_singleton()->globalize_path(base_path + ".sln"); csproj_filepath = ProjectSettings::get_singleton()->globalize_path(base_path + ".csproj"); #endif diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 4b5f5eb137..6d7cde95df 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -369,9 +369,12 @@ bool GDMono::_load_project_assembly() { if (project_assembly) return true; - String project_assembly_name = ProjectSettings::get_singleton()->get("application/config/name"); + String name = ProjectSettings::get_singleton()->get("application/config/name"); + if (name.empty()) { + name = "UnnamedProject"; + } - bool success = _load_assembly(project_assembly_name, &project_assembly); + bool success = _load_assembly(name, &project_assembly); if (success) mono_assembly_set_main(project_assembly->get_assembly()); |