Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MekHQ/resources/mekhq/resources/CampaignGUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down
3 changes: 3 additions & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).\
<p>Assignment follows the following rules:</p>\
<p><b>-</b> All unmaintained units are sorted so that the most valuable units are assigned techs first.\
<br><b>-</b> All techs are sorted so that the tech with the fewest assigned units first. Tech skill is used as a \
tie-breaker.\
<br><b>-</b> Units that already have a tech assigned are ignored.</p>\
<h2 style="text-align:center">Did You Know?</h2>\
This process can be automated using the new day option found in MekHQ Options.\
<p>If selected, on each new day, techs will be assigned to units without tech assignments. This follows the rules \
outlined above.</p>
Comment thread
IllianiBird marked this conversation as resolved.
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/MHQConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions MekHQ/src/mekhq/gui/HangarTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand All @@ -108,6 +113,7 @@ public final class HangarTab extends CampaignGuiTab {
private JComboBox<String> choiceUnit;
private JComboBox<String> choiceUnitView;
private JCheckBox chkHideMothballed;
private JButton btnAssignTechs;
private JScrollPane scrollUnitView;

private UnitTableModel unitModel;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*/
Expand Down
18 changes: 16 additions & 2 deletions MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog {
private JCheckBox optionStratConBatchallBreachConfirmation;
private JCheckBox optionStratConDeployConfirmation;
private JCheckBox optionAbandonUnitsConfirmation;
private JCheckBox optionAssignTechsConfirmation;

// endregion Nag Tab

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1348,7 +1356,8 @@ private JPanel createNagTab() {
.addComponent(optionBeginTransitConfirmation)
.addComponent(optionStratConBatchallBreachConfirmation)
.addComponent(optionStratConDeployConfirmation)
.addComponent(optionAbandonUnitsConfirmation));
.addComponent(optionAbandonUnitsConfirmation)
.addComponent(optionAssignTechsConfirmation));

return panel;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down