Skip to content

Commit

Permalink
Merge pull request #4366 from IllianiCBT/education_manualDropOut
Browse files Browse the repository at this point in the history
Added Ability to Manually Drop Personnel out of Active Education
  • Loading branch information
IllianiCBT authored Jul 12, 2024
2 parents 7b56bb9 + ff40b24 commit 6015d82
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
4 changes: 3 additions & 1 deletion MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ eduUnqualified.text=---<i>Education Level %s+ Required</i></html>
eduFactionConflict.text=---<i>Refusing applications from personnel or campaign faction</i></html>
eduRangeConflict.text=---<i>Beyond Maximum Jump Distance</i></html>
eduNoQualificationsOffered.text=<html><i>This qualification is not currently offered.</i></html>
eduDropOut.text=Drop Out
eduDropOut.toolTip=Instantly drop personnel out of their current education. If personnel are traveling they will automatically arrive and return to active duty.
eduCompleteStage.text=Complete Education Stage
eduCompleteStage.toolTip=Instantly complete the current stage of education (journey to, education, or journey from)
eduCompleteStage.toolTip=Instantly complete the current stage of education (journey to, education, graduation/drop out, or journey from)

### Flags Menu
specialFlagsMenu.text=Flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,23 @@ private static boolean checkForDropout(Campaign campaign, Academy academy, Perso
return false;
}

/**
* This method processes a forced drop out for a person.
*
* @param campaign the campaign to add the drop out report to
* @param person the person who is forced to drop out
* @param academy the academy where the person was studying
*/
public static void processForcedDropOut(Campaign campaign, Person person, Academy academy) {
ResourceBundle resources = ResourceBundle.getBundle("mekhq.resources.Education", MekHQ.getMHQOptions().getLocale());

campaign.addReport(person.getHyperlinkedName() + ' ' + resources.getString("dropOut.text"));
ServiceLogger.eduFailed(person, campaign.getLocalDate(), person.getEduAcademyName(), academy.getQualifications().get(person.getEduCourseIndex()));
person.setEduEducationStage(EducationStage.DROPPING_OUT);

addFacultyXp(campaign, person, academy, 0);
}

/**
* Checks for a conflict between the academy faction and the person's faction
*
Expand Down
33 changes: 29 additions & 4 deletions MekHQ/src/mekhq/gui/adapter/PersonnelTableMouseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class PersonnelTableMouseAdapter extends JPopupMenuAdapter {
private static final String CMD_RMV_AWARD = "RMV_AWARD";
private static final String CMD_BEGIN_EDUCATION = "BEGIN_EDUCATION";
private static final String CMD_COMPLETE_STAGE = "COMPLETE_STAGE";
private static final String CMD_DROP_OUT = "DROP_OUT";

private static final String CMD_EDIT_SALARY = "SALARY";
private static final String CMD_GIVE_PAYMENT = "GIVE_PAYMENT";
Expand Down Expand Up @@ -420,6 +421,25 @@ public void actionPerformed(ActionEvent action) {
}
break;
}
case CMD_DROP_OUT: {
for (Person person : people) {
Academy academy = getAcademy(person.getEduAcademySet(), person.getEduAcademyNameInSet());

EducationStage educationStage = person.getEduEducationStage();

switch (educationStage) {
case JOURNEY_TO_CAMPUS, JOURNEY_FROM_CAMPUS
-> person.changeStatus(gui.getCampaign(), gui.getCampaign().getLocalDate(), PersonnelStatus.ACTIVE);
case EDUCATION
-> EducationController.processForcedDropOut(gui.getCampaign(), person, academy);
default -> {}
}

MekHQ.triggerEvent(new PersonStatusChangedEvent(person));
}

break;
}
case CMD_IMPROVE: {
String type = data[1];
int cost = Integer.parseInt(data[2]);
Expand Down Expand Up @@ -1337,7 +1357,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
gui.getCampaign(), gui.getCampaign().getLocalDate(), person,
potentialSpouse, false))
.sorted(Comparator.comparing((Person p) -> p.getAge(today))
.thenComparing(Person::getSurname)).collect(Collectors.toList());
.thenComparing(Person::getSurname)).toList();

for (final Person potentialSpouse : personnel) {
final String status;
Expand Down Expand Up @@ -1419,9 +1439,6 @@ protected Optional<JPopupMenu> createPopupMenu() {
if ("group".equalsIgnoreCase(award.getItem())) {
awardGroups.add(award.getName());
awardGroupDescriptions.add(award.getDescription());
} else if ("group".equalsIgnoreCase(award.getItem())) {
awardGroups.add(award.getName());
awardGroupDescriptions.add(award.getDescription());
}
}

Expand Down Expand Up @@ -1562,6 +1579,14 @@ protected Optional<JPopupMenu> createPopupMenu() {
}
}

if (StaticChecks.areAllStudents(selected)) {
JMenuItem completeStage = new JMenuItem(resources.getString("eduDropOut.text"));
completeStage.setToolTipText(resources.getString("eduDropOut.toolTip"));
completeStage.setActionCommand(makeCommand(CMD_DROP_OUT));
completeStage.addActionListener(this);
academyMenu.add(completeStage);
}

if ((StaticChecks.areAllStudents(selected)) && (campaign.isGM())) {
JMenuItem completeStage = new JMenuItem(resources.getString("eduCompleteStage.text"));
completeStage.setToolTipText(resources.getString("eduCompleteStage.toolTip"));
Expand Down

0 comments on commit 6015d82

Please sign in to comment.