Skip to content

Commit

Permalink
Fixing NPE in StratCon tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Windchild292 committed Sep 3, 2021
1 parent 5a23a6c commit 0deb651
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions MekHQ/src/mekhq/gui/StratconTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class StratconTab extends CampaignGuiTab {
private static final String OBJECTIVE_FAILED = "x";
private static final String OBJECTIVE_COMPLETED = "✓";
private static final String OBJECTIVE_IN_PROGRESS = "o";

private StratconPanel stratconPanel;
private JPanel infoPanel;
private JComboBox<TrackDropdownItem> cboCurrentTrack;
Expand All @@ -66,7 +66,7 @@ public class StratconTab extends CampaignGuiTab {
private boolean objectivesCollapsed = true;

CampaignManagementDialog cmd;

/**
* Creates an instance of the StratconTab.
*/
Expand All @@ -88,7 +88,7 @@ public void initTab() {
campaignStatusText = new JLabel();
campaignStatusText.setHorizontalAlignment(SwingConstants.LEFT);
campaignStatusText.setVerticalAlignment(SwingConstants.TOP);

objectiveStatusText = new JLabel();
objectiveStatusText.setHorizontalAlignment(SwingConstants.LEFT);
objectiveStatusText.setVerticalAlignment(SwingConstants.TOP);
Expand Down Expand Up @@ -129,7 +129,7 @@ private void initializeInfoPanel() {

infoPanel.add(new JLabel("Current Campaign Status:"));
infoPanel.add(campaignStatusText);

JButton btnManageCampaignState = new JButton("Manage SP/VP");
btnManageCampaignState.setHorizontalAlignment(SwingConstants.LEFT);
btnManageCampaignState.setVerticalAlignment(SwingConstants.TOP);
Expand Down Expand Up @@ -325,17 +325,17 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
boolean objectiveFailed = objective.isObjectiveFailed(track);

// special case: allied facilities can get lost at any point in time
if ((objective.getObjectiveType() == StrategicObjectiveType.AlliedFacilityControl) &&
if ((objective.getObjectiveType() == StrategicObjectiveType.AlliedFacilityControl) &&
!campaignState.allowEarlyVictory()) {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
} else if (objectiveCompleted) {
sb.append("<span color='green'>").append(OBJECTIVE_COMPLETED);
sb.append("<span color='green'>").append(OBJECTIVE_COMPLETED);
} else if (objectiveFailed) {
sb.append("<span color='red'>").append(OBJECTIVE_FAILED);
} else {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
}

sb.append(" ");

if (!coordsRevealed && displayCoordinateData) {
Expand All @@ -354,7 +354,7 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
case AlliedFacilityControl:
sb.append(coordsRevealed ? "M" : "m")
.append("aintain control of designated facility");

if (!campaignState.allowEarlyVictory()) {
sb.append(" until " + campaignState.getContract().getEndingDate());
}
Expand All @@ -380,7 +380,7 @@ private String buildStrategicObjectiveText(StratconCampaignState campaignState)
// special case text reminding player to complete required scenarios
if (!campaignState.getContract().getCommandRights().isIndependent()) {
boolean contractIsActive = campaignState.getContract().isActiveOn(getCampaignGui().getCampaign().getLocalDate());

if (contractIsActive) {
sb.append("<span color='orange'>").append(OBJECTIVE_IN_PROGRESS);
} else if (campaignState.getVictoryPoints() > 0) {
Expand Down Expand Up @@ -431,9 +431,12 @@ private void repopulateTrackList() {
stratconPanel.setVisible(false);
}
}

private void showCampaignStateManagement(ActionEvent e) {
TrackDropdownItem selectedTrack = (TrackDropdownItem) cboCurrentTrack.getSelectedItem();
if (selectedTrack == null) {
return;
}
cmd.display(selectedTrack.contract.getStratconCampaignState(), selectedTrack.track, getCampaign().isGM());
cmd.setModalityType(ModalityType.APPLICATION_MODAL);
cmd.setVisible(true);
Expand Down

0 comments on commit 0deb651

Please sign in to comment.