Skip to content

Commit

Permalink
Merge pull request #3771 from nutritiousemployee/master
Browse files Browse the repository at this point in the history
Childrens filter in personnel screen
  • Loading branch information
NickAragua authored Oct 25, 2023
2 parents 899db66 + df54613 commit 2541a6b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ PersonnelFilter.ADMINISTRATOR_TRANSPORT.text=Administrators (Transport)
PersonnelFilter.ADMINISTRATOR_TRANSPORT.toolTipText=Display transport-focused administrators
PersonnelFilter.ADMINISTRATOR_HR.text=Administrators (HR)
PersonnelFilter.ADMINISTRATOR_HR.toolTipText=Display human resources-focused administrators
PersonnelFilter.KIDS.text=Children
PersonnelFilter.KIDS.toolTipText=Display all personnel under 13.
PersonnelFilter.DEPENDENT.text=Dependents
PersonnelFilter.DEPENDENT.toolTipText=Display active personnel with the Dependent primary role.
PersonnelFilter.FOUNDER.text=Founders
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/PersonnelTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public void filterPersonnel() {
personnelSorter.setRowFilter(new RowFilter<>() {
@Override
public boolean include(Entry<? extends PersonnelTableModel, ? extends Integer> entry) {
return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()));
return filter.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), getCampaignGui().getCampaign().getLocalDate());
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/PersonnelMarketDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private void filterPersonnel() {
sorter.setRowFilter(new RowFilter<>() {
@Override
public boolean include(Entry<? extends PersonnelTableModel, ? extends Integer> entry) {
return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()));
return nGroup.getFilteredInformation(entry.getModel().getPerson(entry.getIdentifier()), hqView.getCampaign().getLocalDate());
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/gui/dialog/RetirementDefectionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public boolean include(Entry<? extends RetirementTableModel, ? extends Integer>
&& !rdTracker.getRetirees(contract).contains(person.getId())) {
return false;
} else {
return nGroup.getFilteredInformation(person);
return nGroup.getFilteredInformation(person, hqView.getCampaign().getLocalDate());
}
}
});
Expand Down
8 changes: 6 additions & 2 deletions MekHQ/src/mekhq/gui/enums/PersonnelFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.enums.PersonnelRole;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -62,7 +63,7 @@ public enum PersonnelFilter {
ASTECH("PersonnelFilter.ASTECH.text", "PersonnelFilter.ASTECH.toolTipText", false, true),
MEDICAL("PersonnelFilter.MEDICAL.text", "PersonnelFilter.MEDICAL.toolTipText", true, false),
DOCTOR("PersonnelFilter.DOCTOR.text", "PersonnelFilter.DOCTOR.toolTipText", false, true),
MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true),
MEDIC("PersonnelFilter.MEDIC.text", "PersonnelFilter.MEDIC.toolTipText", false, true),
ADMINISTRATOR("PersonnelFilter.ADMINISTRATOR.text", "PersonnelFilter.ADMINISTRATOR.toolTipText", true, false),
ADMINISTRATOR_COMMAND("PersonnelFilter.ADMINISTRATOR_COMMAND.text", "PersonnelFilter.ADMINISTRATOR_COMMAND.toolTipText", false, true),
ADMINISTRATOR_LOGISTICS("PersonnelFilter.ADMINISTRATOR_LOGISTICS.text", "PersonnelFilter.ADMINISTRATOR_LOGISTICS.toolTipText", false, true),
Expand All @@ -73,6 +74,7 @@ public enum PersonnelFilter {

//region Expanded Personnel Tab Filters
FOUNDER("PersonnelFilter.FOUNDER.text", "PersonnelFilter.FOUNDER.toolTipText", false, false),
KIDS("PersonnelFilter.KIDS.text", "PersonnelFilter.KIDS.toolTipText"),
PRISONER("PersonnelFilter.PRISONER.text", "PersonnelFilter.PRISONER.toolTipText", false, false),
INACTIVE("PersonnelFilter.INACTIVE.text", "PersonnelFilter.INACTIVE.toolTipText", false, false),
MIA("PersonnelFilter.MIA.text", "PersonnelFilter.MIA.toolTipText", false, false),
Expand Down Expand Up @@ -348,7 +350,7 @@ public static List<PersonnelFilter> getAllIndividualRoleFilters() {
return Arrays.asList(values());
}

public boolean getFilteredInformation(final Person person) {
public boolean getFilteredInformation(final Person person, LocalDate currentDate) {
final boolean active = person.getStatus().isActive() && !person.getPrisonerStatus().isCurrentPrisoner();
switch (this) {
case ALL:
Expand Down Expand Up @@ -468,6 +470,8 @@ public boolean getFilteredInformation(final Person person) {
return active && person.getPrimaryRole().isDependent();
case FOUNDER:
return person.isFounder();
case KIDS:
return person.isChild(currentDate);
case PRISONER:
return person.getPrisonerStatus().isCurrentPrisoner() || person.getPrisonerStatus().isBondsman();
case INACTIVE:
Expand Down

0 comments on commit 2541a6b

Please sign in to comment.