You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #99010 from Hilderin/embedding-game-process
Embed game process in editor
This commit is contained in:
@@ -227,6 +227,7 @@ static bool init_always_on_top = false;
|
||||
static bool init_use_custom_pos = false;
|
||||
static bool init_use_custom_screen = false;
|
||||
static Vector2 init_custom_pos;
|
||||
static int64_t init_embed_parent_window_id = 0;
|
||||
|
||||
// Debug
|
||||
|
||||
@@ -622,6 +623,7 @@ void Main::print_help(const char *p_binary) {
|
||||
#ifndef _3D_DISABLED
|
||||
print_help_option("--xr-mode <mode>", "Select XR (Extended Reality) mode [\"default\", \"off\", \"on\"].\n");
|
||||
#endif
|
||||
print_help_option("--wid <window_id>", "Request parented to window.\n");
|
||||
|
||||
print_help_title("Debug options");
|
||||
print_help_option("-d, --debug", "Debug (local stdout debugger).\n");
|
||||
@@ -1812,6 +1814,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
goto error;
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
} else if (arg == "--wid") {
|
||||
if (N) {
|
||||
init_embed_parent_window_id = N->get().to_int();
|
||||
if (init_embed_parent_window_id == 0) {
|
||||
OS::get_singleton()->print("<window_id> argument for --wid <window_id> must be different then 0.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
OS::get_singleton()->_embedded_in_editor = true;
|
||||
Engine::get_singleton()->set_embedded_in_editor(true);
|
||||
|
||||
N = N->next();
|
||||
} else {
|
||||
OS::get_singleton()->print("Missing <window_id> argument for --wid <window_id>.\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
} else if (arg == "--" || arg == "++") {
|
||||
adding_user_args = true;
|
||||
} else {
|
||||
@@ -2975,9 +2994,16 @@ Error Main::setup2(bool p_show_boot_logo) {
|
||||
context = DisplayServer::CONTEXT_ENGINE;
|
||||
}
|
||||
|
||||
if (init_embed_parent_window_id) {
|
||||
// Reset flags and other settings to be sure it's borderless and windowed. The position and size should have been initialized correctly
|
||||
// from --position and --resolution parameters.
|
||||
window_mode = DisplayServer::WINDOW_MODE_WINDOWED;
|
||||
window_flags = DisplayServer::WINDOW_FLAG_BORDERLESS_BIT;
|
||||
}
|
||||
|
||||
// rendering_driver now held in static global String in main and initialized in setup()
|
||||
Error err;
|
||||
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, err);
|
||||
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, init_embed_parent_window_id, err);
|
||||
if (err != OK || display_server == nullptr) {
|
||||
String last_name = DisplayServer::get_create_function_name(display_driver_idx);
|
||||
|
||||
@@ -2991,7 +3017,7 @@ Error Main::setup2(bool p_show_boot_logo) {
|
||||
String name = DisplayServer::get_create_function_name(i);
|
||||
WARN_PRINT(vformat("Display driver %s failed, falling back to %s.", last_name, name));
|
||||
|
||||
display_server = DisplayServer::create(i, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, err);
|
||||
display_server = DisplayServer::create(i, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, init_embed_parent_window_id, err);
|
||||
if (err == OK && display_server != nullptr) {
|
||||
break;
|
||||
}
|
||||
@@ -3194,15 +3220,17 @@ Error Main::setup2(bool p_show_boot_logo) {
|
||||
|
||||
MAIN_PRINT("Main: Setup Logo");
|
||||
|
||||
if (init_windowed) {
|
||||
//do none..
|
||||
} else if (init_maximized) {
|
||||
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_MAXIMIZED);
|
||||
} else if (init_fullscreen) {
|
||||
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_FULLSCREEN);
|
||||
}
|
||||
if (init_always_on_top) {
|
||||
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP, true);
|
||||
if (!init_embed_parent_window_id) {
|
||||
if (init_windowed) {
|
||||
//do none..
|
||||
} else if (init_maximized) {
|
||||
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_MAXIMIZED);
|
||||
} else if (init_fullscreen) {
|
||||
DisplayServer::get_singleton()->window_set_mode(DisplayServer::WINDOW_MODE_FULLSCREEN);
|
||||
}
|
||||
if (init_always_on_top) {
|
||||
DisplayServer::get_singleton()->window_set_flag(DisplayServer::WINDOW_FLAG_ALWAYS_ON_TOP, true);
|
||||
}
|
||||
}
|
||||
|
||||
Color clear = GLOBAL_DEF_BASIC("rendering/environment/defaults/default_clear_color", Color(0.3, 0.3, 0.3));
|
||||
|
||||
Reference in New Issue
Block a user