feat: implemented interaction tooltips
This commit is contained in:
parent
34db607145
commit
2511ac69c0
7 changed files with 44 additions and 15 deletions
|
|
@ -4,12 +4,17 @@ HeadsUpDisplay *HeadsUpDisplay::singleton_instance{ nullptr };
|
|||
|
||||
void HeadsUpDisplay::_bind_methods() {
|
||||
ClassDB::bind_static_method("HeadsUpDisplay", D_METHOD("get_singleton"), &self_type::get_singleton);
|
||||
ClassDB::bind_method(D_METHOD("set_tooltip"), &self_type::set_tooltip);
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::on_child_entered(Node *child) {
|
||||
child->connect("child_entered_tree", callable_mp(this, &self_type::on_child_entered));
|
||||
if (child->is_unique_name_in_owner() && child->get_name() == "Reticle") {
|
||||
this->reticle = cast_to<Control>(child);
|
||||
}
|
||||
if (child->is_unique_name_in_owner() && child->get_name() == "Tooltip") {
|
||||
this->tooltip = cast_to<Label>(child);
|
||||
}
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::enter_tree() {
|
||||
|
|
@ -46,3 +51,7 @@ void HeadsUpDisplay::set_reticle_visibility(bool visible) {
|
|||
this->reticle->set_visible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
void HeadsUpDisplay::set_tooltip(String const &tooltip) {
|
||||
this->tooltip->set_text(tooltip);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue