From 9ca40f0e0a015599a8fb89bf62e51647dd8f38b0 Mon Sep 17 00:00:00 2001 From: Micky Date: Tue, 30 Aug 2022 10:43:32 +0200 Subject: [PATCH 01/10] Cast between float and ints in SceneTreeTween.`tween_property()` (cherry picked from commit 2b18a4002c8e500597bc8f5d605f9be8d1b22236) --- scene/animation/scene_tree_tween.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scene/animation/scene_tree_tween.cpp b/scene/animation/scene_tree_tween.cpp index d15e3299ba3..4dc1cf2d20e 100644 --- a/scene/animation/scene_tree_tween.cpp +++ b/scene/animation/scene_tree_tween.cpp @@ -65,10 +65,17 @@ Ref SceneTreeTween::tween_property(Object *p_target, NodePath p ERR_FAIL_COND_V_MSG(!valid, nullptr, "SceneTreeTween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a SceneTreeTween that has started. Use stop() first."); -#ifdef DEBUG_ENABLED Variant::Type property_type = p_target->get_indexed(p_property.get_as_property_path().get_subnames()).get_type(); - ERR_FAIL_COND_V_MSG(property_type != p_to.get_type(), Ref(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); -#endif + if (property_type != p_to.get_type()) { + // Cast p_to between floats and ints to avoid minor annoyances. + if (property_type == Variant::REAL && p_to.get_type() == Variant::INT) { + p_to = float(p_to); + } else if (property_type == Variant::INT && p_to.get_type() == Variant::REAL) { + p_to = int(p_to); + } else { + ERR_FAIL_V_MSG(Ref(), "Type mismatch between property and final value: " + Variant::get_type_name(property_type) + " and " + Variant::get_type_name(p_to.get_type())); + } + } Ref tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration)); append(tweener); From 737bfa57d3bbac8dca12cc143ed4b3730e7a6dfb Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 30 Aug 2022 13:32:34 +0200 Subject: [PATCH 02/10] Allow to change the Stop shortcut used at runtime (cherry picked from commit 409613ba7ba50e6cc985c61f6dcc482bac68746e) --- editor/editor_run.cpp | 5 +++++ scene/main/scene_tree.cpp | 32 ++++++++++++++++++++++++++++++-- scene/main/scene_tree.h | 4 ++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 7dc30b5a76b..407f843d5a2 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -235,6 +235,11 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L } } + // Pass the debugger stop shortcut to the running instance(s). + String shortcut; + VariantWriter::write_to_string(ED_GET_SHORTCUT("editor/stop"), shortcut); + OS::get_singleton()->set_environment("__GODOT_EDITOR_STOP_SHORTCUT__", shortcut); + printf("Running: %ls", exec.c_str()); for (List::Element *E = args.front(); E; E = E->next()) { printf(" %ls", E->get().c_str()); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 8a0240069b9..774ed869e7f 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -38,10 +38,12 @@ #include "core/os/os.h" #include "core/print_string.h" #include "core/project_settings.h" +#include "core/variant_parser.h" #include "main/input_default.h" #include "node.h" #include "scene/animation/scene_tree_tween.h" #include "scene/debugger/script_debugger_remote.h" +#include "scene/gui/shortcut.h" #include "scene/resources/dynamic_font.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" @@ -463,9 +465,35 @@ void SceneTree::input_event(const Ref &p_event) { call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) { - //quit from game window using F8 + // Quit from game window using the stop shortcut (F8 by default). + // The custom shortcut is provided via environment variable when running from the editor. + if (debugger_stop_shortcut.is_null()) { + String shortcut_str = OS::get_singleton()->get_environment("__GODOT_EDITOR_STOP_SHORTCUT__"); + if (!shortcut_str.empty()) { + Variant shortcut_var; + + VariantParser::StreamString ss; + ss.s = shortcut_str; + + String errs; + int line; + VariantParser::parse(&ss, shortcut_var, errs, line); + debugger_stop_shortcut = shortcut_var; + } + + if (debugger_stop_shortcut.is_null()) { + // Define a default shortcut if it wasn't provided or is invalid. + Ref ie; + ie.instance(); + ie->set_scancode(KEY_F8); + ie->set_unicode(KEY_F8); + debugger_stop_shortcut.instance(); + debugger_stop_shortcut->set_shortcut(ie); + } + } + Ref k = ev; - if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_F8) { + if (k.is_valid() && k->is_pressed() && !k->is_echo() && debugger_stop_shortcut->is_shortcut(k)) { ScriptDebugger::get_singleton()->request_quit(); } } diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index b3c994b0b8c..6117065e478 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -42,6 +42,7 @@ class PackedScene; class Node; class SceneTreeTween; +class ShortCut; class Spatial; class Viewport; class Material; @@ -230,6 +231,9 @@ private: SelfList::List xform_change_list; friend class ScriptDebuggerRemote; + + Ref debugger_stop_shortcut; + #ifdef DEBUG_ENABLED Map live_edit_node_path_cache; From 739919469e32e9fd26a47e47734c4302693ea408 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 4 Apr 2022 01:24:01 +0200 Subject: [PATCH 03/10] Mention that grab_focus is more reliable deferred (cherry picked from commit 188d5593e1f080181a6e0302b7d54416d2cd96e8) --- doc/classes/Control.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index d76effb4e3f..0735b8fc941 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -395,6 +395,7 @@ Steal the focus from another control and become the focused control (see [member focus_mode]). + [b]Note[/b]: Using this method together with [method Object.call_deferred] makes it more reliable, especially when called inside [method Node._ready]. From a01ae706aec275f1b047021c28d0115fcdcb0824 Mon Sep 17 00:00:00 2001 From: Micky Date: Tue, 30 Aug 2022 16:44:57 +0200 Subject: [PATCH 04/10] Mark Script button if it's tool in Scene Tree Editor Also adds a note on the tooltip if the Script is tool. The color is the same one used on the Script Editor's script list. (cherry picked from commit ad5ff9f78fe0bab4572085803f224026273fd4aa) --- editor/scene_tree_editor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 51baba21579..c020ee7cba6 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -343,10 +343,18 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll Ref