feat: removed reticle from HUD

This commit is contained in:
Sara 2025-08-30 23:07:30 +02:00
parent 5277ac6281
commit 2c95d2e7aa
3 changed files with 0 additions and 21 deletions

View file

@ -4,14 +4,10 @@ HeadsUpDisplay *HeadsUpDisplay::singleton_instance{ nullptr };
void HeadsUpDisplay::_bind_methods() { void HeadsUpDisplay::_bind_methods() {
ClassDB::bind_static_method("HeadsUpDisplay", D_METHOD("get_singleton"), &self_type::get_singleton); 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) { void HeadsUpDisplay::on_child_entered(Node *child) {
child->connect("child_entered_tree", callable_mp(this, &self_type::on_child_entered)); 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") { if (child->is_unique_name_in_owner() && child->get_name() == "Tooltip") {
this->tooltip = cast_to<Label>(child); this->tooltip = cast_to<Label>(child);
} }
@ -46,12 +42,6 @@ HeadsUpDisplay *HeadsUpDisplay::get_singleton() {
return singleton_instance; return singleton_instance;
} }
void HeadsUpDisplay::set_reticle_visibility(bool visible) {
if (this->reticle) {
this->reticle->set_visible(visible);
}
}
void HeadsUpDisplay::set_tooltip(String const &tooltip) { void HeadsUpDisplay::set_tooltip(String const &tooltip) {
this->tooltip->set_text(tooltip); this->tooltip->set_text(tooltip);
} }

View file

@ -17,11 +17,9 @@ protected:
public: public:
static HeadsUpDisplay *get_singleton(); static HeadsUpDisplay *get_singleton();
void set_reticle_visibility(bool visible);
void set_tooltip(String const &tooltip); void set_tooltip(String const &tooltip);
private: private:
Control *reticle{ nullptr };
Label *tooltip{ nullptr }; Label *tooltip{ nullptr };
}; };

View file

@ -1,6 +1,5 @@
#include "rifle.h" #include "rifle.h"
#include "scene/animation/animation_player.h" #include "scene/animation/animation_player.h"
#include "wave_survival/heads_up_display.h"
#include "wave_survival/hitscan_muzzle.h" #include "wave_survival/hitscan_muzzle.h"
#include "wave_survival/macros.h" #include "wave_survival/macros.h"
#include "wave_survival/player_body.h" #include "wave_survival/player_body.h"
@ -88,14 +87,9 @@ void Rifle::on_animation_changed(String new_animation) {
if (new_animation == "aim") { if (new_animation == "aim") {
this->in_alt_mode = true; this->in_alt_mode = true;
this->fov = this->ads_factor; this->fov = this->ads_factor;
HeadsUpDisplay::get_singleton()->set_reticle_visibility(false);
} else if (new_animation == "hip") { } else if (new_animation == "hip") {
this->in_alt_mode = false; this->in_alt_mode = false;
this->fov = 1.0; this->fov = 1.0;
HeadsUpDisplay::get_singleton()->set_reticle_visibility(true);
}
if (new_animation == "reload") {
HeadsUpDisplay::get_singleton()->set_reticle_visibility(false);
} }
} }
@ -182,9 +176,6 @@ void Rifle::notify_deselected() {
get_input()->disconnect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode)); get_input()->disconnect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode));
get_input()->disconnect(PlayerInput::sig_reload, callable_mp(this, &self_type::on_reload)); get_input()->disconnect(PlayerInput::sig_reload, callable_mp(this, &self_type::on_reload));
this->running = false; this->running = false;
if (HeadsUpDisplay * hud{ HeadsUpDisplay::get_singleton() }) {
hud->set_reticle_visibility(true);
}
this->in_alt_mode = false; this->in_alt_mode = false;
this->fov = 1.f; this->fov = 1.f;
} }