summaryrefslogtreecommitdiffstats
path: root/core/debugger/debugger_marshalls.cpp
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-11-10 12:12:46 -0600
committerThaddeus Crews <repiteo@outlook.com>2024-11-10 12:12:46 -0600
commitf3294e59e10b2d408367ea236e4d35a3590e6bfe (patch)
treebf9ca64d51f3b37d09a217babfcd0d421a2a637f /core/debugger/debugger_marshalls.cpp
parent1cad5525d60f7b1ac45dc82788cf4bd9a4ddcb1b (diff)
parentc3e2e468554881c021aa2123efe295c147df3f46 (diff)
downloadredot-engine-f3294e59e10b2d408367ea236e4d35a3590e6bfe.tar.gz
Merge pull request #98891 from Faless/debugger/game_view_settings
[Debugger] Better settings configuration for RuntimeNodeSelect and Window quit
Diffstat (limited to 'core/debugger/debugger_marshalls.cpp')
-rw-r--r--core/debugger/debugger_marshalls.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/debugger/debugger_marshalls.cpp b/core/debugger/debugger_marshalls.cpp
index f4283e0ea9..cc36ca4816 100644
--- a/core/debugger/debugger_marshalls.cpp
+++ b/core/debugger/debugger_marshalls.cpp
@@ -147,3 +147,37 @@ bool DebuggerMarshalls::OutputError::deserialize(const Array &p_arr) {
CHECK_END(p_arr, idx, "OutputError");
return true;
}
+
+Array DebuggerMarshalls::serialize_key_shortcut(const Ref<Shortcut> &p_shortcut) {
+ ERR_FAIL_COND_V(p_shortcut.is_null(), Array());
+ Array keys;
+ for (const Ref<InputEvent> ev : p_shortcut->get_events()) {
+ const Ref<InputEventKey> kev = ev;
+ ERR_CONTINUE(kev.is_null());
+ if (kev->get_physical_keycode() != Key::NONE) {
+ keys.push_back(true);
+ keys.push_back(kev->get_physical_keycode_with_modifiers());
+ } else {
+ keys.push_back(false);
+ keys.push_back(kev->get_keycode_with_modifiers());
+ }
+ }
+ return keys;
+}
+
+Ref<Shortcut> DebuggerMarshalls::deserialize_key_shortcut(const Array &p_keys) {
+ Array key_events;
+ ERR_FAIL_COND_V(p_keys.size() % 2 != 0, Ref<Shortcut>());
+ for (int i = 0; i < p_keys.size(); i += 2) {
+ ERR_CONTINUE(p_keys[i].get_type() != Variant::BOOL);
+ ERR_CONTINUE(p_keys[i + 1].get_type() != Variant::INT);
+ key_events.push_back(InputEventKey::create_reference((Key)p_keys[i + 1].operator int(), p_keys[i].operator bool()));
+ }
+ if (key_events.is_empty()) {
+ return Ref<Shortcut>();
+ }
+ Ref<Shortcut> shortcut;
+ shortcut.instantiate();
+ shortcut->set_events(key_events);
+ return shortcut;
+}