mirror of
https://github.com/godotengine/godot.git
synced 2025-01-22 10:32:54 -05:00
Fix Floating Game Window Title
This commit is contained in:
parent
7b1ed520bd
commit
05fcfede1e
6 changed files with 69 additions and 0 deletions
|
@ -826,6 +826,9 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
|
|||
}
|
||||
} else if (p_msg == "evaluation_return") {
|
||||
expression_evaluator->add_value(p_data);
|
||||
} else if (p_msg == "window:title") {
|
||||
ERR_FAIL_COND(p_data.size() != 1);
|
||||
emit_signal(SNAME("remote_window_title_changed"), p_data[0]);
|
||||
} else {
|
||||
int colon_index = p_msg.find_char(':');
|
||||
ERR_FAIL_COND_MSG(colon_index < 1, "Invalid message received");
|
||||
|
@ -1784,6 +1787,7 @@ void ScriptEditorDebugger::_bind_methods() {
|
|||
ADD_SIGNAL(MethodInfo("remote_object_property_updated", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "property")));
|
||||
ADD_SIGNAL(MethodInfo("remote_tree_updated"));
|
||||
ADD_SIGNAL(MethodInfo("remote_tree_select_requested", PropertyInfo(Variant::NODE_PATH, "path")));
|
||||
ADD_SIGNAL(MethodInfo("remote_window_title_changed", PropertyInfo(Variant::STRING, "title")));
|
||||
ADD_SIGNAL(MethodInfo("output", PropertyInfo(Variant::STRING, "msg"), PropertyInfo(Variant::INT, "level")));
|
||||
ADD_SIGNAL(MethodInfo("stack_dump", PropertyInfo(Variant::ARRAY, "stack_dump")));
|
||||
ADD_SIGNAL(MethodInfo("stack_frame_vars", PropertyInfo(Variant::INT, "num_vars")));
|
||||
|
|
|
@ -145,6 +145,10 @@ bool EmbeddedProcess::is_embedding_completed() {
|
|||
return embedding_completed;
|
||||
}
|
||||
|
||||
int EmbeddedProcess::get_embedded_pid() const {
|
||||
return current_process_id;
|
||||
}
|
||||
|
||||
void EmbeddedProcess::embed_process(OS::ProcessID p_pid) {
|
||||
if (!window) {
|
||||
return;
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
Rect2i get_screen_embedded_window_rect();
|
||||
bool is_embedding_in_progress();
|
||||
bool is_embedding_completed();
|
||||
int get_embedded_pid() const;
|
||||
|
||||
EmbeddedProcess();
|
||||
~EmbeddedProcess();
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/debugger/debugger_marshalls.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "editor/debugger/editor_debugger_node.h"
|
||||
#include "editor/debugger/script_editor_debugger.h"
|
||||
#include "editor/editor_command_palette.h"
|
||||
#include "editor/editor_feature_profile.h"
|
||||
#include "editor/editor_interface.h"
|
||||
|
@ -203,6 +205,12 @@ void GameView::_sessions_changed() {
|
|||
}
|
||||
|
||||
_update_debugger_buttons();
|
||||
|
||||
if (embedded_process->is_embedding_completed()) {
|
||||
if (!embedded_script_debugger || !embedded_script_debugger->is_session_active() || embedded_script_debugger->get_remote_pid() != embedded_process->get_embedded_pid()) {
|
||||
_attach_script_debugger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::_instance_starting_static(int p_idx, List<String> &r_arguments) {
|
||||
|
@ -215,6 +223,11 @@ void GameView::_instance_starting(int p_idx, List<String> &r_arguments) {
|
|||
return;
|
||||
}
|
||||
if (p_idx == 0 && embed_on_play && make_floating_on_play && !window_wrapper->get_window_enabled() && EditorNode::get_singleton()->is_multi_window_enabled()) {
|
||||
// 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));
|
||||
window_wrapper->set_window_title(appname);
|
||||
|
||||
window_wrapper->restore_window_from_saved_position(floating_window_rect, floating_window_screen, floating_window_screen_rect);
|
||||
}
|
||||
|
||||
|
@ -255,6 +268,8 @@ void GameView::_stop_pressed() {
|
|||
return;
|
||||
}
|
||||
|
||||
_detach_script_debugger();
|
||||
|
||||
EditorNode::get_singleton()->set_unfocused_low_processor_usage_mode_enabled(true);
|
||||
embedded_process->reset();
|
||||
_update_ui();
|
||||
|
@ -272,6 +287,7 @@ void GameView::_stop_pressed() {
|
|||
}
|
||||
|
||||
void GameView::_embedding_completed() {
|
||||
_attach_script_debugger();
|
||||
_update_ui();
|
||||
}
|
||||
|
||||
|
@ -563,6 +579,36 @@ void GameView::_update_floating_window_settings() {
|
|||
}
|
||||
}
|
||||
|
||||
void GameView::_attach_script_debugger() {
|
||||
if (embedded_script_debugger) {
|
||||
_detach_script_debugger();
|
||||
}
|
||||
|
||||
embedded_script_debugger = nullptr;
|
||||
for (int i = 0; EditorDebuggerNode::get_singleton()->get_debugger(i); i++) {
|
||||
ScriptEditorDebugger *script_debugger = EditorDebuggerNode::get_singleton()->get_debugger(i);
|
||||
if (script_debugger->is_session_active() && script_debugger->get_remote_pid() == embedded_process->get_embedded_pid()) {
|
||||
embedded_script_debugger = script_debugger;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (embedded_script_debugger) {
|
||||
embedded_script_debugger->connect("remote_window_title_changed", callable_mp(this, &GameView::_remote_window_title_changed));
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::_detach_script_debugger() {
|
||||
if (embedded_script_debugger) {
|
||||
embedded_script_debugger->disconnect("remote_window_title_changed", callable_mp(this, &GameView::_remote_window_title_changed));
|
||||
embedded_script_debugger = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::_remote_window_title_changed(String title) {
|
||||
window_wrapper->set_window_title(title);
|
||||
}
|
||||
|
||||
void GameView::_update_arguments_for_instance(int p_idx, List<String> &r_arguments) {
|
||||
if (p_idx != 0 || !embed_on_play || !DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_WINDOW_EMBEDDING)) {
|
||||
return;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
class EmbeddedProcess;
|
||||
class VSeparator;
|
||||
class WindowWrapper;
|
||||
class ScriptEditorDebugger;
|
||||
|
||||
class GameViewDebugger : public EditorDebuggerPlugin {
|
||||
GDCLASS(GameViewDebugger, EditorDebuggerPlugin);
|
||||
|
@ -101,6 +102,7 @@ class GameView : public VBoxContainer {
|
|||
bool is_feature_enabled = true;
|
||||
int active_sessions = 0;
|
||||
int screen_index_before_start = -1;
|
||||
ScriptEditorDebugger *embedded_script_debugger = nullptr;
|
||||
|
||||
bool embed_on_play = true;
|
||||
bool make_floating_on_play = true;
|
||||
|
@ -162,6 +164,9 @@ class GameView : public VBoxContainer {
|
|||
|
||||
void _window_before_closing();
|
||||
void _update_floating_window_settings();
|
||||
void _attach_script_debugger();
|
||||
void _detach_script_debugger();
|
||||
void _remote_window_title_changed(String title);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "window.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/debugger/engine_debugger.h"
|
||||
#include "core/input/shortcut.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "scene/gui/control.h"
|
||||
|
@ -306,6 +307,14 @@ void Window::set_title(const String &p_title) {
|
|||
}
|
||||
}
|
||||
emit_signal("title_changed");
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (EngineDebugger::get_singleton() && window_id == DisplayServer::MAIN_WINDOW_ID && !Engine::get_singleton()->is_project_manager_hint()) {
|
||||
Array arr;
|
||||
arr.push_back(tr_title);
|
||||
EngineDebugger::get_singleton()->send_message("window:title", arr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
String Window::get_title() const {
|
||||
|
|
Loading…
Reference in a new issue