Skip to content

Commit

Permalink
ForceRenderer - bold unit commanders
Browse files Browse the repository at this point in the history
  • Loading branch information
WeaverThree committed Oct 20, 2024
1 parent f4ebf81 commit edc7f11
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions MekHQ/src/mekhq/gui/ForceRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,29 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
}
String c3network = "";
StringBuilder transport = new StringBuilder();
Unit u = (Unit) value;
Person person = u.getCommander();
Unit unit = (Unit) value;
Person person = unit.getCommander();
if (person != null) {
name = person.getFullTitle();
name += " (" + u.getEntity().getCrew().getGunnery() + '/'
+ u.getEntity().getCrew().getPiloting() + ')';
if (person.needsFixing() || (u.getEntity().getCrew().getHits() > 0)) {
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>";
}
}
String uname = "<i>" + u.getName() + "</i>";
if (u.isDamaged()) {
String uname = "<i>" + unit.getName() + "</i>";
if (unit.isDamaged()) {
uname = "<font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>" + uname
+ "</font>";
}

Entity entity = u.getEntity();
Entity entity = unit.getEntity();
if (entity.hasNavalC3()) {
if (entity.calculateFreeC3Nodes() >= 5) {
c3network += Messages.getString("ChatLounge.NC3None");
} else {
c3network += Messages
.getString("ChatLounge.NC3Network")
+ entity.getC3NetId();
c3network += Messages.getString("ChatLounge.NC3Network") + entity.getC3NetId();
if (entity.calculateFreeC3Nodes() > 0) {
c3network += Messages.getString("ChatLounge.NC3Nodes",
entity.calculateFreeC3Nodes());
Expand All @@ -91,8 +89,7 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
if (entity.calculateFreeC3Nodes() >= 5) {
c3network += Messages.getString("ChatLounge.C3iNone");
} else {
c3network += Messages.getString("ChatLounge.C3iNetwork")
+ entity.getC3NetId();
c3network += Messages.getString("ChatLounge.C3iNetwork") + entity.getC3NetId();
if (entity.calculateFreeC3Nodes() > 0) {
c3network += Messages.getString("ChatLounge.C3iNodes",
entity.calculateFreeC3Nodes());
Expand All @@ -101,16 +98,14 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
} else if (entity.hasC3()) {
if (entity.C3MasterIs(entity)) {
c3network += Messages.getString("ChatLounge.C3Master");
c3network += Messages.getString("ChatLounge.C3MNodes",
entity.calculateFreeC3MNodes());
c3network += Messages.getString("ChatLounge.C3MNodes", entity.calculateFreeC3MNodes());
if (entity.hasC3MM()) {
c3network += Messages.getString("ChatLounge.C3SNodes",
entity.calculateFreeC3Nodes());
}
} else if (!entity.hasC3S()) {
c3network += Messages.getString("ChatLounge.C3Master");
c3network += Messages.getString("ChatLounge.C3SNodes",
entity.calculateFreeC3Nodes());
c3network += Messages.getString("ChatLounge.C3SNodes", entity.calculateFreeC3Nodes());
// an independent master might also be a slave to a company master
if (entity.getC3Master() != null) {
c3network += "<br>" + Messages.getString("ChatLounge.C3Slave")
Expand All @@ -128,22 +123,27 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
c3network = "<br><i>" + c3network + "</i>";
}

if (u.hasTransportShipAssignment()) {
if (unit.hasTransportShipAssignment()) {
transport.append("<br>Transported by: ")
.append(u.getTransportShipAssignment().getTransportShip().getName());
.append(unit.getTransportShipAssignment().getTransportShip().getName());
}
String text = name + ", " + uname + c3network + transport;

Force force = unit.getCampaign().getForce(unit.getForceId());
if((null != person) && (null != force) && (person.getId() == force.getForceCommanderID())) {
text = "<b>" + text + "</b>";
}
setText("<html>" + text + "</html>");
getAccessibleContext().setAccessibleName((u.isDeployed() ? "Deployed Unit: " : "Unit: ") + text);
if (!sel && u.isDeployed()) {
getAccessibleContext().setAccessibleName((unit.isDeployed() ? "Deployed Unit: " : "Unit: ") + text);
if (!sel && unit.isDeployed()) {
setForeground(MekHQ.getMHQOptions().getDeployedForeground());
setBackground(MekHQ.getMHQOptions().getDeployedBackground());
setOpaque(true);
}
} else if (value instanceof Force) {
Force force = (Force) value;
getAccessibleContext()
.setAccessibleName((force.isDeployed() ? "Deployed Force: " : "Force: ") + force.getFullName());
getAccessibleContext().setAccessibleName((
force.isDeployed() ? "Deployed Force: " : "Force: ") + force.getFullName());
if (!sel && force.isDeployed()) {
setForeground(MekHQ.getMHQOptions().getDeployedForeground());
setBackground(MekHQ.getMHQOptions().getDeployedBackground());
Expand Down

0 comments on commit edc7f11

Please sign in to comment.