From bedb12b662d628bb65e8c393b8fa0b39b375d0a2 Mon Sep 17 00:00:00 2001 From: IllianiBird Date: Sun, 17 May 2026 14:41:57 -0500 Subject: [PATCH 1/3] Added Button to Access Quick Tech Assignment --- .../mekhq/resources/CampaignGUI.properties | 3 ++ .../resources/mekhq/resources/GUI.properties | 3 ++ .../ImmersiveDialogConfirmation.properties | 11 ++++++ MekHQ/src/mekhq/MHQConstants.java | 1 + MekHQ/src/mekhq/gui/HangarTab.java | 34 +++++++++++++++++++ .../mekhq/gui/dialog/MHQOptionsDialog.java | 18 ++++++++-- 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/CampaignGUI.properties b/MekHQ/resources/mekhq/resources/CampaignGUI.properties index 58c4a3e6e08..13fe2dae9c1 100644 --- a/MekHQ/resources/mekhq/resources/CampaignGUI.properties +++ b/MekHQ/resources/mekhq/resources/CampaignGUI.properties @@ -273,6 +273,9 @@ choiceUnit.MothballedUnits.filter=All Mothballed Units choiceUnit.UnmaintainedUnits.filter=All Unmaintained Units chkHideMothballed.text=Hide Mothballed chkHideMothballed.toolTipText=Hide mothballed units from the current view +btnAssignTechs.text=Quick Assign Maintenance Techs +btnAssignTechs.toolTipText=Assign maintenance techs to all unmaintained units, where possible. This is identical \ + to the system found in MekHQ Options that assignments techs on new day. lblUnitView.text=View: btnAddMission.toolTipText=Add a new mission. Missions are long-term assignments consisting of multiple scenarios. btnAddMission.text=Add Mission diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index a205d145deb..b36fcbbe644 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -940,6 +940,9 @@ optionStratConDeployConfirmation.toolTipText=This allows you to skip the confirm optionAbandonUnitsConfirmation.text=Hide Abandon Units Confirmation Dialog optionAbandonUnitsConfirmation.toolTipText=This allows you to skip the confirmation dialog which confirms whether \ you are happy abandoning non-jump capable units +optionAssignTechsConfirmation.text=Hide Quick Assign Techs Confirmation Dialog +optionAssignTechsConfirmation.toolTipText=This allows you to skip the confirmation dialog which confirms whether \ + you are happy assigning techs to unmaintained units ## Miscellaneous Tab miscellaneousTab.title=Miscellaneous Options lblUserDir.text=User Files Directory: diff --git a/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties b/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties index fc2d9784b33..5a931f98b00 100644 --- a/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties +++ b/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties @@ -47,3 +47,14 @@ ImmersiveDialogConfirmation.confirmationFactionStandingsUltimatum.text.primary=T select 'confirm,' the consequences of your decision cannot be reversed. ImmersiveDialogConfirmation.confirmationAbandonUnits.text.primary=If you select 'confirm,' all non-jump capable units\ \ will be permanently abandoned or sold (depending on the chosen option). This cannot be reversed. +ImmersiveDialogConfirmation.confirmationAssignTechs.text.primary=If you select 'confirm,' all unmaintained units will\ + \ be assigned a tech (where possible).\ +

Assignment follows the following rules:

\ +

- All unmaintained units are sorted so that the most valuable units are assigned techs first.\ +
- All techs are sorted so that the tech with the fewest assigned units first. Tech skill is used as a \ + tie-breaker.\ +
- Units that already have a tech assigned are ignored.

\ +

Did You Know?

\ + This process can be automated using the new day option found in MekHQ Options.\ +

If selected, periodically, techs will be assigned to units without tech assignments. This follows the rules \ + outlined above.

