feat: added grabbed and released signals to photo

This commit is contained in:
Sara Gerretsen 2025-11-06 01:41:41 +01:00
parent c17c17e0df
commit 18d3a0ec83
2 changed files with 12 additions and 0 deletions

View file

@ -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<InputEvent> 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<InputEvent> 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);
}
}
}

View file

@ -38,4 +38,8 @@ private:
Vector<ConclusionField *> near_fields{};
RichTextLabel *popup_label{ nullptr };
PanelContainer *popup_container{ nullptr };
public:
static String const sig_released;
static String const sig_grabbed;
};