summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp261
1 files changed, 165 insertions, 96 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 7cbafe37a3..75c4433b41 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -35,6 +35,7 @@
#include "core/crypto/crypto.h"
#include "core/debugger/engine_debugger.h"
#include "core/extension/extension_api_dump.h"
+#include "core/extension/native_extension_manager.h"
#include "core/input/input.h"
#include "core/input/input_map.h"
#include "core/io/dir_access.h"
@@ -70,6 +71,7 @@
#include "servers/physics_server_3d.h"
#include "servers/register_server_types.h"
#include "servers/rendering/rendering_server_default.h"
+#include "servers/text/text_server_dummy.h"
#include "servers/text_server.h"
#include "servers/xr_server.h"
@@ -81,6 +83,7 @@
#include "editor/doc_data_class_path.gen.h"
#include "editor/doc_tools.h"
#include "editor/editor_node.h"
+#include "editor/editor_paths.h"
#include "editor/editor_settings.h"
#include "editor/editor_translation.h"
#include "editor/progress_dialog.h"
@@ -118,10 +121,10 @@ static RenderingServer *rendering_server = nullptr;
static CameraServer *camera_server = nullptr;
static XRServer *xr_server = nullptr;
static TextServerManager *tsman = nullptr;
-static PhysicsServer3D *physics_server = nullptr;
-static PhysicsServer2D *physics_2d_server = nullptr;
-static NavigationServer3D *navigation_server = nullptr;
-static NavigationServer2D *navigation_2d_server = nullptr;
+static PhysicsServer3D *physics_server_3d = nullptr;
+static PhysicsServer2D *physics_server_2d = nullptr;
+static NavigationServer3D *navigation_server_3d = nullptr;
+static NavigationServer2D *navigation_server_2d = nullptr;
// We error out if setup2() doesn't turn this true
static bool _start_success = false;
@@ -202,32 +205,32 @@ static String get_full_version_string() {
// to have less code in main.cpp.
void initialize_physics() {
/// 3D Physics Server
- physics_server = PhysicsServer3DManager::new_server(
+ physics_server_3d = PhysicsServer3DManager::new_server(
ProjectSettings::get_singleton()->get(PhysicsServer3DManager::setting_property_name));
- if (!physics_server) {
+ if (!physics_server_3d) {
// Physics server not found, Use the default physics
- physics_server = PhysicsServer3DManager::new_default_server();
+ physics_server_3d = PhysicsServer3DManager::new_default_server();
}
- ERR_FAIL_COND(!physics_server);
- physics_server->init();
+ ERR_FAIL_COND(!physics_server_3d);
+ physics_server_3d->init();
/// 2D Physics server
- physics_2d_server = PhysicsServer2DManager::new_server(
+ physics_server_2d = PhysicsServer2DManager::new_server(
ProjectSettings::get_singleton()->get(PhysicsServer2DManager::setting_property_name));
- if (!physics_2d_server) {
+ if (!physics_server_2d) {
// Physics server not found, Use the default physics
- physics_2d_server = PhysicsServer2DManager::new_default_server();
+ physics_server_2d = PhysicsServer2DManager::new_default_server();
}
- ERR_FAIL_COND(!physics_2d_server);
- physics_2d_server->init();
+ ERR_FAIL_COND(!physics_server_2d);
+ physics_server_2d->init();
}
void finalize_physics() {
- physics_server->finish();
- memdelete(physics_server);
+ physics_server_3d->finish();
+ memdelete(physics_server_3d);
- physics_2d_server->finish();
- memdelete(physics_2d_server);
+ physics_server_2d->finish();
+ memdelete(physics_server_2d);
}
void finalize_display() {
@@ -238,18 +241,18 @@ void finalize_display() {
}
void initialize_navigation_server() {
- ERR_FAIL_COND(navigation_server != nullptr);
+ ERR_FAIL_COND(navigation_server_3d != nullptr);
- navigation_server = NavigationServer3DManager::new_default_server();
- navigation_2d_server = memnew(NavigationServer2D);
+ navigation_server_3d = NavigationServer3DManager::new_default_server();
+ navigation_server_2d = memnew(NavigationServer2D);
}
void finalize_navigation_server() {
- memdelete(navigation_server);
- navigation_server = nullptr;
+ memdelete(navigation_server_3d);
+ navigation_server_3d = nullptr;
- memdelete(navigation_2d_server);
- navigation_2d_server = nullptr;
+ memdelete(navigation_server_2d);
+ navigation_server_2d = nullptr;
}
//#define DEBUG_INIT
@@ -272,7 +275,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -h, --help Display this help message.\n");
OS::get_singleton()->print(" --version Display the version string.\n");
OS::get_singleton()->print(" -v, --verbose Use verbose stdout mode.\n");
- OS::get_singleton()->print(" --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n");
+ OS::get_singleton()->print(" -q, --quiet Quiet mode, silences stdout messages. Errors are still displayed.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Run options:\n");
@@ -281,7 +284,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
OS::get_singleton()->print(" --debug-server <uri> Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)\n");
#endif
- OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
+ OS::get_singleton()->print(" --quit Quit after the first iteration.\n");
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
OS::get_singleton()->print(" --path <directory> Path to a project (<directory> must contain a 'project.godot' file).\n");
OS::get_singleton()->print(" -u, --upwards Scan folders upwards for project.godot file.\n");
@@ -318,9 +321,8 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n");
OS::get_singleton()->print(" --gpu-index <device_index> Use a specific GPU (run with --verbose to get available device list).\n");
-
OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n");
-
+ OS::get_singleton()->print(" --tablet-driver <driver> Pen tablet input driver.\n");
OS::get_singleton()->print(" --headless Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.\n");
OS::get_singleton()->print("\n");
@@ -333,21 +335,22 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --resolution <W>x<H> Request window resolution.\n");
OS::get_singleton()->print(" --position <X>,<Y> Request window position.\n");
OS::get_singleton()->print(" --single-window Use a single window (no separate subwindows).\n");
- OS::get_singleton()->print(" --tablet-driver Pen tablet input driver.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Debug options:\n");
OS::get_singleton()->print(" -d, --debug Debug (local stdout debugger).\n");
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
- OS::get_singleton()->print(" --vk-layers Enable Vulkan Validation layers for debugging.\n");
-#ifdef DEBUG_ENABLED
+ OS::get_singleton()->print(" --gpu-profile Show a GPU profile of the tasks that took the most time during frame rendering.\n");
+ OS::get_singleton()->print(" --vk-layers Enable Vulkan validation layers for debugging.\n");
+#if DEBUG_ENABLED
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
#endif
OS::get_singleton()->print(" --remote-debug <uri> Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
#if defined(DEBUG_ENABLED)
OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n");
OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n");
+ OS::get_singleton()->print(" --debug-stringnames Print all StringName allocations to stdout when the engine quits.\n");
#endif
OS::get_singleton()->print(" --frame-delay <ms> Simulate high CPU load (delay each frame by <ms> milliseconds).\n");
OS::get_singleton()->print(" --time-scale <scale> Force time scale (higher values are faster, 1.0 is normal speed).\n");
@@ -355,7 +358,6 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n");
OS::get_singleton()->print(" --fixed-fps <fps> Force a fixed number of frames per second. This setting disables real-time synchronization.\n");
OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n");
- OS::get_singleton()->print(" --profile-gpu Show a simple profile of the tasks that took more time during frame rendering.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Standalone tools:\n");
@@ -370,11 +372,6 @@ void Main::print_help(const char *p_binary) {
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");
OS::get_singleton()->print(" --dump-extension-api Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.\n");
-#ifdef DEBUG_METHODS_ENABLED
- // TODO: Should be removed together with nativescript eventually.
- OS::get_singleton()->print(" --gdnative-generate-json-api <path> Generate JSON dump of the Godot API for GDNative bindings and save it on the file specified in <path>.\n");
- OS::get_singleton()->print(" --gdnative-generate-json-builtin-api <path> Generate JSON dump of the Godot API of the builtin Variant types and utility functions for GDNative bindings and save it on the file specified in <path>.\n");
-#endif
#ifdef TESTS_ENABLED
OS::get_singleton()->print(" --test [--help] Run unit tests. Use --test --help for more information.\n");
#endif
@@ -404,15 +401,24 @@ Error Main::test_setup() {
translation_server = memnew(TranslationServer);
tsman = memnew(TextServerManager);
- register_core_extensions();
+ if (tsman) {
+ Ref<TextServerDummy> ts;
+ ts.instantiate();
+ tsman->add_interface(ts);
+ }
// From `Main::setup2()`.
- preregister_module_types();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
+ register_core_extensions();
+
preregister_server_types();
register_core_singletons();
+ /** INITIALIZE SERVERS **/
register_server_types();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
translation_server->setup(); //register translations, load them, etc.
if (!locale.is_empty()) {
@@ -424,23 +430,46 @@ Error Main::test_setup() {
ResourceLoader::load_path_remaps();
register_scene_types();
+ register_driver_types();
+
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
#ifdef TOOLS_ENABLED
ClassDB::set_current_api(ClassDB::API_EDITOR);
EditorNode::register_editor_types();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
+
ClassDB::set_current_api(ClassDB::API_CORE);
#endif
register_platform_apis();
- register_module_types();
- register_driver_types();
-
// Theme needs modules to be initialized so that sub-resources can be loaded.
initialize_theme();
ERR_FAIL_COND_V(TextServerManager::get_singleton()->get_interface_count() == 0, ERR_CANT_CREATE);
- TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(0));
+
+ /* Use one with the most features available. */
+ int max_features = 0;
+ for (int i = 0; i < TextServerManager::get_singleton()->get_interface_count(); i++) {
+ uint32_t features = TextServerManager::get_singleton()->get_interface(i)->get_features();
+ int feature_number = 0;
+ while (features) {
+ feature_number += features & 1;
+ features >>= 1;
+ }
+ if (feature_number >= max_features) {
+ max_features = feature_number;
+ text_driver_idx = i;
+ }
+ }
+ if (text_driver_idx >= 0) {
+ TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx));
+ } else {
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface.");
+ }
ClassDB::set_current_api(ClassDB::API_NONE);
@@ -457,14 +486,20 @@ void Main::test_cleanup() {
ResourceLoader::remove_custom_loaders();
ResourceSaver::remove_custom_savers();
- unregister_driver_types();
#ifdef TOOLS_ENABLED
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
EditorNode::unregister_editor_types();
#endif
- unregister_module_types();
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
unregister_platform_apis();
+ unregister_driver_types();
unregister_scene_types();
+
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
unregister_server_types();
OS::get_singleton()->finalize();
@@ -486,6 +521,8 @@ void Main::test_cleanup() {
}
unregister_core_driver_types();
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
+ unregister_core_extensions();
unregister_core_types();
OS::get_singleton()->finalize_core();
@@ -584,8 +621,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
I = I->next();
}
- I = args.front();
-
String display_driver = "";
String audio_driver = "";
String project_path = ".";
@@ -633,7 +668,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
continue;
}
#endif
-
List<String>::Element *N = I->next();
if (I->get() == "-h" || I->get() == "--help" || I->get() == "/?") { // display help
@@ -648,7 +682,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-v" || I->get() == "--verbose") { // verbose output
OS::get_singleton()->_verbose_stdout = true;
- } else if (I->get() == "--quiet") { // quieter output
+ } else if (I->get() == "-q" || I->get() == "--quiet") { // quieter output
quiet_stdout = true;
@@ -791,7 +825,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
Engine::singleton->gpu_idx = I->next()->get().to_int();
N = I->next()->next();
} else {
- OS::get_singleton()->print("Missing gpu index argument, aborting.\n");
+ OS::get_singleton()->print("Missing GPU index argument, aborting.\n");
goto error;
}
} else if (I->get() == "--vk-layers") {
@@ -945,15 +979,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
cmdline_tool = true;
-#ifdef DEBUG_METHODS_ENABLED
- } else if (I->get() == "--gdnative-generate-json-api" || I->get() == "--gdnative-generate-json-builtin-api") {
- // Register as an editor instance to use low-end fallback if relevant.
- editor = true;
- cmdline_tool = true;
- // We still pass it to the main arguments since the argument handling itself is not done in this function,
- // it's done in nativescript init code.
- main_args.push_back(I->get());
-#endif
} else if (I->get() == "--dump-extension-api") {
// Register as an editor instance to use low-end fallback if relevant.
editor = true;
@@ -973,6 +998,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "--doctool") {
// Actually handling is done in start().
cmdline_tool = true;
+
+ // `--doctool` implies `--headless` to avoid spawning an unnecessary window
+ // and speed up class reference generation.
+ audio_driver = "Dummy";
+ display_driver = "headless";
main_args.push_back(I->get());
#endif
} else if (I->get() == "--path") { // set path of project to start or edit
@@ -991,7 +1021,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
} else if (I->get() == "-u" || I->get() == "--upwards") { // scan folders upwards
upwards = true;
- } else if (I->get() == "-q" || I->get() == "--quit") { // Auto quit at the end of the first main loop iteration
+ } else if (I->get() == "--quit") { // Auto quit at the end of the first main loop iteration
auto_quit = true;
} else if (I->get().ends_with("project.godot")) {
String path;
@@ -1156,6 +1186,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// Initialize user data dir.
OS::get_singleton()->ensure_user_data_dir();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
+ register_core_extensions(); // core extensions must be registered after globals setup and before display
+
ResourceUID::get_singleton()->load_from_cache(); // load UUIDs from cache.
GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
@@ -1195,11 +1228,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
if (editor) {
packed_data->set_disabled(true);
globals->set_disable_feature_overrides(true);
- }
-#endif
-
-#ifdef TOOLS_ENABLED
- if (editor) {
Engine::get_singleton()->set_editor_hint(true);
main_args.push_back("--editor");
if (!init_windowed) {
@@ -1276,7 +1304,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_cmdline(execpath, main_args);
- register_core_extensions(); //before display
// possibly be worth changing the default from vulkan to something lower spec,
// for the project manager, depending on how smooth the fallback is.
GLOBAL_DEF_RST("rendering/driver/driver_name", "vulkan");
@@ -1480,6 +1507,28 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
GLOBAL_DEF("display/window/ios/hide_home_indicator", true);
GLOBAL_DEF("input_devices/pointing/ios/touch_delay", 0.150);
+ // XR project settings.
+ GLOBAL_DEF_RST_BASIC("xr/openxr/enabled", false);
+ GLOBAL_DEF_BASIC("xr/openxr/default_action_map", "res://openxr_action_map.tres");
+ ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/default_action_map", PropertyInfo(Variant::STRING, "xr/openxr/default_action_map", PROPERTY_HINT_FILE, "*.tres"));
+
+ GLOBAL_DEF_BASIC("xr/openxr/form_factor", "0");
+ ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/form_factor", PropertyInfo(Variant::INT, "xr/openxr/form_factor", PROPERTY_HINT_ENUM, "Head mounted,Handheld"));
+
+ GLOBAL_DEF_BASIC("xr/openxr/view_configuration", "1");
+ ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/view_configuration", PropertyInfo(Variant::INT, "xr/openxr/view_configuration", PROPERTY_HINT_ENUM, "Mono,Stereo")); // "Mono,Stereo,Quad,Observer"
+
+ GLOBAL_DEF_BASIC("xr/openxr/reference_space", "1");
+ ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/reference_space", PropertyInfo(Variant::INT, "xr/openxr/reference_space", PROPERTY_HINT_ENUM, "Local,Stage"));
+
+#ifdef TOOLS_ENABLED
+ // Disabled for now, using XR inside of the editor we'll be working on during the coming months.
+
+ // 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
+
Engine::get_singleton()->set_frame_delay(frame_delay);
message_queue = memnew(MessageQueue);
@@ -1533,6 +1582,7 @@ error:
}
unregister_core_driver_types();
+ unregister_core_extensions();
unregister_core_types();
OS::get_singleton()->_cmdline.clear();
@@ -1549,7 +1599,12 @@ error:
Error Main::setup2(Thread::ID p_main_tid_override) {
tsman = memnew(TextServerManager);
- preregister_module_types();
+ if (tsman) {
+ Ref<TextServerDummy> ts;
+ ts.instantiate();
+ tsman->add_interface(ts);
+ }
+
preregister_server_types();
// Print engine name and version
@@ -1716,6 +1771,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
register_server_types();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
MAIN_PRINT("Main: Load Boot Image");
@@ -1884,17 +1941,22 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
if (text_driver_idx >= 0) {
TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx));
} else {
- ERR_PRINT("TextServer: Unable to create TextServer interface.");
- return ERR_CANT_CREATE;
+ ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface.");
}
MAIN_PRINT("Main: Load Scene Types");
register_scene_types();
+ register_driver_types();
+
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
#ifdef TOOLS_ENABLED
ClassDB::set_current_api(ClassDB::API_EDITOR);
EditorNode::register_editor_types();
+ initialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
+ NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
ClassDB::set_current_api(ClassDB::API_CORE);
@@ -1903,7 +1965,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
MAIN_PRINT("Main: Load Modules");
register_platform_apis();
- register_module_types();
// Theme needs modules to be initialized so that sub-resources can be loaded.
initialize_theme();
@@ -1927,14 +1988,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
camera_server = CameraServer::create();
- MAIN_PRINT("Main: Load Physics, Drivers, Scripts");
+ MAIN_PRINT("Main: Load Physics");
initialize_physics();
initialize_navigation_server();
register_server_singletons();
- register_driver_types();
-
// This loads global classes, so it must happen before custom loaders and savers are registered
ScriptServer::init_languages();
@@ -1965,6 +2024,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
return OK;
}
+String Main::get_rendering_driver_name() {
+ return rendering_driver;
+}
+
// everything the main loop needs to know about frame timings
static MainTimerSync main_timer_sync;
@@ -2072,8 +2135,8 @@ bool Main::start() {
}
{
- DirAccessRef da = DirAccess::open(doc_tool_path);
- ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");
+ Ref<DirAccess> da = DirAccess::open(doc_tool_path);
+ ERR_FAIL_COND_V_MSG(da.is_null(), false, "Argument supplied to --doctool must be a valid directory path.");
}
#ifndef MODULE_MONO_ENABLED
@@ -2109,9 +2172,8 @@ bool Main::start() {
checked_paths.insert(path);
// Create the module documentation directory if it doesn't exist
- DirAccess *da = DirAccess::create_for_path(path);
+ Ref<DirAccess> da = DirAccess::create_for_path(path);
err = da->make_dir_recursive(path);
- memdelete(da);
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create directory: " + path + ": " + itos(err));
print_line("Loading docs from: " + path);
@@ -2122,9 +2184,8 @@ bool Main::start() {
String index_path = doc_tool_path.plus_file("doc/classes");
// Create the main documentation directory if it doesn't exist
- DirAccess *da = DirAccess::create_for_path(index_path);
+ Ref<DirAccess> da = DirAccess::create_for_path(index_path);
err = da->make_dir_recursive(index_path);
- memdelete(da);
ERR_FAIL_COND_V_MSG(err != OK, false, "Error: Can't create index directory: " + index_path + ": " + itos(err));
print_line("Loading classes from: " + index_path);
@@ -2258,9 +2319,10 @@ bool Main::start() {
bool embed_subwindows = GLOBAL_DEF("display/window/subwindows/embed_subwindows", true);
- if (OS::get_singleton()->is_single_window() || (!project_manager && !editor && embed_subwindows)) {
- sml->get_root()->set_embed_subwindows_hint(true);
+ if (OS::get_singleton()->is_single_window() || (!project_manager && !editor && embed_subwindows) || !DisplayServer::get_singleton()->has_feature(DisplayServer::Feature::FEATURE_SUBWINDOWS)) {
+ sml->get_root()->set_embedding_subwindows(true);
}
+
ResourceLoader::add_custom_loaders();
ResourceSaver::add_custom_savers();
@@ -2285,7 +2347,7 @@ bool Main::start() {
for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) {
const ProjectSettings::AutoloadInfo &info = E.get();
- RES res = ResourceLoader::load(info.path);
+ Ref<Resource> res = ResourceLoader::load(info.path);
ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path);
Node *n = nullptr;
Ref<PackedScene> scn = res;
@@ -2295,7 +2357,7 @@ bool Main::start() {
} else if (script_res.is_valid()) {
StringName ibt = script_res->get_instance_base_type();
bool valid_type = ClassDB::is_parent_class(ibt, "Node");
- ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path);
+ ERR_CONTINUE_MSG(!valid_type, "Script does not inherit from Node: " + info.path);
Object *obj = ClassDB::instantiate(ibt);
@@ -2412,10 +2474,10 @@ bool Main::start() {
"display/window/stretch/aspect",
PROPERTY_HINT_ENUM,
"ignore,keep,keep_width,keep_height,expand"));
- GLOBAL_DEF_BASIC("display/window/stretch/shrink", 1.0);
- ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/shrink",
+ GLOBAL_DEF_BASIC("display/window/stretch/scale", 1.0);
+ ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/scale",
PropertyInfo(Variant::FLOAT,
- "display/window/stretch/shrink",
+ "display/window/stretch/scale",
PROPERTY_HINT_RANGE,
"1.0,8.0,0.1"));
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
@@ -2441,7 +2503,7 @@ bool Main::start() {
"interface/editor/single_window_mode");
if (editor_embed_subwindows) {
- sml->get_root()->set_embed_subwindows_hint(true);
+ sml->get_root()->set_embedding_subwindows(true);
}
}
#endif
@@ -2462,15 +2524,13 @@ bool Main::start() {
int sep = local_game_path.rfind("/");
if (sep == -1) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
local_game_path = da->get_current_dir().plus_file(local_game_path);
- memdelete(da);
} else {
- DirAccess *da = DirAccess::open(local_game_path.substr(0, sep));
- if (da) {
+ Ref<DirAccess> da = DirAccess::open(local_game_path.substr(0, sep));
+ if (da.is_valid()) {
local_game_path = da->get_current_dir().plus_file(
local_game_path.substr(sep + 1, local_game_path.length()));
- memdelete(da);
}
}
}
@@ -2814,17 +2874,24 @@ void Main::cleanup(bool p_force) {
xr_server->set_primary_interface(Ref<XRInterface>());
}
- unregister_driver_types();
-
#ifdef TOOLS_ENABLED
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
EditorNode::unregister_editor_types();
+
#endif
ImageLoader::cleanup();
- unregister_module_types();
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SCENE);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
+
unregister_platform_apis();
+ unregister_driver_types();
unregister_scene_types();
+
+ NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_SERVERS);
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
unregister_server_types();
EngineDebugger::deinitialize();
@@ -2892,6 +2959,8 @@ void Main::cleanup(bool p_force) {
memdelete(message_queue);
unregister_core_driver_types();
+ unregister_core_extensions();
+ uninitialize_modules(MODULE_INITIALIZATION_LEVEL_CORE);
unregister_core_types();
OS::get_singleton()->finalize_core();