summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/debugger/editor_debugger_node.cpp12
-rw-r--r--editor/debugger/editor_debugger_node.h2
-rw-r--r--editor/debugger/editor_debugger_server.cpp27
-rw-r--r--editor/debugger/editor_debugger_server.h12
-rw-r--r--editor/debugger/script_editor_debugger.cpp2
-rw-r--r--editor/editor_export.cpp4
-rw-r--r--editor/editor_export.h1
-rw-r--r--editor/editor_node.cpp39
-rw-r--r--editor/editor_node.h3
-rw-r--r--editor/editor_run.cpp2
-rw-r--r--editor/editor_run_native.cpp4
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp4
12 files changed, 75 insertions, 37 deletions
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp
index 7551214336..5bfb79806e 100644
--- a/editor/debugger/editor_debugger_node.cpp
+++ b/editor/debugger/editor_debugger_node.cpp
@@ -173,7 +173,7 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const {
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
}
-Error EditorDebuggerNode::start() {
+Error EditorDebuggerNode::start(const String &p_protocol) {
stop();
if (EDITOR_GET("run/output/always_open_output_on_play")) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
@@ -181,7 +181,7 @@ Error EditorDebuggerNode::start() {
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
}
- server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create_default());
+ server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create(p_protocol));
const Error err = server->start();
if (err != OK) {
return err;
@@ -213,14 +213,6 @@ void EditorDebuggerNode::stop() {
void EditorDebuggerNode::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
- EditorNode::get_singleton()->connect("play_pressed", callable_mp(this, &EditorDebuggerNode::start));
- EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop));
- } break;
- case NOTIFICATION_EXIT_TREE: {
- EditorNode::get_singleton()->disconnect("play_pressed", callable_mp(this, &EditorDebuggerNode::start));
- EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop));
- } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (tabs->get_tab_count() > 1) {
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h
index 9467442c9a..7546febd05 100644
--- a/editor/debugger/editor_debugger_node.h
+++ b/editor/debugger/editor_debugger_node.h
@@ -183,7 +183,7 @@ public:
void set_camera_override(CameraOverride p_override) { camera_override = p_override; }
CameraOverride get_camera_override() { return camera_override; }
- Error start();
+ Error start(const String &p_protocol = "tcp://");
void stop();
};
diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp
index c80988a662..33f20d9a12 100644
--- a/editor/debugger/editor_debugger_server.cpp
+++ b/editor/debugger/editor_debugger_server.cpp
@@ -44,6 +44,7 @@ private:
Ref<TCP_Server> server;
public:
+ static EditorDebuggerServer *create(const String &p_protocol);
virtual void poll() {}
virtual Error start();
virtual void stop();
@@ -54,6 +55,11 @@ public:
EditorDebuggerServerTCP();
};
+EditorDebuggerServer *EditorDebuggerServerTCP::create(const String &p_protocol) {
+ ERR_FAIL_COND_V(p_protocol != "tcp://", nullptr);
+ return memnew(EditorDebuggerServerTCP);
+}
+
EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
server.instance();
}
@@ -85,6 +91,23 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() {
return memnew(RemoteDebuggerPeerTCP(server->take_connection()));
}
-EditorDebuggerServer *EditorDebuggerServer::create_default() {
- return memnew(EditorDebuggerServerTCP);
+/// EditorDebuggerServer
+Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols;
+
+EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) {
+ ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr);
+ return protocols[p_protocol](p_protocol);
+}
+
+void EditorDebuggerServer::register_protocol_handler(const String &p_protocol, CreateServerFunc p_func) {
+ ERR_FAIL_COND(protocols.has(p_protocol));
+ protocols[p_protocol] = p_func;
+}
+
+void EditorDebuggerServer::initialize() {
+ register_protocol_handler("tcp://", EditorDebuggerServerTCP::create);
+}
+
+void EditorDebuggerServer::deinitialize() {
+ protocols.clear();
}
diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h
index e9798c90b3..515ffce628 100644
--- a/editor/debugger/editor_debugger_server.h
+++ b/editor/debugger/editor_debugger_server.h
@@ -37,7 +37,17 @@
class EditorDebuggerServer : public Reference {
public:
- static EditorDebuggerServer *create_default();
+ typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri);
+
+private:
+ static Map<StringName, CreateServerFunc> protocols;
+
+public:
+ static void initialize();
+ static void deinitialize();
+
+ static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func);
+ static EditorDebuggerServer *create(const String &p_protocol);
virtual void poll() = 0;
virtual Error start() = 0;
virtual void stop() = 0;
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index af79de2991..3ed271c7c6 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -846,6 +846,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
if (is_session_active()) {
+ peer->poll();
+
if (camera_override == CameraOverride::OVERRIDE_2D) {
CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index e8167070d4..24a69fe003 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -284,7 +284,7 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
r_flags.push_back("--remote-debug");
- r_flags.push_back(host + ":" + String::num(remote_port));
+ r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
List<String> breakpoints;
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
@@ -1127,7 +1127,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
r_flags.push_back("--remote-debug");
- r_flags.push_back(host + ":" + String::num(remote_port));
+ r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
List<String> breakpoints;
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
diff --git a/editor/editor_export.h b/editor/editor_export.h
index f47fe9c95e..50d1ff66c6 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -270,6 +270,7 @@ public:
virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual void get_platform_features(List<String> *r_features) = 0;
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0;
+ virtual String get_debug_protocol() const { return "tcp://"; }
EditorExportPlatform();
};
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 1b1ce4ec37..abb639254a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2072,9 +2072,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
args = ProjectSettings::get_singleton()->get("editor/main_run_args");
skip_breakpoints = EditorDebuggerNode::get_singleton()->is_skip_breakpoints();
+ EditorDebuggerNode::get_singleton()->start();
Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
if (error != OK) {
+ EditorDebuggerNode::get_singleton()->stop();
show_accept(TTR("Could not start subprocess!"), TTR("OK"));
return;
}
@@ -2096,6 +2098,24 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
_playing_edited = p_current;
}
+void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
+
+ bool autosave = EDITOR_GET("run/auto_save/save_before_running");
+ if (autosave) {
+ _menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
+ }
+ if (run_native->is_deploy_debug_remote_enabled()) {
+ _menu_option_confirm(RUN_STOP, true);
+
+ if (!call_build())
+ return; // build failed
+
+ EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol());
+ emit_signal("play_pressed");
+ editor_run.run_native_notify();
+ }
+}
+
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
if (!p_confirmed) //this may be a hack..
@@ -2464,6 +2484,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
}
+ EditorDebuggerNode::get_singleton()->stop();
emit_signal("stop_pressed");
} break;
@@ -2482,22 +2503,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_run(true);
} break;
- case RUN_PLAY_NATIVE: {
-
- bool autosave = EDITOR_GET("run/auto_save/save_before_running");
- if (autosave) {
- _menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
- }
- if (run_native->is_deploy_debug_remote_enabled()) {
- _menu_option_confirm(RUN_STOP, true);
-
- if (!call_build())
- break; // build failed
-
- emit_signal("play_pressed");
- editor_run.run_native_notify();
- }
- } break;
case RUN_SCENE_SETTINGS: {
run_settings_dialog->popup_run_settings();
@@ -6346,7 +6351,7 @@ EditorNode::EditorNode() {
run_native = memnew(EditorRunNative);
play_hb->add_child(run_native);
- run_native->connect("native_run", callable_mp(this, &EditorNode::_menu_option), varray(RUN_PLAY_NATIVE));
+ run_native->connect("native_run", callable_mp(this, &EditorNode::_run_native));
play_scene_button = memnew(ToolButton);
play_hb->add_child(play_scene_button);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index c6f04b0749..11f4008936 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -32,6 +32,7 @@
#define EDITOR_NODE_H
#include "editor/editor_data.h"
+#include "editor/editor_export.h"
#include "editor/editor_folding.h"
#include "editor/editor_run.h"
#include "editor/inspector_dock.h"
@@ -161,7 +162,6 @@ private:
RUN_STOP,
RUN_PLAY_SCENE,
- RUN_PLAY_NATIVE,
RUN_PLAY_CUSTOM_SCENE,
RUN_SCENE_SETTINGS,
RUN_SETTINGS,
@@ -492,6 +492,7 @@ private:
void _quick_run();
void _run(bool p_current = false, const String &p_custom = "");
+ void _run_native(const Ref<EditorExportPreset> &p_preset);
void _save_optimized();
void _import_action(const String &p_action);
diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp
index b4ddb7ebfa..01156d9809 100644
--- a/editor/editor_run.cpp
+++ b/editor/editor_run.cpp
@@ -53,7 +53,7 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
}
args.push_back("--remote-debug");
- args.push_back(remote_host + ":" + String::num(remote_port));
+ args.push_back("tcp://" + remote_host + ":" + String::num(remote_port));
args.push_back("--allow_focus_steal_pid");
args.push_back(itos(OS::get_singleton()->get_process_id()));
diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp
index 464666ac6a..d4450acea2 100644
--- a/editor/editor_run_native.cpp
+++ b/editor/editor_run_native.cpp
@@ -133,7 +133,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
return;
}
- emit_signal("native_run");
+ emit_signal("native_run", preset);
int flags = 0;
@@ -160,7 +160,7 @@ void EditorRunNative::resume_run_native() {
void EditorRunNative::_bind_methods() {
- ADD_SIGNAL(MethodInfo("native_run"));
+ ADD_SIGNAL(MethodInfo("native_run", PropertyInfo(Variant::OBJECT, "preset", PROPERTY_HINT_RESOURCE_TYPE, "EditorExportPreset")));
}
bool EditorRunNative::is_deploy_debug_remote_enabled() const {
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index 2b0d3f2582..e0d345663c 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -32,11 +32,14 @@
#include "core/os/keyboard.h"
#include "editor/debugger/editor_debugger_node.h"
+#include "editor/debugger/editor_debugger_server.h"
#include "editor/editor_node.h"
#include "editor/fileserver/editor_file_server.h"
#include "scene/gui/menu_button.h"
DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_debug_menu) {
+ EditorDebuggerServer::initialize();
+
ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11);
ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10);
ED_SHORTCUT("debugger/break", TTR("Break"));
@@ -96,6 +99,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
}
DebuggerEditorPlugin::~DebuggerEditorPlugin() {
+ EditorDebuggerServer::deinitialize();
memdelete(file_server);
}