From 18d3a0ec83a13b9138552b7853ab64231aca1825 Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 6 Nov 2025 01:41:41 +0100 Subject: [PATCH] feat: added grabbed and released signals to photo --- modules/you_done_it/pinned_photo.cpp | 8 ++++++++ modules/you_done_it/pinned_photo.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/modules/you_done_it/pinned_photo.cpp b/modules/you_done_it/pinned_photo.cpp index 7db7bab2..aec43c5d 100644 --- a/modules/you_done_it/pinned_photo.cpp +++ b/modules/you_done_it/pinned_photo.cpp @@ -8,7 +8,12 @@ #include "you_done_it/conclusion_field.h" #include "you_done_it/ydi_networking.h" +String const PinnedPhoto::sig_grabbed{ "grabbed" }; +String const PinnedPhoto::sig_released{ "released" }; + void PinnedPhoto::_bind_methods() { + ADD_SIGNAL(MethodInfo(sig_grabbed)); + ADD_SIGNAL(MethodInfo(sig_released)); BIND_PROPERTY(Variant::BOOL, can_drop); BIND_HPROPERTY(Variant::INT, clue, PROPERTY_HINT_ENUM, NetworkData::ClueID_hint()); } @@ -49,6 +54,7 @@ void PinnedPhoto::on_input_event(Viewport *viewport, Ref event, int set_global_rotation(0); this->popup_container->set_visible(!this->popup_label->get_text().is_empty()); this->get_parent()->move_child(this, this->get_parent()->get_child_count() - 1); + emit_signal(sig_grabbed); } } @@ -63,11 +69,13 @@ void PinnedPhoto::unhandled_input(Ref const &event) { set_global_position(this->conclusion_field->get_global_position()); set_global_rotation(this->conclusion_field->get_global_rotation()); this->popup_container->set_visible(false); + emit_signal(sig_released); } else if (this->can_drop) { this->is_held = false; get_viewport()->set_input_as_handled(); set_global_rotation(0.0); this->popup_container->set_visible(false); + emit_signal(sig_released); } } } diff --git a/modules/you_done_it/pinned_photo.h b/modules/you_done_it/pinned_photo.h index d2827bde..0596944d 100644 --- a/modules/you_done_it/pinned_photo.h +++ b/modules/you_done_it/pinned_photo.h @@ -38,4 +38,8 @@ private: Vector near_fields{}; RichTextLabel *popup_label{ nullptr }; PanelContainer *popup_container{ nullptr }; + +public: + static String const sig_released; + static String const sig_grabbed; };