fix mech energy display for 0 (#27828)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-05-09 05:55:15 +00:00
committed by GitHub
parent 4c68fce064
commit 1f67733775
2 changed files with 12 additions and 3 deletions

View File

@@ -35,9 +35,17 @@ public sealed partial class MechMenu : FancyWindow
IntegrityDisplayBar.Value = integrityPercent.Float();
IntegrityDisplay.Text = Loc.GetString("mech-integrity-display", ("amount", (integrityPercent*100).Int()));
if (mechComp.MaxEnergy != 0f)
{
var energyPercent = mechComp.Energy / mechComp.MaxEnergy;
EnergyDisplayBar.Value = energyPercent.Float();
EnergyDisplay.Text = Loc.GetString("mech-energy-display", ("amount", (energyPercent*100).Int()));
}
else
{
EnergyDisplayBar.Value = 0f;
EnergyDisplay.Text = Loc.GetString("mech-energy-missing");
}
SlotDisplay.Text = Loc.GetString("mech-slot-display",
("amount", mechComp.MaxEquipmentAmount - mechComp.EquipmentContainer.ContainedEntities.Count));

View File

@@ -13,6 +13,7 @@ mech-menu-title = mech control panel
mech-integrity-display = Integrity: {$amount}%
mech-energy-display = Energy: {$amount}%
mech-energy-missing = Energy: MISSING
mech-slot-display = Open Slots: {$amount}
mech-no-enter = You cannot pilot this.