summaryrefslogtreecommitdiff
path: root/editor/debugger/script_editor_debugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/debugger/script_editor_debugger.cpp')
-rw-r--r--editor/debugger/script_editor_debugger.cpp74
1 files changed, 29 insertions, 45 deletions
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 169ff61e71..299f504f1e 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -45,6 +45,7 @@
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor/property_editor.h"
#include "main/performance.h"
+#include "scene/3d/camera.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
@@ -58,12 +59,14 @@
#include "scene/gui/tree.h"
#include "scene/resources/packed_scene.h"
+using CameraOverride = EditorDebuggerNode::CameraOverride;
+
void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) {
if (is_session_active()) {
Array msg;
msg.push_back(p_message);
msg.push_back(p_data);
- ppeer->put_var(msg);
+ peer->put_message(msg);
}
}
@@ -776,7 +779,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
if (is_session_active()) {
- if (camera_override == OVERRIDE_2D) {
+ if (camera_override == CameraOverride::OVERRIDE_2D) {
CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
Dictionary state = editor->get_state();
@@ -791,8 +794,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
msg.push_back(transform);
_put_msg("override_camera_2D:transform", msg);
- } else if (camera_override >= OVERRIDE_3D_1) {
- int viewport_idx = camera_override - OVERRIDE_3D_1;
+ } else if (camera_override >= CameraOverride::OVERRIDE_3D_1) {
+ int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1;
SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx);
Camera *const cam = viewport->get_camera();
@@ -811,30 +814,11 @@ void ScriptEditorDebugger::_notification(int p_what) {
}
}
- if (!is_session_active()) {
- _stop_and_notify();
- break;
- };
-
- if (ppeer->get_available_packet_count() <= 0) {
- break;
- };
-
const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20;
- while (ppeer->get_available_packet_count() > 0) {
+ while (peer->has_message()) {
- Variant cmd;
- Error ret = ppeer->get_var(cmd);
- if (ret != OK) {
- _stop_and_notify();
- ERR_FAIL_MSG("Error decoding variant from peer");
- }
- if (cmd.get_type() != Variant::ARRAY) {
- _stop_and_notify();
- ERR_FAIL_MSG("Invalid message format received from peer");
- }
- Array arr = cmd;
+ Array arr = peer->get_message();
if (arr.size() != 2 || arr[0].get_type() != Variant::STRING || arr[1].get_type() != Variant::ARRAY) {
_stop_and_notify();
ERR_FAIL_MSG("Invalid message format received from peer");
@@ -844,6 +828,10 @@ void ScriptEditorDebugger::_notification(int p_what) {
if (OS::get_singleton()->get_ticks_msec() > until)
break;
}
+ if (!is_session_active()) {
+ _stop_and_notify();
+ break;
+ };
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
@@ -875,14 +863,13 @@ void ScriptEditorDebugger::_clear_execution() {
inspector->clear_stack_variables();
}
-void ScriptEditorDebugger::start(Ref<StreamPeerTCP> p_connection) {
+void ScriptEditorDebugger::start(Ref<EditorDebuggerPeer> p_peer) {
error_count = 0;
warning_count = 0;
stop();
- connection = p_connection;
- ppeer->set_stream_peer(connection);
+ peer = p_peer;
perf_history.clear();
for (int i = 0; i < Performance::MONITOR_MAX; i++) {
@@ -893,7 +880,7 @@ void ScriptEditorDebugger::start(Ref<StreamPeerTCP> p_connection) {
set_process(true);
breaked = false;
can_debug = true;
- camera_override = OVERRIDE_NONE;
+ camera_override = CameraOverride::OVERRIDE_NONE;
tabs->set_current_tab(0);
_set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS);
@@ -936,10 +923,10 @@ void ScriptEditorDebugger::stop() {
_clear_execution();
inspector->clear_cache();
- ppeer->set_stream_peer(Ref<StreamPeer>());
- if (connection.is_valid()) {
- connection.unref();
+ if (peer.is_valid()) {
+ peer->close();
+ peer.unref();
reason->set_text("");
reason->set_tooltip("");
}
@@ -971,9 +958,6 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
void ScriptEditorDebugger::_visual_profiler_activate(bool p_enable) {
- if (!connection.is_valid())
- return;
-
if (p_enable) {
profiler_signature.clear();
_put_msg("start_visual_profiling", Array());
@@ -1328,25 +1312,25 @@ void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const
}
}
-ScriptEditorDebugger::CameraOverride ScriptEditorDebugger::get_camera_override() const {
+CameraOverride ScriptEditorDebugger::get_camera_override() const {
return camera_override;
}
void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) {
- if (p_override == OVERRIDE_2D && camera_override != OVERRIDE_2D) {
+ if (p_override == CameraOverride::OVERRIDE_2D && camera_override != CameraOverride::OVERRIDE_2D) {
Array msg;
msg.push_back(true);
_put_msg("override_camera_2D:set", msg);
- } else if (p_override != OVERRIDE_2D && camera_override == OVERRIDE_2D) {
+ } else if (p_override != CameraOverride::OVERRIDE_2D && camera_override == CameraOverride::OVERRIDE_2D) {
Array msg;
msg.push_back(false);
_put_msg("override_camera_2D:set", msg);
- } else if (p_override >= OVERRIDE_3D_1 && camera_override < OVERRIDE_3D_1) {
+ } else if (p_override >= CameraOverride::OVERRIDE_3D_1 && camera_override < CameraOverride::OVERRIDE_3D_1) {
Array msg;
msg.push_back(true);
_put_msg("override_camera_3D:set", msg);
- } else if (p_override < OVERRIDE_3D_1 && camera_override >= OVERRIDE_3D_1) {
+ } else if (p_override < CameraOverride::OVERRIDE_3D_1 && camera_override >= CameraOverride::OVERRIDE_3D_1) {
Array msg;
msg.push_back(false);
_put_msg("override_camera_3D:set", msg);
@@ -1423,7 +1407,6 @@ void ScriptEditorDebugger::_clear_errors_list() {
error_tree->clear();
error_count = 0;
warning_count = 0;
- update_tabs();
}
// Right click on specific file(s) or folder(s).
@@ -1502,8 +1485,6 @@ void ScriptEditorDebugger::_bind_methods() {
ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
- ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream));
- ppeer->set_input_buffer_max_size((1024 * 1024 * 8) - 4); // 8 MiB should be enough, minus 4 bytes for separator.
editor = p_editor;
tabs = memnew(TabContainer);
@@ -1824,7 +1805,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
add_child(msgdialog);
live_debug = true;
- camera_override = OVERRIDE_NONE;
+ camera_override = CameraOverride::OVERRIDE_NONE;
last_path_id = false;
error_count = 0;
warning_count = 0;
@@ -1833,6 +1814,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
ScriptEditorDebugger::~ScriptEditorDebugger() {
- ppeer->set_stream_peer(Ref<StreamPeer>());
+ if (peer.is_valid()) {
+ peer->close();
+ peer.unref();
+ }
memdelete(scene_tree);
}