From d7ad6b26ccc3dde967027b20b2072fe329ca5d12 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 29 Dec 2023 10:03:25 +0100 Subject: [PATCH] StatusBar: correct free slot displays --- megameklab/src/megameklab/ui/combatVehicle/CVStatusBar.java | 6 +++--- megameklab/src/megameklab/ui/generalUnit/StatusBar.java | 2 +- megameklab/src/megameklab/ui/mek/BMStatusBar.java | 2 +- megameklab/src/megameklab/ui/protoMek/PMStatusBar.java | 2 +- .../src/megameklab/ui/supportVehicle/SVStatusBar.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/megameklab/src/megameklab/ui/combatVehicle/CVStatusBar.java b/megameklab/src/megameklab/ui/combatVehicle/CVStatusBar.java index cc2b2b3fc..f475b1dab 100644 --- a/megameklab/src/megameklab/ui/combatVehicle/CVStatusBar.java +++ b/megameklab/src/megameklab/ui/combatVehicle/CVStatusBar.java @@ -53,8 +53,8 @@ public void refreshMovement() { public void refreshSlots() { Tank tank = getTank(); - int currentSlots = tank.getTotalSlots() - tank.getFreeSlots(); - slots.setText(String.format(SLOTS_LABEL, currentSlots, tank.getTotalSlots())); - slots.setForeground(currentSlots > tank.getTotalSlots() ? GUIPreferences.getInstance().getWarningColor() : null); + int freeSlots = tank.getFreeSlots(); + slots.setText(String.format(SLOTS_LABEL, freeSlots, tank.getTotalSlots())); + slots.setForeground((freeSlots < 0) ? GUIPreferences.getInstance().getWarningColor() : null); } } \ No newline at end of file diff --git a/megameklab/src/megameklab/ui/generalUnit/StatusBar.java b/megameklab/src/megameklab/ui/generalUnit/StatusBar.java index d00516f9b..6d08a87d3 100644 --- a/megameklab/src/megameklab/ui/generalUnit/StatusBar.java +++ b/megameklab/src/megameklab/ui/generalUnit/StatusBar.java @@ -65,7 +65,7 @@ public StatusBar(MegaMekLabMainUI parent) { invalid.setVisible(false); if (!getEntity().isConventionalInfantry()) { - JButton showEquipmentDatabase = new JButton("Show Equipment Database"); + JButton showEquipmentDatabase = new JButton("Equipment Database"); showEquipmentDatabase.addActionListener(evt -> parent.getFloatingEquipmentDatabase().setVisible(true)); add(showEquipmentDatabase); } diff --git a/megameklab/src/megameklab/ui/mek/BMStatusBar.java b/megameklab/src/megameklab/ui/mek/BMStatusBar.java index 10f2acf64..f7524e533 100644 --- a/megameklab/src/megameklab/ui/mek/BMStatusBar.java +++ b/megameklab/src/megameklab/ui/mek/BMStatusBar.java @@ -44,7 +44,7 @@ protected void additionalRefresh() { public void refreshSlots() { int maxCrits = getTestEntity().totalCritSlotCount(); int currentSlots = UnitUtil.countUsedCriticals(getMech()); - slots.setText(String.format(SLOTS_LABEL, currentSlots, maxCrits)); + slots.setText(String.format(SLOTS_LABEL, maxCrits - currentSlots, maxCrits)); slots.setForeground(currentSlots > maxCrits ? GUIPreferences.getInstance().getWarningColor() : null); } diff --git a/megameklab/src/megameklab/ui/protoMek/PMStatusBar.java b/megameklab/src/megameklab/ui/protoMek/PMStatusBar.java index 14ab90f24..527ffba7f 100644 --- a/megameklab/src/megameklab/ui/protoMek/PMStatusBar.java +++ b/megameklab/src/megameklab/ui/protoMek/PMStatusBar.java @@ -48,7 +48,7 @@ public void refreshSlots() { long currentSlots = getProtomech().getEquipment().stream() .filter(m -> TestProtomech.requiresSlot(m.getType())).count(); - slots.setText(String.format(SLOTS_LABEL, currentSlots, maxCrits)); + slots.setText(String.format(SLOTS_LABEL, maxCrits - currentSlots, maxCrits)); slots.setForeground(currentSlots > maxCrits ? GUIPreferences.getInstance().getWarningColor() : null); } } \ No newline at end of file diff --git a/megameklab/src/megameklab/ui/supportVehicle/SVStatusBar.java b/megameklab/src/megameklab/ui/supportVehicle/SVStatusBar.java index 9548dd678..1767418d5 100644 --- a/megameklab/src/megameklab/ui/supportVehicle/SVStatusBar.java +++ b/megameklab/src/megameklab/ui/supportVehicle/SVStatusBar.java @@ -58,7 +58,7 @@ public void refreshSlots() { TestSupportVehicle testEntity = (TestSupportVehicle) getTestEntity(); final int totalSlots = testEntity.totalSlotCount(); final int currentSlots = testEntity.occupiedSlotCount(); - slots.setText(String.format(SLOTS_LABEL, currentSlots, totalSlots)); + slots.setText(String.format(SLOTS_LABEL, totalSlots - currentSlots, totalSlots)); slots.setForeground(currentSlots > totalSlots ? GUIPreferences.getInstance().getWarningColor() : null); } } \ No newline at end of file