diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-11-11 09:07:04 -0500 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-11 09:08:01 -0500 |
commit | 62fbec9f6f0722a1f9825c17f073742932082228 (patch) | |
tree | a10abf56ba93705731da1aaf338f2cf21403c6ad /scene/debugger | |
parent | e7894c2c4efdd51049a21af4892005381fe57cd6 (diff) | |
parent | 0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff) | |
download | redot-engine-62fbec9f6f0722a1f9825c17f073742932082228.tar.gz |
Merge commit godotengine/godot@0f5f3bc9546b46b2029fc8896dc859697f1eab97
Diffstat (limited to 'scene/debugger')
-rw-r--r-- | scene/debugger/scene_debugger.cpp | 47 | ||||
-rw-r--r-- | scene/debugger/scene_debugger.h | 6 |
2 files changed, 45 insertions, 8 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) { diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h index 4429a00edc..ff4fe22e66 100644 --- a/scene/debugger/scene_debugger.h +++ b/scene/debugger/scene_debugger.h @@ -59,6 +59,8 @@ public: #ifdef DEBUG_ENABLED private: + static void _handle_input(const Ref<InputEvent> &p_event, const Ref<Shortcut> &p_shortcut); + static void _save_node(ObjectID id, const String &p_path); static void _set_node_owner_recursive(Node *p_node, Node *p_owner); static void _set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value); @@ -69,6 +71,7 @@ public: static Error parse_message(void *p_user, const String &p_msg, const Array &p_args, bool &r_captured); static void add_to_cache(const String &p_filename, Node *p_node); static void remove_from_cache(const String &p_filename, Node *p_node); + static void reload_cached_files(const PackedStringArray &p_files); #endif }; @@ -202,6 +205,7 @@ private: PopupMenu *selection_list = nullptr; bool selection_visible = true; bool selection_update_queued = false; + bool warped_panning = false; bool camera_override = false; @@ -272,7 +276,7 @@ private: NodeType node_select_type = NODE_TYPE_2D; SelectMode node_select_mode = SELECT_MODE_SINGLE; - void _setup(); + void _setup(const Dictionary &p_settings); void _node_set_type(NodeType p_type); void _select_set_mode(SelectMode p_mode); |