diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 82 |
1 files changed, 49 insertions, 33 deletions
diff --git a/main/main.cpp b/main/main.cpp index 89c8832731..fb42f71a75 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -61,7 +61,6 @@ #include "scene/main/window.h" #include "scene/register_scene_types.h" #include "scene/resources/packed_scene.h" -#include "servers/arvr_server.h" #include "servers/audio_server.h" #include "servers/camera_server.h" #include "servers/display_server.h" @@ -72,6 +71,7 @@ #include "servers/register_server_types.h" #include "servers/rendering/rendering_server_raster.h" #include "servers/rendering/rendering_server_wrap_mt.h" +#include "servers/xr_server.h" #ifdef TOOLS_ENABLED #include "editor/doc_data.h" @@ -87,29 +87,29 @@ // Singletons // Initialized in setup() -static Engine *engine = NULL; -static ProjectSettings *globals = NULL; -static InputFilter *input = NULL; -static InputMap *input_map = NULL; -static TranslationServer *translation_server = NULL; -static Performance *performance = NULL; -static PackedData *packed_data = NULL; +static Engine *engine = nullptr; +static ProjectSettings *globals = nullptr; +static InputFilter *input = nullptr; +static InputMap *input_map = nullptr; +static TranslationServer *translation_server = nullptr; +static Performance *performance = nullptr; +static PackedData *packed_data = nullptr; #ifdef MINIZIP_ENABLED -static ZipArchive *zip_packed_data = NULL; +static ZipArchive *zip_packed_data = nullptr; #endif -static FileAccessNetworkClient *file_access_network_client = NULL; -static MessageQueue *message_queue = NULL; +static FileAccessNetworkClient *file_access_network_client = nullptr; +static MessageQueue *message_queue = nullptr; // Initialized in setup2() -static AudioServer *audio_server = NULL; -static DisplayServer *display_server = NULL; -static RenderingServer *rendering_server = NULL; -static CameraServer *camera_server = NULL; -static ARVRServer *arvr_server = NULL; -static PhysicsServer3D *physics_server = NULL; -static PhysicsServer2D *physics_2d_server = NULL; -static NavigationServer3D *navigation_server = NULL; -static NavigationServer2D *navigation_2d_server = NULL; +static AudioServer *audio_server = nullptr; +static DisplayServer *display_server = nullptr; +static RenderingServer *rendering_server = nullptr; +static CameraServer *camera_server = nullptr; +static XRServer *xr_server = nullptr; +static PhysicsServer3D *physics_server = nullptr; +static PhysicsServer2D *physics_2d_server = nullptr; +static NavigationServer3D *navigation_server = nullptr; +static NavigationServer2D *navigation_2d_server = nullptr; // We error out if setup2() doesn't turn this true static bool _start_success = false; @@ -220,7 +220,7 @@ void finalize_display() { } void initialize_navigation_server() { - ERR_FAIL_COND(navigation_server != NULL); + ERR_FAIL_COND(navigation_server != nullptr); navigation_server = NavigationServer3DManager::new_default_server(); navigation_2d_server = memnew(NavigationServer2D); @@ -228,10 +228,10 @@ void initialize_navigation_server() { void finalize_navigation_server() { memdelete(navigation_server); - navigation_server = NULL; + navigation_server = nullptr; memdelete(navigation_2d_server); - navigation_2d_server = NULL; + navigation_2d_server = nullptr; } //#define DEBUG_INIT @@ -478,6 +478,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph I = args.front(); while (I) { +#ifdef OSX_ENABLED + // Ignore the process serial number argument passed by macOS Gatekeeper. + // Otherwise, Godot would try to open a non-existent project on the first start and abort. + if (I->get().begins_with("-psn_")) { + I = I->next(); + continue; + } +#endif List<String>::Element *N = I->next(); @@ -1297,8 +1305,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) { audio_server = memnew(AudioServer); audio_server->init(); - // also init our arvr_server from here - arvr_server = memnew(ARVRServer); + // also init our xr_server from here + xr_server = memnew(XRServer); register_core_singletons(); @@ -1642,7 +1650,7 @@ bool Main::start() { game_path = GLOBAL_DEF("application/run/main_scene", ""); } - MainLoop *main_loop = NULL; + MainLoop *main_loop = nullptr; if (editor) { main_loop = memnew(SceneTree); }; @@ -1723,7 +1731,9 @@ bool Main::start() { } #endif - if (single_window) { + bool embed_subwindows = GLOBAL_DEF("display/window/subwindows/embed_subwindows", false); + + if (single_window || (!project_manager && !editor && embed_subwindows)) { sml->get_root()->set_embed_subwindows_hint(true); } ResourceLoader::add_custom_loaders(); @@ -1772,7 +1782,7 @@ bool Main::start() { RES res = ResourceLoader::load(path); ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + path); - Node *n = NULL; + Node *n = nullptr; if (res->is_class("PackedScene")) { Ref<PackedScene> ps = res; n = ps->instance(); @@ -1784,7 +1794,7 @@ bool Main::start() { Object *obj = ClassDB::instance(ibt); - ERR_CONTINUE_MSG(obj == NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); + ERR_CONTINUE_MSG(obj == nullptr, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); n = Object::cast_to<Node>(obj); n->set_script(script_res); @@ -1811,7 +1821,7 @@ bool Main::start() { } #ifdef TOOLS_ENABLED - EditorNode *editor_node = NULL; + EditorNode *editor_node = nullptr; if (editor) { editor_node = memnew(EditorNode); sml->get_root()->add_child(editor_node); @@ -1942,6 +1952,12 @@ bool Main::start() { #ifdef TOOLS_ENABLED if (editor) { + bool editor_embed_subwindows = EditorSettings::get_singleton()->get_setting("interface/editor/single_window_mode"); + + if (editor_embed_subwindows) { + sml->get_root()->set_embed_subwindows_hint(true); + } + if (game_path != GLOBAL_GET("application/run/main_scene") || !editor_node->has_scenes_in_session()) { Error serr = editor_node->load_scene(local_game_path); if (serr != OK) @@ -1961,7 +1977,7 @@ bool Main::start() { Crypto::load_default_certificates(GLOBAL_DEF("network/ssl/certificates", "")); if (game_path != "") { - Node *scene = NULL; + Node *scene = nullptr; Ref<PackedScene> scenedata = ResourceLoader::load(local_game_path); if (scenedata.is_valid()) scene = scenedata->instance(); @@ -2268,9 +2284,9 @@ void Main::cleanup() { EditorNode::unregister_editor_types(); #endif - if (arvr_server) { + if (xr_server) { // cleanup now before we pull the rug from underneath... - memdelete(arvr_server); + memdelete(xr_server); } ImageLoader::cleanup(); |