summaryrefslogtreecommitdiffstats
path: root/scene/debugger/scene_debugger.cpp
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-11 09:07:04 -0500
committerSpartan322 <Megacake1234@gmail.com>2024-11-11 09:08:01 -0500
commit62fbec9f6f0722a1f9825c17f073742932082228 (patch)
treea10abf56ba93705731da1aaf338f2cf21403c6ad /scene/debugger/scene_debugger.cpp
parente7894c2c4efdd51049a21af4892005381fe57cd6 (diff)
parent0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff)
downloadredot-engine-62fbec9f6f0722a1f9825c17f073742932082228.tar.gz
Merge commit godotengine/godot@0f5f3bc9546b46b2029fc8896dc859697f1eab97
Diffstat (limited to 'scene/debugger/scene_debugger.cpp')
-rw-r--r--scene/debugger/scene_debugger.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index 1a1780d737..6f92b3e0ff 100644
--- a/scene/debugger/scene_debugger.cpp
+++ b/scene/debugger/scene_debugger.cpp
@@ -32,6 +32,7 @@
#include "scene_debugger.h"
+#include "core/debugger/debugger_marshalls.h"
#include "core/debugger/engine_debugger.h"
#include "core/io/marshalls.h"
#include "core/object/script_language.h"
@@ -95,6 +96,13 @@ void SceneDebugger::deinitialize() {
}
#ifdef DEBUG_ENABLED
+void SceneDebugger::_handle_input(const Ref<InputEvent> &p_event, const Ref<Shortcut> &p_shortcut) {
+ Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && p_shortcut->matches_event(k)) {
+ EngineDebugger::get_singleton()->send_message("request_quit", Array());
+ }
+}
+
Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured) {
SceneTree *scene_tree = SceneTree::get_singleton();
if (!scene_tree) {
@@ -111,7 +119,10 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
}
r_captured = true;
- if (p_msg == "request_scene_tree") { // Scene tree
+ if (p_msg == "setup_scene") {
+ SceneTree::get_singleton()->get_root()->connect(SceneStringName(window_input), callable_mp_static(SceneDebugger::_handle_input).bind(DebuggerMarshalls::deserialize_key_shortcut(p_args)));
+
+ } else if (p_msg == "request_scene_tree") { // Scene tree
live_editor->_send_tree();
} else if (p_msg == "save_node") { // Save node.
@@ -149,7 +160,6 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA);
Transform2D transform = p_args[0];
scene_tree->get_root()->set_canvas_transform_override(transform);
-
runtime_node_select->_queue_selection_update();
#ifndef _3D_DISABLED
@@ -166,16 +176,19 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
scene_tree->get_root()->set_camera_3d_override_orthogonal(size_or_fov, depth_near, depth_far);
}
scene_tree->get_root()->set_camera_3d_override_transform(transform);
-
runtime_node_select->_queue_selection_update();
#endif // _3D_DISABLED
} else if (p_msg == "set_object_property") {
ERR_FAIL_COND_V(p_args.size() < 3, ERR_INVALID_DATA);
_set_object_property(p_args[0], p_args[1], p_args[2]);
-
runtime_node_select->_queue_selection_update();
+ } else if (p_msg == "reload_cached_files") {
+ ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA);
+ PackedStringArray files = p_args[0];
+ reload_cached_files(files);
+
} else if (p_msg.begins_with("live_")) { /// Live Edit
if (p_msg == "live_set_root") {
ERR_FAIL_COND_V(p_args.size() < 2, ERR_INVALID_DATA);
@@ -271,7 +284,8 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
} else if (p_msg.begins_with("runtime_node_select_")) { /// Runtime Node Selection
if (p_msg == "runtime_node_select_setup") {
- runtime_node_select->_setup();
+ ERR_FAIL_COND_V(p_args.is_empty() || p_args[0].get_type() != Variant::DICTIONARY, ERR_INVALID_DATA);
+ runtime_node_select->_setup(p_args[0]);
} else if (p_msg == "runtime_node_select_set_type") {
ERR_FAIL_COND_V(p_args.is_empty(), ERR_INVALID_DATA);
@@ -291,8 +305,10 @@ Error SceneDebugger::parse_message(void *p_user, const String &p_msg, const Arra
} else if (p_msg == "runtime_node_select_reset_camera_2d") {
runtime_node_select->_reset_camera_2d();
+#ifndef _3D_DISABLED
} else if (p_msg == "runtime_node_select_reset_camera_3d") {
runtime_node_select->_reset_camera_3d();
+#endif // _3D_DISABLED
} else {
return ERR_SKIP;
@@ -415,6 +431,15 @@ void SceneDebugger::remove_from_cache(const String &p_filename, Node *p_node) {
}
}
+void SceneDebugger::reload_cached_files(const PackedStringArray &p_files) {
+ for (const String &file : p_files) {
+ Ref<Resource> res = ResourceCache::get_ref(file);
+ if (res.is_valid()) {
+ res->reload_from_file();
+ }
+ }
+}
+
/// SceneDebuggerObject
SceneDebuggerObject::SceneDebuggerObject(ObjectID p_id) {
id = ObjectID();
@@ -1212,7 +1237,7 @@ RuntimeNodeSelect::~RuntimeNodeSelect() {
#endif // _3D_DISABLED
}
-void RuntimeNodeSelect::_setup() {
+void RuntimeNodeSelect::_setup(const Dictionary &p_settings) {
Window *root = SceneTree::get_singleton()->get_root();
ERR_FAIL_COND(root->is_connected(SceneStringName(window_input), callable_mp(this, &RuntimeNodeSelect::_root_window_input)));
@@ -1229,6 +1254,14 @@ void RuntimeNodeSelect::_setup() {
panner.instantiate();
panner->set_callbacks(callable_mp(this, &RuntimeNodeSelect::_pan_callback), callable_mp(this, &RuntimeNodeSelect::_zoom_callback));
+ ViewPanner::ControlScheme panning_scheme = (ViewPanner::ControlScheme)p_settings.get("editors/panning/2d_editor_panning_scheme", 0).operator int();
+ bool simple_panning = p_settings.get("editors/panning/simple_panning", false);
+ int pan_speed = p_settings.get("editors/panning/2d_editor_pan_speed", 20);
+ Array keys = p_settings.get("canvas_item_editor/pan_view", Array()).operator Array();
+ panner->setup(panning_scheme, DebuggerMarshalls::deserialize_key_shortcut(keys), simple_panning);
+ panner->set_scroll_speed(pan_speed);
+ warped_panning = p_settings.get("editors/panning/warped_mouse_panning", false);
+
/// 2D Selection Box Generation
sbox_2d_canvas = RS::get_singleton()->canvas_create();
@@ -1338,7 +1371,7 @@ void RuntimeNodeSelect::_root_window_input(const Ref<InputEvent> &p_event) {
if (camera_override) {
if (node_select_type == NODE_TYPE_2D) {
- if (panner->gui_input(p_event, Rect2(Vector2(), root->get_size()))) {
+ if (panner->gui_input(p_event, warped_panning ? Rect2(Vector2(), root->get_size()) : Rect2())) {
return;
}
} else if (node_select_type == NODE_TYPE_3D) {