From 96f21354facfcefef2b89c3097a47983fcbc5bdc Mon Sep 17 00:00:00 2001 From: Pithlit Date: Wed, 2 Aug 2023 11:04:00 +0200 Subject: [PATCH] hide gui elements when system is not available (beams, missiles, shields) --- src/menus/shipSelectionScreen.cpp | 2 -- src/screenComponents/aimLock.cpp | 11 +++++++++++ src/screens/crew4/tacticalScreen.cpp | 4 +--- src/screens/crew6/weaponsScreen.cpp | 3 +-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/menus/shipSelectionScreen.cpp b/src/menus/shipSelectionScreen.cpp index 7806d88a55..db8bf46ede 100644 --- a/src/menus/shipSelectionScreen.cpp +++ b/src/menus/shipSelectionScreen.cpp @@ -434,8 +434,6 @@ void ShipSelectionScreen::update(float delta) for(int n = 0; n < GameGlobalInfo::max_player_ships; n++) { P ship = gameGlobalInfo->getPlayerShip(n); - if (ship) - LOG(DEBUG) << ship->getCallSign() << "\t" << int(ship->is_fighter) << "\t" << int(ship->getIsFighter()) << "\t" << fighter_toggle_selector->getSelectionIndex(); if (ship && (int(ship->getIsFighter()) == fighter_toggle_selector->getSelectionIndex())) { string ship_name = ship->getLocaleFaction() + " " + ship->getTypeName() + " " + ship->getCallSign(); diff --git a/src/screenComponents/aimLock.cpp b/src/screenComponents/aimLock.cpp index 78376c9db3..76465022ec 100644 --- a/src/screenComponents/aimLock.cpp +++ b/src/screenComponents/aimLock.cpp @@ -24,6 +24,11 @@ void AimLockButton::onUpdate() { if (!isVisible()) return; + if (!my_spaceship->hasSystem(SYS_MissileSystem)) + { + setVisible(false); + return; + } if (keys.weapons_toggle_aim_lock.getDown()) { setAimLock(!getValue()); @@ -60,6 +65,12 @@ AimLock::AimLock(GuiContainer* owner, string id, GuiRadarView* radar, float min_ void AimLock::onDraw(sp::RenderTarget& renderer) { + if (!my_spaceship->hasSystem(SYS_MissileSystem)) + { + setVisible(false); + return; + } + auto center = getCenterPoint(); float view_rotation = radar->getViewRotation(); float radius = std::min(rect.size.x, rect.size.y); diff --git a/src/screens/crew4/tacticalScreen.cpp b/src/screens/crew4/tacticalScreen.cpp index 2016456195..08481e9c98 100644 --- a/src/screens/crew4/tacticalScreen.cpp +++ b/src/screens/crew4/tacticalScreen.cpp @@ -84,12 +84,11 @@ TacticalScreen::TacticalScreen(GuiContainer* owner) radar->enableTargetProjections(tube_controls); // Beam controls beneath the radar. - if (gameGlobalInfo->use_beam_shield_frequencies || gameGlobalInfo->use_system_damage) + if (my_spaceship->hasSystem(SYS_BeamWeapons) && (gameGlobalInfo->use_beam_shield_frequencies || gameGlobalInfo->use_system_damage)) { GuiElement* beam_info_box = new GuiElement(this, "BEAM_INFO_BOX"); beam_info_box->setPosition(0, -20, sp::Alignment::BottomCenter)->setSize(460, 50); (new GuiLabel(beam_info_box, "BEAM_INFO_LABEL", tr("Beams Target"), 30))->addBackground()->setPosition(0, 0, sp::Alignment::BottomLeft)->setSize(160, 50); - (new GuiPowerDamageIndicator(beam_info_box, "", SYS_BeamWeapons, sp::Alignment::CenterLeft))->setPosition(0, 0, sp::Alignment::BottomLeft)->setSize(160, 50); (new GuiBeamTargetSelector(beam_info_box, "BEAM_TARGET_SELECTOR"))->setPosition(0, 0, sp::Alignment::BottomRight)->setSize(288, 50); } @@ -145,7 +144,6 @@ void TacticalScreen::onDraw(sp::RenderTarget& renderer) } else { shields_display->hide(); } - targets.set(my_spaceship->getTarget()); } GuiOverlay::onDraw(renderer); diff --git a/src/screens/crew6/weaponsScreen.cpp b/src/screens/crew6/weaponsScreen.cpp index 805ebcfd8e..368291673e 100644 --- a/src/screens/crew6/weaponsScreen.cpp +++ b/src/screens/crew6/weaponsScreen.cpp @@ -57,8 +57,7 @@ WeaponsScreen::WeaponsScreen(GuiContainer* owner) lock_aim = new AimLockButton(this, "LOCK_AIM", tube_controls, missile_aim); lock_aim->setPosition(250, 20, sp::Alignment::TopCenter)->setSize(130, 50); - - if (gameGlobalInfo->use_beam_shield_frequencies || gameGlobalInfo->use_system_damage) + if (my_spaceship->hasSystem(SYS_BeamWeapons) && (gameGlobalInfo->use_beam_shield_frequencies || gameGlobalInfo->use_system_damage)) { GuiElement* beam_info_box = new GuiElement(this, "BEAM_INFO_BOX"); beam_info_box->setPosition(-20, -120, sp::Alignment::BottomRight)->setSize(280, 150);