Skip to content

Commit

Permalink
hide beams/shields gui when system does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Pithlit committed Jul 28, 2023
1 parent 951bf8b commit a0d434d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/screenComponents/shieldFreqencySelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void GuiShieldFrequencySelect::onDraw(sp::RenderTarget& renderer)
{
calibrate_button->setEnable(my_spaceship->shield_calibration_delay <= 0.0f);
new_frequency->setEnable(my_spaceship->shield_calibration_delay <= 0.0f);
calibrate_button->setVisible(my_spaceship->hasSystem(SYS_FrontShield) || my_spaceship->hasSystem(SYS_RearShield));
new_frequency->setVisible(my_spaceship->hasSystem(SYS_FrontShield) || my_spaceship->hasSystem(SYS_RearShield));
}
GuiElement::onDraw(renderer);
}
Expand Down
5 changes: 5 additions & 0 deletions src/screenComponents/shieldsEnableButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ void GuiShieldsEnableButton::onDraw(sp::RenderTarget& target)
else
button->setText(tr("Shields: {status}").format({{"status", shield_status}}));
}
if (!(my_spaceship->hasSystem(SYS_FrontShield) || my_spaceship->hasSystem(SYS_RearShield)))
{
button->hide();
bar->hide();
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/screens/crew4/engineeringAdvancedScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ EngineeringAdvancedScreen::EngineeringAdvancedScreen(GuiContainer* owner)
//The shield frequency selection includes a shield enable button.
(new GuiShieldFrequencySelect(this, "SHIELD_FREQ"))->setPosition(20, 310, sp::Alignment::TopLeft)->setSize(240, 100);

GuiElement* beam_info_box = new GuiElement(this, "BEAM_INFO_BOX");
beam_info_box->setPosition(20, 410, sp::Alignment::TopLeft)->setSize(240, 50);
(new GuiLabel(beam_info_box, "BEAM_INFO_LABEL", tr("Beams"), 30))->addBackground()->setPosition(20, 0, sp::Alignment::TopLeft)->setSize(80, 50);
(new GuiBeamFrequencySelector(beam_info_box, "BEAM_FREQUENCY_SELECTOR"))->setPosition(120, 0, sp::Alignment::TopLeft)->setSize(120, 50);
(new GuiPowerDamageIndicator(beam_info_box, "", SYS_BeamWeapons, sp::Alignment::CenterLeft))->setPosition(0, 0, sp::Alignment::BottomLeft)->setSize(240, 50);
if (my_spaceship->hasSystem(SYS_BeamWeapons))
{
GuiElement* beam_info_box = new GuiElement(this, "BEAM_INFO_BOX");
beam_info_box->setPosition(20, 410, sp::Alignment::TopLeft)->setSize(240, 50);
(new GuiLabel(beam_info_box, "BEAM_INFO_LABEL", tr("Beams"), 30))->addBackground()->setPosition(20, 0, sp::Alignment::TopLeft)->setSize(80, 50);
(new GuiBeamFrequencySelector(beam_info_box, "BEAM_FREQUENCY_SELECTOR"))->setPosition(120, 0, sp::Alignment::TopLeft)->setSize(120, 50);
(new GuiPowerDamageIndicator(beam_info_box, "", SYS_BeamWeapons, sp::Alignment::CenterLeft))->setPosition(0, 0, sp::Alignment::BottomLeft)->setSize(240, 50);
}
}else{
(new GuiShieldsEnableButton(this, "SHIELDS_ENABLE"))->setPosition(20, 310, sp::Alignment::TopLeft)->setSize(240, 50);
}
Expand Down

0 comments on commit a0d434d

Please sign in to comment.