Skip to content

Commit

Permalink
Merge pull request #5017 from WeaverThree/wvr-advmed-injuries-ui
Browse files Browse the repository at this point in the history
Display Advanced Medical Injuries in UI
  • Loading branch information
IllianiCBT authored Oct 11, 2024
2 parents 8a09d8f + fb4b93d commit bfff557
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 8 deletions.
6 changes: 5 additions & 1 deletion MekHQ/src/mekhq/gui/enums/PersonnelTableModelColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,11 @@ public String getCellValue(final Campaign campaign, final PersonnelMarket person
? Integer.toString(person.getSkill(SkillType.S_SCROUNGE).getFinalSkillValue())
: "-";
case INJURIES:
return Integer.toString(person.getHits());
if (campaign.getCampaignOptions().isUseAdvancedMedical()) {
return Integer.toString(person.getInjuries().size());
} else {
return Integer.toString(person.getHits());
}
case KILLS:
return Integer.toString(campaign.getKillsFor(person.getId()).size());
case SALARY:
Expand Down
76 changes: 69 additions & 7 deletions MekHQ/src/mekhq/gui/view/ForceViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import mekhq.campaign.unit.Unit;
import mekhq.gui.baseComponents.JScrollablePanel;
import mekhq.gui.utilities.MarkdownRenderer;
import mekhq.utilities.ReportingUtilities;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -458,14 +459,75 @@ private void fillSubUnits() {
}

public String getForceSummary(Person person, Unit unit) {
String toReturn = "<html><font><b>" + person.getFullTitle() + "</b><br/>";
toReturn += person.getSkillLevel(campaign, false) + " " + person.getRoleDesc();
if (null != unit && null != unit.getEntity()
&& null != unit.getEntity().getCrew() && unit.getEntity().getCrew().getHits() > 0) {
toReturn += "<br><font color='" + MekHQ.getMHQOptions().getFontColorNegativeHexColor() + "'>" + unit.getEntity().getCrew().getHits() + " hit(s)";
if(null == person) {
return "";
}
toReturn += "</font></html>";
return toReturn;

StringBuilder toReturn = new StringBuilder();
toReturn.append("<html><nobr><font size='3'><b>")
.append(person.getFullTitle())
.append("</b><br/>")
.append(person.getSkillLevel(campaign, false))
.append(' ')
.append(person.getRoleDesc());

toReturn.append("<br>");

boolean isInjured = false;
boolean isFatigued = false;

if (campaign.getCampaignOptions().isUseAdvancedMedical()) {
if (person.hasInjuries(true)) {
isInjured = true;
int injuryCount = person.getInjuries().size();

StringBuilder injuriesMessage = new StringBuilder(16);
injuriesMessage.append(' ')
.append(injuryCount)
.append(injuryCount == 1 ? " injury" : " injuries");

toReturn.append(ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorNegativeHexColor(), injuriesMessage.toString()));
}

} else {
if (null != unit && null != unit.getEntity() && null != unit.getEntity().getCrew()
&& unit.getEntity().getCrew().getHits() > 0) {
isInjured = true;
int hitCount = unit.getEntity().getCrew().getHits();

StringBuilder hitsMessage = new StringBuilder(16);
hitsMessage.append(' ')
.append(hitCount)
.append(hitCount == 1 ? " hit" : " hits");

toReturn.append(ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorNegativeHexColor(), hitsMessage.toString()));
}
}

if (campaign.getCampaignOptions().isUseFatigue() && (person.getEffectiveFatigue(campaign) > 0)) {
isFatigued = true;
if (isInjured) {
toReturn.append(',');
}
toReturn.append(' ');

StringBuilder fatigueMessage = new StringBuilder(16);

fatigueMessage.append(person.getEffectiveFatigue(campaign));
fatigueMessage.append(" fatigue");

toReturn.append(ReportingUtilities.messageSurroundedBySpanWithColor(
MekHQ.getMHQOptions().getFontColorWarningHexColor(), fatigueMessage.toString()));
}

if (!(isInjured || isFatigued)) {
toReturn.append("&nbsp;");
}

toReturn.append("</font></nobr></html>");
return toReturn.toString();
}

public String getForceSummary(Unit unit) {
Expand Down

0 comments on commit bfff557

Please sign in to comment.