Skip to content

Commit

Permalink
hide gui elements when system is not available (beams, missiles, shie…
Browse files Browse the repository at this point in the history
…lds)
  • Loading branch information
Piglit committed Aug 2, 2023
1 parent ab6100c commit 96f2135
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/menus/shipSelectionScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ void ShipSelectionScreen::update(float delta)
for(int n = 0; n < GameGlobalInfo::max_player_ships; n++)
{
P<PlayerSpaceship> 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();
Expand Down
11 changes: 11 additions & 0 deletions src/screenComponents/aimLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/screens/crew4/tacticalScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -145,7 +144,6 @@ void TacticalScreen::onDraw(sp::RenderTarget& renderer)
} else {
shields_display->hide();
}

targets.set(my_spaceship->getTarget());
}
GuiOverlay::onDraw(renderer);
Expand Down
3 changes: 1 addition & 2 deletions src/screens/crew6/weaponsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 96f2135

Please sign in to comment.