Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Display for Original Unit to Person View Panel #4908

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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