From 2ba3b94944f1dcc76787e41387b1fa03d0aed56d Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sat, 3 Aug 2024 17:43:54 -0400 Subject: [PATCH 01/12] GH-655 Use `EditorInterface::get_singleton` where possible --- src/common/file_utils.cpp | 6 ++---- src/common/file_utils.h | 2 +- src/common/scene_utils.cpp | 17 ++++++++--------- src/editor/about_dialog.cpp | 3 +-- src/editor/component_panels/component_panel.cpp | 6 +++--- src/editor/component_panels/functions_panel.cpp | 4 ++-- src/editor/component_panels/signals_panel.cpp | 7 +++---- src/editor/component_panels/variables_panel.cpp | 5 +++-- src/editor/editor_cache.cpp | 6 +++--- src/editor/editor_panel.cpp | 8 ++++---- src/editor/editor_viewport.cpp | 2 +- src/editor/file_dialog.cpp | 5 ++--- src/editor/graph/graph_edit.cpp | 17 ++++++++--------- src/editor/graph/graph_edit.h | 5 +---- .../graph/pins/graph_node_pin_node_path.cpp | 4 ++-- src/editor/plugins/inspector_plugins.cpp | 4 ++-- .../plugins/orchestrator_editor_plugin.cpp | 13 ++++--------- src/editor/plugins/orchestrator_editor_plugin.h | 2 -- src/editor/script_editor_viewport.cpp | 3 +-- src/editor/search/search_dialog.cpp | 6 ++---- src/editor/window_wrapper.cpp | 6 ++---- 21 files changed, 55 insertions(+), 76 deletions(-) diff --git a/src/common/file_utils.cpp b/src/common/file_utils.cpp index 8f0b9ed8..16d0a497 100644 --- a/src/common/file_utils.cpp +++ b/src/common/file_utils.cpp @@ -16,8 +16,6 @@ // #include "common/file_utils.h" -#include "editor/plugins/orchestrator_editor_plugin.h" - #include #include @@ -25,11 +23,11 @@ namespace FileUtils { Ref open_project_settings_file(const String& p_file_name, FileAccess::ModeFlags p_flags) { - const EditorPaths* ep = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_paths(); + const EditorPaths* ep = EditorInterface::get_singleton()->get_editor_paths(); return FileAccess::open(ep->get_project_settings_dir().path_join(p_file_name), p_flags); } - void for_each_line(const Ref& p_file, std::function p_callback) + void for_each_line(const Ref& p_file, const std::function& p_callback) { if (p_file.is_valid() && p_file->is_open()) { diff --git a/src/common/file_utils.h b/src/common/file_utils.h index 58438993..9cd58d35 100644 --- a/src/common/file_utils.h +++ b/src/common/file_utils.h @@ -33,7 +33,7 @@ namespace FileUtils /// For the specified file, reads each line and calls the specified callback function with the line. /// @param p_file the file to read /// @param p_callback the callback function to call for each line - void for_each_line(const Ref& p_file, std::function p_callback); + void for_each_line(const Ref& p_file, const std::function& p_callback); } #endif // ORCHESTRATOR_FILE_UTILS_H \ No newline at end of file diff --git a/src/common/scene_utils.cpp b/src/common/scene_utils.cpp index 6b9e46d1..ea774cd0 100644 --- a/src/common/scene_utils.cpp +++ b/src/common/scene_utils.cpp @@ -16,7 +16,6 @@ // #include "scene_utils.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include "script/script_server.h" #include @@ -36,7 +35,7 @@ namespace SceneUtils { ERR_FAIL_COND_V_MSG(p_class_name.is_empty(), nullptr, "Class name cannot be empty."); - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); if (vbox->has_theme_icon(p_class_name, "EditorIcons")) return vbox->get_theme_icon(p_class_name, "EditorIcons"); @@ -66,13 +65,13 @@ namespace SceneUtils bool has_editor_icon(const String& p_icon_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->has_theme_icon(p_icon_name); } Color get_editor_color(const String& p_color_name, const String& p_category) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_color(p_color_name, p_category); } @@ -83,31 +82,31 @@ namespace SceneUtils Ref get_editor_icon(const String& p_icon_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_icon(p_icon_name, "EditorIcons"); } Ref get_editor_style(const String& p_style_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_stylebox(p_style_name, "EditorStyles"); } Ref get_editor_font(const String& p_font_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_font(p_font_name, "EditorFonts"); } int get_editor_font_size(const String& p_font_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_font_size(p_font_name, "EditorFonts"); } Ref get_editor_stylebox(const String& p_stylebox_name, const String& p_class_name) { - VBoxContainer* vbox = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_main_screen(); + VBoxContainer* vbox = EditorInterface::get_singleton()->get_editor_main_screen(); return vbox->get_theme_stylebox(p_stylebox_name, p_class_name); } diff --git a/src/editor/about_dialog.cpp b/src/editor/about_dialog.cpp index 325e7a8b..94dca6db 100644 --- a/src/editor/about_dialog.cpp +++ b/src/editor/about_dialog.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -259,7 +258,7 @@ void OrchestratorAboutDialog::_on_theme_changed() } } - Ref theme = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_theme(); + Ref theme = EditorInterface::get_singleton()->get_editor_theme(); if (theme.is_valid()) { Ref sb = theme->get_stylebox("panel", "EditorAbout"); diff --git a/src/editor/component_panels/component_panel.cpp b/src/editor/component_panels/component_panel.cpp index 18227592..738e0ee5 100644 --- a/src/editor/component_panels/component_panel.cpp +++ b/src/editor/component_panels/component_panel.cpp @@ -19,11 +19,11 @@ #include "common/callable_lambda.h" #include "common/name_utils.h" #include "common/scene_utils.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include #include #include +#include #include #include #include @@ -112,7 +112,7 @@ void OrchestratorScriptComponentPanel::_remove_confirmed() { if (_tree->get_selected()) { - OrchestratorPlugin::get_singleton()->get_editor_interface()->inspect_object(nullptr); + EditorInterface::get_singleton()->inspect_object(nullptr); _handle_remove(_tree->get_selected()); update(); @@ -234,7 +234,7 @@ void OrchestratorScriptComponentPanel::_update_theme() if (!_theme_changing) return; - Ref theme = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_theme(); + Ref theme = EditorInterface::get_singleton()->get_editor_theme(); if (theme.is_valid() && _panel) { Ref sb = theme->get_stylebox("panel", "ItemList")->duplicate(); diff --git a/src/editor/component_panels/functions_panel.cpp b/src/editor/component_panels/functions_panel.cpp index 86002d07..64ae65c2 100644 --- a/src/editor/component_panels/functions_panel.cpp +++ b/src/editor/component_panels/functions_panel.cpp @@ -20,11 +20,11 @@ #include "common/dictionary_utils.h" #include "common/scene_utils.h" #include "common/settings.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include "editor/script_connections.h" #include "script/script.h" #include +#include #include #include #include @@ -147,7 +147,7 @@ void OrchestratorScriptFunctionsComponentPanel::_handle_item_selected() { const Ref node = function->get_owning_node(); if (node.is_valid()) - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(node); + EditorInterface::get_singleton()->edit_resource(node); } } } diff --git a/src/editor/component_panels/signals_panel.cpp b/src/editor/component_panels/signals_panel.cpp index d0fb4760..834cb592 100644 --- a/src/editor/component_panels/signals_panel.cpp +++ b/src/editor/component_panels/signals_panel.cpp @@ -18,9 +18,8 @@ #include "common/dictionary_utils.h" #include "common/scene_utils.h" -#include "common/settings.h" -#include "editor/plugins/orchestrator_editor_plugin.h" +#include #include #include @@ -73,13 +72,13 @@ void OrchestratorScriptSignalsComponentPanel::_handle_item_selected() TreeItem* item = _tree->get_selected(); Ref signal = _orchestration->get_custom_signal(_get_tree_item_name(item)); - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(signal); + EditorInterface::get_singleton()->edit_resource(signal); } void OrchestratorScriptSignalsComponentPanel::_handle_item_activated(TreeItem* p_item) { Ref signal = _orchestration->get_custom_signal(_get_tree_item_name(p_item)); - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(signal); + EditorInterface::get_singleton()->edit_resource(signal); } bool OrchestratorScriptSignalsComponentPanel::_handle_item_renamed(const String& p_old_name, const String& p_new_name) diff --git a/src/editor/component_panels/variables_panel.cpp b/src/editor/component_panels/variables_panel.cpp index 6c5b97b3..64723817 100644 --- a/src/editor/component_panels/variables_panel.cpp +++ b/src/editor/component_panels/variables_panel.cpp @@ -22,6 +22,7 @@ #include "editor/plugins/inspector_plugins.h" #include "editor/plugins/orchestrator_editor_plugin.h" +#include #include #include @@ -145,13 +146,13 @@ void OrchestratorScriptVariablesComponentPanel::_handle_item_selected() TreeItem* item = _tree->get_selected(); Ref variable = _orchestration->get_variable(_get_tree_item_name(item)); - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(variable); + EditorInterface::get_singleton()->edit_resource(variable); } void OrchestratorScriptVariablesComponentPanel::_handle_item_activated(TreeItem* p_item) { Ref variable = _orchestration->get_variable(_get_tree_item_name(p_item)); - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(variable); + EditorInterface::get_singleton()->edit_resource(variable); } bool OrchestratorScriptVariablesComponentPanel::_handle_item_renamed(const String& p_old_name, const String& p_new_name) diff --git a/src/editor/editor_cache.cpp b/src/editor/editor_cache.cpp index c86b1718..f4deeb17 100644 --- a/src/editor/editor_cache.cpp +++ b/src/editor/editor_cache.cpp @@ -16,8 +16,8 @@ // #include "editor/editor_cache.h" #include "plugins/orchestrator_editor_debugger_plugin.h" -#include "plugins/orchestrator_editor_plugin.h" +#include #include #if GODOT_VERSION >= 0x040300 @@ -29,7 +29,7 @@ PackedInt64Array OrchestratorEditorCache::_get_breakpoints_for_path(const String Error OrchestratorEditorCache::load() { - const EditorInterface* ei = OrchestratorPlugin::get_singleton()->get_editor_interface(); + const EditorInterface* ei = EditorInterface::get_singleton(); _cache = Ref(memnew(ConfigFile)); @@ -65,7 +65,7 @@ Error OrchestratorEditorCache::save() { if (_cache.is_valid()) { - const EditorInterface* ei = OrchestratorPlugin::get_singleton()->get_editor_interface(); + const EditorInterface* ei = EditorInterface::get_singleton(); return _cache->save(ei->get_editor_paths()->get_project_settings_dir().path_join(CACHE_FILE)); } diff --git a/src/editor/editor_panel.cpp b/src/editor/editor_panel.cpp index d813d7f5..e3143171 100644 --- a/src/editor/editor_panel.cpp +++ b/src/editor/editor_panel.cpp @@ -195,7 +195,7 @@ void OrchestratorEditorPanel::_update_scene_tab_signals(bool p_connect) void OrchestratorEditorPanel::_update_file_system_dock_signals(bool p_connect) { - FileSystemDock* file_system_dock = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_file_system_dock(); + FileSystemDock* file_system_dock = EditorInterface::get_singleton()->get_file_system_dock(); if (!file_system_dock) return; @@ -405,7 +405,7 @@ bool OrchestratorEditorPanel::_has_open_files() const void OrchestratorEditorPanel::_show_editor_viewport(const String& p_file_name) { - OrchestratorPlugin::get_singleton()->get_editor_interface()->inspect_object(nullptr); + EditorInterface::get_singleton()->inspect_object(nullptr); _files_context.show(p_file_name); @@ -567,7 +567,7 @@ void OrchestratorEditorPanel::_show_create_new_script_dialog() _script_create_dialog->set_title("Create Orchestration"); _script_create_dialog->config(inherits, "new_script.os", false, false); - Ref editor_settings = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_settings(); + Ref editor_settings = EditorInterface::get_singleton()->get_editor_settings(); editor_settings->set_project_metadata("script_setup", "last_selected_language", language_name); _script_create_dialog->popup_centered(); @@ -821,7 +821,7 @@ void OrchestratorEditorPanel::_navigate_to_file_in_filesystem() const String file_name = _files_context.get_selected_file_name(); if (!file_name.is_empty()) - OrchestratorPlugin::get_singleton()->get_editor_interface()->get_file_system_dock()->navigate_to_path(file_name); + EditorInterface::get_singleton()->get_file_system_dock()->navigate_to_path(file_name); } void OrchestratorEditorPanel::edit_resource(const Ref& p_resource) diff --git a/src/editor/editor_viewport.cpp b/src/editor/editor_viewport.cpp index ef1cbb2e..a295a890 100644 --- a/src/editor/editor_viewport.cpp +++ b/src/editor/editor_viewport.cpp @@ -162,7 +162,7 @@ OrchestratorGraphEdit* OrchestratorEditorViewport::_get_or_create_tab(const Stri if (!script_graph.is_valid()) return nullptr; - OrchestratorGraphEdit* graph = memnew(OrchestratorGraphEdit(OrchestratorPlugin::get_singleton(), script_graph)); + OrchestratorGraphEdit* graph = memnew(OrchestratorGraphEdit(script_graph)); _tabs->add_child(graph); const String tab_icon = graph->is_function() ? "MemberMethod" : "ClassList"; diff --git a/src/editor/file_dialog.cpp b/src/editor/file_dialog.cpp index cc1a39e7..d1bbe93f 100644 --- a/src/editor/file_dialog.cpp +++ b/src/editor/file_dialog.cpp @@ -16,7 +16,7 @@ // #include "editor/file_dialog.h" -#include "plugins/orchestrator_editor_plugin.h" +#include #include void OrchestratorFileDialog::_focus_file_text() @@ -37,8 +37,7 @@ void OrchestratorFileDialog::_focus_file_text() void OrchestratorFileDialog::popup_file_dialog() { - const float EDSCALE = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_scale(); - popup_centered_clamped(Size2(1050, 700) * EDSCALE, 0.8); + popup_centered_clamped(Size2(1050, 700) * EditorInterface::get_singleton()->get_editor_scale(), 0.8); _focus_file_text(); } diff --git a/src/editor/graph/graph_edit.cpp b/src/editor/graph/graph_edit.cpp index 8bcaa6fa..4b543b05 100644 --- a/src/editor/graph/graph_edit.cpp +++ b/src/editor/graph/graph_edit.cpp @@ -29,7 +29,6 @@ #include "editor/graph/graph_node_pin.h" #include "editor/graph/graph_node_spawner.h" #include "editor/graph/nodes/graph_node_comment.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include "nodes/graph_node_factory.h" #include "script/language.h" #include "script/nodes/script_nodes.h" @@ -40,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -99,7 +99,7 @@ EPinDirection OrchestratorGraphEdit::DragContext::get_direction() const return output_port ? PD_Output : PD_Input; } -OrchestratorGraphEdit::OrchestratorGraphEdit(OrchestratorPlugin* p_plugin, const Ref& p_graph) +OrchestratorGraphEdit::OrchestratorGraphEdit(const Ref& p_graph) { internal::gdextension_interface_get_godot_version(&_version); _is_43p = _version.major == 4 && _version.minor >= 3; @@ -109,7 +109,6 @@ OrchestratorGraphEdit::OrchestratorGraphEdit(OrchestratorPlugin* p_plugin, const set_show_arrange_button(OrchestratorSettings::get_singleton()->get_setting("ui/graph/show_arrange_button", false)); set_right_disconnects(true); - _plugin = p_plugin; _script_graph = p_graph; _cache_connection_knots(); @@ -356,8 +355,8 @@ void OrchestratorGraphEdit::set_spawn_position_center_view() void OrchestratorGraphEdit::goto_class_help(const String& p_class_name) { - _plugin->get_editor_interface()->set_main_screen_editor("Script"); - _plugin->get_editor_interface()->get_script_editor()->call("_help_class_open", p_class_name); + EditorInterface::get_singleton()->set_main_screen_editor("Script"); + EditorInterface::get_singleton()->get_script_editor()->call("_help_class_open", p_class_name); } void OrchestratorGraphEdit::for_each_graph_node(std::function p_func) @@ -1634,12 +1633,12 @@ void OrchestratorGraphEdit::_on_node_selected(Node* p_node) // object to resolve whether the object has any property default values so // it can properly revert values accordingly with the rollback button. // - _plugin->get_editor_interface()->edit_resource(node->get_inspect_object()); + EditorInterface::get_singleton()->edit_resource(node->get_inspect_object()); } void OrchestratorGraphEdit::_on_node_deselected(Node* p_node) { - _plugin->get_editor_interface()->inspect_object(nullptr); + EditorInterface::get_singleton()->inspect_object(nullptr); OrchestratorSettings* os = OrchestratorSettings::get_singleton(); if (os->get_setting("ui/nodes/highlight_selected_connections", false)) @@ -1874,9 +1873,9 @@ void OrchestratorGraphEdit::_on_project_settings_changed() void OrchestratorGraphEdit::_on_inspect_script() { - _plugin->get_editor_interface()->inspect_object(get_orchestration()->get_self().ptr()); + EditorInterface::get_singleton()->inspect_object(get_orchestration()->get_self().ptr()); - EditorInspector* inspector = _plugin->get_editor_interface()->get_inspector(); + EditorInspector* inspector = EditorInterface::get_singleton()->get_inspector(); TypedArray fields = inspector->find_children("*", "EditorPropertyClassName", true, false); if (!fields.is_empty()) diff --git a/src/editor/graph/graph_edit.h b/src/editor/graph/graph_edit.h index e84ad572..c9ff3e22 100644 --- a/src/editor/graph/graph_edit.h +++ b/src/editor/graph/graph_edit.h @@ -36,7 +36,6 @@ using namespace godot; class OScriptNode; class OrchestratorScriptAutowireSelections; class OrchestratorGraphKnot; -class OrchestratorPlugin; /// Helper class for storing a reference to a position for the knot in the graph class OrchestratorKnotPoint : public RefCounted @@ -126,7 +125,6 @@ class OrchestratorGraphEdit : public GraphEdit DragContext _drag_context; //! Drag context details int _deferred_tween_node{ -1 }; //! Node id to tween to upon load PopupMenu* _context_menu{ nullptr }; //! Graph context menu - OrchestratorPlugin* _plugin{ nullptr }; //! The plugin Control* _status{ nullptr }; //! Displays status in the center of graphs Label* _drag_hint{ nullptr }; //! Displays the drag status at the bottom of the graph Timer* _drag_hint_timer{ nullptr }; //! Timer for drag hint messages @@ -155,9 +153,8 @@ class OrchestratorGraphEdit : public GraphEdit static void free_clipboard(); /// Creates the Orchestration OrchestratorGraphEdit instance. - /// @param p_plugin the plugin instance, should never be null /// @param p_graph the orchestration graph, should never be invalid - OrchestratorGraphEdit(OrchestratorPlugin* p_plugin, const Ref& p_graph); + OrchestratorGraphEdit(const Ref& p_graph); /// Godot callback that handles notifications /// @param p_what the notification to be handled diff --git a/src/editor/graph/pins/graph_node_pin_node_path.cpp b/src/editor/graph/pins/graph_node_pin_node_path.cpp index ebb10704..6bd93756 100644 --- a/src/editor/graph/pins/graph_node_pin_node_path.cpp +++ b/src/editor/graph/pins/graph_node_pin_node_path.cpp @@ -20,7 +20,6 @@ #include "common/scene_utils.h" #include "common/string_utils.h" #include "common/version.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include "editor/property_selector.h" #include "editor/scene_node_selector.h" #include "script/nodes/functions/call_function.h" @@ -29,9 +28,10 @@ #include "script/script.h" #include +#include #include -#define EDSCALE OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_scale() +#define EDSCALE EditorInterface::get_singleton()->get_editor_scale() Vector OrchestratorGraphNodePinNodePath::_descriptors; diff --git a/src/editor/plugins/inspector_plugins.cpp b/src/editor/plugins/inspector_plugins.cpp index 1ea5659c..b64e8765 100644 --- a/src/editor/plugins/inspector_plugins.cpp +++ b/src/editor/plugins/inspector_plugins.cpp @@ -173,8 +173,8 @@ void OrchestratorEditorInspectorPluginVariable::edit_classification(Object* p_ob return; // This is done to clear and reset the editor interface - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_node(nullptr); - OrchestratorPlugin::get_singleton()->get_editor_interface()->edit_resource(variable); + EditorInterface::get_singleton()->edit_node(nullptr); + EditorInterface::get_singleton()->edit_resource(variable); _classification->edit(); } \ No newline at end of file diff --git a/src/editor/plugins/orchestrator_editor_plugin.cpp b/src/editor/plugins/orchestrator_editor_plugin.cpp index 58327f29..941247b3 100644 --- a/src/editor/plugins/orchestrator_editor_plugin.cpp +++ b/src/editor/plugins/orchestrator_editor_plugin.cpp @@ -16,6 +16,7 @@ // #include "editor/plugins/orchestrator_editor_plugin.h" +#include "common/callable_lambda.h" #include "common/version.h" #include "editor/editor_panel.h" #include "editor/graph/graph_edit.h" @@ -41,7 +42,6 @@ OrchestratorPlugin* OrchestratorPlugin::_plugin = nullptr; OrchestratorPlugin::OrchestratorPlugin() - : _editor(*get_editor_interface()) { } @@ -92,7 +92,7 @@ void OrchestratorPlugin::_notification(int p_what) _editor_panel = memnew(OrchestratorEditorPanel(_window_wrapper)); - _editor.get_editor_main_screen()->add_child(_window_wrapper); + get_editor_interface()->get_editor_main_screen()->add_child(_window_wrapper); _window_wrapper->set_wrapped_control(_editor_panel); _window_wrapper->set_v_size_flags(Control::SIZE_EXPAND_FILL); _window_wrapper->hide(); @@ -244,7 +244,7 @@ void OrchestratorPlugin::save_metadata(const Ref& p_metadata) void OrchestratorPlugin::make_active() { - _editor.set_main_screen_editor(_get_plugin_name()); + get_editor_interface()->set_main_screen_editor(_get_plugin_name()); } void OrchestratorPlugin::make_build_panel_active() @@ -266,7 +266,7 @@ void OrchestratorPlugin::request_editor_restart() request->add_child(container); - request->connect("confirmed", callable_mp(this, &OrchestratorPlugin::_on_editor_restart)); + request->connect("confirmed", callable_mp_lambda(this, []{ EditorInterface::get_singleton()->restart_editor(true); })); request->popup_centered(); } @@ -361,8 +361,3 @@ void OrchestratorPlugin::_on_window_visibility_changed(bool p_visible) { // todo: see script_editor_plugin.cpp } - -void OrchestratorPlugin::_on_editor_restart() -{ - get_editor_interface()->restart_editor(true); -} diff --git a/src/editor/plugins/orchestrator_editor_plugin.h b/src/editor/plugins/orchestrator_editor_plugin.h index 8a3fba1c..fe7c75b5 100644 --- a/src/editor/plugins/orchestrator_editor_plugin.h +++ b/src/editor/plugins/orchestrator_editor_plugin.h @@ -44,7 +44,6 @@ class OrchestratorPlugin : public EditorPlugin static OrchestratorPlugin* _plugin; - EditorInterface& _editor; //! Godot editor interface reference OrchestratorEditorPanel* _editor_panel{ nullptr }; //! Plugin's editor panel OrchestratorWindowWrapper* _window_wrapper{ nullptr }; //! Window wrapper Vector> _inspector_plugins; @@ -143,7 +142,6 @@ class OrchestratorPlugin : public EditorPlugin private: void _on_window_visibility_changed(bool p_visible); - void _on_editor_restart(); }; #endif // ORCHESTRATOR_EDITOR_PLUGIN_H \ No newline at end of file diff --git a/src/editor/script_editor_viewport.cpp b/src/editor/script_editor_viewport.cpp index a0036492..908004cb 100644 --- a/src/editor/script_editor_viewport.cpp +++ b/src/editor/script_editor_viewport.cpp @@ -495,8 +495,7 @@ void OrchestratorScriptEditorViewport::add_script_function(Object* p_object, con return; } - EditorInterface* editor_interface = OrchestratorPlugin::get_singleton()->get_editor_interface(); - editor_interface->set_main_screen_editor(OrchestratorPlugin::get_singleton()->_get_plugin_name()); + OrchestratorPlugin::get_singleton()->make_active(); MethodInfo method; method.name = p_function_name; diff --git a/src/editor/search/search_dialog.cpp b/src/editor/search/search_dialog.cpp index da7e44f8..04cfbdde 100644 --- a/src/editor/search/search_dialog.cpp +++ b/src/editor/search/search_dialog.cpp @@ -17,7 +17,6 @@ #include "editor/search/search_dialog.h" #include "common/scene_utils.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include #include @@ -337,7 +336,7 @@ void OrchestratorEditorSearchDialog::_set_search_item_collapse_state(TreeItem* p bool should_collapse = _get_search_item_collapse_suggestion(p_item); - Ref settings = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_settings(); + Ref settings = EditorInterface::get_singleton()->get_editor_settings(); if (should_collapse && bool(settings->get_setting("docks/scene_tree/start_create_dialog_fully_expanded"))) should_collapse = false; @@ -497,8 +496,7 @@ void OrchestratorEditorSearchDialog::popup_create(bool p_dont_clear, bool p_repl _save_and_update_favorites_list(); - EditorInterface* ei = OrchestratorPlugin::get_singleton()->get_editor_interface(); - Rect2 saved_size = ei->get_editor_settings()->get_project_metadata("dialog_bounds", "create_new_node", Rect2()); + Rect2 saved_size = EditorInterface::get_singleton()->get_editor_settings()->get_project_metadata("dialog_bounds", "create_new_node", Rect2()); if (saved_size != Rect2()) popup(saved_size); else diff --git a/src/editor/window_wrapper.cpp b/src/editor/window_wrapper.cpp index 0f89bf22..9ab2d187 100644 --- a/src/editor/window_wrapper.cpp +++ b/src/editor/window_wrapper.cpp @@ -17,7 +17,6 @@ #include "window_wrapper.h" #include "common/scene_utils.h" -#include "editor/plugins/orchestrator_editor_plugin.h" #include #include @@ -27,7 +26,6 @@ #include #include #include -#include #include OrchestratorWindowWrapper::OrchestratorWindowWrapper() @@ -136,7 +134,7 @@ void OrchestratorWindowWrapper::_set_window_rect(const Rect2 p_rect) _window->set_position(p_rect.position); _window->set_size(p_rect.size); - Ref es = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_settings(); + Ref es = EditorInterface::get_singleton()->get_editor_settings(); if (es.is_valid() && es->get_setting("interface/multi_window/maximize_window")) _window->set_mode(Window::MODE_MAXIMIZED); } @@ -253,7 +251,7 @@ void OrchestratorWindowWrapper::enable_window_on_screen(int p_screen, bool p_aut int current_screen = Object::cast_to(get_viewport())->get_current_screen(); int screen = p_screen < 0 ? current_screen : p_screen; - Ref es = OrchestratorPlugin::get_singleton()->get_editor_interface()->get_editor_settings(); + Ref es = EditorInterface::get_singleton()->get_editor_settings(); bool auto_scale = p_auto_scale && !es->get_setting("interface/multi_window/maximize_window"); if (auto_scale && current_screen != screen) From 2bed314a36a2e99d5aef3a542874bf8f9ab0a40e Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Thu, 15 Aug 2024 12:07:54 -0400 Subject: [PATCH 02/12] GH-738 Fix `Select Group` to include Knots and Nodes --- src/editor/graph/graph_edit.cpp | 17 +++++++++++++++++ src/editor/graph/graph_edit.h | 6 ++++++ src/editor/graph/graph_node.cpp | 6 +++--- src/editor/graph/graph_node.h | 4 ++-- src/editor/graph/nodes/graph_node_comment.cpp | 16 ++++++++-------- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/editor/graph/graph_edit.cpp b/src/editor/graph/graph_edit.cpp index 4b543b05..cdbb3280 100644 --- a/src/editor/graph/graph_edit.cpp +++ b/src/editor/graph/graph_edit.cpp @@ -368,6 +368,23 @@ void OrchestratorGraphEdit::for_each_graph_node(std::function& p_func, bool p_nodes, bool p_knots) +{ + const int child_count = get_child_count(); + for (int index = 0; index < child_count; index++) + { + GraphElement* element = Object::cast_to(get_child(index)); + if (!element) + continue; + + const OrchestratorGraphNode* node = Object::cast_to(element); + const OrchestratorGraphKnot* knot = Object::cast_to(element); + + if ((p_nodes && node) || (p_knots && knot)) + p_func(element); + } +} + void OrchestratorGraphEdit::execute_action(const String& p_action_name) { Ref action = memnew(InputEventAction); diff --git a/src/editor/graph/graph_edit.h b/src/editor/graph/graph_edit.h index c9ff3e22..22ff97db 100644 --- a/src/editor/graph/graph_edit.h +++ b/src/editor/graph/graph_edit.h @@ -209,6 +209,12 @@ class OrchestratorGraphEdit : public GraphEdit /// @param p_func the lambda to be applied void for_each_graph_node(std::function p_func); + /// Perform an action for each GraphNode object type + /// @param p_func the function to call for each graph element + /// @param p_nodes whether OrchestratorGraphNode objects are included, defaults to true + /// @param p_knots whether OrchestratorGraphKnot objects are included, defaults to true + void for_each_graph_element(const std::function& p_func, bool p_nodes = true, bool p_knots = true); + /// Execute the specified action /// @param p_action_name the action to execute void execute_action(const String& p_action_name); diff --git a/src/editor/graph/graph_node.cpp b/src/editor/graph/graph_node.cpp index 450add28..81794d31 100644 --- a/src/editor/graph/graph_node.cpp +++ b/src/editor/graph/graph_node.cpp @@ -618,12 +618,12 @@ void OrchestratorGraphNode::_add_option_pin() function_call_node->add_dynamic_pin(); } -List OrchestratorGraphNode::get_nodes_within_global_rect() +List OrchestratorGraphNode::get_elements_within_global_rect() { Rect2 rect = get_global_rect(); - List results; - _graph->for_each_graph_node([&](OrchestratorGraphNode* other) { + List results; + _graph->for_each_graph_element([&](GraphElement* other) { if (other && other != this) { Rect2 other_rect = other->get_global_rect(); diff --git a/src/editor/graph/graph_node.h b/src/editor/graph/graph_node.h index b7a13330..66069044 100644 --- a/src/editor/graph/graph_node.h +++ b/src/editor/graph/graph_node.h @@ -159,8 +159,8 @@ class OrchestratorGraphNode : public GraphNode /// Set whether node icons are shown virtual void show_icons(bool p_show_icons) { } - /// Get a list of nodes within this node's global rect. - List get_nodes_within_global_rect(); + /// Get a list of elements within this node's global rect. + List get_elements_within_global_rect(); /// Get the specified point index at the given position and direction /// @param p_position the position diff --git a/src/editor/graph/nodes/graph_node_comment.cpp b/src/editor/graph/nodes/graph_node_comment.cpp index 1d63d182..f36f184e 100644 --- a/src/editor/graph/nodes/graph_node_comment.cpp +++ b/src/editor/graph/nodes/graph_node_comment.cpp @@ -121,8 +121,8 @@ void OrchestratorGraphNodeComment::_on_raise_request() bool OrchestratorGraphNodeComment::is_group_selected() { - List intersections = get_nodes_within_global_rect(); - for (OrchestratorGraphNode* child : intersections) + List intersections = get_elements_within_global_rect(); + for (GraphElement* child : intersections) if (!child->is_selected()) return false; return true; @@ -131,16 +131,16 @@ bool OrchestratorGraphNodeComment::is_group_selected() void OrchestratorGraphNodeComment::select_group() { // Select all child nodes - List intersections = get_nodes_within_global_rect(); - for (OrchestratorGraphNode* child : intersections) + List intersections = get_elements_within_global_rect(); + for (GraphElement* child : intersections) child->set_selected(true); } void OrchestratorGraphNodeComment::deselect_group() { // Deselects all child nodes - List intersections = get_nodes_within_global_rect(); - for (OrchestratorGraphNode* child : intersections) + List intersections = get_elements_within_global_rect(); + for (GraphElement* child : intersections) child->set_selected(false); } @@ -148,7 +148,7 @@ void OrchestratorGraphNodeComment::raise_request_node_reorder() { // This guarantees that any node that intersects with a comment node will be repositioned // in the scene after the comment, so that the rendering order appears correct. - List intersections = get_nodes_within_global_rect(); - for (OrchestratorGraphNode* node : intersections) + List intersections = get_elements_within_global_rect(); + for (GraphElement* node : intersections) get_parent()->move_child(node, -1); } \ No newline at end of file From 5c8dbcaa5ba9d1265925eed5a8141d206e304a45 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Thu, 15 Aug 2024 23:09:58 -0400 Subject: [PATCH 03/12] GH-737 Allow knot node operations within comment nodes --- src/editor/graph/graph_edit.cpp | 120 +++++++++++++++--- src/editor/graph/graph_edit.h | 24 +++- src/editor/graph/graph_node.cpp | 32 ++--- src/editor/graph/nodes/graph_node_comment.cpp | 86 +++++++++---- src/editor/graph/nodes/graph_node_comment.h | 6 +- 5 files changed, 195 insertions(+), 73 deletions(-) diff --git a/src/editor/graph/graph_edit.cpp b/src/editor/graph/graph_edit.cpp index cdbb3280..3b2e8888 100644 --- a/src/editor/graph/graph_edit.cpp +++ b/src/editor/graph/graph_edit.cpp @@ -239,6 +239,7 @@ void OrchestratorGraphEdit::_notification(int p_what) _action_menu->connect("action_selected", callable_mp(this, &OrchestratorGraphEdit::_on_action_menu_action_selected)); // Wire up our signals + connect("child_entered_tree", callable_mp(this, &OrchestratorGraphEdit::_resort_child_nodes_on_add)); connect("connection_from_empty", callable_mp(this, &OrchestratorGraphEdit::_on_attempt_connection_from_empty)); connect("connection_to_empty", callable_mp(this, &OrchestratorGraphEdit::_on_attempt_connection_to_empty)); connect("connection_request", callable_mp(this, &OrchestratorGraphEdit::_on_connection)); @@ -284,8 +285,6 @@ void OrchestratorGraphEdit::_notification(int p_what) void OrchestratorGraphEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_synchronize_child_order"), &OrchestratorGraphEdit::_synchronize_child_order); - ADD_SIGNAL(MethodInfo("nodes_changed")); ADD_SIGNAL(MethodInfo("focus_requested", PropertyInfo(Variant::OBJECT, "target"))); ADD_SIGNAL(MethodInfo("collapse_selected_to_function")); @@ -526,6 +525,34 @@ void OrchestratorGraphEdit::_move_selected(const Vector2& p_delta) } } +void OrchestratorGraphEdit::_resort_child_nodes_on_add(Node* p_node) +{ + if (_is_comment_node(p_node)) + { + const int position = _get_connection_layer_index(); + + // Comment nodes should always be before the "_connection_layer" + // This needs to be deferred, don't change. + call_deferred("move_child", p_node, position); + } +} + +int OrchestratorGraphEdit::_get_connection_layer_index() const +{ + int index = 0; // generally this is the first child; however, comments will causes resorts + for (; index < get_child_count(); index++) + { + if (get_child(index)->get_name().match("_connection_layer")) + break; + } + return index; +} + +bool OrchestratorGraphEdit::_is_comment_node(Node* p_node) const +{ + return Object::cast_to(p_node); +} + void OrchestratorGraphEdit::_gui_input(const Ref& p_event) { // In Godot 4.2, the UI delete events only apply to GraphNode and not GraphElement objects @@ -553,7 +580,7 @@ void OrchestratorGraphEdit::_gui_input(const Ref& p_event) // This is to avoid triggering the display text or our internal hover_connection logic. Ref me = p_event; - if (me.is_valid() && !_is_position_within_node_rect(me->get_position())) + if (me.is_valid() && !_is_position_valid_for_knot(me->get_position())) { Ref mm = p_event; if (mm.is_valid()) @@ -581,6 +608,71 @@ void OrchestratorGraphEdit::_gui_input(const Ref& p_event) } } + Ref mb = p_event; + if (mb.is_valid()) + { + if (mb->get_button_index() == MOUSE_BUTTON_LEFT && mb->is_pressed()) + { + // This checks whether the LMB click should trigger box-selection + // + // While GraphEdit manages this, this information isn't directly exposed as signals, and our + // implementation needs this detail to know if we should ignore selecting specific custom + // graph elements, like GraphEdit does for GraphFrame in Godot 4.3. + GraphElement* element = nullptr; + for (int i = get_child_count() - 1; i >= 0; i--) + { + // Only interested in graph elements + GraphElement* selected = Object::cast_to(get_child(i)); + if (!selected) + continue; + + const Rect2 rect2(Point2(), selected->get_size()); + if (rect2.has_point((mb->get_position() - selected->get_position()) / get_zoom())) + { + OrchestratorGraphNodeComment* comment = Object::cast_to(selected); + if (comment && comment->_has_point((mb->get_position() - selected->get_position()) / get_zoom())) + { + element = selected; + break; + } + } + } + + if (!element) + { + _box_selection = true; + _box_selection_from = mb->get_position(); + } + } + + if (mb->get_button_index() == MOUSE_BUTTON_LEFT && !mb->is_pressed() && _box_selection) + _box_selection = false; + } + + // Our implementation needs to detect box selection and its rect to know whether the selection + // fully encloses our comment node implementations, similar to GraphFrame in Godot 4.3 + Ref mm = p_event; + if (mm.is_valid() && _box_selection) + { + const Vector2 selection_to = mm->get_position(); + const Rect2 select_rect = Rect2(_box_selection_from.min(selection_to), (_box_selection_from - selection_to).abs()); + + for (int i = get_child_count() - 1; i >= 0; i--) + { + GraphElement* element = Object::cast_to(get_child(i)); + if (!element) + continue; + + const bool is_comment = _is_comment_node(element); + const Rect2 r = element->get_rect(); + const bool should_be_selected = is_comment ? select_rect.encloses(r) : select_rect.intersects(r); + + // This must be deferred, don't change + if (is_comment && !should_be_selected) + element->call_deferred("set_selected", false); + } + } + const Ref key = p_event; if (key.is_valid() && key->is_pressed()) { @@ -847,11 +939,16 @@ void OrchestratorGraphEdit::_notify(const String& p_text, const String& p_title) dialog->popup_centered(); } -bool OrchestratorGraphEdit::_is_position_within_node_rect(const Vector2& p_position) const +bool OrchestratorGraphEdit::_is_position_valid_for_knot(const Vector2& p_position) const { for (int i = 0; i < get_child_count(); ++i) { GraphNode* child = Object::cast_to(get_child(i)); + + // Skip/ignore any comment nodes from knot logic validity + if (_is_comment_node(child)) + continue; + if (child && child->get_rect().has_point(p_position)) return true; } @@ -1160,8 +1257,6 @@ void OrchestratorGraphEdit::_synchronize_graph_with_script(bool p_apply_position _synchronize_graph_connections_with_script(); - call_deferred("_synchronize_child_order"); - if (p_apply_position) { // These must be deferred, don't change. @@ -1258,19 +1353,6 @@ void OrchestratorGraphEdit::_synchronize_graph_node(Ref p_node) } } -void OrchestratorGraphEdit::_synchronize_child_order() -{ - // Always place comment nodes above the nodes that are contained within their rects. - for_each_graph_node([&](OrchestratorGraphNode* node) { - if (OrchestratorGraphNodeComment* comment = Object::cast_to(node)) - { - // Raises the child - move_child(comment, -1); - comment->call_deferred("raise_request_node_reorder"); - } - }); -} - void OrchestratorGraphEdit::_complete_spawn(const Ref& p_spawned, const Callable& p_callback) { if (p_spawned.is_valid()) diff --git a/src/editor/graph/graph_edit.h b/src/editor/graph/graph_edit.h index 22ff97db..71ff34a6 100644 --- a/src/editor/graph/graph_edit.h +++ b/src/editor/graph/graph_edit.h @@ -134,6 +134,8 @@ class OrchestratorGraphEdit : public GraphEdit HashMap>> _knots; //! Knots for each graph connection GDExtensionGodotVersion _version; //! Godot version bool _is_43p{ false }; //! Is Godot 4.3+ + bool _box_selection{ false }; //! Is graph doing box selection? + Vector2 _box_selection_from; //! Mouse position box selection started from OrchestratorScriptAutowireSelections* _autowire{ nullptr }; OrchestratorGraphEdit() = default; @@ -145,6 +147,19 @@ class OrchestratorGraphEdit : public GraphEdit /// @param p_delta the delta to move selected nodes by void _move_selected(const Vector2& p_delta); + /// Sorts child nodes after a node is added as a child. + /// @param p_node the node that was added + void _resort_child_nodes_on_add(Node* p_node); + + /// Gets the child index for the GraphEdit's _connection_layer control. + /// @return the child index of the connection layer control + int _get_connection_layer_index() const; + + /// Checks whether the specified node is a comment node + /// @param p_node the node to check + /// @return true if it's a comment node, false otherwise + bool _is_comment_node(Node* p_node) const; + public: // The OrchestratorGraphEdit maintains a static clipboard so that data can be shared across different graph // instances easily in the tab view, and so these methods are called by the MainView during the @@ -266,10 +281,10 @@ class OrchestratorGraphEdit : public GraphEdit /// @param p_title the notification window title text void _notify(const String& p_text, const String& p_title); - /// Checks whether the specified position is within any node rect. + /// Checks whether the specified position is valid for knot operations /// @param p_position the position to check - /// @return true if the position is within any node rect, false otherwise - bool _is_position_within_node_rect(const Vector2& p_position) const; + /// @return true if the position is valid for knot operations, false otherwise + bool _is_position_valid_for_knot(const Vector2& p_position) const; /// Caches the graph knots for use. /// Copies the knot data from the OScriptGraph to this GraphEdit instance. @@ -346,9 +361,6 @@ class OrchestratorGraphEdit : public GraphEdit /// @param p_node the node to update. void _synchronize_graph_node(Ref p_node); - /// Synchronizes the child order - void _synchronize_child_order(); - /// Perform any post-steps after spawning a node /// @param p_spawned the spawned node /// @param p_callback a callback that is called after spawning the node diff --git a/src/editor/graph/graph_node.cpp b/src/editor/graph/graph_node.cpp index 81794d31..dcc09413 100644 --- a/src/editor/graph/graph_node.cpp +++ b/src/editor/graph/graph_node.cpp @@ -97,28 +97,28 @@ void OrchestratorGraphNode::_notification(int p_what) void OrchestratorGraphNode::_gui_input(const Ref& p_event) { - Ref button = p_event; - if (button.is_null() || !button->is_pressed()) - return; - - if (button->is_double_click() && button->get_button_index() == MOUSE_BUTTON_LEFT) + const Ref button = p_event; + if (button.is_valid() && button->is_pressed()) { - if (_node->can_jump_to_definition()) + if (button->is_double_click() && button->get_button_index() == MOUSE_BUTTON_LEFT) { - if (Object* target = _node->get_jump_target_for_double_click()) + if (_node->can_jump_to_definition()) { - _graph->request_focus(target); - accept_event(); + if (Object* target = _node->get_jump_target_for_double_click()) + { + _graph->request_focus(target); + accept_event(); + } } } - return; - } - else if (button->get_button_index() == MOUSE_BUTTON_RIGHT) - { - // Show menu - _show_context_menu(button->get_position()); - accept_event(); + else if (button->get_button_index() == MOUSE_BUTTON_RIGHT) + { + // Show menu + _show_context_menu(button->get_position()); + accept_event(); + } } + return GraphNode::_gui_input(p_event); } OrchestratorGraphEdit* OrchestratorGraphNode::get_graph() diff --git a/src/editor/graph/nodes/graph_node_comment.cpp b/src/editor/graph/nodes/graph_node_comment.cpp index f36f184e..64404138 100644 --- a/src/editor/graph/nodes/graph_node_comment.cpp +++ b/src/editor/graph/nodes/graph_node_comment.cpp @@ -26,6 +26,9 @@ OrchestratorGraphNodeComment::OrchestratorGraphNodeComment(OrchestratorGraphEdit : OrchestratorGraphNode(p_graph, p_node) , _comment_node(p_node) { + // Since _has_point is const, we need to cache this + _title_hbox = get_titlebar_hbox(); + MarginContainer* container = memnew(MarginContainer); container->add_theme_constant_override("margin_top", 4); container->add_theme_constant_override("margin_bottom", 4); @@ -46,7 +49,6 @@ OrchestratorGraphNodeComment::OrchestratorGraphNodeComment(OrchestratorGraphEdit void OrchestratorGraphNodeComment::_bind_methods() { - ClassDB::bind_method(D_METHOD("raise_request_node_reorder"), &OrchestratorGraphNodeComment::raise_request_node_reorder); } void OrchestratorGraphNodeComment::_update_pins() @@ -92,31 +94,68 @@ void OrchestratorGraphNodeComment::_notification(int p_what) connect("raise_request", callable_mp(this, &OrchestratorGraphNodeComment::_on_raise_request)); } +bool OrchestratorGraphNodeComment::_has_point(const Vector2& p_point) const +{ + Ref sb_panel = get_theme_stylebox("panel"); + Ref sb_titlebar = get_theme_stylebox("titlebar"); + Ref resizer = get_theme_icon("resizer"); + + if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) + return true; + + // Grab titlebar + int titlebar_height = _title_hbox->get_size().height + sb_titlebar->get_minimum_size().height; + if (Rect2(0, 0, get_size().width, titlebar_height).has_point(p_point)) + return true; + + // Allow grabbing on all sides of comment + Rect2 rect = Rect2(0, 0, get_size().width, get_size().height); + Rect2 no_drag_rect = rect.grow(-16); + + if (rect.has_point(p_point) && !no_drag_rect.has_point(p_point)) + return true; + + return false; +} + void OrchestratorGraphNodeComment::_gui_input(const Ref& p_event) { - Ref mb = p_event; - if (mb.is_valid()) + Ref mb = p_event; + if (mb.is_valid()) + { + if (mb->is_double_click() && mb->get_button_index() == MOUSE_BUTTON_LEFT) + { + if (is_group_selected()) + deselect_group(); + else + select_group(); + + accept_event(); + return; + } + } + return OrchestratorGraphNode::_gui_input(p_event); +} + +void OrchestratorGraphNodeComment::_on_raise_request() +{ + // When comment nodes are raised, their order must always be behind the connection layer. + // This guarantees that connection wires render properly. + if (OrchestratorGraphEdit* graph_edit = Object::cast_to(get_parent())) { - if (mb->is_double_click() && mb->get_button_index() == MOUSE_BUTTON_LEFT) + int position = 0; + for (int index = 0; index < graph_edit->get_child_count(); index++) { - if (is_group_selected()) - deselect_group(); - else - select_group(); + Node* child = graph_edit->get_child(index); - accept_event(); - return; + OrchestratorGraphNodeComment* comment = Object::cast_to(child); + if (comment && comment != this) + graph_edit->call_deferred("move_child", comment, position++); } - } - return OrchestratorGraphNode::_gui_input(p_event); -} -void OrchestratorGraphNodeComment::_on_raise_request() -{ - // This call must be deferred because the Godot GraphNode implementation raises this node - // after this method has been called, so we want to guarantee that we reorder the nodes - // of the scene after this node has been properly raised. - call_deferred("raise_request_node_reorder"); + graph_edit->call_deferred("move_child", this, position); + graph_edit->call_deferred("move_child", graph_edit->find_child("_connection_layer", false, false), position + 1); + } } bool OrchestratorGraphNodeComment::is_group_selected() @@ -142,13 +181,4 @@ void OrchestratorGraphNodeComment::deselect_group() List intersections = get_elements_within_global_rect(); for (GraphElement* child : intersections) child->set_selected(false); -} - -void OrchestratorGraphNodeComment::raise_request_node_reorder() -{ - // This guarantees that any node that intersects with a comment node will be repositioned - // in the scene after the comment, so that the rendering order appears correct. - List intersections = get_elements_within_global_rect(); - for (GraphElement* node : intersections) - get_parent()->move_child(node, -1); } \ No newline at end of file diff --git a/src/editor/graph/nodes/graph_node_comment.h b/src/editor/graph/nodes/graph_node_comment.h index 4404db2c..1617e88c 100644 --- a/src/editor/graph/nodes/graph_node_comment.h +++ b/src/editor/graph/nodes/graph_node_comment.h @@ -33,15 +33,12 @@ class OrchestratorGraphNodeComment : public OrchestratorGraphNode protected: Label* _label{ nullptr }; + HBoxContainer* _title_hbox{ nullptr }; Ref _comment_node; bool _selected{ false }; OrchestratorGraphNodeComment() = default; - /// Reorders graph nodes that intersect the comment node, making sure that any - /// other nodes that intersect are positioned after this comment node. - void raise_request_node_reorder(); - /// Called when the comment node is raised, brought to the front. void _on_raise_request(); @@ -65,6 +62,7 @@ class OrchestratorGraphNodeComment : public OrchestratorGraphNode //~ End Object Interface //~ Begin Control Interface + bool _has_point(const Vector2& p_point) const override; void _gui_input(const Ref& p_event) override; //~ End Control Interface }; From 771d8e06119493e5be98b7c54bd5002d9490debe Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 16 Aug 2024 01:13:57 -0400 Subject: [PATCH 04/12] GH-736 Fix knot movement/alignment --- src/editor/graph/graph_knot.cpp | 70 +++++++++++++++++++++++---------- src/editor/graph/graph_knot.h | 11 +++--- 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/editor/graph/graph_knot.cpp b/src/editor/graph/graph_knot.cpp index 3efbefb5..7a345732 100644 --- a/src/editor/graph/graph_knot.cpp +++ b/src/editor/graph/graph_knot.cpp @@ -31,23 +31,18 @@ void OrchestratorGraphKnot::_connections_changed(const String& p_caller) void OrchestratorGraphKnot::_position_changed() { _knot->point = get_position_offset(); - - set_block_signals(true); - set_position_offset(get_position_offset() - RENDER_OFFSET); - set_block_signals(false); - emit_signal("knot_position_changed", _knot->point); } void OrchestratorGraphKnot::_node_selected() { OrchestratorSettings* os = OrchestratorSettings::get_singleton(); - _icon->set_modulate(os->get_setting("ui/graph/knot_selected_color", Color(0.68f, 0.44f, 0.09f))); + _draw_color = os->get_setting("ui/graph/knot_selected_color", Color(0.68f, 0.44f, 0.09f)); } void OrchestratorGraphKnot::_node_deselected() { - _icon->set_modulate(_color); + _draw_color = _color; } void OrchestratorGraphKnot::set_graph(const Ref& p_graph) @@ -62,7 +57,15 @@ void OrchestratorGraphKnot::set_knot(const Ref& p_knot) { _knot = p_knot; - set_position_offset(_knot->point - RENDER_OFFSET); + set_position_offset(_knot->point); +} + +void OrchestratorGraphKnot::set_color(const Color& p_color) +{ + _color = p_color; + + if (!is_selected()) + _draw_color = _color; } void OrchestratorGraphKnot::_gui_input(const Ref& p_event) @@ -85,24 +88,39 @@ void OrchestratorGraphKnot::_gui_input(const Ref& p_event) GraphElement::_gui_input(p_event); } +bool OrchestratorGraphKnot::_has_point(const Vector2& p_point) const +{ + // Wrap mouse actions around the top-left point rather than around the snapped GraphElement + return Rect2(-(get_size() /2), get_size()).has_point(p_point); +} + void OrchestratorGraphKnot::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) + switch (p_what) { - set_mouse_filter(MOUSE_FILTER_STOP); - - VBoxContainer* vbox = memnew(VBoxContainer); - add_child(vbox); + case NOTIFICATION_ENTER_TREE: + { + const double scale = EditorInterface::get_singleton()->get_editor_scale(); - _icon = memnew(TextureRect); - _icon->set_texture(SceneUtils::get_editor_icon("GuiGraphNodePort")); - _icon->set_custom_minimum_size(RENDER_ICON_SIZE); - _icon->set_modulate(_color); - vbox->add_child(_icon); + _icon = SceneUtils::get_editor_icon("GuiGraphNodePort"); + set_custom_minimum_size(_icon.is_valid() ? scale * _icon->get_size() : Size2(16, 16) * scale); + break; + } + case NOTIFICATION_READY: + { + connect("position_offset_changed", callable_mp(this, &OrchestratorGraphKnot::_position_changed)); + connect("node_selected", callable_mp(this, &OrchestratorGraphKnot::_node_selected)); + connect("node_deselected", callable_mp(this, &OrchestratorGraphKnot::_node_deselected)); + break; + } + case NOTIFICATION_DRAW: + { + const Vector2 icon_position = -get_size() / 2.0; - connect("position_offset_changed", callable_mp(this, &OrchestratorGraphKnot::_position_changed)); - connect("node_selected", callable_mp(this, &OrchestratorGraphKnot::_node_selected)); - connect("node_deselected", callable_mp(this, &OrchestratorGraphKnot::_node_deselected)); + // todo: add rim color + draw_texture(_icon, icon_position, _draw_color); + break; + } } } @@ -111,3 +129,13 @@ void OrchestratorGraphKnot::_bind_methods() ADD_SIGNAL(MethodInfo("knot_position_changed", PropertyInfo(Variant::VECTOR2, "position"))); ADD_SIGNAL(MethodInfo("knot_delete_requested", PropertyInfo(Variant::STRING, "name"))); } + +OrchestratorGraphKnot::OrchestratorGraphKnot() +{ + set_mouse_filter(MOUSE_FILTER_STOP); + + VBoxContainer* vbox = memnew(VBoxContainer); + vbox->set_h_size_flags(SIZE_EXPAND_FILL); + vbox->set_v_size_flags(SIZE_EXPAND_FILL); + add_child(vbox); +} diff --git a/src/editor/graph/graph_knot.h b/src/editor/graph/graph_knot.h index 757f4693..2918b6dc 100644 --- a/src/editor/graph/graph_knot.h +++ b/src/editor/graph/graph_knot.h @@ -35,8 +35,9 @@ class OrchestratorGraphKnot : public GraphElement OScriptConnection _connection; //! The connection this knot belongs Ref _graph; //! The owning graph Ref _knot; //! The knot - TextureRect* _icon; //! The icon Color _color; //! The knot color + Color _draw_color; //! The knot draw color + Ref _icon; //! Port icon //~ Begin Signal Handlers void _connections_changed(const String& p_caller); @@ -45,9 +46,6 @@ class OrchestratorGraphKnot : public GraphElement void _node_deselected(); //~ End Signal Handlers - const Vector2 RENDER_OFFSET{ 8, 8 }; - const Vector2 RENDER_ICON_SIZE = RENDER_OFFSET * 2; - public: //~ Begin Wrapped Interface void _notification(int p_what); @@ -55,6 +53,7 @@ class OrchestratorGraphKnot : public GraphElement //~ Begin Control Interface void _gui_input(const Ref& p_event) override; + bool _has_point(const Vector2& p_point) const override; //~ End Control Interface /// Set the owning graph @@ -79,7 +78,9 @@ class OrchestratorGraphKnot : public GraphElement /// Set the knot's color /// @param p_color the color - void set_color(const Color& p_color) { _color = p_color; } + void set_color(const Color& p_color); + + OrchestratorGraphKnot(); }; #endif // ORCHESTRATOR_GRAPH_KNOT_H \ No newline at end of file From e13784e6a6188f4edc98e48ffe569d9297677421 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 16 Aug 2024 02:28:59 -0400 Subject: [PATCH 05/12] GH-752 Restrict arrow-key movement to only selected elements --- src/editor/graph/graph_edit.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/editor/graph/graph_edit.cpp b/src/editor/graph/graph_edit.cpp index 3b2e8888..68b37a08 100644 --- a/src/editor/graph/graph_edit.cpp +++ b/src/editor/graph/graph_edit.cpp @@ -513,12 +513,16 @@ void OrchestratorGraphEdit::_move_selected(const Vector2& p_delta) { for (int i = 0; i < get_child_count(); i++) { - if (OrchestratorGraphNode* node = Object::cast_to(get_child(i))) + GraphElement* element = Object::cast_to(get_child(i)); + if (!element || !element->is_selected()) + continue; + + if (OrchestratorGraphNode* node = Object::cast_to(element)) { node->set_position_offset(node->get_position_offset() + p_delta); node->get_script_node()->set_position(node->get_position_offset()); } - else if (OrchestratorGraphKnot* knot = Object::cast_to(get_child(i))) + else if (OrchestratorGraphKnot* knot = Object::cast_to(element)) { knot->set_position_offset(knot->get_knot()->point + p_delta); } From 4861adb35d519f2eeb74455249c2a7a5113425ec Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 16 Aug 2024 17:39:32 -0400 Subject: [PATCH 06/12] GH-712 Clamp `All Actions` dialog within screen rect. --- src/editor/graph/actions/action_menu.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/editor/graph/actions/action_menu.cpp b/src/editor/graph/actions/action_menu.cpp index 9d752cbe..5c0b5eff 100644 --- a/src/editor/graph/actions/action_menu.cpp +++ b/src/editor/graph/actions/action_menu.cpp @@ -26,6 +26,7 @@ #include "editor/graph/graph_node_spawner.h" #include +#include #include #include @@ -142,11 +143,24 @@ void OrchestratorGraphActionMenu::apply_filter(const OrchestratorGraphActionFilt _action_db.load(_filter); _generate_filtered_actions(); - set_size(Vector2(350, 700) * EditorInterface::get_singleton()->get_editor_scale()); - OrchestratorSettings* os = OrchestratorSettings::get_singleton(); - if (os && os->get_setting("ui/actions_menu/center_on_mouse")) - set_position(get_position() - (get_size() / 2)); + bool center_on_mouse = os->get_setting("ui/actions/center_on_mouse", true); + + const int32_t screenId = DisplayServer::get_singleton()->get_keyboard_focus_screen(); + Rect2 screen_rect = DisplayServer::get_singleton()->screen_get_usable_rect(screenId); + screen_rect.grow_by(-32); + screen_rect = screen_rect.grow_side(SIDE_TOP, -8); + + Size2 size = Vector2(350, 700); + + // Adjust position first + Vector2 position = center_on_mouse ? (get_position() - (get_size() / 2)) : get_position(); + position = position.clamp(screen_rect.position, screen_rect.position + screen_rect.size - size); + set_position(position); + + // Adjust size + size = size.clamp(Vector2(), screen_rect.position + screen_rect.size - position); + set_size(size); _on_collapse_tree(true); From ed31e69287dc89004c2061f3698e9bbbeae92329 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sat, 17 Aug 2024 11:18:43 -0400 Subject: [PATCH 07/12] GH-756 Fix validated variable getter state consistency --- src/script/nodes/variables/variable_get.cpp | 38 +++++++++++++++------ src/script/nodes/variables/variable_get.h | 2 ++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/script/nodes/variables/variable_get.cpp b/src/script/nodes/variables/variable_get.cpp index 0b9061c7..ad027bdf 100644 --- a/src/script/nodes/variables/variable_get.cpp +++ b/src/script/nodes/variables/variable_get.cpp @@ -99,16 +99,29 @@ void OScriptNodeVariableGet::_variable_changed() { if (_is_in_editor()) { - Ref output = find_pin("value", PD_Output); - if (output.is_valid() && output->has_any_connections()) + if (!can_be_validated() && _validated) + set_validated(false); + + // Defer this so that all nodes have updated + // This is necessary so that all target types that may have changed (i.e. get connected to set) + // have updated to make sure that the "can_accept" logic works as expected. + callable_mp(this, &OScriptNodeVariableGet::_validate_output_connection).call_deferred(); + } + + super::_variable_changed(); +} + +void OScriptNodeVariableGet::_validate_output_connection() +{ + Ref output = find_pin("value", PD_Output); + if (output.is_valid() && output->has_any_connections()) + { + for (const Ref& target : output->get_connections()) { - Ref target = output->get_connections()[0]; if (target.is_valid() && !target->can_accept(output)) - output->unlink_all(); + output->unlink(target); } } - - super::_variable_changed(); } void OScriptNodeVariableGet::allocate_default_pins() @@ -196,22 +209,27 @@ void OScriptNodeVariableGet::set_validated(bool p_validated) } // Record the connection before the change - Ref connection; + Vector> connections; Ref value = find_pin("value", PD_Output); if (value.is_valid() && value->has_any_connections()) { - connection = value->get_connections()[0]; + for (const Ref& target : value->get_connections()) + connections.push_back(target); + value->unlink_all(); } _notify_pins_changed(); - if (connection.is_valid()) + if (!connections.is_empty()) { // Relink connection on change value = find_pin("value", PD_Output); if (value.is_valid()) - value->link(connection); + { + for (const Ref& target : connections) + value->link(target); + } } } } diff --git a/src/script/nodes/variables/variable_get.h b/src/script/nodes/variables/variable_get.h index 6e09dbe5..82b30f0d 100644 --- a/src/script/nodes/variables/variable_get.h +++ b/src/script/nodes/variables/variable_get.h @@ -42,6 +42,8 @@ class OScriptNodeVariableGet : public OScriptNodeVariable void _variable_changed() override; //~ End OScriptNodeVariable Interface + void _validate_output_connection(); + public: //~ Begin OScriptNode Interface void allocate_default_pins() override; From 97a5e95f8093d457c19869ec6f6ee4f09218c372 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sun, 18 Aug 2024 13:57:17 -0400 Subject: [PATCH 08/12] GH-427 Support custom icons for comment nodes --- src/editor/graph/graph_node.cpp | 11 +++++++++-- src/script/nodes/utilities/comment.cpp | 16 +++++++++++++++- src/script/nodes/utilities/comment.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/editor/graph/graph_node.cpp b/src/editor/graph/graph_node.cpp index dcc09413..5dee7e3d 100644 --- a/src/editor/graph/graph_node.cpp +++ b/src/editor/graph/graph_node.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -306,15 +307,21 @@ void OrchestratorGraphNode::_update_titlebar() { Ref icon_texture; if (!_node->get_icon().is_empty()) - icon_texture = SceneUtils::get_editor_icon(_node->get_icon()); + { + if (_node->get_icon().begins_with("res://")) + icon_texture = ResourceLoader::get_singleton()->load(_node->get_icon()); + else + icon_texture = SceneUtils::get_editor_icon(_node->get_icon()); + } TextureRect* rect = Object::cast_to(titlebar->get_child(0)); if (!rect && icon_texture.is_valid()) { // Add node's icon to the UI rect = memnew(TextureRect); - rect->set_custom_minimum_size(Vector2(0, 24)); rect->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); + rect->set_expand_mode(TextureRect::EXPAND_FIT_WIDTH_PROPORTIONAL); + rect->set_size(Vector2(24, 24)); rect->set_texture(icon_texture); // Add the icon and move it to the start of the HBox. diff --git a/src/script/nodes/utilities/comment.cpp b/src/script/nodes/utilities/comment.cpp index 0d9bf350..74a7e14a 100644 --- a/src/script/nodes/utilities/comment.cpp +++ b/src/script/nodes/utilities/comment.cpp @@ -16,11 +16,14 @@ // #include "comment.h" +#include "common/string_utils.h" + void OScriptNodeComment::_get_property_list(List* r_list) const { const String movement_modes = "Group Movement,Comment"; r_list->push_back(PropertyInfo(Variant::STRING, "title")); + r_list->push_back(PropertyInfo(Variant::STRING, "icon", PROPERTY_HINT_FILE)); r_list->push_back(PropertyInfo(Variant::BOOL, "align_center")); r_list->push_back(PropertyInfo(Variant::COLOR, "background_color")); r_list->push_back(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "0,64")); @@ -60,6 +63,11 @@ bool OScriptNodeComment::_get(const StringName& p_name, Variant& r_value) const r_value = _title; return true; } + else if (p_name.match("icon")) + { + r_value = _icon; + return true; + } return false; } @@ -101,6 +109,12 @@ bool OScriptNodeComment::_set(const StringName& p_name, const Variant& p_value) _notify_pins_changed(); return true; } + else if (p_name.match("icon")) + { + _icon = p_value; + _notify_pins_changed(); + return true; + } return false; } @@ -119,5 +133,5 @@ String OScriptNodeComment::get_node_title() const String OScriptNodeComment::get_icon() const { - return "VisualShaderNodeComment"; + return StringUtils::default_if_empty(_icon, "VisualShaderNodeComment"); } diff --git a/src/script/nodes/utilities/comment.h b/src/script/nodes/utilities/comment.h index 2afc52d7..1916952f 100644 --- a/src/script/nodes/utilities/comment.h +++ b/src/script/nodes/utilities/comment.h @@ -28,6 +28,7 @@ class OScriptNodeComment : public OScriptNode protected: String _comments; String _title{ "Comment" }; + String _icon; bool _align_center{ false }; Color _background_color{ 0.6, 0.6, 0.6, 0.05 }; Color _text_color{ 1.0, 1.0, 1.0, 1.0 }; From aa4fdebfe38653e8b26a276c7f349facb8e4c8d0 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sun, 18 Aug 2024 18:52:46 -0400 Subject: [PATCH 09/12] GH-765 Disable debug symbols on Linux/Android builds --- CMakeLists.txt | 65 ++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a004256..efbc3260 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,36 +98,36 @@ INCLUDE(GodotCompilerWarnings) # Setup compiler options for GDExtension Library based on the compiler used TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC $<${compiler_is_msvc}: - /EHsc - /utf-8 - /Zc:preprocessor - /wd5054 # operator '|' deprecated between enumerations of different types - $<$: - /MDd - > - $<$: - /MD - /O2 - > + /EHsc + /utf-8 + /Zc:preprocessor + /wd5054 # operator '|' deprecated between enumerations of different types + $<$: + /MDd + > + $<$: + /MD + /O2 + > > $<$: - -g - -Wno-unused-value - $<${compiler_is_gnu}: - -Wno-attributes - -Wno-attributes=r1:: - > - $<${compiler_is_clang}: - -Wno-ignored-attributes - -Wno-unknown-attributes - > - $<$: - -fno-omit-frame-pointer - -O0 - > - $<$: - -O3 - > + -Wno-unused-value + $<${compiler_is_gnu}: + -Wno-attributes + -Wno-attributes=r1:: + > + $<${compiler_is_clang}: + -Wno-ignored-attributes + -Wno-unknown-attributes + > + $<$: + -g + -fno-omit-frame-pointer + -O0 + > + $<$: + -O3 + > > ) @@ -147,9 +147,12 @@ IF (NOT APPLE) # Linker options for the GDExtension library TARGET_LINK_OPTIONS(${PROJECT_NAME} PRIVATE $<$: - -static-libgcc - -static-libstdc++ - -Wl,-R,'$$ORIGIN' + -static-libgcc + -static-libstdc++ + -Wl,-R,'$$ORIGIN' + $<$: + $<$:-s> + > > ) ENDIF () From 528753986758f808eee667c9b59d7ed4292b877f Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 23 Aug 2024 15:30:59 -0400 Subject: [PATCH 10/12] GH-774 Relax return node validation for sequence nodes --- src/script/nodes/flow_control/sequence.h | 3 +++ src/script/nodes/functions/function_result.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/script/nodes/flow_control/sequence.h b/src/script/nodes/flow_control/sequence.h index 0d7e1235..e0eedfa1 100644 --- a/src/script/nodes/flow_control/sequence.h +++ b/src/script/nodes/flow_control/sequence.h @@ -58,6 +58,9 @@ class OScriptNodeSequence : public OScriptEditablePinNode void remove_dynamic_pin(const Ref& p_pin) override; String get_pin_prefix() const override { return "then"; } //~ End OScriptEditablePinNode Interface + + // Get the number of configured steps + int get_steps() const { return _steps; } }; #endif // ORCHESTRATOR_SCRIPT_NODE_SEQUENCE_H diff --git a/src/script/nodes/functions/function_result.cpp b/src/script/nodes/functions/function_result.cpp index ec9af314..ad8fed32 100644 --- a/src/script/nodes/functions/function_result.cpp +++ b/src/script/nodes/functions/function_result.cpp @@ -17,6 +17,7 @@ #include "function_result.h" #include "common/property_utils.h" +#include "script/nodes/flow_control/sequence.h" class OScriptNodeFunctionResultInstance : public OScriptNodeInstance { @@ -137,8 +138,22 @@ void OScriptNodeFunctionResult::validate_node_during_build(BuildLog& p_log) cons const Ref source = graph_nodes[E.from_node]; if (source.is_valid()) { + const Ref sequence = source; + if (source->is_loop_port(E.from_port)) + { skipped.insert(E.to_node); + } + else if (sequence.is_valid()) + { + // Sequence nodes are designed to execute each "Then X" output pin in sequential + // order and therefore, only the last sequence output port should be mandated to + // connect to a return node, skipping the prior branches similar to loops. + const int steps = sequence->get_steps(); + if (E.from_port < (steps - 1)) + skipped.insert(E.to_node); + } + } if (skipped.has(E.from_node)) From 9da528a9b2da879d35be1582762363a5d45f8daf Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sat, 24 Aug 2024 14:35:55 -0400 Subject: [PATCH 11/12] Prefer `&&` rather than `and` operator --- src/script/nodes/data/arrays.cpp | 2 +- src/script/nodes/utilities/autoload.cpp | 2 +- src/script/nodes/utilities/engine_singleton.cpp | 2 +- src/script/nodes/utilities/self.cpp | 2 +- src/script/nodes/variables/local_variable.cpp | 2 +- src/script/nodes/variables/variable_get.cpp | 2 +- src/script/nodes/variables/variable_set.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/script/nodes/data/arrays.cpp b/src/script/nodes/data/arrays.cpp index 57970304..54a636fe 100644 --- a/src/script/nodes/data/arrays.cpp +++ b/src/script/nodes/data/arrays.cpp @@ -355,7 +355,7 @@ void OScriptNodeMakeArray::add_dynamic_pin() bool OScriptNodeMakeArray::can_remove_dynamic_pin(const Ref& p_pin) const { - return _element_count > 0 and p_pin->is_input(); + return _element_count > 0 && p_pin->is_input(); } void OScriptNodeMakeArray::remove_dynamic_pin(const Ref& p_pin) diff --git a/src/script/nodes/utilities/autoload.cpp b/src/script/nodes/utilities/autoload.cpp index 1048468c..9cd0fc1e 100644 --- a/src/script/nodes/utilities/autoload.cpp +++ b/src/script/nodes/utilities/autoload.cpp @@ -72,7 +72,7 @@ bool OScriptNodeAutoload::_set(const StringName& p_name, const Variant& p_value) void OScriptNodeAutoload::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - makes sure that autoload class type is encoded in pin Ref pin = find_pin("autoload", PD_Output); diff --git a/src/script/nodes/utilities/engine_singleton.cpp b/src/script/nodes/utilities/engine_singleton.cpp index 1c710c51..01a02f1a 100644 --- a/src/script/nodes/utilities/engine_singleton.cpp +++ b/src/script/nodes/utilities/engine_singleton.cpp @@ -68,7 +68,7 @@ bool OScriptNodeEngineSingleton::_set(const StringName& p_name, const Variant& p void OScriptNodeEngineSingleton::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - makes sure that singleton class type is encoded in pin const Ref singleton = find_pin("singleton", PD_Output); diff --git a/src/script/nodes/utilities/self.cpp b/src/script/nodes/utilities/self.cpp index b84aba2f..4d9c7b3f 100644 --- a/src/script/nodes/utilities/self.cpp +++ b/src/script/nodes/utilities/self.cpp @@ -39,7 +39,7 @@ class OScriptNodeSelfInstance : public OScriptNodeInstance void OScriptNodeSelf::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - makes sure that base type matches pin const Ref self = find_pin("self", PD_Output); diff --git a/src/script/nodes/variables/local_variable.cpp b/src/script/nodes/variables/local_variable.cpp index 22ad8b40..523c5f78 100644 --- a/src/script/nodes/variables/local_variable.cpp +++ b/src/script/nodes/variables/local_variable.cpp @@ -186,7 +186,7 @@ void OScriptNodeLocalVariable::initialize(const OScriptNodeInitContext& p_contex void OScriptNodeAssignLocalVariable::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - make sure variant is encoded for nils Ref variable = find_pin("variable", PD_Input); diff --git a/src/script/nodes/variables/variable_get.cpp b/src/script/nodes/variables/variable_get.cpp index ad027bdf..21320c2a 100644 --- a/src/script/nodes/variables/variable_get.cpp +++ b/src/script/nodes/variables/variable_get.cpp @@ -81,7 +81,7 @@ bool OScriptNodeVariableGet::_set(const StringName& p_name, const Variant& p_val void OScriptNodeVariableGet::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - makes sure that stored property matches variable, if not reconstructs if (_variable.is_valid()) diff --git a/src/script/nodes/variables/variable_set.cpp b/src/script/nodes/variables/variable_set.cpp index c238eb87..fb5b0e6d 100644 --- a/src/script/nodes/variables/variable_set.cpp +++ b/src/script/nodes/variables/variable_set.cpp @@ -68,7 +68,7 @@ class OScriptNodeVariableSetInstance : public OScriptNodeInstance void OScriptNodeVariableSet::_upgrade(uint32_t p_version, uint32_t p_current_version) { - if (p_version == 1 and p_current_version >= 2) + if (p_version == 1 && p_current_version >= 2) { // Fixup - makes sure that stored property matches variable, if not reconstructs if (_variable.is_valid()) From 8d91743c87689c38fc33cf3496fa40191096f9ee Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sun, 25 Aug 2024 02:46:32 -0400 Subject: [PATCH 12/12] GH-778 Fix crash on Windows 10 - Revert GH-653 --- src/editor/plugins/orchestrator_editor_plugin.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/editor/plugins/orchestrator_editor_plugin.cpp b/src/editor/plugins/orchestrator_editor_plugin.cpp index 941247b3..3e55ab37 100644 --- a/src/editor/plugins/orchestrator_editor_plugin.cpp +++ b/src/editor/plugins/orchestrator_editor_plugin.cpp @@ -31,8 +31,6 @@ #include #include #include -#include -#include #include #include #include @@ -155,18 +153,7 @@ String OrchestratorPlugin::_get_plugin_name() const Ref OrchestratorPlugin::_get_plugin_icon() const { - Ref icon = ResourceLoader::get_singleton()->load(OScriptLanguage::ICON); - - const double scale = EditorInterface::get_singleton()->get_editor_scale(); - if (UtilityFunctions::is_equal_approx(1.0, scale)) - return icon; - - // Godot automatically scales icons that are part of the Editor pack but does not do - // that with custom icons, we must do this when the display size changes. - const Ref image = icon->get_image(); - image->resize(static_cast(image->get_width() * scale), static_cast(image->get_height() * scale)); - - return ImageTexture::create_from_image(image); + return ResourceLoader::get_singleton()->load(OScriptLanguage::ICON); } String OrchestratorPlugin::get_plugin_online_documentation_url() const