Skip to content

Commit

Permalink
Remove resupply mechanics and related UI elements
Browse files Browse the repository at this point in the history
Consolidated StratCon support point management by removing resupply mechanics and replacing the "Request Resupply" button with "Remove SP (GM)." Simplified codebase by eliminating unused resupply-related logic, improving maintainability. Updated UI labels and button actions accordingly.
  • Loading branch information
IllianiCBT committed Jan 9, 2025
1 parent 74fd623 commit 4879492
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 93 deletions.
Binary file modified MekHQ/docs/Stratcon and Against the Bot/Resupply & Convoys.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion MekHQ/resources/mekhq/resources/AtBStratCon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ reinforcementEvasionUnsuccessful.text=%s<b>Evasion Unsuccessful</b>%s (%s vs. %s
\ force has already been assigned to this new scenario.

trackScenarioOdds.text=Track Scenario Odds: %d%%
btnRequestResupply.text=Request Resupply
btnRemoveSP.text=Remove SP (GM)
btnAddSP.text=Add SP (GM)
btnAddCVP.text=Add CVP (GM)
btnRemoveCVP.text=Remove CVP (GM)
Expand Down
14 changes: 0 additions & 14 deletions MekHQ/src/mekhq/gui/BriefingTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import mekhq.campaign.mission.*;
import mekhq.campaign.mission.atb.AtBScenarioFactory;
import mekhq.campaign.mission.enums.MissionStatus;
import mekhq.campaign.mission.resupplyAndCaches.Resupply;
import mekhq.campaign.mission.resupplyAndCaches.Resupply.ResupplyType;
import mekhq.campaign.personnel.Person;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.autoAwards.AutoAwardsController;
Expand Down Expand Up @@ -74,7 +72,6 @@
import java.util.stream.Collectors;

import static megamek.client.ratgenerator.ForceDescriptor.RATING_5;
import static mekhq.campaign.mission.resupplyAndCaches.PerformResupply.performResupply;

/**
* Displays Mission/Contract and Scenario details.
Expand Down Expand Up @@ -489,17 +486,6 @@ && getCampaign().getFinances().getBalance().isGreaterOrEqualThan(rdd.totalPayout
}
}

// exchange remaining support points to Resupplys
if (getCampaign().getCampaignOptions().isUseStratCon() && (mission instanceof AtBContract)) {
int remainingSupportPoints = ((AtBContract) mission).getStratconCampaignState().getSupportPoints();

if (remainingSupportPoints > 0) {
Resupply resupply = new Resupply(getCampaign(), ((AtBContract) mission),
ResupplyType.RESUPPLY_CONTRACT_END);
performResupply(resupply, ((AtBContract) mission), remainingSupportPoints);
}
}

if (getCampaign().getCampaignOptions().isUseAtB() && (mission instanceof AtBContract)) {
getCampaign().getContractMarket().checkForFollowup(getCampaign(), (AtBContract) mission);
}
Expand Down
90 changes: 12 additions & 78 deletions MekHQ/src/mekhq/gui/stratcon/CampaignManagementDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
import megamek.client.ui.swing.util.UIUtil;
import mekhq.MekHQ;
import mekhq.campaign.Campaign;
import mekhq.campaign.mission.AtBContract;
import mekhq.campaign.mission.resupplyAndCaches.Resupply;
import mekhq.campaign.mission.resupplyAndCaches.Resupply.ResupplyType;
import mekhq.campaign.stratcon.StratconCampaignState;
import mekhq.campaign.stratcon.StratconRulesManager;
import mekhq.campaign.stratcon.StratconTrackState;
Expand All @@ -35,8 +32,6 @@
import java.awt.event.ActionEvent;
import java.util.ResourceBundle;

import static mekhq.campaign.mission.resupplyAndCaches.PerformResupply.performResupply;

/**
* This class handles the UI for campaign VP/SP management
* @author NickAragua
Expand All @@ -46,7 +41,7 @@ public class CampaignManagementDialog extends JDialog {
private StratconCampaignState currentCampaignState;
private final StratconTab parent;
private JButton btnRemoveCVP;
private JButton btnRequestResupply;
private JButton btnGMRemoveSP;
private JButton btnGMAddVP;
private JButton btnGMAddSP;
private JLabel lblTrackScenarioOdds;
Expand All @@ -68,7 +63,7 @@ public void display(Campaign campaign, StratconCampaignState campaignState,
currentCampaignState = campaignState;

btnRemoveCVP.setEnabled(currentCampaignState.getVictoryPoints() > 0);
btnRequestResupply.setEnabled(currentCampaignState.getSupportPoints() > 0);
btnGMRemoveSP.setEnabled(currentCampaignState.getSupportPoints() > 0);
btnGMAddVP.setEnabled(gmMode);
btnGMAddSP.setEnabled(gmMode);

Expand Down Expand Up @@ -105,16 +100,16 @@ private void initializeUI() {
gbc.anchor = GridBagConstraints.CENTER;
getContentPane().add(lblTrackScenarioOdds, gbc);

// Add the "Request Resupply" button
btnRequestResupply = new JButton(resources.getString("btnRequestResupply.text"));
btnRequestResupply.addActionListener(evt -> {
// Add the "Remove SP" button
btnGMRemoveSP = new JButton(resources.getString("btnRemoveSP.text"));
btnGMRemoveSP.addActionListener(evt -> {
dispose();
requestResupply(evt);
removeSP(evt);
});
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
getContentPane().add(btnRequestResupply, gbc);
getContentPane().add(btnGMRemoveSP, gbc);

// Add the "Add SP (GM)" button
btnGMAddSP = new JButton(resources.getString("btnAddSP.text"));
Expand Down Expand Up @@ -149,76 +144,15 @@ private void removeCVP(ActionEvent e) {
parent.updateCampaignState();
}

/**
* Requests resupply. If there are more than one available support points, it triggers a dialog
* to specify how many points to use for the resupply.
* If there is exactly one support point, it automatically uses this one point to resupply.
* It also updates the button state based on the remaining support points and updates the parent
* campaign state.
*
* @param event The triggering ActionEvent (not used in this method).
*/
private void requestResupply(ActionEvent event) {
if (currentCampaignState.getSupportPoints() > 1) {
supplyDropDialog();
} else {
AtBContract contract = currentCampaignState.getContract();
Resupply resupply = new Resupply(campaign, contract, ResupplyType.RESUPPLY_NORMAL);
performResupply(resupply, contract);
private void removeSP(ActionEvent event) {
int currentSupportPoints = currentCampaignState.getSupportPoints();
if (currentSupportPoints > 1) {
currentCampaignState.setSupportPoints(currentSupportPoints - 1);
}

btnRequestResupply.setEnabled(currentCampaignState.getSupportPoints() > 0);
parent.updateCampaignState();
}

public void supplyDropDialog() {
final JDialog dialog = new JDialog();
dialog.setLayout(new GridBagLayout());
dialog.setTitle(resources.getString("requestingResupply.title"));
dialog.setSize(UIUtil.scaleForGUI(500, 200));
dialog.setLocationRelativeTo(null);

GridBagConstraints constraints = new GridBagConstraints();
int insertSize = UIUtil.scaleForGUI(8);
constraints.insets = new Insets(insertSize, insertSize, insertSize, insertSize);

constraints.gridx = 0;
constraints.gridy = 0;
JLabel description = new JLabel(
String.format("<html><div style='width: %s; text-align:center;'>%s</div></html>",
UIUtil.scaleForGUI(500), resources.getString("supplyPointExpenditure.text")));
description.setAlignmentX(Component.CENTER_ALIGNMENT);
dialog.add(description, constraints);

constraints.gridx = 0;
constraints.gridy = 1;
SpinnerNumberModel numberModel = new SpinnerNumberModel(1, 1,
currentCampaignState.getSupportPoints(), 1);
JSpinner spinner = new JSpinner(numberModel);
dialog.add(spinner, constraints);

constraints.gridx = 0;
constraints.gridy = 2;
constraints.gridwidth = 1;
constraints.anchor = GridBagConstraints.SOUTH;
JButton btnConfirm = new JButton(resources.getString("btnConfirm.text"));
btnConfirm.addActionListener( e-> {
dialog.dispose();

AtBContract contract = currentCampaignState.getContract();
Resupply resupply = new Resupply(campaign, contract, ResupplyType.RESUPPLY_NORMAL);
performResupply(resupply, contract);

currentCampaignState.useSupportPoints((int) numberModel.getValue());
});

dialog.add(btnConfirm, constraints);

dialog.pack();
dialog.setModal(true);
dialog.setVisible(true);
}

private void gmAddVPHandler(ActionEvent e) {
currentCampaignState.updateVictoryPoints(1);
btnRemoveCVP.setEnabled(currentCampaignState.getVictoryPoints() > 0);
Expand All @@ -227,7 +161,7 @@ private void gmAddVPHandler(ActionEvent e) {

private void gmAddSPHandler(ActionEvent e) {
currentCampaignState.addSupportPoints(1);
btnRequestResupply.setEnabled(currentCampaignState.getSupportPoints() > 0);
btnGMRemoveSP.setEnabled(currentCampaignState.getSupportPoints() > 0);
parent.updateCampaignState();
}
}

0 comments on commit 4879492

Please sign in to comment.