diff --git a/MekHQ/src/mekhq/MHQConstants.java b/MekHQ/src/mekhq/MHQConstants.java index 71ff93d9680..f84c2eeeabb 100644 --- a/MekHQ/src/mekhq/MHQConstants.java +++ b/MekHQ/src/mekhq/MHQConstants.java @@ -241,6 +241,7 @@ public final class MHQConstants extends SuiteConstants { public static final String CONFIRMATION_STRATCON_BATCHALL_BREACH = "confirmationStratConBatchallBreach"; public static final String CONFIRMATION_STRATCON_DEPLOY = "confirmationStratConDeploy"; public static final String CONFIRMATION_ABANDON_UNITS = "confirmationAbandonUnits"; + public static final String CONFIRMATION_ASSIGN_TECHS = "confirmationAssignTechs"; // endregion Nag Tab // region Miscellaneous Options diff --git a/MekHQ/src/mekhq/gui/HangarTab.java b/MekHQ/src/mekhq/gui/HangarTab.java index d62682af1d0..a626e35bdbf 100644 --- a/MekHQ/src/mekhq/gui/HangarTab.java +++ b/MekHQ/src/mekhq/gui/HangarTab.java @@ -74,7 +74,10 @@ import mekhq.campaign.events.units.UnitRemovedEvent; import mekhq.campaign.unit.Unit; import mekhq.campaign.unit.UnitOrder; +import mekhq.campaign.utilities.AutomatedTechAssignments; import mekhq.gui.adapter.UnitTableMouseAdapter; +import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogConfirmation; +import mekhq.gui.baseComponents.roundedComponents.RoundedJButton; import mekhq.gui.baseComponents.roundedComponents.RoundedLineBorder; import mekhq.gui.enums.MHQTabType; import mekhq.gui.model.UnitTableModel; @@ -86,6 +89,8 @@ import mekhq.gui.sorter.WeightClassSorter; import mekhq.gui.view.UnitViewPanel; +import static mekhq.MHQConstants.CONFIRMATION_ASSIGN_TECHS; + /** * Displays a table of all units in the force. */ @@ -108,6 +113,7 @@ public final class HangarTab extends CampaignGuiTab { private JComboBox choiceUnit; private JComboBox choiceUnitView; private JCheckBox chkHideMothballed; + private JButton btnAssignTechs; private JScrollPane scrollUnitView; private UnitTableModel unitModel; @@ -204,6 +210,18 @@ public void initTab() { gridBagConstraints.insets = new Insets(5, 5, 0, 0); add(choiceUnitView, gridBagConstraints); + btnAssignTechs = new RoundedJButton(resourceMap.getString("btnAssignTechs.text")); + btnAssignTechs.setToolTipText(resourceMap.getString("btnAssignTechs.toolTipText")); + btnAssignTechs.addActionListener(ev -> quickAssignTechs()); + gridBagConstraints = new GridBagConstraints(); + gridBagConstraints.gridx = 5; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = GridBagConstraints.NONE; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.anchor = GridBagConstraints.WEST; + gridBagConstraints.insets = new Insets(5, 5, 0, 0); + add(btnAssignTechs, gridBagConstraints); + unitModel = new UnitTableModel(getCampaign()); unitTable = new JTable(unitModel); unitTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); @@ -269,6 +287,22 @@ public void initTab() { UnitTableMouseAdapter.connect(getCampaignGui(), unitTable, unitModel, splitUnit); } + private void quickAssignTechs() { + boolean wasConfirmedOverall; + + if (!MekHQ.getMHQOptions().getNagDialogIgnore(CONFIRMATION_ASSIGN_TECHS)) { + ImmersiveDialogConfirmation confirmation = new ImmersiveDialogConfirmation(getCampaign(), + CONFIRMATION_ASSIGN_TECHS); + wasConfirmedOverall = confirmation.wasConfirmed(); + } else { + wasConfirmedOverall = true; + } + + if (wasConfirmedOverall) { + AutomatedTechAssignments.handleTheAutomaticAssignmentOfUnmaintainedUnits(getCampaign()); + } + } + /** * These need to be migrated to the Suite Constants / Suite Options Setup */ diff --git a/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java index 31fec8fcdf6..b04142c144f 100644 --- a/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java @@ -238,6 +238,7 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog { private JCheckBox optionStratConBatchallBreachConfirmation; private JCheckBox optionStratConDeployConfirmation; private JCheckBox optionAbandonUnitsConfirmation; + private JCheckBox optionAssignTechsConfirmation; // endregion Nag Tab @@ -1283,6 +1284,12 @@ private JPanel createNagTab() { "optionAbandonUnitsConfirmation.toolTipText")); optionAbandonUnitsConfirmation.setName("optionAbandonUnitsConfirmation"); + optionAssignTechsConfirmation = new JCheckBox(resources.getString( + "optionAssignTechsConfirmation.text")); + optionAssignTechsConfirmation.setToolTipText(resources.getString( + "optionAssignTechsConfirmation.toolTipText")); + optionAssignTechsConfirmation.setName("optionAssignTechsConfirmation"); + // Layout the UI final JPanel panel = new JPanel(); @@ -1319,7 +1326,8 @@ private JPanel createNagTab() { .addComponent(optionBeginTransitConfirmation) .addComponent(optionStratConBatchallBreachConfirmation) .addComponent(optionStratConDeployConfirmation) - .addComponent(optionAbandonUnitsConfirmation)); + .addComponent(optionAbandonUnitsConfirmation) + .addComponent(optionAssignTechsConfirmation)); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(optionUnmaintainedUnitsNag) @@ -1348,7 +1356,8 @@ private JPanel createNagTab() { .addComponent(optionBeginTransitConfirmation) .addComponent(optionStratConBatchallBreachConfirmation) .addComponent(optionStratConDeployConfirmation) - .addComponent(optionAbandonUnitsConfirmation)); + .addComponent(optionAbandonUnitsConfirmation) + .addComponent(optionAssignTechsConfirmation)); return panel; } @@ -1712,6 +1721,9 @@ protected void okAction() { options .setNagDialogIgnore(MHQConstants.CONFIRMATION_ABANDON_UNITS, optionAbandonUnitsConfirmation.isSelected()); + options + .setNagDialogIgnore(MHQConstants.CONFIRMATION_ASSIGN_TECHS, + optionAssignTechsConfirmation.isSelected()); PreferenceManager.getClientPreferences().setUserDir(txtUserDir.getText()); PreferenceManager.getInstance().save(); @@ -1908,6 +1920,8 @@ private void setInitialState() { .getNagDialogIgnore(MHQConstants.CONFIRMATION_STRATCON_DEPLOY)); optionAbandonUnitsConfirmation.setSelected(options .getNagDialogIgnore(MHQConstants.CONFIRMATION_ABANDON_UNITS)); + optionAssignTechsConfirmation.setSelected(options + .getNagDialogIgnore(MHQConstants.CONFIRMATION_ASSIGN_TECHS)); txtUserDir.setText(PreferenceManager.getClientPreferences().getUserDir()); spnStartGameDelay.setValue(options.getStartGameDelay()); spnStartGameClientDelay.setValue(options.getStartGameClientDelay()); From 93be358ebc05530f70b55ae0031897fe5d943990 Mon Sep 17 00:00:00 2001 From: Illiani <103902653+IllianiBird@users.noreply.github.com> Date: Mon, 18 May 2026 10:58:47 -0500 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../mekhq/resources/ImmersiveDialogConfirmation.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties b/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties index 5a931f98b00..bb6ae52be70 100644 --- a/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties +++ b/MekHQ/resources/mekhq/resources/ImmersiveDialogConfirmation.properties @@ -56,5 +56,5 @@ ImmersiveDialogConfirmation.confirmationAssignTechs.text.primary=If you select '
- Units that already have a tech assigned are ignored.

\

Did You Know?

\ This process can be automated using the new day option found in MekHQ Options.\ -

If selected, periodically, techs will be assigned to units without tech assignments. This follows the rules \ +

If selected, on each new day, techs will be assigned to units without tech assignments. This follows the rules \ outlined above.

From f616a8aab0b86a26cee74b4fa7e80ad0bd243e33 Mon Sep 17 00:00:00 2001 From: IllianiBird Date: Mon, 18 May 2026 10:59:48 -0500 Subject: [PATCH 3/3] Fixed typo --- MekHQ/resources/mekhq/resources/CampaignGUI.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/resources/mekhq/resources/CampaignGUI.properties b/MekHQ/resources/mekhq/resources/CampaignGUI.properties index 13fe2dae9c1..e8a66d5be27 100644 --- a/MekHQ/resources/mekhq/resources/CampaignGUI.properties +++ b/MekHQ/resources/mekhq/resources/CampaignGUI.properties @@ -275,7 +275,7 @@ chkHideMothballed.text=Hide Mothballed chkHideMothballed.toolTipText=Hide mothballed units from the current view btnAssignTechs.text=Quick Assign Maintenance Techs btnAssignTechs.toolTipText=Assign maintenance techs to all unmaintained units, where possible. This is identical \ - to the system found in MekHQ Options that assignments techs on new day. + to the system found in MekHQ Options that assigns techs on new day. lblUnitView.text=View: btnAddMission.toolTipText=Add a new mission. Missions are long-term assignments consisting of multiple scenarios. btnAddMission.text=Add Mission