diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 200 |
1 files changed, 102 insertions, 98 deletions
diff --git a/main/main.cpp b/main/main.cpp index d70f0eb291..71dd3cf1ad 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -71,7 +71,6 @@ #include "servers/physics_server_3d.h" #include "servers/register_server_types.h" #include "servers/rendering/rendering_server_default.h" -#include "servers/rendering/rendering_server_wrap_mt.h" #include "servers/text_server.h" #include "servers/xr_server.h" @@ -124,7 +123,9 @@ static bool _start_success = false; // Drivers +String tablet_driver = ""; String text_driver = ""; + static int text_driver_idx = -1; static int display_driver_idx = -1; static int audio_driver_idx = -1; @@ -330,13 +331,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" --enable-vsync-via-compositor When vsync is enabled, vsync via the OS' window compositor (Windows only).\n"); OS::get_singleton()->print(" --disable-vsync-via-compositor Disable vsync via the OS' window compositor (Windows only).\n"); OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n"); - OS::get_singleton()->print(" --tablet-driver Tablet input driver ("); - for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) { - if (i != 0) - OS::get_singleton()->print(", "); - OS::get_singleton()->print("'%s'", OS::get_singleton()->get_tablet_driver_name(i).utf8().get_data()); - } - OS::get_singleton()->print(") (Windows only).\n"); + OS::get_singleton()->print(" --tablet-driver Pen tablet input driver.\n"); OS::get_singleton()->print("\n"); #endif @@ -400,6 +395,8 @@ Error Main::test_setup() { GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); + translation_server = memnew(TranslationServer); + // From `Main::setup2()`. preregister_module_types(); preregister_server_types(); @@ -407,6 +404,16 @@ Error Main::test_setup() { register_core_singletons(); register_server_types(); + + translation_server->setup(); //register translations, load them, etc. + if (locale != "") { + translation_server->set_locale(locale); + } + translation_server->load_translations(); + ResourceLoader::load_translation_remaps(); //load remaps for resources + + ResourceLoader::load_path_remaps(); + register_scene_types(); #ifdef TOOLS_ENABLED @@ -446,6 +453,9 @@ void Main::test_cleanup() { OS::get_singleton()->finalize(); + if (translation_server) { + memdelete(translation_server); + } if (globals) { memdelete(globals); } @@ -516,8 +526,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph MAIN_PRINT("Main: Initialize Globals"); - globals = memnew(ProjectSettings); input_map = memnew(InputMap); + globals = memnew(ProjectSettings); register_core_settings(); //here globals is present @@ -557,7 +567,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph String display_driver = ""; String audio_driver = ""; - String tablet_driver = ""; String project_path = "."; bool upwards = false; String debug_uri = ""; @@ -726,19 +735,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else if (I->get() == "--tablet-driver") { if (I->next()) { tablet_driver = I->next()->get(); - bool found = false; - for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) { - if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) { - found = true; - } - } - - if (!found) { - OS::get_singleton()->print("Unknown tablet driver '%s', aborting.\n", - tablet_driver.utf8().get_data()); - goto error; - } - N = I->next()->next(); } else { OS::get_singleton()->print("Missing tablet driver argument, aborting.\n"); @@ -1126,29 +1122,29 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } #endif - GLOBAL_DEF("logging/file_logging/enable_file_logging", false); + GLOBAL_DEF("debug/file_logging/enable_file_logging", false); // Only file logging by default on desktop platforms as logs can't be // accessed easily on mobile/Web platforms (if at all). // This also prevents logs from being created for the editor instance, as feature tags // are disabled while in the editor (even if they should logically apply). - GLOBAL_DEF("logging/file_logging/enable_file_logging.pc", true); - GLOBAL_DEF("logging/file_logging/log_path", "user://logs/godot.log"); - GLOBAL_DEF("logging/file_logging/max_log_files", 5); - ProjectSettings::get_singleton()->set_custom_property_info("logging/file_logging/max_log_files", + GLOBAL_DEF("debug/file_logging/enable_file_logging.pc", true); + GLOBAL_DEF("debug/file_logging/log_path", "user://logs/godot.log"); + GLOBAL_DEF("debug/file_logging/max_log_files", 5); + ProjectSettings::get_singleton()->set_custom_property_info("debug/file_logging/max_log_files", PropertyInfo(Variant::INT, - "logging/file_logging/max_log_files", + "debug/file_logging/max_log_files", PROPERTY_HINT_RANGE, "0,20,1,or_greater")); //no negative numbers if (!project_manager && !editor && FileAccess::get_create_func(FileAccess::ACCESS_USERDATA) && - GLOBAL_GET("logging/file_logging/enable_file_logging")) { + GLOBAL_GET("debug/file_logging/enable_file_logging")) { // Don't create logs for the project manager as they would be written to // the current working directory, which is inconvenient. - String base_path = GLOBAL_GET("logging/file_logging/log_path"); - int max_files = GLOBAL_GET("logging/file_logging/max_log_files"); + String base_path = GLOBAL_GET("debug/file_logging/log_path"); + int max_files = GLOBAL_GET("debug/file_logging/max_log_files"); OS::get_singleton()->add_logger(memnew(RotatedFileLogger(base_path, max_files))); } - if (main_args.size() == 0 && String(GLOBAL_DEF("application/run/main_scene", "")) == "") { + if (main_args.size() == 0 && String(GLOBAL_GET("application/run/main_scene")) == "") { #ifdef TOOLS_ENABLED if (!editor && !project_manager) { #endif @@ -1180,28 +1176,28 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_cmdline(execpath, main_args); - GLOBAL_DEF("rendering/quality/driver/driver_name", "Vulkan"); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", + GLOBAL_DEF("rendering/driver/driver_name", "Vulkan"); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/driver/driver_name", PropertyInfo(Variant::STRING, - "rendering/quality/driver/driver_name", + "rendering/driver/driver_name", PROPERTY_HINT_ENUM, "Vulkan")); if (display_driver == "") { - display_driver = GLOBAL_GET("rendering/quality/driver/driver_name"); + display_driver = GLOBAL_GET("rendering/driver/driver_name"); } - GLOBAL_DEF("display/window/size/width", 1024); + GLOBAL_DEF_BASIC("display/window/size/width", 1024); ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/width", PropertyInfo(Variant::INT, "display/window/size/width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution - GLOBAL_DEF("display/window/size/height", 600); + GLOBAL_DEF_BASIC("display/window/size/height", 600); ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/height", PropertyInfo(Variant::INT, "display/window/size/height", PROPERTY_HINT_RANGE, "0,4320,or_greater")); // 8K resolution - GLOBAL_DEF("display/window/size/resizable", true); - GLOBAL_DEF("display/window/size/borderless", false); - GLOBAL_DEF("display/window/size/fullscreen", false); + GLOBAL_DEF_BASIC("display/window/size/resizable", true); + GLOBAL_DEF_BASIC("display/window/size/borderless", false); + GLOBAL_DEF_BASIC("display/window/size/fullscreen", false); GLOBAL_DEF("display/window/size/always_on_top", false); GLOBAL_DEF("display/window/size/test_width", 0); ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/test_width", @@ -1249,7 +1245,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } - GLOBAL_DEF("display/window/force_right_to_left_layout_direction", false); + GLOBAL_DEF("internationalization/rendering/force_right_to_left_layout_direction", false); if (!force_lowdpi) { OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false); @@ -1268,28 +1264,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->_vsync_via_compositor = window_vsync_via_compositor; - if (tablet_driver == "") { // specified in project.godot - tablet_driver = GLOBAL_DEF_RST_NOVAL("display/window/tablet_driver", OS::get_singleton()->get_tablet_driver_name(0)); - } - - for (int i = 0; i < OS::get_singleton()->get_tablet_driver_count(); i++) { - if (tablet_driver == OS::get_singleton()->get_tablet_driver_name(i)) { - OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(i)); - break; - } - } - - if (tablet_driver == "") { - OS::get_singleton()->set_current_tablet_driver(OS::get_singleton()->get_tablet_driver_name(0)); - } - /* todo restore OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false); video_mode.layered = GLOBAL_DEF("display/window/per_pixel_transparency/enabled", false); */ - GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); - GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3); - if (editor || project_manager) { // The editor and project manager always detect and use hiDPI if needed OS::get_singleton()->_allow_hidpi = true; @@ -1298,7 +1276,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); if (rtm == -1) { - rtm = GLOBAL_DEF("rendering/threads/thread_model", OS::RENDER_THREAD_SAFE); + rtm = GLOBAL_DEF("rendering/driver/threads/thread_model", OS::RENDER_THREAD_SAFE); } if (rtm >= 0 && rtm < 3) { @@ -1326,7 +1304,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } if (audio_driver == "") { // specified in project.godot - audio_driver = GLOBAL_DEF_RST_NOVAL("audio/driver", AudioDriverManager::get_driver(0)->get_name()); + audio_driver = GLOBAL_DEF_RST_NOVAL("audio/driver/driver", AudioDriverManager::get_driver(0)->get_name()); } for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { @@ -1360,7 +1338,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } - Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/physics_fps", 60)); + Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60)); ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", PropertyInfo(Variant::INT, "physics/common/physics_fps", PROPERTY_HINT_RANGE, "1,120,1,or_greater")); @@ -1477,9 +1455,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) { /* Determine text driver */ - GLOBAL_DEF("display/window/text_name", ""); if (text_driver == "") { - text_driver = GLOBAL_GET("display/window/text_name"); + text_driver = GLOBAL_GET("internationalization/rendering/text_driver"); } if (text_driver != "") { @@ -1508,7 +1485,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { } } } - printf("Using %s text server...\n", TextServerManager::get_interface_name(text_driver_idx).utf8().get_data()); + print_verbose("Using \"" + TextServerManager::get_interface_name(text_driver_idx) + "\" text server..."); /* Initialize Text Server */ @@ -1568,15 +1545,38 @@ Error Main::setup2(Thread::ID p_main_tid_override) { display_server->screen_set_orientation(window_orientation); } - /* Initialize Visual Server */ + /* Initialize Pen Table Driver */ + + { + GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", ""); + GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver.windows", ""); + ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pen_tablet/driver.windows", PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink")); + } - rendering_server = memnew(RenderingServerDefault); - if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) { - rendering_server = memnew(RenderingServerWrapMT(rendering_server, - OS::get_singleton()->get_render_thread_mode() == - OS::RENDER_SEPARATE_THREAD)); + if (tablet_driver == "") { // specified in project.godot + tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver"); + if (tablet_driver == "") { + tablet_driver = DisplayServer::get_singleton()->tablet_get_driver_name(0); + } + } + + for (int i = 0; i < DisplayServer::get_singleton()->tablet_get_driver_count(); i++) { + if (tablet_driver == DisplayServer::get_singleton()->tablet_get_driver_name(i)) { + DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(i)); + break; + } + } + + if (DisplayServer::get_singleton()->tablet_get_current_driver() == "") { + DisplayServer::get_singleton()->tablet_set_current_driver(DisplayServer::get_singleton()->tablet_get_driver_name(0)); } + print_verbose("Using \"" + tablet_driver + "\" pen tablet driver..."); + + /* Initialize Visual Server */ + + rendering_server = memnew(RenderingServerDefault(OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD)); + rendering_server->init(); rendering_server->set_render_loop_enabled(!disable_render_loop); @@ -1608,7 +1608,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: Setup Logo"); -#ifdef JAVASCRIPT_ENABLED +#if defined(JAVASCRIPT_ENABLED) || defined(ANDROID_ENABLED) bool show_logo = false; #else bool show_logo = true; @@ -1636,7 +1636,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: Load Boot Image"); - Color clear = GLOBAL_DEF("rendering/environment/default_clear_color", Color(0.3, 0.3, 0.3)); + Color clear = GLOBAL_DEF("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! @@ -1689,7 +1689,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/default_clear_color", Color(0.3, 0.3, 0.3))); + GLOBAL_DEF("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", @@ -1976,8 +1976,8 @@ bool Main::start() { #endif - if (script == "" && game_path == "" && String(GLOBAL_DEF("application/run/main_scene", "")) != "") { - game_path = GLOBAL_DEF("application/run/main_scene", ""); + if (script == "" && game_path == "" && String(GLOBAL_GET("application/run/main_scene")) != "") { + game_path = GLOBAL_GET("application/run/main_scene"); } MainLoop *main_loop = nullptr; @@ -2152,10 +2152,10 @@ bool Main::start() { if (!editor && !project_manager) { //standard helpers that can be changed from main config - String stretch_mode = GLOBAL_DEF("display/window/stretch/mode", "disabled"); - String stretch_aspect = GLOBAL_DEF("display/window/stretch/aspect", "ignore"); - Size2i stretch_size = Size2i(GLOBAL_DEF("display/window/size/width", 0), - GLOBAL_DEF("display/window/size/height", 0)); + String stretch_mode = GLOBAL_DEF_BASIC("display/window/stretch/mode", "disabled"); + String stretch_aspect = GLOBAL_DEF_BASIC("display/window/stretch/aspect", "ignore"); + Size2i stretch_size = Size2i(GLOBAL_DEF_BASIC("display/window/size/width", 0), + GLOBAL_DEF_BASIC("display/window/size/height", 0)); Window::ContentScaleMode cs_sm = Window::CONTENT_SCALE_MODE_DISABLED; if (stretch_mode == "canvas_items") { @@ -2195,30 +2195,30 @@ bool Main::start() { bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true); sml->get_root()->set_snap_controls_to_pixels(snap_controls); - bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true); + bool font_oversampling = GLOBAL_DEF("gui/fonts/dynamic_fonts/use_oversampling", true); sml->get_root()->set_use_font_oversampling(font_oversampling); - int texture_filter = GLOBAL_DEF("rendering/canvas_textures/default_texture_filter", 1); - int texture_repeat = GLOBAL_DEF("rendering/canvas_textures/default_texture_repeat", 0); + int texture_filter = GLOBAL_DEF("rendering/textures/canvas_textures/default_texture_filter", 1); + int texture_repeat = GLOBAL_DEF("rendering/textures/canvas_textures/default_texture_repeat", 0); sml->get_root()->set_default_canvas_item_texture_filter( Viewport::DefaultCanvasItemTextureFilter(texture_filter)); sml->get_root()->set_default_canvas_item_texture_repeat( Viewport::DefaultCanvasItemTextureRepeat(texture_repeat)); } else { - GLOBAL_DEF("display/window/stretch/mode", "disabled"); + GLOBAL_DEF_BASIC("display/window/stretch/mode", "disabled"); ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/mode", PropertyInfo(Variant::STRING, "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,canvas_items,viewport")); - GLOBAL_DEF("display/window/stretch/aspect", "ignore"); + GLOBAL_DEF_BASIC("display/window/stretch/aspect", "ignore"); ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", PROPERTY_HINT_ENUM, "ignore,keep,keep_width,keep_height,expand")); - GLOBAL_DEF("display/window/stretch/shrink", 1.0); + GLOBAL_DEF_BASIC("display/window/stretch/shrink", 1.0); ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink", PropertyInfo(Variant::FLOAT, "display/window/stretch/shrink", @@ -2226,18 +2226,18 @@ bool Main::start() { "1.0,8.0,0.1")); sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true)); sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true)); - GLOBAL_DEF("gui/common/snap_controls_to_pixels", true); - GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true); + GLOBAL_DEF_BASIC("gui/common/snap_controls_to_pixels", true); + GLOBAL_DEF_BASIC("gui/fonts/dynamic_fonts/use_oversampling", true); - GLOBAL_DEF("rendering/canvas_textures/default_texture_filter", 1); + GLOBAL_DEF_BASIC("rendering/textures/canvas_textures/default_texture_filter", 1); ProjectSettings::get_singleton()->set_custom_property_info( - "rendering/canvas_textures/default_texture_filter", - PropertyInfo(Variant::INT, "rendering/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, + "rendering/textures/canvas_textures/default_texture_filter", + PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapLinear,MipmapNearest")); - GLOBAL_DEF("rendering/canvas_textures/default_texture_repeat", 0); + GLOBAL_DEF_BASIC("rendering/textures/canvas_textures/default_texture_repeat", 0); ProjectSettings::get_singleton()->set_custom_property_info( - "rendering/canvas_textures/default_texture_repeat", - PropertyInfo(Variant::INT, "rendering/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, + "rendering/textures/canvas_textures/default_texture_repeat", + PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_repeat", PROPERTY_HINT_ENUM, "Disable,Enable,Mirror")); } @@ -2451,6 +2451,7 @@ bool Main::iteration() { for (int iters = 0; iters < advance.physics_steps; ++iters) { uint64_t physics_begin = OS::get_singleton()->get_ticks_usec(); + PhysicsServer3D::get_singleton()->sync(); PhysicsServer3D::get_singleton()->flush_queries(); PhysicsServer2D::get_singleton()->sync(); @@ -2465,6 +2466,7 @@ bool Main::iteration() { message_queue->flush(); + PhysicsServer3D::get_singleton()->end_sync(); PhysicsServer3D::get_singleton()->step(physics_step * time_scale); PhysicsServer2D::get_singleton()->end_sync(); @@ -2574,8 +2576,10 @@ void Main::force_redraw() { * so that the engine closes cleanly without leaking memory or crashing. * The order matters as some of those steps are linked with each other. */ -void Main::cleanup() { - ERR_FAIL_COND(!_start_success); +void Main::cleanup(bool p_force) { + if (!p_force) { + ERR_FAIL_COND(!_start_success); + } EngineDebugger::deinitialize(); |