summaryrefslogtreecommitdiff
path: root/main/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main/main.cpp')
-rw-r--r--main/main.cpp63
1 files changed, 26 insertions, 37 deletions
diff --git a/main/main.cpp b/main/main.cpp
index bfe560fa31..ccd48a9343 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -81,6 +81,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"
@@ -370,11 +371,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
@@ -424,6 +420,7 @@ Error Main::test_setup() {
ResourceLoader::load_path_remaps();
register_scene_types();
+ register_driver_types();
#ifdef TOOLS_ENABLED
ClassDB::set_current_api(ClassDB::API_EDITOR);
@@ -434,7 +431,6 @@ Error Main::test_setup() {
register_platform_apis();
register_module_types();
- register_driver_types();
// Theme needs modules to be initialized so that sub-resources can be loaded.
initialize_theme();
@@ -457,13 +453,13 @@ void Main::test_cleanup() {
ResourceLoader::remove_custom_loaders();
ResourceSaver::remove_custom_savers();
- unregister_driver_types();
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif
unregister_module_types();
unregister_platform_apis();
+ unregister_driver_types();
unregister_scene_types();
unregister_server_types();
@@ -486,6 +482,7 @@ void Main::test_cleanup() {
}
unregister_core_driver_types();
+ unregister_core_extensions();
unregister_core_types();
OS::get_singleton()->finalize_core();
@@ -633,7 +630,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
@@ -945,15 +941,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;
@@ -1156,6 +1143,8 @@ 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();
+ 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 +1184,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) {
@@ -1212,6 +1196,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// If we didn't find a project, we fall back to the project manager.
project_manager = !found_project && !cmdline_tool;
}
+
+ if (project_manager) {
+ Engine::get_singleton()->set_project_manager_hint(true);
+ }
#endif
GLOBAL_DEF("debug/file_logging/enable_file_logging", false);
@@ -1272,7 +1260,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");
@@ -1529,6 +1516,7 @@ error:
}
unregister_core_driver_types();
+ unregister_core_extensions();
unregister_core_types();
OS::get_singleton()->_cmdline.clear();
@@ -1888,6 +1876,10 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
register_scene_types();
+ MAIN_PRINT("Main: Load Driver Types");
+
+ register_driver_types();
+
#ifdef TOOLS_ENABLED
ClassDB::set_current_api(ClassDB::API_EDITOR);
EditorNode::register_editor_types();
@@ -1923,14 +1915,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();
@@ -1961,6 +1951,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;
@@ -2105,9 +2099,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);
+ DirAccessRef 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);
@@ -2118,9 +2111,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);
+ DirAccessRef 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);
@@ -2458,15 +2450,13 @@ bool Main::start() {
int sep = local_game_path.rfind("/");
if (sep == -1) {
- DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ DirAccessRef 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));
+ DirAccessRef da = DirAccess::open(local_game_path.substr(0, sep));
if (da) {
local_game_path = da->get_current_dir().plus_file(
local_game_path.substr(sep + 1, local_game_path.length()));
- memdelete(da);
}
}
}
@@ -2540,7 +2530,6 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (project_manager) {
Engine::get_singleton()->set_editor_hint(true);
- Engine::get_singleton()->set_project_manager_hint(true);
ProjectManager *pmanager = memnew(ProjectManager);
ProgressDialog *progress_dialog = memnew(ProgressDialog);
pmanager->add_child(progress_dialog);
@@ -2811,8 +2800,6 @@ void Main::cleanup(bool p_force) {
xr_server->set_primary_interface(Ref<XRInterface>());
}
- unregister_driver_types();
-
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif
@@ -2821,6 +2808,7 @@ void Main::cleanup(bool p_force) {
unregister_module_types();
unregister_platform_apis();
+ unregister_driver_types();
unregister_scene_types();
unregister_server_types();
@@ -2889,6 +2877,7 @@ void Main::cleanup(bool p_force) {
memdelete(message_queue);
unregister_core_driver_types();
+ unregister_core_extensions();
unregister_core_types();
OS::get_singleton()->finalize_core();