Skip to content

Commit

Permalink
Merge pull request #4884 from IllianiCBT/personnel_massEdit
Browse files Browse the repository at this point in the history
Refactored GM Person Editing to Handle Multiple Selections
  • Loading branch information
HammerGS authored Sep 25, 2024
2 parents 1341ebe + cc1f3b2 commit ab432b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 47 deletions.
2 changes: 1 addition & 1 deletion MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ add1XP.text=Add 1 XP
addXP.text=Add XP
setXP.text=Set XP
setEdge.text=Set Edge
edit.text=Edit
editPerson.text=Edit Person
loadGMTools.text=Load GM Tools
removeAllInjuries.text=Remove All Injuries
removeInjury.format=Remove Injury: %s
Expand Down
73 changes: 27 additions & 46 deletions MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,6 @@
*/
package mekhq.gui.adapter;

import static megamek.client.ui.WrapLayout.wordWrap;
import static mekhq.campaign.personnel.education.Academy.skillParser;
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
import static mekhq.campaign.personnel.education.EducationController.makeEnrollmentCheck;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JSplitPane;
import javax.swing.JTable;

import megamek.client.generator.RandomCallsignGenerator;
import megamek.client.generator.RandomNameGenerator;
import megamek.client.ui.dialogs.PortraitChooserDialog;
Expand All @@ -62,26 +41,12 @@
import mekhq.campaign.finances.enums.TransactionType;
import mekhq.campaign.log.LogEntry;
import mekhq.campaign.log.PersonalLogger;
import mekhq.campaign.personnel.Award;
import mekhq.campaign.personnel.AwardsFactory;
import mekhq.campaign.personnel.Injury;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.PersonnelOptions;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.SpecialAbility;
import mekhq.campaign.personnel.*;
import mekhq.campaign.personnel.autoAwards.AutoAwardsController;
import mekhq.campaign.personnel.education.Academy;
import mekhq.campaign.personnel.education.AcademyFactory;
import mekhq.campaign.personnel.education.EducationController;
import mekhq.campaign.personnel.enums.ManeiDominiClass;
import mekhq.campaign.personnel.enums.ManeiDominiRank;
import mekhq.campaign.personnel.enums.MergingSurnameStyle;
import mekhq.campaign.personnel.enums.PersonnelRole;
import mekhq.campaign.personnel.enums.PersonnelStatus;
import mekhq.campaign.personnel.enums.PrisonerStatus;
import mekhq.campaign.personnel.enums.Profession;
import mekhq.campaign.personnel.enums.ROMDesignation;
import mekhq.campaign.personnel.enums.SplittingSurnameStyle;
import mekhq.campaign.personnel.enums.*;
import mekhq.campaign.personnel.enums.education.EducationLevel;
import mekhq.campaign.personnel.enums.education.EducationStage;
import mekhq.campaign.personnel.generator.SingleSpecialAbilityGenerator;
Expand All @@ -104,6 +69,21 @@
import mekhq.gui.utilities.MultiLineTooltip;
import mekhq.gui.utilities.StaticChecks;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.time.LocalDate;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static megamek.client.ui.WrapLayout.wordWrap;
import static mekhq.campaign.personnel.education.Academy.skillParser;
import static mekhq.campaign.personnel.education.EducationController.getAcademy;
import static mekhq.campaign.personnel.education.EducationController.makeEnrollmentCheck;

public class PersonnelTableMouseAdapter extends JPopupMenuAdapter {
private static final MMLogger logger = MMLogger.create(PersonnelTableMouseAdapter.class);

Expand Down Expand Up @@ -845,10 +825,12 @@ public void actionPerformed(ActionEvent action) {
break;
}
case CMD_EDIT: {
CustomizePersonDialog npd = new CustomizePersonDialog(
gui.getFrame(), true, selectedPerson, gui.getCampaign());
npd.setVisible(true);
gui.getCampaign().personUpdated(selectedPerson);
for (Person person : people) {
CustomizePersonDialog npd = new CustomizePersonDialog(gui.getFrame(), true,
person, gui.getCampaign());
npd.setVisible(true);
gui.getCampaign().personUpdated(selectedPerson);
}
break;
}
case CMD_EDIT_HITS: {
Expand Down Expand Up @@ -2916,13 +2898,12 @@ protected Optional<JPopupMenu> createPopupMenu() {
menuItem.addActionListener(this);
menu.add(menuItem);
}
menuItem = new JMenuItem(resources.getString("editPerson.text"));
menuItem.setActionCommand(CMD_EDIT);
menuItem.addActionListener(this);
menu.add(menuItem);

if (oneSelected) {
menuItem = new JMenuItem(resources.getString("edit.text"));
menuItem.setActionCommand(CMD_EDIT);
menuItem.addActionListener(this);
menu.add(menuItem);

menuItem = new JMenuItem(resources.getString("loadGMTools.text"));
menuItem.addActionListener(evt -> loadGMToolsForPerson(person));
menu.add(menuItem);
Expand Down

0 comments on commit ab432b9

Please sign in to comment.