diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/main/main.cpp b/main/main.cpp index 20270190b3..b2667d11e6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -87,6 +87,7 @@ #include "editor/editor_settings.h" #include "editor/editor_translation.h" #include "editor/progress_dialog.h" +#include "editor/project_converter_3_to_4.h" #include "editor/project_manager.h" #ifndef NO_EDITOR_SPLASH #include "main/splash_editor.gen.h" @@ -368,6 +369,8 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n"); OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n"); OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n"); + OS::get_singleton()->print(" --convert-3to4 Converts project from Godot 3.x to Godot 4.x.\n"); + OS::get_singleton()->print(" --validate-conversion-3to4 Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n"); OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n"); OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n"); OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n"); @@ -996,6 +999,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph editor = true; cmdline_tool = true; main_args.push_back(I->get()); + } else if (I->get() == "--convert-3to4") { + // Actually handling is done in start(). + cmdline_tool = true; + main_args.push_back(I->get()); + } else if (I->get() == "--validate-conversion-3to4") { + // Actually handling is done in start(). + cmdline_tool = true; + main_args.push_back(I->get()); } else if (I->get() == "--doctool") { // Actually handling is done in start(). cmdline_tool = true; @@ -1765,14 +1776,14 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: Load Boot Image"); - Color clear = GLOBAL_DEF("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3)); + Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3)); RenderingServer::get_singleton()->set_default_clear_color(clear); if (show_logo) { //boot logo! - const bool boot_logo_image = GLOBAL_DEF("application/boot_splash/show_image", true); - const String boot_logo_path = String(GLOBAL_DEF("application/boot_splash/image", String())).strip_edges(); - const bool boot_logo_scale = GLOBAL_DEF("application/boot_splash/fullsize", true); - const bool boot_logo_filter = GLOBAL_DEF("application/boot_splash/use_filter", true); + const bool boot_logo_image = GLOBAL_DEF_BASIC("application/boot_splash/show_image", true); + const String boot_logo_path = String(GLOBAL_DEF_BASIC("application/boot_splash/image", String())).strip_edges(); + const bool boot_logo_scale = GLOBAL_DEF_BASIC("application/boot_splash/fullsize", true); + const bool boot_logo_filter = GLOBAL_DEF_BASIC("application/boot_splash/use_filter", true); ProjectSettings::get_singleton()->set_custom_property_info("application/boot_splash/image", PropertyInfo(Variant::STRING, "application/boot_splash/image", @@ -1797,10 +1808,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) { #if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH) const Color boot_bg_color = - GLOBAL_DEF("application/boot_splash/bg_color", + GLOBAL_DEF_BASIC("application/boot_splash/bg_color", (editor || project_manager) ? boot_splash_editor_bg_color : boot_splash_bg_color); #else - const Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); + const Color boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color); #endif if (boot_logo.is_valid()) { RenderingServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale, @@ -1832,7 +1843,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: DCC"); RenderingServer::get_singleton()->set_default_clear_color( - GLOBAL_DEF("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3))); + GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3))); GLOBAL_DEF("application/config/icon", String()); ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon", @@ -1958,9 +1969,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) { // Theme needs modules to be initialized so that sub-resources can be loaded. initialize_theme(); - GLOBAL_DEF("display/mouse_cursor/custom_image", String()); - GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2()); - GLOBAL_DEF("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); + GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image", String()); + GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image_hotspot", Vector2()); + GLOBAL_DEF_BASIC("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); ProjectSettings::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image", PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", @@ -2035,6 +2046,8 @@ bool Main::start() { String _export_preset; bool export_debug = false; bool export_pack_only = false; + bool converting_project = false; + bool validating_converting_project = false; #endif main_timer_sync.init(OS::get_singleton()->get_ticks_usec()); @@ -2050,6 +2063,10 @@ bool Main::start() { #ifdef TOOLS_ENABLED } else if (args[i] == "--no-docbase") { doc_base = false; + } else if (args[i] == "--convert-3to4") { + converting_project = true; + } else if (args[i] == "--validate-conversion-3to4") { + validating_converting_project = true; } else if (args[i] == "-e" || args[i] == "--editor") { editor = true; } else if (args[i] == "-p" || args[i] == "--project-manager") { @@ -2203,6 +2220,18 @@ bool Main::start() { NativeExtensionAPIDump::generate_extension_json_file("extension_api.json"); return false; } + + if (converting_project) { + int exit_code = ProjectConverter3To4().convert(); + OS::get_singleton()->set_exit_code(exit_code); + return false; + } + if (validating_converting_project) { + int exit_code = ProjectConverter3To4().validate_conversion(); + OS::get_singleton()->set_exit_code(exit_code); + return false; + } + #endif if (script.is_empty() && game_path.is_empty() && String(GLOBAL_GET("application/run/main_scene")) != "") { |