Skip to content

Commit

Permalink
ForceRenderer - Add some ReportingUtilities
Browse files Browse the repository at this point in the history
  • Loading branch information
WeaverThree committed Oct 21, 2024
1 parent edc7f11 commit 43d1e34
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions MekHQ/src/mekhq/gui/ForceRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import mekhq.campaign.force.Force;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.unit.Unit;
import mekhq.utilities.ReportingUtilities;

public class ForceRenderer extends DefaultTreeCellRenderer {
private static final MMLogger logger = MMLogger.create(ForceRenderer.class);
Expand All @@ -51,7 +52,8 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
setOpaque(false);

if (value instanceof Unit) {
String name = "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>No Crew</font>";
String name = ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorNegativeHexColor(), "No Crew");
if (((Unit) value).getEntity() instanceof GunEmplacement) {
name = "AutoTurret";
}
Expand All @@ -64,14 +66,14 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
name += " (" + unit.getEntity().getCrew().getGunnery() + '/'
+ unit.getEntity().getCrew().getPiloting() + ')';
if (person.needsFixing() || (unit.getEntity().getCrew().getHits() > 0)) {
name = "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>" + name
+ "</font>";
name = ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorNegativeHexColor(), name);
}
}
String uname = "<i>" + unit.getName() + "</i>";
String unitName = "<i>" + unit.getName() + "</i>";
if (unit.isDamaged()) {
uname = "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>" + uname
+ "</font>";
unitName = ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorNegativeHexColor(), unitName);
}

Entity entity = unit.getEntity();
Expand Down Expand Up @@ -127,7 +129,7 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
transport.append("<br>Transported by: ")
.append(unit.getTransportShipAssignment().getTransportShip().getName());
}
String text = name + ", " + uname + c3network + transport;
String text = name + ", " + unitName + c3network + transport;

Force force = unit.getCampaign().getForce(unit.getForceId());
if((null != person) && (null != force) && (person.getId() == force.getForceCommanderID())) {
Expand Down

0 comments on commit 43d1e34

Please sign in to comment.