From eb77840501cf4bcf11cb3ca055f4f917d4a711cc Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 10 Jun 2024 00:21:18 -0500 Subject: [PATCH] refactor: Fixed conditions in CustomizePersonDialog.java - Removed unnecessary nested condition on choiceOriginalUnit selection - Set fatigue regardless of unit selection - Fixed setting of person's original unit properties and visibility status --- .../gui/dialog/CustomizePersonDialog.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java index daf0d57abc..07589a428d 100644 --- a/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/CustomizePersonDialog.java @@ -1031,24 +1031,22 @@ private void btnOkActionPerformed(ActionEvent evt) { person.setEduHighestEducation(MathUtility.clamp(Integer.parseInt(textEducationLevel.getText()), 0, 4)); } catch (NumberFormatException ignored) {} - if (null == choiceOriginalUnit.getSelectedItem()) { - try { - person.setFatigue(Integer.parseInt(textFatigue.getText())); - } catch (NumberFormatException ignored) {} - - if (choiceOriginalUnit.getSelectedItem() == null) { - person.setOriginalUnit(null); - person.setOriginalUnitWeight(choiceUnitWeight.getSelectedIndex()); - person.setOriginalUnitTech(choiceUnitTech.getSelectedIndex()); - } else { - person.setOriginalUnitId(((Unit) choiceOriginalUnit.getSelectedItem()).getId()); - } + try { + person.setFatigue(Integer.parseInt(textFatigue.getText())); + } catch (NumberFormatException ignored) {} - person.setFounder(chkFounder.isSelected()); - setSkills(); - setOptions(); - setVisible(false); + if (null == choiceOriginalUnit.getSelectedItem()) { + person.setOriginalUnit(null); + person.setOriginalUnitWeight(choiceUnitWeight.getSelectedIndex()); + person.setOriginalUnitTech(choiceUnitTech.getSelectedIndex()); + } else { + person.setOriginalUnit((Unit) choiceOriginalUnit.getSelectedItem()); } + + person.setFounder(chkFounder.isSelected()); + setSkills(); + setOptions(); + setVisible(false); } private void randomName() {