From f601117c742686c126e223fc49de6c1abd4c4f53 Mon Sep 17 00:00:00 2001
From: Hilderin <81109165+Hilderin@users.noreply.github.com>
Date: Fri, 31 Jan 2025 07:22:24 -0500
Subject: [PATCH] Fix Embed Game not available when multi window is disabled
---
doc/classes/EditorSettings.xml | 4 +++-
doc/classes/ProjectSettings.xml | 1 +
editor/plugins/game_view_plugin.cpp | 9 +++++----
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 3900a81502c..fd478216733 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -887,6 +887,7 @@
If [code]true[/code], embed modal windows such as docks inside the main editor window. When single-window mode is enabled, tooltips will also be embedded inside the main editor window, which means they can't be displayed outside of the editor window. Single-window mode can be faster as it does not need to create a separate window for every popup and tooltip, which can be a slow operation depending on the operating system and rendering method in use.
This is equivalent to [member ProjectSettings.display/window/subwindows/embed_subwindows] in the running project, except the setting's value is inverted.
[b]Note:[/b] To query whether the editor can use multiple windows in an editor plugin, use [method EditorInterface.is_multi_window_enabled] instead of querying the value of this editor setting.
+ [b]Note:[/b] If [code]true[/code], game embedding is disabled.
Editor UI default layout direction.
@@ -971,7 +972,7 @@
If [code]true[/code], display OpenType features marked as [code]hidden[/code] by the font file in the [Font] editor.
- If [code]true[/code], multiple window support in editor is enabled. The following panels can become dedicated windows (i.e. made floating): Docks, Script editor, and Shader editor.
+ If [code]true[/code], multiple window support in editor is enabled. The following panels can become dedicated windows (i.e. made floating): Docks, Script editor, Shader editor, and Game Workspace.
[b]Note:[/b] When [member interface/editor/single_window_mode] is [code]true[/code], the multi window support is always disabled.
[b]Note:[/b] To query whether the editor can use multiple windows in an editor plugin, use [method EditorInterface.is_multi_window_enabled] instead of querying the value of this editor setting.
@@ -1148,6 +1149,7 @@
The window mode to use to display the project when starting the project from the editor.
+ [b]Note:[/b] Game embedding is not available for "Force Maximized" or "Force Fullscreen."
The custom position to use when starting the project from the editor (in pixels from the top-left corner). Only effective if [member run/window_placement/rect] is set to [b]Custom Position[/b].
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 131ac6ea930..6bdd24ecb83 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -879,6 +879,7 @@
Main window mode. See [enum DisplayServer.WindowMode] for possible values and how each mode behaves.
+ [b]Note:[/b] Game embedding is available only in the "Windowed" mode.
Main window can't be focused. No-focus window will ignore all input, except mouse clicks.
diff --git a/editor/plugins/game_view_plugin.cpp b/editor/plugins/game_view_plugin.cpp
index 6c4ecc8be9f..d96ee851374 100644
--- a/editor/plugins/game_view_plugin.cpp
+++ b/editor/plugins/game_view_plugin.cpp
@@ -223,7 +223,7 @@ void GameView::_instance_starting(int p_idx, List &r_arguments) {
if (!is_feature_enabled) {
return;
}
- if (p_idx == 0 && embed_on_play && make_floating_on_play && !window_wrapper->get_window_enabled() && _get_embed_available() == EMBED_AVAILABLE) {
+ if (p_idx == 0 && embed_on_play && make_floating_on_play && window_wrapper->is_window_available() && !window_wrapper->get_window_enabled() && _get_embed_available() == EMBED_AVAILABLE) {
// Set the Floating Window default title. Always considered in DEBUG mode, same as in Window::set_title.
String appname = GLOBAL_GET("application/config/name");
appname = vformat("%s (DEBUG)", TranslationServer::get_singleton()->translate(appname));
@@ -431,7 +431,7 @@ GameView::EmbedAvailability GameView::_get_embed_available() {
if (!DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_WINDOW_EMBEDDING)) {
return EMBED_NOT_AVAILABLE_FEATURE_NOT_SUPPORTED;
}
- if (!EditorNode::get_singleton()->is_multi_window_enabled()) {
+ if (get_tree()->get_root()->is_embedding_subwindows()) {
return EMBED_NOT_AVAILABLE_SINGLE_WINDOW_MODE;
}
@@ -505,11 +505,12 @@ void GameView::_update_ui() {
}
void GameView::_update_embed_menu_options() {
+ bool is_multi_window = window_wrapper->is_window_available();
PopupMenu *menu = embed_options_menu->get_popup();
menu->set_item_checked(menu->get_item_index(EMBED_RUN_GAME_EMBEDDED), embed_on_play);
- menu->set_item_checked(menu->get_item_index(EMBED_MAKE_FLOATING_ON_PLAY), make_floating_on_play);
+ menu->set_item_checked(menu->get_item_index(EMBED_MAKE_FLOATING_ON_PLAY), make_floating_on_play && is_multi_window);
- menu->set_item_disabled(menu->get_item_index(EMBED_MAKE_FLOATING_ON_PLAY), !embed_on_play);
+ menu->set_item_disabled(menu->get_item_index(EMBED_MAKE_FLOATING_ON_PLAY), !embed_on_play || !is_multi_window);
fixed_size_button->set_pressed(embed_size_mode == SIZE_MODE_FIXED);
keep_aspect_button->set_pressed(embed_size_mode == SIZE_MODE_KEEP_ASPECT);