diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 88 |
1 files changed, 74 insertions, 14 deletions
diff --git a/main/main.cpp b/main/main.cpp index fa50a3039f..5206e9b84c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -80,9 +80,11 @@ #include "servers/navigation_server_2d.h" #include "servers/navigation_server_2d_dummy.h" #include "servers/physics_server_2d.h" +#include "servers/physics_server_2d_dummy.h" #ifndef _3D_DISABLED #include "servers/physics_server_3d.h" +#include "servers/physics_server_3d_dummy.h" #include "servers/xr_server.h" #endif // _3D_DISABLED @@ -243,6 +245,7 @@ static MovieWriter *movie_writer = nullptr; static bool disable_vsync = false; static bool print_fps = false; #ifdef TOOLS_ENABLED +static bool editor_pseudolocalization = false; static bool dump_gdextension_interface = false; static bool dump_extension_api = false; static bool include_docs_in_extension_api_dump = false; @@ -320,7 +323,15 @@ void initialize_physics() { // Physics server not found, Use the default physics physics_server_3d = PhysicsServer3DManager::get_singleton()->new_default_server(); } - ERR_FAIL_NULL(physics_server_3d); + + // Fall back to dummy if no default server has been registered. + if (!physics_server_3d) { + WARN_PRINT(vformat("Falling back to dummy PhysicsServer3D; 3D physics functionality will be disabled. If this is intended, set the %s project setting to Dummy.", PhysicsServer3DManager::setting_property_name)); + physics_server_3d = memnew(PhysicsServer3DDummy); + } + + // Should be impossible, but make sure it's not null. + ERR_FAIL_NULL_MSG(physics_server_3d, "Failed to initialize PhysicsServer3D."); physics_server_3d->init(); #endif // _3D_DISABLED @@ -331,7 +342,15 @@ void initialize_physics() { // Physics server not found, Use the default physics physics_server_2d = PhysicsServer2DManager::get_singleton()->new_default_server(); } - ERR_FAIL_NULL(physics_server_2d); + + // Fall back to dummy if no default server has been registered. + if (!physics_server_2d) { + WARN_PRINT(vformat("Falling back to dummy PhysicsServer2D; 2D physics functionality will be disabled. If this is intended, set the %s project setting to Dummy.", PhysicsServer2DManager::setting_property_name)); + physics_server_2d = memnew(PhysicsServer2DDummy); + } + + // Should be impossible, but make sure it's not null. + ERR_FAIL_NULL_MSG(physics_server_2d, "Failed to initialize PhysicsServer2D."); physics_server_2d->init(); } @@ -594,7 +613,9 @@ void Main::print_help(const char *p_binary) { print_help_option("--position <X>,<Y>", "Request window position.\n"); print_help_option("--screen <N>", "Request window screen.\n"); print_help_option("--single-window", "Use a single window (no separate subwindows).\n"); +#ifndef _3D_DISABLED print_help_option("--xr-mode <mode>", "Select XR (Extended Reality) mode [\"default\", \"off\", \"on\"].\n"); +#endif print_help_title("Debug options"); print_help_option("-d, --debug", "Debug (local stdout debugger).\n"); @@ -629,6 +650,9 @@ void Main::print_help(const char *p_binary) { print_help_option("--fixed-fps <fps>", "Force a fixed number of frames per second. This setting disables real-time synchronization.\n"); print_help_option("--delta-smoothing <enable>", "Enable or disable frame delta smoothing [\"enable\", \"disable\"].\n"); print_help_option("--print-fps", "Print the frames per second to the stdout.\n"); +#ifdef TOOLS_ENABLED + print_help_option("--editor-pseudolocalization", "Enable pseudolocalization for the editor and the project manager.\n"); +#endif print_help_title("Standalone tools"); print_help_option("-s, --script <script>", "Run a script.\n"); @@ -641,6 +665,8 @@ void Main::print_help(const char *p_binary) { print_help_option("", "The target directory must exist.\n"); print_help_option("--export-debug <preset> <path>", "Export the project in debug mode using the given preset and output path. See --export-release description for other considerations.\n", CLI_OPTION_AVAILABILITY_EDITOR); print_help_option("--export-pack <preset> <path>", "Export the project data only using the given preset and output path. The <path> extension determines whether it will be in PCK or ZIP format.\n", CLI_OPTION_AVAILABILITY_EDITOR); + print_help_option("--export-patch <preset> <path>", "Export pack with changed files only. See --export-pack description for other considerations.\n", CLI_OPTION_AVAILABILITY_EDITOR); + print_help_option("--patches <paths>", "List of patches to use with --export-patch. The list is comma-separated.\n", CLI_OPTION_AVAILABILITY_EDITOR); print_help_option("--install-android-build-template", "Install the Android build template. Used in conjunction with --export-release or --export-debug.\n", CLI_OPTION_AVAILABILITY_EDITOR); #ifndef DISABLE_DEPRECATED // Commands are long; split the description to a second line. @@ -1460,12 +1486,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph wait_for_import = true; quit_after = 1; } else if (arg == "--export-release" || arg == "--export-debug" || - arg == "--export-pack") { // Export project + arg == "--export-pack" || arg == "--export-patch") { // Export project // Actually handling is done in start(). editor = true; cmdline_tool = true; wait_for_import = true; main_args.push_back(arg); + } else if (arg == "--patches") { + if (N) { + // Actually handling is done in start(). + main_args.push_back(arg); + main_args.push_back(N->get()); + + N = N->next(); + } else { + OS::get_singleton()->print("Missing comma-separated list of patches after --patches, aborting.\n"); + goto error; + } #ifndef DISABLE_DEPRECATED } else if (arg == "--export") { // For users used to 3.x syntax. OS::get_singleton()->print("The Godot 3 --export option was changed to more explicit --export-release / --export-debug / --export-pack options.\nSee the --help output for details.\n"); @@ -1683,6 +1720,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph disable_vsync = true; } else if (arg == "--print-fps") { print_fps = true; +#ifdef TOOLS_ENABLED + } else if (arg == "--editor-pseudolocalization") { + editor_pseudolocalization = true; +#endif // TOOLS_ENABLED } else if (arg == "--profile-gpu") { profile_gpu = true; } else if (arg == "--disable-crash-handler") { @@ -2540,6 +2581,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF("display/window/ios/hide_status_bar", true); GLOBAL_DEF("display/window/ios/suppress_ui_gesture", true); +#ifndef _3D_DISABLED // XR project settings. GLOBAL_DEF_RST_BASIC("xr/openxr/enabled", false); GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "xr/openxr/default_action_map", PROPERTY_HINT_FILE, "*.tres"), "res://openxr_action_map.tres"); @@ -2568,7 +2610,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph // editor settings (it seems we're too early in the process when setting up rendering, to access editor settings...) // EDITOR_DEF_RST("xr/openxr/in_editor", false); // GLOBAL_DEF("xr/openxr/in_editor", false); -#endif +#endif // TOOLS_ENABLED +#endif // _3D_DISABLED Engine::get_singleton()->set_frame_delay(frame_delay); @@ -2720,7 +2763,6 @@ Error Main::setup2(bool p_show_boot_logo) { bool prefer_wayland_found = false; bool prefer_wayland = false; - bool remember_window_size_and_position_found = false; if (editor) { screen_property = "interface/editor/editor_screen"; @@ -2736,7 +2778,7 @@ Error Main::setup2(bool p_show_boot_logo) { prefer_wayland_found = true; } - while (!screen_found || !prefer_wayland_found || !remember_window_size_and_position_found) { + while (!screen_found || !prefer_wayland_found) { assign = Variant(); next_tag.fields.clear(); next_tag.name = String(); @@ -2750,17 +2792,16 @@ Error Main::setup2(bool p_show_boot_logo) { if (!screen_found && assign == screen_property) { init_screen = value; screen_found = true; + + if (editor) { + restore_editor_window_layout = value.operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO; + } } if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") { prefer_wayland = value; prefer_wayland_found = true; } - - if (!remember_window_size_and_position_found && assign == "interface/editor/remember_window_size_and_position") { - restore_editor_window_layout = value; - remember_window_size_and_position_found = true; - } } } @@ -3471,9 +3512,11 @@ int Main::start() { bool doc_tool_implicit_cwd = false; BitField<DocTools::GenerateFlags> gen_flags; String _export_preset; + Vector<String> patches; bool export_debug = false; bool export_pack_only = false; bool install_android_build_template = false; + bool export_patch = false; #ifdef MODULE_GDSCRIPT_ENABLED String gdscript_docs_path; #endif @@ -3563,6 +3606,14 @@ int Main::start() { editor = true; _export_preset = E->next()->get(); export_pack_only = true; + } else if (E->get() == "--export-patch") { + ERR_FAIL_COND_V_MSG(!editor && !found_project, EXIT_FAILURE, "Please provide a valid project path when exporting, aborting."); + editor = true; + _export_preset = E->next()->get(); + export_pack_only = true; + export_patch = true; + } else if (E->get() == "--patches") { + patches = E->next()->get().split(",", false); #endif } else { // The parameter does not match anything known, don't skip the next argument @@ -3963,10 +4014,15 @@ int Main::start() { if (editor) { OS::get_singleton()->benchmark_begin_measure("Startup", "Editor"); editor_node = memnew(EditorNode); + + if (editor_pseudolocalization) { + translation_server->get_editor_domain()->set_pseudolocalization_enabled(true); + } + sml->get_root()->add_child(editor_node); if (!_export_preset.is_empty()) { - editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only, install_android_build_template); + editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only, install_android_build_template, export_patch, patches); game_path = ""; // Do not load anything. } @@ -4050,8 +4106,7 @@ int Main::start() { if (editor_embed_subwindows) { sml->get_root()->set_embedding_subwindows(true); } - restore_editor_window_layout = EditorSettings::get_singleton()->get_setting( - "interface/editor/remember_window_size_and_position"); + restore_editor_window_layout = EditorSettings::get_singleton()->get_setting("interface/editor/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO; } #endif @@ -4158,6 +4213,11 @@ int Main::start() { ProjectManager *pmanager = memnew(ProjectManager); ProgressDialog *progress_dialog = memnew(ProgressDialog); pmanager->add_child(progress_dialog); + + if (editor_pseudolocalization) { + translation_server->get_editor_domain()->set_pseudolocalization_enabled(true); + } + sml->get_root()->add_child(pmanager); OS::get_singleton()->benchmark_end_measure("Startup", "Project Manager"); } |