Skip to content

Commit

Permalink
Show refitting techs and fix refit countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
WeaverThree committed Nov 8, 2024
1 parent 3725917 commit 907de4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion MekHQ/src/mekhq/campaign/personnel/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -3777,7 +3777,9 @@ public int getDailyAvailableTechTime() {
}

public int getMaintenanceTimeUsing() {
return getTechUnits().stream().mapToInt(Unit::getMaintenanceTime).sum();
return getTechUnits().stream()
.filter(unit -> !(unit.isRefitting() && unit.getRefit().getTech() == this))
.mapToInt(Unit::getMaintenanceTime).sum();
}

public boolean isMothballing() {
Expand Down
13 changes: 11 additions & 2 deletions MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import mekhq.campaign.unit.Unit;
import mekhq.campaign.universe.Planet;
import mekhq.gui.sorter.*;
import mekhq.utilities.ReportingUtilities;

import javax.swing.*;
import java.util.Comparator;
Expand Down Expand Up @@ -526,13 +527,21 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person

// Check for tech units
if (!person.getTechUnits().isEmpty()) {
Unit refitUnit = person.getTechUnits().stream()
.filter(u -> u.isRefitting() && u.getRefit().getTech() == person)
.findFirst().orElse(null);
String refitString = null != refitUnit ?
"<b>Refitting</b> " + refitUnit.getName() : "";
if (person.getTechUnits().size() == 1) {
unit = person.getTechUnits().get(0);
if (unit != null) {
return unit.getName() + " (" + person.getMaintenanceTimeUsing() + "m)";
return "<html>" + ReportingUtilities.separateIf(refitString, ", ",
unit.getName() + " (" + person.getMaintenanceTimeUsing() + "m)") + "</html>";
}
} else {
return person.getTechUnits().size() + " units (" + person.getMaintenanceTimeUsing() + "m)";
return "<html>" + ReportingUtilities.separateIf(refitString, ", ",
person.getTechUnits().size() + " units (" + person.getMaintenanceTimeUsing() + "m)")
+ "</html>";
}
}
}
Expand Down

0 comments on commit 907de4f

Please sign in to comment.