|
32 | 32 | import mekhq.campaign.force.CombatTeam; |
33 | 33 | import mekhq.campaign.force.Force; |
34 | 34 | import mekhq.campaign.icons.enums.OperationalStatus; |
| 35 | +import mekhq.campaign.personnel.Person; |
| 36 | +import mekhq.campaign.unit.Unit; |
| 37 | + |
| 38 | +import javax.swing.*; |
| 39 | +import java.awt.*; |
| 40 | +import java.util.UUID; |
35 | 41 |
|
36 | 42 | import static mekhq.campaign.icons.enums.OperationalStatus.NOT_OPERATIONAL; |
| 43 | +import static mekhq.utilities.MHQInternationalization.getFormattedTextAt; |
37 | 44 | import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG; |
38 | 45 | import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor; |
39 | 46 |
|
|
49 | 56 | * @author NickAragua |
50 | 57 | */ |
51 | 58 | public class ScenarioWizardLanceRenderer extends JLabel implements ListCellRenderer<Force> { |
| 59 | + final private String RESOURCE_BUNDLE = "mekhq.resources." + getClass().getSimpleName(); |
| 60 | + |
52 | 61 | private final Campaign campaign; |
53 | 62 |
|
54 | 63 | public ScenarioWizardLanceRenderer(Campaign campaign) { |
@@ -96,10 +105,29 @@ public Component getListCellRendererComponent(final JList<? extends Force> list, |
96 | 105 | String originNodeName = ", " + campaign.getForce(0).getName(); |
97 | 106 | forceName = forceName.replaceAll(originNodeName, ""); |
98 | 107 |
|
| 108 | + String fatigueReport = ""; |
| 109 | + if (campaign.getCampaignOptions().isUseFatigue()) { |
| 110 | + int highestFatigue = 0; |
| 111 | + for (UUID unitId : force.getAllUnits(false)) { |
| 112 | + Unit unit = campaign.getUnit(unitId); |
| 113 | + |
| 114 | + if (unit == null) { |
| 115 | + continue; |
| 116 | + } |
| 117 | + |
| 118 | + for (Person person : unit.getCrew()) { |
| 119 | + if (person.getFatigue() > highestFatigue) { |
| 120 | + highestFatigue = person.getEffectiveFatigue(campaign); |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + fatigueReport = getFormattedTextAt(RESOURCE_BUNDLE, "fatigueReport.string", highestFatigue); |
| 125 | + } |
| 126 | + |
99 | 127 | // Format string |
100 | | - setText(String.format("<html>%s<b>%s%s, %s</b> - BV %s<br> <i>%s</i></html>", |
101 | | - statusOpenFormat, force.getName(), statusCloseFormat, roleString, |
102 | | - force.getTotalBV(campaign, true), forceName)); |
| 128 | + setText(getFormattedTextAt(RESOURCE_BUNDLE, "report.string", statusOpenFormat, force.getName(), |
| 129 | + statusCloseFormat, roleString, force.getTotalBV(campaign, true), |
| 130 | + fatigueReport, forceName)); |
103 | 131 |
|
104 | 132 | return this; |
105 | 133 | } |
|
0 commit comments