Skip to content

Commit

Permalink
Merge pull request #4908 from IllianiCBT/personView_unitOwnership
Browse files Browse the repository at this point in the history
Added Display for Original Unit to Person View Panel
  • Loading branch information
HammerGS authored Sep 26, 2024
2 parents 606516b + bb84f32 commit 92a4121
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions MekHQ/resources/mekhq/resources/PersonViewPanel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lblAge1.text=<html><nobr><b>Age:</b></nobr></html>;
lblGender1.text=<html><nobr><b>Gender:</b></nobr></html>;
lblStatus1.text=<html><nobr><b>Status:</b></nobr></html>;
lblOrigin1.text=<html><nobr><b>Origin:</b></nobr></html>;
lblOriginalUnit1.text=<html><nobr><b>Original Unit:</b></nobr></html>;
lblDueDate1.text=<html><nobr><b>Due Date:</b></nobr></html>;
lblRetirement1.text=<html><nobr><b>Retired:</b></nobr></html>;
lblTotalEarnings1.text=<html><nobr><b>Total Earnings:</b></nobr></html>;
Expand Down
42 changes: 42 additions & 0 deletions MekHQ/src/mekhq/gui/view/PersonViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.util.stream.Collectors;

import static megamek.client.ui.WrapLayout.wordWrap;
import static megamek.common.EntityWeightClass.WEIGHT_ULTRA_LIGHT;
import static mekhq.campaign.personnel.Person.getLoyaltyName;

/**
Expand Down Expand Up @@ -574,6 +575,8 @@ private JPanel fillInfo() {
JLabel lblAge2 = new JLabel();
JLabel lblGender1 = new JLabel();
JLabel lblGender2 = new JLabel();
JLabel lblOriginalUnit1 = new JLabel();
JLabel lblOriginalUnit2 = new JLabel();
JLabel lblDueDate1 = new JLabel();
JLabel lblDueDate2 = new JLabel();
JLabel lblRecruited1 = new JLabel();
Expand Down Expand Up @@ -736,6 +739,45 @@ public void mouseClicked(MouseEvent e) {
pnlInfo.add(lblGender2, gridBagConstraints);
y++;

boolean displayOriginalUnit = person.getOriginalUnitId() != null
|| person.getOriginalUnitWeight() != WEIGHT_ULTRA_LIGHT;

if (displayOriginalUnit) {
lblOriginalUnit1.setName("lblOriginalUnit1");
lblOriginalUnit1.setText(resourceMap.getString("lblOriginalUnit1.text"));
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = y;
gridBagConstraints.fill = GridBagConstraints.NONE;
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
pnlInfo.add(lblOriginalUnit1, gridBagConstraints);

lblOriginalUnit2.setName("lblOriginalUnit2");

if (campaign.getUnit(person.getOriginalUnitId()) != null) {
lblOriginalUnit2.setText(campaign.getUnit(person.getOriginalUnitId()).getName());
} else {
List<String> originalUnitWeight = List.of("None", "Light", "Medium", "Heavy", "Assault");
int originalUnitWeightIndex = person.getOriginalUnitWeight();

List<String> originalUnitTech = List.of("IS1", "IS2", "Clan");
int originalUnitTechIndex = person.getOriginalUnitTech();

lblOriginalUnit2.setText(originalUnitWeight.get(originalUnitWeightIndex)
+ " (" + originalUnitTech.get(originalUnitTechIndex) + ')');
}
lblOriginalUnit1.setLabelFor(lblOriginalUnit2);
gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = y;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new Insets(0, 10, 0, 0);
gridBagConstraints.fill = GridBagConstraints.NONE;
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
pnlInfo.add(lblOriginalUnit2, gridBagConstraints);
y++;
}

if (person.isPregnant()) {
lblDueDate1.setName("lblDueDate1");
lblDueDate1.setText(resourceMap.getString("lblDueDate1.text"));
Expand Down

0 comments on commit 92a4121

Please sign in to comment.